Expand description

Code related to RSASSA_PKCS1_v1_5

Functions

Export an RSASSA_PKCS1_v1_5 public or private key

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

Parameters

Returns Promise<ArrayBuffer | JsonWebKey>

Generate a new RSASSA_PKCS1_v1_5 keypair

example
const keyPair = await RSASSA_PKCS1_v1_5.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<RsassaPkcs1V15ProxiedCryptoKeyPair>

Generate a new RSASSA_PKCS1_v1_5 keypair

alias

generateKey

example
const keyPair = await RSASSA_PKCS1_v1_5.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<RsassaPkcs1V15ProxiedCryptoKeyPair>

Import an RSASSA_PKCS1_v1_5 public or private key

example
const key = await RSASSA_PKCS1_v1_5.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<RsassaPkcs1V15ProxiedPubCryptoKey | RsassaPkcs1V15ProxiedPrivCryptoKey>

Sign a given payload

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

Parameters

Returns Promise<ArrayBuffer>

Verify a given signature

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

Parameters

Returns Promise<boolean>