Skip to content

Commit c8a0fc2

Browse files
committed
crypto: rsa consistent naming generateKeyPair
1 parent a92fe4b commit c8a0fc2

3 files changed

Lines changed: 6 additions & 5 deletions

File tree

bin/gentesthtml.js

100644100755
File mode changed.

crypto.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const testEncryption = async tc => {
1919
t.compare(data, dec)
2020
})
2121
await t.groupAsync('RSA', async () => {
22-
const keypair = await rsa.generateKey()
22+
const keypair = await rsa.generateKeyPair()
2323
const enc = await rsa.encrypt(keypair.publicKey, data)
2424
const dec = await rsa.decrypt(keypair.privateKey, enc)
2525
t.compare(data, dec)
@@ -35,8 +35,8 @@ export const testEncryption = async tc => {
3535
})
3636
await t.groupAsync('asymmetric can fail', async () => {
3737
await t.failsAsync(async () => {
38-
const keypair = await rsa.generateKey()
39-
const keypair2 = await rsa.generateKey()
38+
const keypair = await rsa.generateKeyPair()
39+
const keypair2 = await rsa.generateKeyPair()
4040
const enc = await rsa.encrypt(keypair.privateKey, data)
4141
const dec = await rsa.decrypt(keypair2.publicKey, enc)
4242
t.compare(data, dec)
@@ -102,7 +102,7 @@ export const testImportExport = async tc => {
102102
t.compare(jwkPublic, ejwkPublic)
103103
})
104104
await t.groupAsync('rsa-oaep', async () => {
105-
const keypair = await rsa.generateKey({ extractable: true })
105+
const keypair = await rsa.generateKeyPair({ extractable: true })
106106
const jwkPrivate = await rsa.exportKey(keypair.privateKey)
107107
const jwkPublic = await rsa.exportKey(keypair.publicKey)
108108
const ekeyPrivate = await rsa.importKey(jwkPrivate, { extractable: true })

crypto/rsa-oaep.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ export const decrypt = (key, data) =>
5252
* @param {Object} opts
5353
* @param {boolean} [opts.extractable]
5454
* @param {Usages} [opts.usages]
55+
* @return {Promise<CryptoKeyPair>}
5556
*/
56-
export const generateKey = ({ extractable = false, usages = defaultUsages } = {}) =>
57+
export const generateKeyPair = ({ extractable = false, usages = defaultUsages } = {}) =>
5758
webcrypto.subtle.generateKey(
5859
{
5960
name: 'RSA-OAEP',

0 commit comments

Comments
 (0)