Expand description

Code related to RSA_PSS

Functions

Export an RSA_PSS public or private key

example
const pubKeyJwk = await RSA_PSS.importKey("jwk", keyPair.publicKey.self);
example
const pubKeyJwk = await keyPair.publicKey.importKey("jwk");

Parameters

Returns Promise<ArrayBuffer | JsonWebKey>

Generate a new RSA_PSS keypair

example
const keyPair = await RSA_PSS.generateKey();

Parameters

  • algorithm: Omit<EnforcedRsaHashedKeyGenParams, "name"> = { hash: SHA.Variant.SHA_512, modulusLength: 4096, publicExponent: new Uint8Array([0x01, 0x00, 0x01]), }
  • Optional extractable: boolean
  • Optional keyUsages: KeyUsage[]

Returns Promise<RsaPssProxiedCryptoKeyPair>

Generate a new RSA_PSS keypair

alias

generateKey

example
const keyPair = await RSA_PSS.generateKeyPair();

Parameters

  • algorithm: Omit<EnforcedRsaHashedKeyGenParams, "name"> = { hash: SHA.Variant.SHA_512, modulusLength: 4096, publicExponent: new Uint8Array([0x01, 0x00, 0x01]), }
  • Optional extractable: boolean
  • Optional keyUsages: KeyUsage[]

Returns Promise<RsaPssProxiedCryptoKeyPair>

Import an RSA_PSS public or private key

example
const key = await RSA_PSS.importKey("jwk", pubKey, { hash: "SHA-512" }, true, ['verify']);

Parameters

  • format: KeyFormat
  • key: BufferSource | JsonWebKey
  • algorithm: Omit<EnforcedRsaHashedImportParams, "name">
  • Optional extractable: boolean
  • Optional keyUsages: KeyUsage[]

Returns Promise<RsaPssProxiedPubCryptoKey | RsaPssProxiedPrivCryptoKey>

Sign a given payload

example
const message = new TextEncoder().encode("a message");
const signature = await RSA_PSS.sign(128, keyPair.privateKey.self, message);
example
const message = new TextEncoder().encode("a message");
const signature = await keyPair.privateKey.sign(128, message);

Parameters

Returns Promise<ArrayBuffer>

Verify a given signature

example
const message = new TextEncoder().encode("a message");
const isVerified = await ECDSA.verify(128, keyPair.publicKey.self, signature, message);
example
const message = new TextEncoder().encode("a message");
const isVerified = await keyPair.publicKey.verify(128, signature, message);

Parameters

Returns Promise<boolean>