| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4363,6 +4363,27 @@ std::optional<EVP_PKEY_CTX*> EVPMDCtxPointer::signInitWithContext( | |||
| 4363 | 4363 | #ifdef OSSL_SIGNATURE_PARAM_CONTEXT_STRING | |
| 4364 | 4364 | EVP_PKEY_CTX* ctx = nullptr; | |
| 4365 | 4365 | ||
| 4366 | + #ifdef OSSL_SIGNATURE_PARAM_INSTANCE | ||
| 4367 | + // Ed25519 requires the INSTANCE param to switch into Ed25519ctx mode. | ||
| 4368 | + // Without it, OpenSSL silently ignores the context string. | ||
| 4369 | + if (key.id() == EVP_PKEY_ED25519) { | ||
| 4370 | + const OSSL_PARAM params[] = { | ||
| 4371 | + OSSL_PARAM_construct_utf8_string( | ||
| 4372 | + OSSL_SIGNATURE_PARAM_INSTANCE, const_cast<char*>("Ed25519ctx"), 0), | ||
| 4373 | + OSSL_PARAM_construct_octet_string( | ||
| 4374 | + OSSL_SIGNATURE_PARAM_CONTEXT_STRING, | ||
| 4375 | + const_cast<unsigned char*>(context_string.data), | ||
| 4376 | + context_string.len), | ||
| 4377 | + OSSL_PARAM_END}; | ||
| 4378 | + | ||
| 4379 | + if (!EVP_DigestSignInit_ex( | ||
| 4380 | + ctx_.get(), &ctx, nullptr, nullptr, nullptr, key.get(), params)) { | ||
| 4381 | + return std::nullopt; | ||
| 4382 | + } | ||
| 4383 | + return ctx; | ||
| 4384 | + } | ||
| 4385 | + #endif // OSSL_SIGNATURE_PARAM_INSTANCE | ||
| 4386 | + | ||
| 4366 | 4387 | const OSSL_PARAM params[] = { | |
| 4367 | 4388 | OSSL_PARAM_construct_octet_string( | |
| 4368 | 4389 | OSSL_SIGNATURE_PARAM_CONTEXT_STRING, | |
@@ -4387,6 +4408,27 @@ std::optional<EVP_PKEY_CTX*> EVPMDCtxPointer::verifyInitWithContext( | |||
| 4387 | 4408 | #ifdef OSSL_SIGNATURE_PARAM_CONTEXT_STRING | |
| 4388 | 4409 | EVP_PKEY_CTX* ctx = nullptr; | |
| 4389 | 4410 | ||
| 4411 | + #ifdef OSSL_SIGNATURE_PARAM_INSTANCE | ||
| 4412 | + // Ed25519 requires the INSTANCE param to switch into Ed25519ctx mode. | ||
| 4413 | + // Without it, OpenSSL silently ignores the context string. | ||
| 4414 | + if (key.id() == EVP_PKEY_ED25519) { | ||
| 4415 | + const OSSL_PARAM params[] = { | ||
| 4416 | + OSSL_PARAM_construct_utf8_string( | ||
| 4417 | + OSSL_SIGNATURE_PARAM_INSTANCE, const_cast<char*>("Ed25519ctx"), 0), | ||
| 4418 | + OSSL_PARAM_construct_octet_string( | ||
| 4419 | + OSSL_SIGNATURE_PARAM_CONTEXT_STRING, | ||
| 4420 | + const_cast<unsigned char*>(context_string.data), | ||
| 4421 | + context_string.len), | ||
| 4422 | + OSSL_PARAM_END}; | ||
| 4423 | + | ||
| 4424 | + if (!EVP_DigestVerifyInit_ex( | ||
| 4425 | + ctx_.get(), &ctx, nullptr, nullptr, nullptr, key.get(), params)) { | ||
| 4426 | + return std::nullopt; | ||
| 4427 | + } | ||
| 4428 | + return ctx; | ||
| 4429 | + } | ||
| 4430 | + #endif // OSSL_SIGNATURE_PARAM_INSTANCE | ||
| 4431 | + | ||
| 4390 | 4432 | const OSSL_PARAM params[] = { | |
| 4391 | 4433 | OSSL_PARAM_construct_octet_string( | |
| 4392 | 4434 | OSSL_SIGNATURE_PARAM_CONTEXT_STRING, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6039,6 +6039,9 @@ Throws an error if FIPS mode is not available. | |||
| 6039 | 6039 | <!-- YAML | |
| 6040 | 6040 | added: v12.0.0 | |
| 6041 | 6041 | changes: | |
| 6042 | + - version: REPLACEME | ||
| 6043 | + pr-url: https://github.com/nodejs/node/pull/62474 | ||
| 6044 | + description: Add support for Ed25519 context parameter. | ||
| 6042 | 6045 | - version: v24.8.0 | |
| 6043 | 6046 | pr-url: https://github.com/nodejs/node/pull/59570 | |
| 6044 | 6047 | description: Add support for ML-DSA, Ed448, and SLH-DSA context parameter. | |
@@ -6102,9 +6105,10 @@ additional properties can be passed: | |||
| 6102 | 6105 | `crypto.constants.RSA_PSS_SALTLEN_DIGEST` sets the salt length to the digest | |
| 6103 | 6106 | size, `crypto.constants.RSA_PSS_SALTLEN_MAX_SIGN` (default) sets it to the | |
| 6104 | 6107 | maximum permissible value. | |
| 6105 | - * `context` {ArrayBuffer|Buffer|TypedArray|DataView} For Ed448, ML-DSA, and SLH-DSA, | ||
| 6106 | - this option specifies the optional context to differentiate signatures generated | ||
| 6107 | - for different purposes with the same key. | ||
| 6108 | + * `context` {ArrayBuffer|Buffer|TypedArray|DataView} For Ed25519[^openssl32] | ||
| 6109 | + (using Ed25519ctx from [RFC 8032][]), Ed448, ML-DSA, and SLH-DSA, | ||
| 6110 | + this option specifies the optional context to differentiate signatures | ||
| 6111 | + generated for different purposes with the same key. | ||
| 6108 | 6112 | ||
| 6109 | 6113 | If the `callback` function is provided this function uses libuv's threadpool. | |
| 6110 | 6114 | ||
@@ -6164,6 +6168,9 @@ not introduce timing vulnerabilities. | |||
| 6164 | 6168 | <!-- YAML | |
| 6165 | 6169 | added: v12.0.0 | |
| 6166 | 6170 | changes: | |
| 6171 | + - version: REPLACEME | ||
| 6172 | + pr-url: https://github.com/nodejs/node/pull/62474 | ||
| 6173 | + description: Add support for Ed25519 context parameter. | ||
| 6167 | 6174 | - version: v24.8.0 | |
| 6168 | 6175 | pr-url: https://github.com/nodejs/node/pull/59570 | |
| 6169 | 6176 | description: Add support for ML-DSA, Ed448, and SLH-DSA context parameter. | |
@@ -6233,9 +6240,10 @@ additional properties can be passed: | |||
| 6233 | 6240 | `crypto.constants.RSA_PSS_SALTLEN_DIGEST` sets the salt length to the digest | |
| 6234 | 6241 | size, `crypto.constants.RSA_PSS_SALTLEN_MAX_SIGN` (default) sets it to the | |
| 6235 | 6242 | maximum permissible value. | |
| 6236 | - * `context` {ArrayBuffer|Buffer|TypedArray|DataView} For Ed448, ML-DSA, and SLH-DSA, | ||
| 6237 | - this option specifies the optional context to differentiate signatures generated | ||
| 6238 | - for different purposes with the same key. | ||
| 6243 | + * `context` {ArrayBuffer|Buffer|TypedArray|DataView} For Ed25519[^openssl32] | ||
| 6244 | + (using Ed25519ctx from [RFC 8032][]), Ed448, ML-DSA, and SLH-DSA, | ||
| 6245 | + this option specifies the optional context to differentiate signatures | ||
| 6246 | + generated for different purposes with the same key. | ||
| 6239 | 6247 | ||
| 6240 | 6248 | The `signature` argument is the previously calculated signature for the `data`. | |
| 6241 | 6249 | ||
@@ -6835,6 +6843,7 @@ See the [list of SSL OP Flags][] for details. | |||
| 6835 | 6843 | [RFC 5208]: https://www.rfc-editor.org/rfc/rfc5208.txt | |
| 6836 | 6844 | [RFC 5280]: https://www.rfc-editor.org/rfc/rfc5280.txt | |
| 6837 | 6845 | [RFC 7517]: https://www.rfc-editor.org/rfc/rfc7517.txt | |
| 6846 | + [RFC 8032]: https://www.rfc-editor.org/rfc/rfc8032.txt | ||
| 6838 | 6847 | [Web Crypto API documentation]: webcrypto.md | |
| 6839 | 6848 | [`BN_is_prime_ex`]: https://www.openssl.org/docs/man1.1.1/man3/BN_is_prime_ex.html | |
| 6840 | 6849 | [`Buffer`]: buffer.md | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -241,6 +241,7 @@ bool SupportsContextString(const EVPKeyPointer& key) { | |||
| 241 | 241 | return false; | |
| 242 | 242 | #else | |
| 243 | 243 | switch (key.id()) { | |
| 244 | + case EVP_PKEY_ED25519: | ||
| 244 | 245 | case EVP_PKEY_ED448: | |
| 245 | 246 | #if OPENSSL_WITH_PQC | |
| 246 | 247 | case EVP_PKEY_ML_DSA_44: | |
| Back | FazBrowse Home | New Git URL |
0 commit comments