Module rsa/rsassa_pkcs1_v1_5
source · [−]Expand description
Code related to RSASSA_PKCS1_v1_5
Functions
sourceexportKey
exportKey
source(format: KeyFormat, key: RsassaPkcs1V15PubCryptoKey | RsassaPkcs1V15PrivCryptoKey): Promise<ArrayBuffer | JsonWebKey>
(format: KeyFormat, key: RsassaPkcs1V15PubCryptoKey | RsassaPkcs1V15PrivCryptoKey): Promise<ArrayBuffer | JsonWebKey>
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
format: KeyFormat
key: RsassaPkcs1V15PubCryptoKey | RsassaPkcs1V15PrivCryptoKey
Returns Promise<ArrayBuffer | JsonWebKey>
sourcegenerateKey
generateKey
source(algorithm?: Omit<EnforcedRsaHashedKeyGenParams, "name">, extractable?: boolean, keyUsages?: KeyUsage[]): Promise<RsassaPkcs1V15ProxiedCryptoKeyPair>
(algorithm?: Omit<EnforcedRsaHashedKeyGenParams, "name">, extractable?: boolean, keyUsages?: KeyUsage[]): Promise<RsassaPkcs1V15ProxiedCryptoKeyPair>
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>
sourcegenerateKeyPair
generateKeyPair
source(algorithm?: Omit<EnforcedRsaHashedKeyGenParams, "name">, extractable?: boolean, keyUsages?: KeyUsage[]): Promise<RsassaPkcs1V15ProxiedCryptoKeyPair>
(algorithm?: Omit<EnforcedRsaHashedKeyGenParams, "name">, extractable?: boolean, keyUsages?: KeyUsage[]): 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>
sourceimportKey
importKey
source(format: KeyFormat, key: BufferSource | JsonWebKey, algorithm: Omit<EnforcedRsaHashedImportParams, "name">, extractable?: boolean, keyUsages?: KeyUsage[]): Promise<RsassaPkcs1V15ProxiedPubCryptoKey | RsassaPkcs1V15ProxiedPrivCryptoKey>
(format: KeyFormat, key: BufferSource | JsonWebKey, algorithm: Omit<EnforcedRsaHashedImportParams, "name">, extractable?: boolean, keyUsages?: KeyUsage[]): Promise<RsassaPkcs1V15ProxiedPubCryptoKey | RsassaPkcs1V15ProxiedPrivCryptoKey>
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>
sourcesign
sign
source(key: RsassaPkcs1V15PrivCryptoKey, data: BufferSource): Promise<ArrayBuffer>
(key: RsassaPkcs1V15PrivCryptoKey, data: BufferSource): Promise<ArrayBuffer>
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
key: RsassaPkcs1V15PrivCryptoKey
data: BufferSource
Returns Promise<ArrayBuffer>
sourceverify
verify
source(key: RsassaPkcs1V15PubCryptoKey, signature: BufferSource, data: BufferSource): Promise<boolean>
(key: RsassaPkcs1V15PubCryptoKey, signature: BufferSource, data: BufferSource): Promise<boolean>
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
key: RsassaPkcs1V15PubCryptoKey
signature: BufferSource
data: BufferSource