Lightpanda: the headless browser designed for AI and automation
webapi: RSA-PSS (generateKey, import, export, sign, verify)
orezraey45dd9423c331
diff --git a/src/browser/tests/crypto.html b/src/browser/tests/crypto.htmlindex 9c9b14e6a..41970f776 100644--- a/src/browser/tests/crypto.html+++ b/src/browser/tests/crypto.html@@ -656,11 +656,8 @@spkiNoUsages: await errorName(() => subtle.importKey("spki", rsaTestKey.spki, algo, true, [])),noHash: await errorName(() => subtle.importKey("spki", rsaTestKey.spki, "RSASSA-PKCS1-v1_5", true, ["verify"])),badHash: await errorName(() => subtle.importKey("spki", rsaTestKey.spki, { ...algo, hash: "SHA-224" }, true, ["verify"])),- // RSA-PSS isn't implemented yet.- pss: await errorName(() => subtle.importKey("spki", rsaTestKey.spki, { name: "RSA-PSS", hash: "SHA-256" }, true, ["verify"])),- // Generation: the private key must get "sign". RSA-PSS isn't implemented yet.+ // Generation: the private key must get "sign".verifyOnly: await errorName(() => gen("RSASSA-PKCS1-v1_5", ["verify"])),- pssGenerate: await errorName(() => gen("RSA-PSS", ["sign", "verify"])),// JWK: a "sig" key whose `alg` names the requested hash.publicForSign: await importPublic(pubNoOps, ["sign"]),useEnc: await importPublic({ ...publicJwk, use: "enc" }),@@ -690,9 +687,7 @@testing.expectEqual(null, results.spkiNoUsages);testing.expectEqual("TypeError", results.noHash);testing.expectEqual("NotSupportedError", results.badHash);- testing.expectEqual("NotSupportedError", results.pss);testing.expectEqual("SyntaxError", results.verifyOnly);- testing.expectEqual("NotSupportedError", results.pssGenerate);testing.expectEqual("SyntaxError", results.publicForSign);testing.expectEqual("DataError", results.useEnc);testing.expectEqual("DataError", results.algOtherHash);@@ -702,6 +697,142 @@});</script>+<script id=rsa-pss type=module>+ const state = await testing.async();+ const subtle = crypto.subtle;+ const errorName = async (fn) => {+ try {+ await fn();+ return null;+ } catch (err) {+ return err.name;+ }+ };+ const b64 = (buf) => btoa(String.fromCharCode(...new Uint8Array(buf)));+ const algo = { name: "RSA-PSS", hash: "SHA-256" };+ const data = new TextEncoder().encode("lightpanda rsa-pss");+ const privateKey = await subtle.importKey("pkcs8", rsaTestKey.pkcs8, algo, false, ["sign"]);+ const publicKey = await subtle.importKey("spki", rsaTestKey.spki, algo, false, ["verify"]);++ // With no salt, PSS is deterministic: this is what OpenSSL (and Chrome)+ // produce for the shared test key, SHA-256 and MGF1 over SHA-256.+ const expected = "Y8BivUzQOY0aMtDqK7PaK6scH2T8i6mbTYvrO81MIcYUXmYEvVAhSgTrYTyxPEJd+KH+n0/XM08WdgV4WOwMBjwgezfKyjd21Llir//NrYitf9qlvqRbKprrQLd8rGQ5PBb41pgwkEvM3u3PAVjaeKmeHtfdVZZ59cJwe36P5X+e3aGhjnaxggjFcBk2c+amVnXMjFlkubtkjXecA0dXSdhap6Cpr4q/OajQrnLJTjrsO1kfIzpRCq0IXdx3cKADwagjv6rEoh1I2+2tsk8vsTmugWh4Crxa/IXc/M/qRdVWjZu2RA442B4tB/APpYOOCoSMRQ6qPgw2OO68l/PiXw==";+ const unsalted = await subtle.sign({ name: "RSA-PSS", saltLength: 0 }, privateKey, data);+ // A salt makes each signature different; both verify with that salt length only.+ const salted = await subtle.sign({ name: "rsa-pss", saltLength: 32 }, privateKey, data);+ const saltedAgain = await subtle.sign({ name: "RSA-PSS", saltLength: 32 }, privateKey, data);++ // Generated keys, and the JWK of each hash ("PS1", "PS256", ...).+ const pair = await subtle.generateKey(+ { ...algo, modulusLength: 1024, publicExponent: new Uint8Array([1, 0, 1]) },+ true,+ ["sign", "verify"],+ );+ const publicJwk = await subtle.exportKey("jwk", pair.publicKey);+ const privateJwk = await subtle.exportKey("jwk", pair.privateKey);+ const jwkPrivate = await subtle.importKey("jwk", privateJwk, algo, true, ["sign"]);+ const algs = [];+ for (const hash of ["SHA-1", "SHA-256", "SHA-384", "SHA-512"]) {+ const key = await subtle.importKey("jwk", { kty: "RSA", n: publicJwk.n, e: publicJwk.e }, { ...algo, hash }, true, ["verify"]);+ algs.push((await subtle.exportKey("jwk", key)).alg);+ }+ const pss = (saltLength) => ({ name: "RSA-PSS", saltLength });+ const generatedSignature = await subtle.sign(pss(20), jwkPrivate, data);+ const rsassa = await subtle.importKey("spki", rsaTestKey.spki, { name: "RSASSA-PKCS1-v1_5", hash: "SHA-256" }, false, ["verify"]);+ // Each hash also drives MGF1.+ const hashRoundTrips = [];+ for (const hash of ["SHA-1", "SHA-384", "SHA-512"]) {+ const signer = await subtle.importKey("pkcs8", rsaTestKey.pkcs8, { name: "RSA-PSS", hash }, false, ["sign"]);+ const verifier = await subtle.importKey("spki", rsaTestKey.spki, { name: "RSA-PSS", hash }, false, ["verify"]);+ const signature = await subtle.sign(pss(16), signer, data);+ hashRoundTrips.push(await subtle.verify(pss(16), verifier, signature, data) && !(await subtle.verify(pss(16), publicKey, signature, data)));+ }+ // An invalid saltLength rejects the promise rather than throwing.+ const noSaltPromise = subtle.sign("RSA-PSS", privateKey, data);+ const noSaltIsPromise = noSaltPromise instanceof Promise;+ await noSaltPromise.catch(() => {});+ const hmac = await subtle.generateKey({ name: "HMAC", hash: "SHA-256" }, true, ["sign"]);++ const results = {+ unsaltedValid: await subtle.verify(pss(0), publicKey, unsalted, data),+ saltedValid: await subtle.verify(pss(32), publicKey, salted, data),+ saltedAgainValid: await subtle.verify(pss(32), publicKey, saltedAgain, data),+ wrongSaltLength: await subtle.verify(pss(48), publicKey, salted, data),+ otherData: await subtle.verify(pss(32), publicKey, salted, new TextEncoder().encode("other")),+ generatedValid: await subtle.verify(pss(20), pair.publicKey, generatedSignature, data),+ // The salt must fit the key: 2048 bits with SHA-256 leave room for 222 bytes.+ maxSalt: await errorName(() => subtle.sign(pss(222), privateKey, data)),+ saltTooLong: await errorName(() => subtle.sign(pss(223), privateKey, data)),+ longSaltVerify: await subtle.verify(pss(1000), publicKey, salted, data),+ // The spec has no error here: past 2^31 - 1 too, it's a signature that+ // doesn't verify. (Chrome rejects those with OperationError.)+ hugeSaltVerify: await subtle.verify(pss(4294967295), publicKey, salted, data).catch((err) => err.name),+ // saltLength is a required [EnforceRange] unsigned long, checked before the key.+ noSalt: await errorName(() => subtle.sign("RSA-PSS", privateKey, data)),+ noSaltObject: await errorName(() => subtle.verify({ name: "RSA-PSS" }, publicKey, salted, data)),+ negativeSalt: await errorName(() => subtle.sign(pss(-1), privateKey, data)),+ saltOverflow: await errorName(() => subtle.sign(pss(4294967296), privateKey, data)),+ nanSalt: await errorName(() => subtle.sign(pss(NaN), privateKey, data)),+ noSaltOnHmac: await errorName(() => subtle.sign("RSA-PSS", hmac, data)),+ stringSalt: await errorName(() => subtle.sign(pss("32"), privateKey, data)),+ // null converts to 0, as for any unsigned long.+ nullSalt: await subtle.verify(pss(0), publicKey, await subtle.sign(pss(null), privateKey, data), data),+ // Other algorithms ignore the member.+ hmacWithSalt: await errorName(() => subtle.sign({ name: "HMAC", saltLength: -1 }, hmac, data)),+ // RSA-PSS and RSASSA-PKCS1-v1_5 keys don't mix.+ pssOnRsassa: await errorName(() => subtle.verify(pss(32), rsassa, salted, data)),+ rsassaOnPss: await errorName(() => subtle.sign("RSASSA-PKCS1-v1_5", privateKey, data)),+ // JWK: a "sig" key whose `alg` is the PS one of the requested hash.+ jwkAlgOtherHash: await errorName(() => subtle.importKey("jwk", { ...publicJwk, alg: "PS384" }, algo, true, ["verify"])),+ jwkAlgRs: await errorName(() => subtle.importKey("jwk", { ...publicJwk, alg: "RS256" }, algo, true, ["verify"])),+ jwkUseEnc: await errorName(() => subtle.importKey("jwk", { ...publicJwk, use: "enc" }, algo, true, ["verify"])),+ // Usages: sign for the private key, verify for the public one.+ verifyOnly: await errorName(() => subtle.generateKey(+ { ...algo, modulusLength: 1024, publicExponent: new Uint8Array([1, 0, 1]) }, true, ["verify"])),+ spkiForSign: await errorName(() => subtle.importKey("spki", rsaTestKey.spki, algo, true, ["sign"])),+ };++ state.resolve();+ await state.done(() => {+ testing.expectEqual(expected, b64(unsalted));+ testing.expectEqual(true, results.unsaltedValid);+ testing.expectEqual(256, salted.byteLength);+ testing.expectEqual(false, b64(salted) === b64(saltedAgain));+ testing.expectEqual(true, results.saltedValid);+ testing.expectEqual(true, results.saltedAgainValid);+ testing.expectEqual(false, results.wrongSaltLength);+ testing.expectEqual(false, results.otherData);+ testing.expectEqual(true, results.generatedValid);+ testing.expectEqual(null, results.maxSalt);+ testing.expectEqual("OperationError", results.saltTooLong);+ testing.expectEqual(false, results.longSaltVerify);+ testing.expectEqual(false, results.hugeSaltVerify);+ testing.expectEqual("TypeError", results.noSalt);+ testing.expectEqual("TypeError", results.noSaltObject);+ testing.expectEqual("TypeError", results.negativeSalt);+ testing.expectEqual("TypeError", results.saltOverflow);+ testing.expectEqual("TypeError", results.nanSalt);+ testing.expectEqual("TypeError", results.noSaltOnHmac);+ testing.expectEqual(null, results.stringSalt);+ testing.expectEqual(true, results.nullSalt);+ testing.expectEqual("true,true,true", hashRoundTrips.join(","));+ testing.expectEqual(true, noSaltIsPromise);+ testing.expectEqual(null, results.hmacWithSalt);+ testing.expectEqual("InvalidAccessError", results.pssOnRsassa);+ testing.expectEqual("InvalidAccessError", results.rsassaOnPss);+ testing.expectEqual("DataError", results.jwkAlgOtherHash);+ testing.expectEqual("DataError", results.jwkAlgRs);+ testing.expectEqual("DataError", results.jwkUseEnc);+ testing.expectEqual("SyntaxError", results.verifyOnly);+ testing.expectEqual("SyntaxError", results.spkiForSign);+ testing.expectEqual("RSA-PSS", privateKey.algorithm.name);+ testing.expectEqual("RSA-PSS", jwkPrivate.algorithm.name);+ testing.expectEqual("PS256", publicJwk.alg);+ testing.expectEqual("sign", privateJwk.key_ops.join(","));+ testing.expectEqual("PS1,PS256,PS384,PS512", algs.join(","));+ });+</script>+<script id=wrap-unwrap type=module>const state = await testing.async();const subtle = crypto.subtle;diff --git a/src/browser/webapi/SubtleCrypto.zig b/src/browser/webapi/SubtleCrypto.zigindex 1bd531efe..15441109d 100644--- a/src/browser/webapi/SubtleCrypto.zig+++ b/src/browser/webapi/SubtleCrypto.zig@@ -652,10 +652,11 @@ pub fn sign(exec: *const Execution,) !js.Promise {const local = exec.js.local.?;+ const salt_length = try pssSaltLength(algo, local);try checkSigningKey(algo, key, CryptoKey.Usages.sign);const signature = switch (key._type) {.hmac => try HMAC.sign(key, data, exec),- .rsa => try RSA.sign(key, data, exec),+ .rsa => try RSA.sign(key, data, salt_length, exec),// A signing algorithm with no sign here yet (ECDSA).else => {log.debug(.not_implemented, "SubtleCrypto.sign", .{ .key_type = key._type });@@ -675,10 +676,11 @@ pub fn verify(exec: *const Execution,) !js.Promise {const local = exec.js.local.?;+ const salt_length = try pssSaltLength(algo, local);try checkSigningKey(algo, key, CryptoKey.Usages.verify);const valid = switch (key._type) {.hmac => try HMAC.verify(key, signature, data),- .rsa => try RSA.verify(key, signature, data),+ .rsa => try RSA.verify(key, signature, data, salt_length),// A signing algorithm with no verify here yet (ECDSA).else => {log.debug(.not_implemented, "SubtleCrypto.verify", .{ .key_type = key._type });@@ -688,6 +690,17 @@ pub fn verify(return local.resolvePromise(valid);}+/// The `saltLength` of an RSA-PSS algorithm (RsaPssParams), null for the other+/// algorithms. Normalization comes before the key checks: a missing member or+/// one outside [EnforceRange] unsigned long is a TypeError.+fn pssSaltLength(algo: algorithm.Sign, local: *const js.Local) !?u32 {+ if (!eqlIgnoreCase(algo.algoName(), "RSA-PSS")) {+ return null;+ }+ const value = algo.saltLength() orelse return local.typeError("RSA-PSS requires a saltLength");+ return js.enforceRange(u32, try value.toF64()) catch local.typeError("saltLength is out of range");+}+/// The checks sign/verify make before the algorithm's own, in the spec's/// order: an algorithm that signs (else NotSupported), the key's own algorithm,/// and the sign or verify usage (else InvalidAccessError). The names matchdiff --git a/src/browser/webapi/crypto/RSA.zig b/src/browser/webapi/crypto/RSA.zigindex 7a4e5ac52..131965766 100644--- a/src/browser/webapi/crypto/RSA.zig+++ b/src/browser/webapi/crypto/RSA.zig@@ -16,11 +16,11 @@// You should have received a copy of the GNU Affero General Public License// along with this program. If not, see <https://www.gnu.org/licenses/>.-//! RSA-OAEP and RSASSA-PKCS1-v1_5: key generation, import and export+//! RSA-OAEP, RSASSA-PKCS1-v1_5 and RSA-PSS: key generation, import and export//! (spki/pkcs8 DER and JWK), the encrypt/decrypt operations of RSA-OAEP and-//! the sign/verify operations of RSASSA-PKCS1-v1_5. The key material lives as-//! a libcrypto EVP_PKEY in `CryptoKey._vary.pkey`. See EC.zig for the-//! asymmetric-key rationale.+//! the sign/verify operations of RSASSA-PKCS1-v1_5 and RSA-PSS. The key+//! material lives as a libcrypto EVP_PKEY in `CryptoKey._vary.pkey`. See+//! EC.zig for the asymmetric-key rationale.const std = @import("std");@@ -94,7 +94,7 @@ pub const Scheme = struct {/// The JWK `use` of the keys.jwk_use: []const u8,/// The JWK `alg` for each of `hashes`: the values of JWA, sections 3.1 and- /// 4.1, and WebCrypto's "RS1" for RSASSA-PKCS1-v1_5 with SHA-1.+ /// 4.1, and WebCrypto's "RS1" and "PS1" for the signatures with SHA-1.jwk_algs: [hashes.len][]const u8,};@@ -113,6 +113,13 @@ const schemes = [_]Scheme{.jwk_use = "sig",.jwk_algs = .{ "RS1", "RS256", "RS384", "RS512" },},+ .{+ .name = "RSA-PSS",+ .private_usages = &.{"sign"},+ .public_usages = &.{"verify"},+ .jwk_use = "sig",+ .jwk_algs = .{ "PS1", "PS256", "PS384", "PS512" },+ },};/// The scheme of an RSA algorithm name (case-insensitive), or null if it isn't@@ -168,8 +175,6 @@ pub fn generate(const local = exec.js.local.?;try validate(params, key_usages);- // validate() also accepts RSA-PSS (so its parameter errors are reported- // correctly), but it isn't implemented.const s = scheme(params.name) orelse return error.NotSupported;// Generation runs on the main thread and can't be interrupted, and its cost@@ -280,8 +285,8 @@ pub fn import(/// public key, plus `d`, `p`, `q`, `dp`, `dq` and `qi` for a private one (the/// presence of `d` decides, as in SubtleCrypto.importKind, which already/// validated the usages against it). Follows the "import key" steps of-/// RSA-OAEP and RSASSA-PKCS1-v1_5: a JWK that doesn't fit the requested key, or-/// describes an invalid one, is DataError.+/// RSA-OAEP, RSASSA-PKCS1-v1_5 and RSA-PSS: a JWK that doesn't fit the+/// requested key, or describes an invalid one, is DataError.pub fn importJwk(s: *const Scheme,jwk: algorithm.KeyData.Jwk,@@ -521,13 +526,14 @@ pub fn crypt(return out[0..out_len];}-/// RSASSA-PKCS1-v1_5 signature generation (RFC 8017, section 8.2.1) of `data`-/// with the key's hash. SubtleCrypto.sign checked the algorithm and the sign-/// usage; only a private key signs.-pub fn sign(key: *const CryptoKey, data: []const u8, exec: *const Execution) ![]const u8 {+/// RSASSA-PKCS1-v1_5 or RSA-PSS signature generation (RFC 8017, sections+/// 8.2.1 and 8.1.1) of `data` with the key's hash. `salt_length` is RSA-PSS's,+/// in bytes. SubtleCrypto.sign checked the algorithm and the sign usage; only+/// a private key signs.+pub fn sign(key: *const CryptoKey, data: []const u8, salt_length: ?u32, exec: *const Execution) ![]const u8 {if (key._kind != .private) return error.InvalidAccessError;- const ctx = try digestContext(key, false);+ const ctx = try digestContext(key, false, salt_length);defer crypto.EVP_MD_CTX_free(ctx);// First call (null output) reports the size; the second writes the buffer.@@ -538,14 +544,15 @@ pub fn sign(key: *const CryptoKey, data: []const u8, exec: *const Execution) ![]return out[0..sig_len];}-/// RSASSA-PKCS1-v1_5 signature verification (RFC 8017, section 8.2.2) of-/// `signature` over `data` with the key's hash. SubtleCrypto.verify checked-/// the algorithm and the verify usage; only a public key verifies. A signature-/// that doesn't match, whatever its length, is false rather than an error.-pub fn verify(key: *const CryptoKey, signature: []const u8, data: []const u8) !bool {+/// RSASSA-PKCS1-v1_5 or RSA-PSS signature verification (RFC 8017, sections+/// 8.2.2 and 8.1.2) of `signature` over `data` with the key's hash, and+/// RSA-PSS's `salt_length`. SubtleCrypto.verify checked the algorithm and the+/// verify usage; only a public key verifies. A signature that doesn't match,+/// whatever its length or salt, is false rather than an error.+pub fn verify(key: *const CryptoKey, signature: []const u8, data: []const u8, salt_length: ?u32) !bool {if (key._kind != .public) return error.InvalidAccessError;- const ctx = try digestContext(key, true);+ const ctx = try digestContext(key, true, salt_length);defer crypto.EVP_MD_CTX_free(ctx);if (crypto.EVP_DigestVerify(ctx, signature.ptr, signature.len, data.ptr, data.len) == 1) return true;@@ -555,9 +562,10 @@ pub fn verify(key: *const CryptoKey, signature: []const u8, data: []const u8) !breturn false;}-/// A digest context set up to sign or verify with `key`: its hash, and-/// PKCS #1 v1.5 padding. Free it with EVP_MD_CTX_free.-fn digestContext(key: *const CryptoKey, verifying: bool) !*crypto.EVP_MD_CTX {+/// A digest context set up to sign or verify with `key`: its hash, and the+/// padding of its algorithm (PKCS #1 v1.5, or PSS with MGF1 over the same hash+/// and `salt_length`). Free it with EVP_MD_CTX_free.+fn digestContext(key: *const CryptoKey, verifying: bool, salt_length: ?u32) !*crypto.EVP_MD_CTX {const hash_name = key._algorithm.hash orelse return error.OperationError;const md = crypto.findDigest(hash_name) catch return error.OperationError;@@ -570,7 +578,18 @@ fn digestContext(key: *const CryptoKey, verifying: bool) !*crypto.EVP_MD_CTX {elsecrypto.EVP_DigestSignInit(ctx, &pctx, md, null, key.getKeyObject());if (init_ok != 1) return error.OperationError;- if (crypto.EVP_PKEY_CTX_set_rsa_padding(pctx, crypto.RSA_PKCS1_PADDING) != 1) return error.OperationError;++ if (!std.mem.eql(u8, key._algorithm.name, "RSA-PSS")) {+ if (crypto.EVP_PKEY_CTX_set_rsa_padding(pctx, crypto.RSA_PKCS1_PADDING) != 1) return error.OperationError;+ return ctx;+ }+ // Negative lengths are libcrypto's special values (the digest's length,+ // the maximum), so a length past c_int is capped instead: it's longer than+ // any key allows, and signing or verifying with it fails as it should.+ const salt: c_int = @intCast(@min(salt_length orelse return error.OperationError, std.math.maxInt(c_int)));+ if (crypto.EVP_PKEY_CTX_set_rsa_padding(pctx, crypto.RSA_PKCS1_PSS_PADDING) != 1) return error.OperationError;+ if (crypto.EVP_PKEY_CTX_set_rsa_mgf1_md(pctx, md) != 1) return error.OperationError;+ if (crypto.EVP_PKEY_CTX_set_rsa_pss_saltlen(pctx, salt) != 1) return error.OperationError;return ctx;}diff --git a/src/browser/webapi/crypto/algorithm.zig b/src/browser/webapi/crypto/algorithm.zigindex d1f9f644b..96e0064bc 100644--- a/src/browser/webapi/crypto/algorithm.zig+++ b/src/browser/webapi/crypto/algorithm.zig@@ -224,7 +224,13 @@ pub const Encrypt = union(enum) {/// For `sign()` functionality.pub const Sign = union(enum) {string: []const u8,- object: struct { name: []const u8 },+ object: struct {+ name: []const u8,+ /// RSA-PSS. Kept as a value: it's only converted (an [EnforceRange]+ /// unsigned long) when the algorithm is RSA-PSS, so another algorithm+ /// ignores the member, as normalization does.+ saltLength: ?js.Value = null,+ },pub fn algoName(self: Sign) []const u8 {return switch (self) {@@ -232,4 +238,12 @@ pub const Sign = union(enum) {.object => |object| object.name,};}++ /// The `saltLength` member, if present.+ pub fn saltLength(self: Sign) ?js.Value {+ return switch (self) {+ .string => null,+ .object => |object| object.saltLength,+ };+ }};diff --git a/src/sys/libcrypto.zig b/src/sys/libcrypto.zigindex 9ee15c1a8..7434d2747 100644--- a/src/sys/libcrypto.zig+++ b/src/sys/libcrypto.zig@@ -158,6 +158,7 @@ pub extern fn d2i_AutoPrivateKey(out: ?*?*EVP_PKEY, inp: *[*c]const u8, len: c_lpub const EVP_PKEY_RSA = 6; // NID_rsaEncryptionpub const RSA_PKCS1_PADDING = 1;pub const RSA_PKCS1_OAEP_PADDING = 4;+pub const RSA_PKCS1_PSS_PADDING = 6;const struct_rsa_st = opaque {};pub const RSA = struct_rsa_st;@@ -217,6 +218,9 @@ pub extern fn EVP_PKEY_decrypt(ctx: ?*EVP_PKEY_CTX, out: [*c]u8, out_len: *usizepub extern fn EVP_PKEY_CTX_set_rsa_padding(ctx: ?*EVP_PKEY_CTX, padding: c_int) c_int;pub extern fn EVP_PKEY_CTX_set_rsa_oaep_md(ctx: ?*EVP_PKEY_CTX, md: *const EVP_MD) c_int;pub extern fn EVP_PKEY_CTX_set_rsa_mgf1_md(ctx: ?*EVP_PKEY_CTX, md: *const EVP_MD) c_int;+/// Negative values are special: -1 is the digest's length; -2 is the maximum+/// when signing, and any length (read from the signature) when verifying.+pub extern fn EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx: ?*EVP_PKEY_CTX, salt_len: c_int) c_int;/// Takes ownership of `label` (an OPENSSL_malloc buffer) on success only.pub extern fn EVP_PKEY_CTX_set0_rsa_oaep_label(ctx: ?*EVP_PKEY_CTX, label: [*]u8, label_len: usize) c_int;