307 Commits
Author SHA1 Message Date
David Benjamin 208361a22e Add EVP_PKEY_ALG-based raw public/private key importers
Keeping it to X25519/Ed25519 for now, but arguably we could pick "raw"
options for most of our keys. The problem is just when there's a couple
different options. (ECPrivateKey or just the serialized scalar for EC
keys, compressed vs uncompressed points.)

Bug: 42290364
Change-Id: I1e1a0a3fa971f27a962946301091ebe11bac2725
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/81667
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2025-08-28 12:30:53 -07:00
David Benjamin 815fec1839 Replace OPENSSL_ARRAY_SIZE with std::size
In the STL, <iterator> has a std::size for arrays. Some of these could
also just be ranged for loops. One static_assert could not use
std::size(out->whatever) because out was not a compile-time value, but
std::extent_v<decltype(out->whatever)> works instead.

Change-Id: I28007c79f5583e09167b81a34a447e205ee6dd9b
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/81658
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2025-08-28 12:22:59 -07:00
David Benjamin a352ae6bae Unexport the Kyber implementation
Kyber was the prestandard version of ML-KEM. Callers should be using
ML-KEM now. For now, keep the implementation behind an internal header
for libssl, but we expect to remove that soon too.

Update-Note: <openssl/experimental/kyber.h> is gone. Use
<openssl/mlkem.h> instead.

Bug: 438787615
Change-Id: I02919e5d627dcbe863e70e433c79e360a556d462
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/81287
Reviewed-by: Lily Chen <chlily@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2025-08-18 09:23:13 -07:00
David Benjamin 71bcfad967 Remove MSVC C4702 suppressions in code
We've since suppressed it project-wide because the warning is a bit too
aggressive.

Change-Id: I66b5de66e608a891123dece31fcca3300e0868db
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/77907
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2025-03-21 17:12:37 -07:00
David Benjamin 126de11fc1 Remove MSVC warning suppressions around Windows system headers
These seem to no longer be needed? Over time we have gotten a bit more
measured about enabling all of MSVC's warnings (MSVC is just not
designed to be used with -Wall), so I'm guessing that's what changed.

Change-Id: If71850136fb83841a423b63bdf65c2d546ba0223
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/77887
Auto-Submit: David Benjamin <davidben@google.com>
Reviewed-by: Bob Beck <bbe@google.com>
Commit-Queue: Bob Beck <bbe@google.com>
2025-03-20 21:40:35 -07:00
David Benjamin 33d1049b1f Switch the license to Apache 2.0, matching OpenSSL upstream
We use the standard Apache 2.0 file header, described in "APPENDIX: How
to apply the Apache License to your work."

This was primarily automated by running:

  git ls-tree -r --name-only HEAD | xargs go run ./util/relicense.go

See go/boringssl-relicensing-triage for the results of triaging the
output of the tool.

As part of this, switch from taking fiat-crypto under MIT license to
Apache 2.0. (It is licensed under MIT OR Apache-2.0 OR BSD-1-Clause.)

The copyright_summary tool can also be used to confirm we didn't
accidentally drop any copyright lines:

  # Run before the CL
  git grep -l Copyright | xargs go run ./util/copyright_summary.go  -out /tmp/old.json
  # Run after the CL
  git grep -l Copyright | xargs go run ./util/copyright_summary.go  -compare /tmp/old.json

Bug: 364634028
Change-Id: I17c50e761e9d077a1f92e25969e50ed35e320c59
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/75852
Reviewed-by: Bob Beck <bbe@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2025-02-03 15:05:16 -08:00
David Benjamin a85ef9aa6c Rename foo_extra to foo
The foo / foo_extra split will make increasingly less sense as we stop
putting public APIs in crypto/fipsmodule. Just call it crypto/foo and
crypto/fipsmodule/foo.

Bug: 42290602
Change-Id: I5143d3edfb768ed7a1aa288ff606f6f13faa9278
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/75151
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Bob Beck <bbe@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
2025-01-16 13:21:47 -08:00
David Benjamin f60995084e Remove calls to now unnecessary MakeSpan/MakeConstSpan
CTAD takes care of all of these.

Bug: 42290600
Change-Id: I191c5710f402835d1b50250225edd4e535c7580c
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/75208
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2025-01-13 10:57:19 -08:00
Adam Langley 163dee5b58 Move ML-DSA and Keccak into the FIPS module.
Change-Id: I615e25bbd5056d2149cb9795bb08b2c79abbae5e
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/73327
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Bob Beck <bbe@google.com>
2024-12-11 15:46:42 -08:00
David Benjamin 6f4159567d Start maintaining an AUTHORS file
Following the guidance in
https://opensource.google/documentation/reference/releasing/authors,
start maintaining an AUTHORS file.

Update all existing Google copyright lines to 'The BoringSSL Authors'
per the document. This CL also changes the styling to match the new
guidance: removed the '(c)' and the comma.

All other existing copyright lines are left unmodified. Going forward,
our preference will be that new contributions to BoringSSL use 'The
BoringSSL Authors', optionally adding to the AUTHORS file if the
contributor desires.

To avoid being presumptuous, this CL does *not* proactively list every
past contributor in the BoringSSL half of the AUTHORS file. Past
contributors are welcome to send us a patch to be added, or request that
we add you. (Listed or not, the commit log continues to be a more
accurate record, and any existing non-Google copyright lines were left
unmodified.)

The OpenSSL half of the AUTHORS file is seeded with the contents of the
current OpenSSL AUTHORS file, as of writing. The current contents in the
latest revision of the 1.1.1 branch
(b372b1f76450acdfed1e2301a39810146e28b02c) and master
(d992e8729ee38b082482dc010e090bb20d1c7bd5) are identical, just formatted
in text vs Markdown.

Note when reviewing: CONTRIBUTING.md and AUTHORS contain non-mechanical
changes.

Bug: 364634028
Change-Id: I319d0ee63ec021ad85e248e8e3304b9cf9566681
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/74149
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2024-12-11 13:52:41 -08:00
Adam Langley 411173bb2c spx: remove
SPX is replaced by SLH-DSA. Please see slhdsa.h for stateless, hash-based
signature needs.

Change-Id: Iea71099755a7735ce65d4563fc20d9ebbc6a811d
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/73988
Auto-Submit: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2024-12-05 23:54:21 +00:00
Adam Langley 642e8e56de Add SLH-DSA-SHA2-128s from FIPS 205.
Change-Id: I4844f20f6989be2d7fbe9687d9f8fc2c70f0d0f9
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/70907
Reviewed-by: David Benjamin <davidben@google.com>
2024-09-13 16:21:27 +00:00
Adam Langley 0ee584bb51 ML-DSA: focus the API on saving private keys as seeds.
There are two ways to save an ML-DSA or ML-KEM private key:

NIST specifies a partial serialization of the contents of the keys and this takes up several kilobytes.

But one can also save the seed that the key was generated from and simply regenerate the private key as needed.

* The seed is approximately two orders of magnitude smaller.
* It is fast to expand a private key from a seed.
* The NIST format requires validating several aspects of the partially expanded private key.

Because of this, seeds seem clearly better and having two different
serializations in the API is a bit weird when currently neither of them
are used anywhere.

Thus this change emphasizes using seeds to save private keys and moves
the marshalling function for the NIST format into the internal API.
ML-KEM already follows this pattern, although saving the seed is still
optional there because ephemeral keys are a major use case for ML-KEM.

Change-Id: I439224e745ad8747d26f57288f1d503593e0e52c
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/70407
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2024-08-21 19:54:38 +00:00
Adam Langley 500fa1f9d2 Add ML-KEM.
This change implements FIPS 203.

This marks the first use of C++ in libcrypto. If you can't compile C++
in this context, please reach out to boringssl@ and filter out the .cc
files for now.

This also makes marshaling a private key an internal function and,
instead, exposes the seed from the generation process and a function to
calculate a private key from a seed. Seeds are significantly smaller
than NIST's format for private keys and don't require validation.

On an M1 Pro:

Did 22320 Kyber generate + decap operations in 1001900us (22277.7 ops/sec)
Did 39000 Kyber parse + encap operations in 1005523us (38785.8 ops/sec)
Did 22608 ML-KEM-768 generate + decap operations in 1010509us (22372.9 ops/sec)
Did 44000 ML-KEM-768 parse + encap operations in 1013729us (43404.1 ops/sec)
Did 15410 ML-KEM-1024 generate + decap operations in 1011500us (15234.8 ops/sec)
Did 29000 ML-KEM-1024 parse + encap operations in 1003919us (28886.8 ops/sec)

Change-Id: Ib563bd4d45228237b55cedbe7d7fdf0f0221a3cc
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/69928
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2024-08-21 19:37:53 +00:00
Bob Beck 74a51c6ab3 Deprecate the experimental dilithium code.
Now that ML-DSA has been standardized, code should be using
<openssl/mldsa.h> not <openssl/experimental/dilithium.h>.

This marks the dilithium functions as OPENSSL_DEPRECATED
and removes the dilithium speed from bssl.

The code remains in the library for a short while to allow
anyone who used it to transition to mldsa.

Change-Id: I5c9fab376185dc045d7d588eff4b6a626527aff5
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/70329
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Auto-Submit: Bob Beck <bbe@google.com>
2024-08-20 21:08:16 +00:00
Adam Langley 0ba2001733 Add ML-DSA.
This change implements FIPS 204.

Change-Id: I0043850767c93cc7235a15c701798fee6e1af1bf
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/69987
Reviewed-by: Bob Beck <bbe@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2024-08-19 20:09:26 +00:00
Jennie Brown 942454eaf7 Add RSA 3072 to bssl SpeedRSA benchmark.
Change-Id: Icdd1192a24d3bdc62198ca9243f4bbf9f64f3c29
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/70287
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2024-08-14 22:07:46 +00:00
David Benjamin 2fcdd11f6d Make BoringSSL initialization-less
Now that we don't depend on external CRYPTO_library_init calls or the
static initializer to initialize CPU capabilities, we can drop a ton of
code.

This makes CRYPTO_library_init, and all its wrappers, into no-ops and
drops the (non-FIPS) static initializer. I've added an internal
OPENSSL_init_cpuid function for the places where the library actually
needs to initialize the CPU vector.

Note this slightly changes the default, previously
static-initializer-full build: previously, CRYPTO_library_init was a
no-op and we relied on the static initializer. Now we uniformly use
CRYPTO_once. This should be an atomic read in the steady state and
essentially free. We can restore the static initializer by default if
this ends up being a problem, but having only one mode is more
straightforward. This also avoids problems if an application calls into
BoringSSL during its own static initializer. Static initializers are not
coherently ordered.

Update-Note: The BORINGSSL_NO_STATIC_INITIALIZER build option and
CRYPTO_library_init are now unnecessary. Once updating past this
revision, those options can now be cleaned up from downstream projects.

Fixed: 40644931
Change-Id: Idc2e6ea7a73d6352e0360fd886c46d88dba3568c
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/69508
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2024-06-21 04:01:30 +00:00
Bob Beck e491eeb610 Mark kyber as experimental
Kyber will be changing once the standardization of ML_KEM
is finalized by NIST.

Update-Note: The use of Kyber functions from
<openssl/experimental/kyber.h> will not compile unless the build
using them defines an appropriate preprocessor define.

As this interface will change once NIST finalizes the
standardization of ML_KEM. Users of this code must be aware, and be
prepared to make changes when this happens

Change-Id: I159bae38e58dd059b3fcccf69ae9f3d5fb03bd46
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/66868
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Bob Beck <bbe@google.com>
2024-06-04 20:39:03 +00:00
Bob Beck 7c44f45054 Re-apply dilithium and make it work with a limited stack
This reverts commit a56407d27d.

On top of this it then makes changes to make dilithium work without
consuming excessive stack space..

This makes DILITHIUM_sign and DILITHIUM_generate_key and friends
fallible for malloc failures. It removes the abort() calls that
were previously present if CBB allocations did not work and
rolls them into the malloc failure case.

Change-Id: Ibcd70a98bb500c76df8885c0a7d06f8e9f5b18c3
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/67027
Commit-Queue: Bob Beck <bbe@google.com>
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-by: Guillaume Endignoux <guillaumee@google.com>
Reviewed-by: Sophie Schmieg <sschmieg@google.com>
2024-05-08 22:04:25 +00:00
Bob Beck 06fb6e1b12 Make it plainly obvious this is experimental code.
Since we are saying this will die when standardized, let us
ensure users of this code from this location take notice
and action before using it.

We then selectively allow it in the speed tool and in our tests.

If we like this approach, I'll go back and apply it to kyber
(which will have some other fallout consequences to fix) but this
one should be painless right now.

This can also be applied to Dilithium when it comes back.

Future experimentals could be added in this manner.

Change-Id: Ie3b41cf16278868562ef1c8b28f2caed5e0e2dd1
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/66887
Commit-Queue: Bob Beck <bbe@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2024-03-21 06:02:41 +00:00
Bob Beck a56407d27d Revert "Add a Dilithium implementation."
This reverts commit 9b34a32240.

Sadly this blow's up google3 because of stack usage being higher
than google3's limits

Change-Id: I8f1493a158e5fcab508593841ac3a37eb8404dcc
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/66847
Auto-Submit: Bob Beck <bbe@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2024-03-09 00:11:19 +00:00
Guillaume Endignoux 9b34a32240 Add a Dilithium implementation.
This is a reference implementation, not intended to be optimized, but
reasonably efficient to be usable and (best-effort) constant time.

Change-Id: I47489b566f65e946edd519aa168aee359d1e9f1a
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/63685
Reviewed-by: Bob Beck <bbe@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2024-03-06 13:31:29 +00:00
Bob Beck 2fb5cdb6c4 Move spx from internal to include/openssl/experimental
Change-Id: I5c8db3bbca774c7f503538b43f79077421574b0f
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/66487
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Bob Beck <bbe@google.com>
2024-03-06 00:02:56 +00:00
Bob Beck 85c5d9668f Make an include/openssl/experimental. Move kyber to it for now.
Update-Note: <openssl/kyber.h> has moved to
<openssl/experimental/kyber.h>

Change-Id: I51d37aeb2b6cfbbaae494cc38f1b0a82669d2692
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/66467
Reviewed-by: David Benjamin <davidben@google.com>
Auto-Submit: Bob Beck <bbe@google.com>
Commit-Queue: Bob Beck <bbe@google.com>
2024-02-23 17:00:23 +00:00
David Benjamin 07cd196232 Always use a 32-byte shared secret for Kyber
Although the round-3 specification has a variable-length output, the
final ML-KEM construction is expected to use a fixed 32-byte output. To
simplify the future transition, we apply the same restriction.

Update-Note: The Kyber public APIs have changed slightly, but we do not
believe there are any users of them yet.

Change-Id: Iea4fb1b13ecfcc3fead62989cee79de011f413c5
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/64349
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
2023-11-30 21:55:32 +00:00
Stefan Koelbl f714cb2935 Add basic C implementation of SPHINCS+-SHA2-128s.
The implementation is based on the current round 3 specification with
the modifications to FORS indices generation suggest on the mailing
list. The implementation passes test vectors and uses the default SHA256 implementation of BoringSSL.

Change-Id: Iab2dbaf5f692d490577dc940d9f3e298a72e9193
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/60965
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2023-11-01 23:01:16 +00:00
David Benjamin 70be01270b Use constant curve-specific groups whenever possible
Also remove unnecessary EC_GROUP_free calls. EC_GROUP_free is only
necessary in codepaths where arbitrary groups are possible.

Bug: 20
Change-Id: I3dfb7f07b890ab002ba8a302724d8bc671590cfe
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/60932
Reviewed-by: Bob Beck <bbe@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2023-07-11 20:07:57 +00:00
David Benjamin a36ac0a2e7 Use std::make_unique when possible
We've required C++14 for a while now. As we're mostly C with a little
C++, this is less helpful, but may as well avoid bare new where
possible.

Change-Id: Icf3386e3f3b6f2092bb0089ed874cc50985f1a40
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/61429
Reviewed-by: Bob Beck <bbe@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2023-07-11 19:22:41 +00:00
David Benjamin 99ce1e01fc Use sources.cmake for the bssl tool
Bug: 542
Change-Id: I94684f2398a28792cc0a31c8e776eecac8cc3cba
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/61305
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Bob Beck <bbe@google.com>
2023-07-05 21:38:27 +00:00
David Benjamin d4553e0538 Make RSA opaque
Three years of updating calling code are finally complete!

Update-Note: Accessing the RSA struct directly is no longer supported.
Use accessors instead.

Bug: 316, 325
Change-Id: I27b4c9899cb96f5807075b8fe351eaf72a9a9d44
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/60610
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-by: Bob Beck <bbe@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2023-06-09 02:57:17 +00:00
David Benjamin 335523a2c4 Align remaining TLS ECDH APIs on "group" terminology
This adds "group" versions of our codepoint-based APIs. This is mostly
because it looks weird to switch terminology randomly in the
implementation. See I7a356793d36419fc668364c912ca7b4f5c6c23a2 for
additional context.

I've not bothered renaming the bssl_shim flags. That seems a waste of
time.

Change-Id: I566ad132f5a33d99efd8cb2bb8b76d9a6038c825
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/60207
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2023-05-31 15:22:16 +00:00
David Benjamin c1f5d795c2 Add a multi-threaded mode to bssl speed
This is inspired somewhat from how https://github.com/google/benchmark's
threaded benchmark support works. (It seems to spawn a bunch of threads,
latch them all together, and then run.)

This adds a TimeFunctionParallel which runs multiple copies of the
benchmark in parallel, after waiting for all the threads to synchronize.
Some functions had to be tweaked so they don't write to a single, shared
output buffer.

This probably could use some improvement. In playing with it, the
numbers are pretty unstable. We also don't currently benchmark anything
that captures EVP's internal refcounts. But hopefully it's enough to get
a start. I am able to measure impacts from the PRNG locks at least.

Bug: 570
Change-Id: I92c29a05ba082fc45701afd6f0effe23f7b148bd
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/59845
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
2023-05-14 16:50:42 +00:00
David Benjamin 5e988c4055 Rename EC_RAW_POINT to EC_JACOBIAN
EC_RAW_POINT is a confusing name. It's mostly about whether this is
stack-allocated EC_POINT without the EC_GROUP pointer. Now that we have
EC_AFFINE, EC_JACOBIAN captures what it's doing a bit better.

Fixed: 326
Change-Id: I5b71a387e899a94c79be8cd5e0b54b8432f7d5da
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/59565
Reviewed-by: Adam Langley <agl@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2023-05-04 20:15:19 +00:00
Sophie Schmieg 58472cc752 Adding a C implementation of Kyber.
Passes test vectors, and should be constant time, but is currently
not optimized and neither the API nor the standard is stable.

Change-Id: I89b90877e023a43ee7238e11b86065444ab3bdec
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/57845
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2023-03-30 17:05:20 +00:00
David Benjamin 8c75ed046f Remove global_target from build.
This was added with the generated symbol-prefixing header. But it
seems to be sufficient for crypto to have a dependency on the
generated header, along with some of the stray bits of delocate.

It's a little unclear from CMake documentation how these are processed;
normally .o files can be built before libraries are built or linked,
only the link step depends on.

But, empirically, if A links B, and B has a dependency on C, then CMake
seems to run C before building any of A. I tested this by making a small
project where the generation step slept for three seconds and running
with enough parallelism that we'd have tripped.

Interestingly, in the Makefile output, the individual object file
targets didn't have that dependency, but the target itself did. But this
was true on both A and B, so I think that just might not work.

Also fix the dependency in the custom target. The old formulation broke
when using an absolute path to the symbols file.

Change-Id: I2053d44949f907d465da403a5ec69c191740268f
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/56928
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Bob Beck <bbe@google.com>
2023-02-14 21:00:31 +00:00
David Benjamin e5f7266884 Don't include custom builds of libc++ in CMake installs
Also stick the very verbose default install directory in a variable so
we don't have to repeat it everywhere.

Change-Id: I1a6a85c4d42d3a6e766e52b2d0ecd8e81c6ed4e3
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/56607
Reviewed-by: Bob Beck <bbe@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2023-02-14 20:42:03 +00:00
David Benjamin 0e68520eb2 Specify -Iinclude with the crypto target.
It's unclear to me whether doing it target-by-target is an improvement
in crypto/fipsmodule, but this otherwise does seem a bit tidier. This
aligns with CMake's documentation and "modern CMake" which prefers this
pattern.

Change-Id: I36c81842bff8b36eeaaf5dd3e0695fb45f3376c9
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/56585
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Bob Beck <bbe@google.com>
2023-02-14 20:26:56 +00:00
David Benjamin 3950d6ce25 Implement P256_XMD:SHA-256_SSWU_RO_ and P384_XMD:SHA-384_SSWU_RO_
Also add public APIs for this, now that the specification is no longer
expected to change, and because a project external to the library wishes
to use it.

For now, I've kept the P-256 version using the generic felem_exp, but we
should update that to use the specialized field arithmetic.

Trust Tokens will presumably move to this later and, in the meantime,
another team wants this.

Bug: chromium:1414562
Change-Id: Ie38203b4439ff55659c4fb2070f45d524c55aa2a
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/57147
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
2023-02-14 15:56:40 +00:00
David Benjamin 0586618453 Trim unnecessary -lrt and ws2_32 deps in the build.
The ws2_32 dependency comes from BIO, which is in libcrypto. Once it's
added there, it should get inherited by anything downstream, so we don't
need to keep listing it.

We also no longer need -lrt. We tried to remove it in
https://boringssl-review.googlesource.com/4622, but had to revert it in
https://boringssl-review.googlesource.com/4894 because of clock_gettime.

clock_gettime, per the Linux man page, is now in libc, not librt, as of
glibc 2.17. THat was released December 2012, well past our five year
watermark, so clean this part of the build up.

Change-Id: Ie6a07434b0cb02fe916b32ab8c326ec33d40bcb6
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/56606
Reviewed-by: Bob Beck <bbe@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2023-02-07 18:53:21 +00:00
Steven Valdez 80a243e07e Remove old Trust Token redeem API.
This removes TRUST_TOKEN_ISSUER_redeem and renames
TRUST_TOKEN_ISSUER_redeem_raw to TRUST_TOKEN_ISSUER_redeem.

Change-Id: Ifc07c73a6827ea21b5f2b0469d4bed4d9bf8fa84
Update-Note: Callers of TRUST_TOKEN_ISSUER_redeem_raw should remove the _raw.
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/56365
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
Auto-Submit: Steven Valdez <svaldez@google.com>
2023-01-27 16:26:54 +00:00
David Benjamin df8a55bf62 Const-correct sk_FOO_deep_copy's copy callback.
This aligns with upstream OpenSSL, so it's hopefully more compatible.
Code search says no one outside of the project uses this function, so
it's unlikely to break anyone.

Whether it makes things better is a bit of a wash: OBJ_dup and
OPENSSL_strdup loose a pointless wrapper. X509_NAME_dup gains one, but
hopefully that can be resolved once we solve the X509_NAME
const-correctness problem. CRYPTO_BUFFER_up_ref gains one... really
FOO_up_ref should have type const T * -> T *, but OpenSSL decided it
returns int, so we've got to cast.

Change-Id: Ifa6eaf26777ac7239db6021fc1eafcaed98e42c4
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/56032
Reviewed-by: Bob Beck <bbe@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2023-01-17 19:43:35 +00:00
David Benjamin 1a46f8fb6f Switch microsecond and iteration counts in bssl speed to uint64_t.
We were mixing uint64_t and unsigned, which flagged -Wshorten-64-to-32.
While I'm here, switch the iteration count to uint64_t to cut down on
uses of 'unsigned'. While we have no real risk of overflow a u32 here,
counting the number of times we perform some operation in a loop would
probably best be u64.

(I'm guessing we originally used unsigned mostly so that %u worked. But
PRIu64 exists, though it's wordy.)

Bug: 516
Change-Id: I6abc24ecb029c2c223bb940c903d497868bab9fc
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/55455
Reviewed-by: Bob Beck <bbe@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2022-12-03 21:37:07 +00:00
David Benjamin 1e7cb684a7 Replace malloc/memcpy pairs with memdup.
Change-Id: Icc56ceb3f27be3c02aeb6a169b044c7846f1ce97
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/55268
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2022-11-21 19:55:43 +00:00
David Benjamin 7ac94aa279 More -Wshorten-64-to-32 fixes.
I had a rewrite of the decrepit ciphers (CAST and Blowfish) to use
CRYPTO_{load,store}_u32_be and drop the old macros, but this is probably
not worth the effort to review. Instead, just fix the type in the macro.

Bug: 516
Change-Id: I1cdecc16f6108a6235f90cf9c2198bc797c6716e
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/54985
Reviewed-by: Bob Beck <bbe@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2022-11-14 20:24:08 +00:00
Daniel Thornburgh 48f794765b Fix build for older CMake versions.
CMake versions newer than ~3.1x automatically determine the subdirectory under CMAKE_INSTALL_PREFIX using the type of the installed target. Older versions need this to be manually computed using the GNUInstallDirs library.

Since we override the CMAKE_INSTALL_PREFIX default, this just controls
the internal layout of the install/ directory generated underneath the
boringssl checkout.

Bug: 488
Change-Id: I97b02006301e463bb0cfd54acb2b27656484cc85
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/52345
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2022-04-26 16:13:27 +00:00
Daniel Thornburgh f299342e38 [build] Fix build with HEAD clang.
The HEAD version of Clang fails to build boringssl due to the following
warning triggered at -Werror:

    /usr/local/google/home/dthorn/curl/boringssl/tool/digest.cc:229:12:
    error: variable 'bad_hash_lines' set but not used

This change removes the variable.

Change-Id: I25009925d9a2dfc5b1783accab19e4b861db4ec2
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/52265
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2022-04-21 22:33:05 +00:00
Daniel Thornburgh 2fc6d38391 Add CMake install rules.
This creates an install directory under the top level source directory.
The install contains a CMake config file that produces variables and
targets compatible with FindOpenSSL, or the directory can be scanned by
FindOpenSSL via -DOPEN_SSL_ROOT. This allows using BoringSSL with
third-party dependencies that find an SSL implementation via CMake.

Change-Id: Iffeac64b9cced027d549486c98a6cd9721415454
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/52205
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2022-04-14 19:02:21 +00:00
David Benjamin 08970b3121 Include the EKU extension in bssl server's self-signed certs.
macOS requires an explicit EKU extension. This fixes connection failing
with ERR_CERT_INVALID in Chrome (when the built-in verifier isn't
enabled).
https://support.apple.com/en-us/HT210176

Change-Id: Ida23391107fe0168a854c1f4ea3ac52db670e7e8
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/51525
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2022-02-22 21:56:42 +00:00
David Benjamin 345c86b1cf Switch CRYPTO_BUFFER_POOL to SipHash-2-4.
This hash table, in applications that use pooling, can dedup received
certificates in memory and thus should use a keyed hash.

Change-Id: Idc40dc8f7463025183121642b30ea0de43ebac0e
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/51125
Reviewed-by: Adam Langley <agl@google.com>
2022-01-24 19:05:20 +00:00