Module rsa/rsa_pss
source · [−]Expand description
Code related to RSA_PSS
Functions
sourceexportKey
exportKey
source(format: KeyFormat, key: RsaPssPubCryptoKey | RsaPssPrivCryptoKey): Promise<ArrayBuffer | JsonWebKey>
(format: KeyFormat, key: RsaPssPubCryptoKey | RsaPssPrivCryptoKey): Promise<ArrayBuffer | JsonWebKey>
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
format: KeyFormat
key: RsaPssPubCryptoKey | RsaPssPrivCryptoKey
Returns Promise<ArrayBuffer | JsonWebKey>
sourcegenerateKey
generateKey
source(algorithm?: Omit<EnforcedRsaHashedKeyGenParams, "name">, extractable?: boolean, keyUsages?: KeyUsage[]): Promise<RsaPssProxiedCryptoKeyPair>
(algorithm?: Omit<EnforcedRsaHashedKeyGenParams, "name">, extractable?: boolean, keyUsages?: KeyUsage[]): Promise<RsaPssProxiedCryptoKeyPair>
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>
sourcegenerateKeyPai
generateKeyPai
source(algorithm?: Omit<EnforcedRsaHashedKeyGenParams, "name">, extractable?: boolean, keyUsages?: KeyUsage[]): Promise<RsaPssProxiedCryptoKeyPair>
(algorithm?: Omit<EnforcedRsaHashedKeyGenParams, "name">, extractable?: boolean, keyUsages?: KeyUsage[]): 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>
sourceimportKey
importKey
source(format: KeyFormat, key: BufferSource | JsonWebKey, algorithm: Omit<EnforcedRsaHashedImportParams, "name">, extractable?: boolean, keyUsages?: KeyUsage[]): Promise<RsaPssProxiedPubCryptoKey | RsaPssProxiedPrivCryptoKey>
(format: KeyFormat, key: BufferSource | JsonWebKey, algorithm: Omit<EnforcedRsaHashedImportParams, "name">, extractable?: boolean, keyUsages?: KeyUsage[]): Promise<RsaPssProxiedPubCryptoKey | RsaPssProxiedPrivCryptoKey>
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>
sourcesign
sign
source(saltLength: number, key: RsaPssPrivCryptoKey, data: BufferSource): Promise<ArrayBuffer>
(saltLength: number, key: RsaPssPrivCryptoKey, data: BufferSource): Promise<ArrayBuffer>
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
saltLength: number
key: RsaPssPrivCryptoKey
data: BufferSource
Returns Promise<ArrayBuffer>
sourceverify
verify
source(saltLength: number, key: RsaPssPubCryptoKey, signature: BufferSource, data: BufferSource): Promise<boolean>
(saltLength: number, key: RsaPssPubCryptoKey, signature: BufferSource, data: BufferSource): Promise<boolean>
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
saltLength: number
key: RsaPssPubCryptoKey
signature: BufferSource
data: BufferSource