Initial commit

This commit is contained in:
talksik
2021-12-29 01:57:42 -08:00
commit ce39a60b42
4634 changed files with 997667 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
const { randomBytes } = require('crypto')
const { createSecretKey } = require('../help/key_object')
const { KEYLENGTHS } = require('../registry')
const Key = require('../jwk/key/oct')
module.exports = (alg) => {
const keyLength = KEYLENGTHS.get(alg)
if (!keyLength) {
return new Key({ type: 'secret' })
}
return new Key(createSecretKey(randomBytes(keyLength / 8)), { use: 'enc', alg })
}