Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
e91af7e
crypto: the scheme tags and prehashed move to crypto::signing_schemes…
Nov 30, 2026
c34dc49
crypto: the signing_schemes move lint fix
Nov 30, 2026
cb92afc
crypto: the signing_schemes move lint fix, Jamfile comments
Nov 30, 2026
924da0e
crypto: the examples' tag lines stand alone, the static_assert texts …
Nov 30, 2026
0db68e1
crypto: verify, async_verify and recover take a mandatory verificatio…
Nov 30, 2026
5d27179
crypto: the verification policies lint fix
Nov 30, 2026
26df1ef
crypto: the verification policies' doc comments, one catch-all of the…
Nov 30, 2026
27cbd79
crypto: P-256's async_verify applies the policy before the engine, pr…
Dec 1, 2026
9710e5d
crypto: the guide's lookup sentence keeps its code as written
Dec 1, 2026
ea8fab7
crypto: the policy row lint fix
Dec 1, 2026
2d7f4cb
crypto: is_low_s() and low_s() are members of the ECDSA signatures, a…
Dec 1, 2026
6655a3b
crypto: low S members lint fix
Dec 1, 2026
6f37a64
crypto: low S members lint fix 2
Dec 1, 2026
c3e5503
crypto: low S members lint fix 3
Dec 1, 2026
30128d9
crypto: one secp256k1 low-S predicate for the members and recover, th…
Dec 1, 2026
1fddaec
crypto: generator lines lint fix
Dec 1, 2026
413df0e
crypto: formats on codecs: the tags, the point forms, pem over codecs…
Dec 1, 2026
be1bab7
crypto: formats on codecs lint fix
Dec 1, 2026
a80b065
crypto: formats on codecs lint fix 2
Dec 1, 2026
fb503f7
crypto: formats on codecs lint fix 3
Dec 1, 2026
ba72c80
crypto: user_globals leaves codecs' headers out: MSVC instantiates th…
Dec 1, 2026
ba9ab6a
crypto: a PEM of crypto's pair decodes in place from every text, the …
Dec 1, 2026
c74dbdf
crypto: PEM fix round lint fix
Dec 1, 2026
ecdeff7
crypto: the PEM test's past-the-bound wipe counted, not found by anot…
Dec 1, 2026
c17b5f8
crypto: the fuzz lane on codecs' model, libFuzzer on Linux and a repl…
Dec 1, 2026
bab5711
crypto: fuzz lane lint fix
Dec 1, 2026
6ffac84
crypto: the Base58Check fuzz target reads its wipe record; the wasip2…
Dec 1, 2026
7f2e4b5
crypto: Ed25519's formats are codecs value codecs, raw, spki, pkcs8 a…
Dec 1, 2026
0d31299
crypto: Ed25519's formats lint fix
Dec 1, 2026
bc6e7d1
crypto: Ed25519's formats members' briefs of one sentence, as the ref…
Dec 1, 2026
7f537b6
crypto: RFC 8410's prefix verdict on libsodium marked public, as repo…
Dec 1, 2026
4d8fd11
crypto: the Ed25519 formats test's sentinel byte named apart from the…
Dec 1, 2026
9414dcf
crypto: Ed25519's value codecs' results [[nodiscard]], as the toy's; …
Dec 1, 2026
62a5522
crypto: Ed25519's formats fix round lint fix
Dec 1, 2026
48a1146
crypto: the generator's test types its operation of two functions, fo…
Dec 1, 2026
f5c207b
crypto: X25519's formats over its typed keys; its old functions go
Dec 1, 2026
fa45a2f
crypto: X25519's formats lint fix
Dec 1, 2026
9f7551d
crypto: X25519's formats lint fix, the Wycheproof case id printed as …
Dec 1, 2026
6af5fc1
crypto: a message test for X25519's formats header missing
Dec 1, 2026
709a36b
crypto: key_formats' tag line apart from its description, and generat…
Dec 1, 2026
d6943a6
crypto: the verb-level timing coverage of Ed25519's and X25519's pem(…
Dec 1, 2026
9558ee9
crypto: P-256's formats as codecs value codecs, the compressed point …
Dec 1, 2026
5a223ab
crypto: P-256's formats lint fix
Dec 1, 2026
8cc2ba7
crypto: P-256's formats lint fix, a Jamfile comment's width
Dec 1, 2026
7f7be0e
crypto: the P-256 page's raw paragraph without a backtick before an a…
Dec 1, 2026
794637e
crypto: the constant-time check of P-256's PEM reads the scalar's cha…
Dec 1, 2026
eedc974
crypto: P-256's formats for MSVC: spki's point forms chosen at compil…
Dec 1, 2026
1d59350
crypto: P-256's compressed point decompressed on BearSSL's internal i…
Dec 1, 2026
8edf524
crypto: BearSSL's P-256 decompression's parameter named apart from us…
Dec 1, 2026
6a9bba8
crypto: Task 8 fix round 1: every BearSSL without-b2 and canary text …
Dec 1, 2026
d571045
crypto: P-256's decompression on BearSSL in the backend header, on Be…
Dec 1, 2026
93e98e0
crypto: detail/bearssl_i31.hpp compiles alone, for the lint's database
Dec 1, 2026
e31a70c
crypto: the i31 prototypes' test reads inner.h at its own warnings on…
Dec 1, 2026
097eaeb
crypto: the p256_formats_bearssl comment above its own target again, …
Dec 1, 2026
19a1fb6
crypto: secp256k1's x-only public key is a type: from_bytes, bytes, o…
Dec 1, 2026
402996c
crypto: secp256k1's x-only key lint fix: designated initializers, the…
Dec 1, 2026
f1cc3b0
crypto: Task 9 fix round 1: a wrong policy on the x-only key stops at…
Dec 1, 2026
3b3fd30
crypto: secp256k1's formats as codecs value codecs, uncompressed by d…
Dec 2, 2026
3675f3a
crypto: secp256k1's formats lint fix: trailing commas, the round trip…
Dec 2, 2026
560312a
crypto: Task 10 fix round 1: a secp256k1 key pair decodes into a memo…
Dec 2, 2026
c7eb353
crypto: Task 10 fix round 1 lint fix: decode_pem's guard takes a name…
Dec 2, 2026
308a650
crypto: crypto::pem, pem.hpp and the family pem go, codecs' armor bei…
Dec 2, 2026
78cb548
crypto: Task 11 fix round 1: root.adoc names formats::pem, codecs' ar…
Dec 2, 2026
1f81cae
crypto: the guide's formats, signing and x-only chapters on the new n…
Dec 2, 2026
bee52b3
crypto: the guide's formats table and WIF example lint fix: the table…
Dec 2, 2026
8e011df
crypto: the formats table's generator lint fix: a pair's spelling rea…
Dec 2, 2026
2c89ba5
crypto: Task 12 fix round 1: invalid_encoding is spki's, pkcs8's and …
Dec 2, 2026
892211e
crypto: Task 12 fix round 1 lint fix: the normalized signature's chec…
Dec 2, 2026
b89a17d
crypto: final review: a crypto pair's PEM keeps its inner format's la…
Dec 2, 2026
239cfd2
crypto: final review: the curves' formats checks shared in test/suppo…
Dec 2, 2026
8c98dcb
crypto: final review: the timing coverage's duplicates dropped, low S…
Dec 2, 2026
bbe14be
crypto: final review: every message test has its MSVC twin or states …
Dec 2, 2026
4b37cb0
crypto: final review: the migration table and changelog name the x-on…
Dec 2, 2026
00ef98b
crypto: final review: the changelog's x-only words render as written
Dec 2, 2026
549dda2
crypto: final review lint fix: unused names dropped, the label check …
Dec 2, 2026
5c5953c
crypto: final review lint fix: the NOLINT on the line it covers
Dec 2, 2026
f5a27df
crypto: final review lint fix: a Jam comment wrapped at 80
Dec 2, 2026
25bd6e3
crypto: final review residual: the four longest MSVC twins renamed an…
Dec 2, 2026
332a0a8
crypto: BearSSL at webcpporg/bearssl 27611cc, the ECDSA nonce fix wit…
Dec 2, 2026
5d2be9e
crypto: BearSSL at upstream 7bea48e, with no fix of webcpp's (owner d…
Dec 2, 2026
0915042
crypto: BearSSL at webcpporg/bearssl ae63032, upstream 7bea48e and th…
Dec 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
* text=auto eol=lf
*.bat text eol=crlf
# The fuzz corpora are inputs byte for byte: no line ending of theirs is converted.
test/fuzz/corpus/** -text
16 changes: 11 additions & 5 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ specific to crypto.
- **webcpp's own library** (`"port-of": null`) over C backends: BearSSL, OpenSSL, ctaes,
libsecp256k1 and libsodium (the superproject's `/third_party//sodium`, shared with
webcpp::hash). The algorithms are the backends'; crypto is the interface shaped as Boost.Hash2's.
crypto depends on config, hash and secure: the timing guard, `erase_secret`,
crypto depends on config, hash, secure and codecs: the timing guard, `erase_secret`,
`constant_time_equal`, `secret<N>` and `declassify` are webcpp::secure's, with no copy and no
alias in crypto.
alias in crypto; the key formats are codecs formats, registered through `codecs::value_codec`,
and only `include/webcpp/crypto/formats.hpp` and each `curves/<curve>/formats.hpp` include a
codecs header (an include boundary).
- **No oracle.** No original runs beside crypto: the evidence is the published vectors (the GCM
specification's cases, Wycheproof, FIPS 197, RFC 8439 and RFC 8032, BIP340 and BIP341), the
backends' own suites in the lane `c-suites`, and the agreement tests, which compare two backends
Expand Down Expand Up @@ -66,8 +68,12 @@ specific to crypto.
form `(q | -q) >> 31`), so the public point and `agree` are checked traced by memcheck alone.
- A test of a backend is a `.cpp` of its own per backend, never a define that changes the backend
of one source (spec section 4.3's pitfall).
- Every C library is upstream code, unchanged except where CODING-GUIDELINES.md chapter 5 rule 1
allows a security fix on the mirror's `webcpp` branch (BearSSL: 32381d6, ECDSA's nonce
decoding); a moved pin carries that commit. A moved pin is a change of its own (rule 12).
- Every C library is upstream code (CODING-GUIDELINES.md chapter 5 rule 1): never modify
third-party code; a defect found in a dependency is reported to the owner, who submits the fix
upstream, and until upstream applies it the pin may point at our fork's branch carrying exactly
that patch. BearSSL is ae63032 of webcpporg/bearssl's branch
upstream/ecdsa-bits2int-constant-time: upstream 7bea48e and the ECDSA nonce fix submitted
upstream (bits2int, a Minerva-class leak); the pin returns to upstream once the patch is
applied. A moved pin is a change of its own (rule 12).
- X25519's constant time on wasip2 is an open finding (the page's constant-time table): do not
describe it as a pass.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@ MSVC), wasip2, wasip3 and Emscripten.
`aead::seal` and `aead::open` of every AEAD.
- `webcpp::crypto::curves::secp256k1`: BIP 340 Schnorr and ECDSA signatures, their verification,
ECDH, ECDSA's strict DER and low-S forms, and the x-only tweak.
- `webcpp::crypto::curves::ed25519`: Ed25519 signatures (RFC 8032) with strict verification, the
- `webcpp::crypto::curves::ed25519`: Ed25519 signatures (RFC 8032) with canonical verification, the
conversion of a key pair and of a public key to X25519's typed keys, `to_x25519()`, and
Ed25519ph over SHA-512 for a message given in pieces.
- `webcpp::crypto::curves::x25519`: X25519 key agreement (RFC 7748), refusing an all-zero shared
secret, with a peer known by its Ed25519 key once its `to_x25519()` converts it.
- Ed25519's and X25519's keys in RFC 8410's SPKI and PKCS#8, as OpenSSL and WebCrypto write them,
and `webcpp::crypto::pem` for their PEM text, each decoded strictly.
- `webcpp::crypto::curves::p256`: P-256's ECDSA signatures over SHA-256, low S or any S as the
verification policy says, and its ECDH, on BearSSL natively and on WebCrypto in a browser.
- `webcpp::crypto::formats`: every curve's keys and signatures in their formats, as OpenSSL,
WebCrypto and node write them, through `crypto::encode` and `crypto::decode` (codecs' value
codecs): a key's raw bytes with its point forms, RFC 5480's and RFC 8410's SPKI, PKCS#8, an ECDSA
signature's strict DER, and the PEM of the SPKI and PKCS#8, `formats::pem`, codecs' armor over
the DER, each decoded strictly.
- `webcpp::crypto::public_key_encryption`: NaCl's and libsodium's boxes between two key pairs
(`box`, `box_xchacha20poly1305`), refusing a peer key of small order, and sealed boxes
(`sealed_box`), anonymous encryption to a public key.
Expand Down
74 changes: 49 additions & 25 deletions bench/operations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,16 @@ class secp256k1 {
filled<32>(static_cast<std::uint8_t>(seed | 1U))),
"from_secret")) {}

std::uint8_t run() { return take(key_.sign(schnorr, message_, aux_), "sign").bytes()[0]; }
std::uint8_t run() {
return take(key_.sign(signing_schemes::schnorr, message_, aux_), "sign").bytes()[0];
}

bool check() {
auto const signature = take(key_.sign(schnorr, message_, aux_), "sign");
auto const signature = take(key_.sign(signing_schemes::schnorr, message_, aux_), "sign");
auto const public_key = take(key_.public_key(), "public_key");
return crypto::verify(schnorr, signature, message_, public_key).has_value();
return crypto::verify(signing_schemes::schnorr, verification_policies::canonical, signature,
message_, public_key)
.has_value();
}

private:
Expand Down Expand Up @@ -249,19 +253,25 @@ class secp256k1_recover {
key_(take(curves::secp256k1::basic_keypair<Backend>::from_secret(
filled<32>(static_cast<std::uint8_t>(seed | 1U))),
"from_secret")),
signature_(take(key_.sign(ecdsa_sha256_recoverable, prehashed{hash_}), "sign")) {}
signature_(take(key_.sign(signing_schemes::ecdsa_sha256_recoverable,
signing_schemes::prehashed{hash_}),
"sign")) {}

std::uint8_t run() {
auto const recovered = take(curves::secp256k1::recover<Backend>(
ecdsa_sha256_recoverable, signature_, prehashed{hash_}),
"recover");
auto const recovered =
take(curves::secp256k1::recover<Backend>(signing_schemes::ecdsa_sha256_recoverable,
verification_policies::low_s_only, signature_,
signing_schemes::prehashed{hash_}),
"recover");
return recovered.compressed()[1];
}

bool check() {
auto const recovered = take(curves::secp256k1::recover<Backend>(
ecdsa_sha256_recoverable, signature_, prehashed{hash_}),
"recover");
auto const recovered =
take(curves::secp256k1::recover<Backend>(signing_schemes::ecdsa_sha256_recoverable,
verification_policies::low_s_only, signature_,
signing_schemes::prehashed{hash_}),
"recover");
return recovered == take(key_.public_key(), "public_key");
}

Expand Down Expand Up @@ -339,7 +349,8 @@ class secp256k1_musig {
std::uint8_t run() { return sign().bytes()[0]; }

bool check() {
return crypto::verify(schnorr, sign(), message_, signers_key_.xonly_public_key())
return crypto::verify(signing_schemes::schnorr, verification_policies::canonical, sign(),
message_, signers_key_.xonly_public_key())
.has_value();
}

Expand Down Expand Up @@ -466,15 +477,19 @@ class p256 {
"from_secret")) {}

std::uint8_t run() {
return take(key_.sign(ecdsa_sha256, prehashed{digest_}), "sign").bytes()[0];
return take(key_.sign(signing_schemes::ecdsa_sha256, signing_schemes::prehashed{digest_}),
"sign")
.bytes()[0];
}

bool check() {
auto const signature = take(key_.sign(ecdsa_sha256, prehashed{digest_}), "sign");
auto const signature = take(
key_.sign(signing_schemes::ecdsa_sha256, signing_schemes::prehashed{digest_}), "sign");
auto const public_key = take(key_.public_key(), "public_key");
return crypto::verify(ecdsa_sha256, signature, prehashed{digest_}, public_key)
return crypto::verify(signing_schemes::ecdsa_sha256, verification_policies::low_s_only,
signature, signing_schemes::prehashed{digest_}, public_key)
.has_value() &&
curves::p256::is_low_s(signature);
signature.is_low_s();
}

private:
Expand All @@ -483,8 +498,8 @@ class p256 {
};

// The verification of an ECDSA signature of a 32-byte SHA-256 digest on P-256, `crypto::verify(
// ecdsa_sha256, signature, prehashed{digest}, public_key)`; the signature and the public key are
// made once, outside what is measured.
// ecdsa_sha256, low_s_only, signature, prehashed{digest}, public_key)`, the policy of a signature
// crypto made; the signature and the public key are made once, outside what is measured.
template <class Backend>
class p256_verify_ecdsa {
public:
Expand All @@ -496,10 +511,14 @@ class p256_verify_ecdsa {
filled<32>(static_cast<std::uint8_t>(seed | 1U))),
"from_secret")),
public_key_(take(key_.public_key(), "public_key")),
signature_(take(key_.sign(ecdsa_sha256, prehashed{digest_}), "sign")) {}
signature_(
take(key_.sign(signing_schemes::ecdsa_sha256, signing_schemes::prehashed{digest_}),
"sign")) {}

std::uint8_t run() {
take(crypto::verify(ecdsa_sha256, signature_, prehashed{digest_}, public_key_), "verify");
take(crypto::verify(signing_schemes::ecdsa_sha256, verification_policies::low_s_only,
signature_, signing_schemes::prehashed{digest_}, public_key_),
"verify");
return signature_.bytes()[0];
}

Expand All @@ -508,9 +527,12 @@ class p256_verify_ecdsa {
other_bytes[63] ^= 1U;
auto const other =
take(curves::p256::ecdsa_signature::from_bytes(other_bytes), "from_bytes");
return crypto::verify(ecdsa_sha256, signature_, prehashed{digest_}, public_key_)
return crypto::verify(signing_schemes::ecdsa_sha256, verification_policies::low_s_only,
signature_, signing_schemes::prehashed{digest_}, public_key_)
.has_value() &&
!crypto::verify(ecdsa_sha256, other, prehashed{digest_}, public_key_).has_value();
!crypto::verify(signing_schemes::ecdsa_sha256, verification_policies::low_s_only,
other, signing_schemes::prehashed{digest_}, public_key_)
.has_value();
}

private:
Expand Down Expand Up @@ -565,13 +587,15 @@ class ed25519 {
key_(take(curves::ed25519::basic_keypair<Backend>::from_secret(filled<32>(seed)),
"from_secret")) {}

std::uint8_t run() { return take(key_.sign(eddsa, message_), "sign").bytes()[0]; }
std::uint8_t run() {
return take(key_.sign(signing_schemes::eddsa, message_), "sign").bytes()[0];
}

bool check() {
auto const signature = take(key_.sign(eddsa, message_), "sign");
auto const signature = take(key_.sign(signing_schemes::eddsa, message_), "sign");
auto const public_key = take(key_.public_key(), "public_key");
return crypto::verify<Backend>(eddsa, signature, message_, public_key,
curves::ed25519::strict)
return crypto::verify<Backend>(signing_schemes::eddsa, verification_policies::canonical,
signature, message_, public_key)
.has_value();
}

Expand Down
22 changes: 7 additions & 15 deletions build.jam
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@ project /webcpp/crypto ;

# Header-only, on webcpp's configuration, with webcpp::hash's header-only
# alias, whose algorithms name a signature's prehash (Ed25519ph's SHA-512;
# design D1), and webcpp::secure's, whose timing guard, erase_secret,
# design D1), webcpp::secure's, whose timing guard, erase_secret,
# constant_time_equal, secret<N> and declassify crypto's code holds and
# returns. random_device reads Windows' generator through bcrypt
# (BCryptGenRandom), a system library.
# returns, and webcpp::codecs', header-only on config and secure, into which
# the key formats register (formats.hpp and each curve's formats.hpp, the
# only headers that include codecs'; design R32).
# random_device reads Windows' generator through bcrypt (BCryptGenRandom), a
# system library.
# tag::crypto[]
alias crypto : : : : <include>include <library>/boost//headers
<library>/webcpp/config//config <library>/webcpp/hash//hash
<library>/webcpp/secure//secure
<library>/webcpp/secure//secure <library>/webcpp/codecs//codecs
<target-os>windows:<find-shared-library>bcrypt ;
# end::crypto[]

Expand Down Expand Up @@ -125,17 +128,6 @@ rule kx-default-linked ( properties * )
}
}
alias kx-default : : : : <conditional>@kx-default-linked ;
rule pem-default-linked ( properties * )
{
switch [ webcpp-target.target-of $(properties) ]
{
case native : return <library>/third_party//sodium ;
case wasip2 : return <library>/third_party//sodium ;
case wasip3 : return <library>/third_party//sodium ;
case emscripten : return <library>/third_party//sodium ;
}
}
alias pem-default : : : : <conditional>@pem-default-linked ;
rule chacha20_poly1305-default-linked ( properties * )
{
switch [ webcpp-target.target-of $(properties) ]
Expand Down
19 changes: 11 additions & 8 deletions doc/async.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,23 @@ its own, and the handler would run off the program's loop.
| `void(error_code, Secretbox)` for `async_from_key`, `void(error_code, tag)` for `async_seal`, `void(error_code)` for `async_open`

| Ed25519 (<<crypto-ed25519>>)
| `async_from_secret<Keypair>(executor, seed, token)`, `async_generate<Keypair>(executor, token)`, `async_sign(executor, key_pair, crypto::eddsa, message, token)`, `async_verify(executor, crypto::eddsa, signature, message, public_key, token)`, the policy optional before the token; on a native backend the same under `crypto::eddsa_prehashed` with `+crypto::prehashed{digest}+`, the message's SHA-512 (<<crypto-ed25519>>), which the browser's backend refuses at compile time
| `async_from_secret<Keypair>(executor, seed, token)`, `async_generate<Keypair>(executor, token)`, `async_sign(executor, key_pair, crypto::signing_schemes::eddsa, message, token)`, `async_verify(executor, crypto::signing_schemes::eddsa, crypto::verification_policies::canonical, signature, message, public_key, token)`; on a native backend the same under `crypto::signing_schemes::eddsa_prehashed` with `+crypto::signing_schemes::prehashed{digest}+`, the message's SHA-512 (<<crypto-ed25519>>), which the browser's backend refuses at compile time
| `void(error_code, Keypair)` for `async_from_secret` and `async_generate`, `void(error_code, signature)` for `async_sign`, `void(error_code)` for `async_verify`

| X25519 (<<crypto-x25519>>)
| `async_from_secret<Keypair>(executor, secret_key, token)`, `async_generate<Keypair>(executor, token)`, `async_agree(executor, key_pair, peer_public_key, token)`, the peer's key a `curves::x25519::public_key`
| `void(error_code, Keypair)` for `async_from_secret` and `async_generate`, `void(error_code, secure::secret<32>)` for `async_agree`

| P-256 (<<crypto-p256>>)
| `async_from_secret<Keypair>(executor, scalar, token)`, `async_generate<Keypair>(executor, token)`, `async_sign(executor, key_pair, crypto::ecdsa_sha256, input, token)`, `async_verify(executor, crypto::ecdsa_sha256, signature, input, public_key, token)`, `async_agree(executor, key_pair, peer_public_key, token)`
| `async_from_secret<Keypair>(executor, scalar, token)`, `async_generate<Keypair>(executor, token)`, `async_sign(executor, key_pair, crypto::signing_schemes::ecdsa_sha256, input, token)`, `async_verify(executor, crypto::signing_schemes::ecdsa_sha256, crypto::verification_policies::low_s_only, signature, input, public_key, token)`, `async_agree(executor, key_pair, peer_public_key, token)`
| `void(error_code, Keypair)` for `async_from_secret` and `async_generate`, `void(error_code, signature)` for `async_sign`, `void(error_code)` for `async_verify`, `void(error_code, secure::secret<32>)` for `async_agree`
|===

Each function has its member form, which the free function calls, with the
same arguments but the object: `Keypair::async_from_secret(executor, bytes, token)`,
`Keypair::async_generate(executor, token)`,
`key_pair.async_sign(executor, scheme, input, token)`,
`public_key.async_verify(executor, scheme, signature, input, token)`,
`public_key.async_verify(executor, scheme, policy, signature, input, token)`,
`key_pair.async_agree(executor, peer, token)` on X25519 and P-256, and every
AEAD's and secret box's `C::async_from_key`, `aead.async_seal` and
`aead.async_open`, and a crypto_box's `box.async_seal` and `box.async_open`.
Expand All @@ -82,18 +82,21 @@ the call does not compile, the compiler saying that the member's deduced
return type is used before it is defined (<<crypto-jamfile-messages>>).

`async_sign` and `async_verify` take the scheme and the input of the
synchronous `sign` and `crypto::verify`, and check them as `crypto::can_sign`
and `crypto::can_verify` do before anything else, so that a pair the
synchronous `sign` and `crypto::verify`, `async_verify` the policy after the
scheme too, and check them as `crypto::can_sign` and `crypto::can_verify` do
before anything else, so that a pair the
synchronous call refuses stops the build here too
(<<crypto-curves-signatures>>). P-256's input is the message, which they hash
with SHA-256, as WebCrypto's `+sign({name: "ECDSA", hash: "SHA-256"}, ...)+`
hashes and signs in one call
(link:https://www.w3.org/TR/WebCryptoAPI/#ecdsa-operations[W3C, ECDSA's
operations]), or `+crypto::prehashed{digest}+`, signed as given. WebCrypto has no
operations]), or `+crypto::signing_schemes::prehashed{digest}+`, signed as given. WebCrypto has no
prehash mode, so a backend that completes by itself, as the browser's will
(<<crypto-async-webcrypto>>), refuses the marker at compile time. The signature
is r then s, 64 bytes, WebCrypto's form, low S as `sign` gives it; one of
another size completes `async_verify` with `invalid_signature`. Their keys are
is r then s, 64 bytes, WebCrypto's form, low S as `sign` gives it, verified
under `crypto::verification_policies::low_s_only` or `any_s` as the synchronous
call is (<<crypto-p256-ecdsa>>); one of another size completes `async_verify`
with `invalid_signature`. Their keys are
P-256's own types, the key pair and the validated `public_key`, and
`async_agree` gives the shared point's raw x, as WebCrypto's `deriveBits` does
(<<crypto-p256-ecdh>>).
Expand Down
Loading
Loading