Add getRandomCandidate() and defaults for keyFormat
This commit is contained in:
parent
7af5e072fd
commit
96e9210407
1 changed files with 35 additions and 6 deletions
|
@ -194,6 +194,7 @@ make.crypto = {
|
|||
return this.alg()
|
||||
},
|
||||
presets: {
|
||||
raw: null,
|
||||
jwk: [
|
||||
{
|
||||
kty: 'RSA',
|
||||
|
@ -255,6 +256,7 @@ make.crypto = {
|
|||
return this.alg()
|
||||
},
|
||||
presets: {
|
||||
raw: null,
|
||||
jwk: [
|
||||
{
|
||||
kty: 'RSA',
|
||||
|
@ -327,6 +329,7 @@ make.crypto = {
|
|||
return this.alg()
|
||||
},
|
||||
presets: {
|
||||
raw: null,
|
||||
jkw: [
|
||||
{
|
||||
kty: 'RSA',
|
||||
|
@ -387,6 +390,7 @@ make.crypto = {
|
|||
return this.alg()
|
||||
},
|
||||
presets: {
|
||||
raw: null,
|
||||
jwk: [
|
||||
{
|
||||
kty: 'EC',
|
||||
|
@ -506,6 +510,7 @@ make.crypto = {
|
|||
return this.encrypt()
|
||||
},
|
||||
presets: {
|
||||
raw: new Uint8Array([122, 94, 39, 230, 46, 23, 151, 80, 131, 230, 3, 101, 80, 234, 143, 9, 251, 152, 229, 228, 89, 222, 31, 135, 214, 104, 55, 68, 67, 59, 5, 51]),
|
||||
jwk: [
|
||||
{
|
||||
kty: 'oct',
|
||||
|
@ -514,7 +519,8 @@ make.crypto = {
|
|||
ext: true
|
||||
}
|
||||
],
|
||||
raw: new Uint8Array([122, 94, 39, 230, 46, 23, 151, 80, 131, 230, 3, 101, 80, 234, 143, 9, 251, 152, 229, 228, 89, 222, 31, 135, 214, 104, 55, 68, 67, 59, 5, 51])
|
||||
spki: null,
|
||||
pkcs8: null
|
||||
}
|
||||
},
|
||||
'AES-CBC': {
|
||||
|
@ -566,6 +572,7 @@ make.crypto = {
|
|||
}
|
||||
},
|
||||
presets: {
|
||||
raw: new Uint8Array([122, 94, 39, 230, 46, 23, 151, 80, 131, 230, 3, 101, 80, 234, 143, 9, 251, 152, 229, 228, 89, 222, 31, 135, 214, 104, 55, 68, 67, 59, 5, 51]),
|
||||
jwk: [
|
||||
{
|
||||
kty: 'oct',
|
||||
|
@ -574,7 +581,8 @@ make.crypto = {
|
|||
ext: true
|
||||
}
|
||||
],
|
||||
raw: new Uint8Array([122, 94, 39, 230, 46, 23, 151, 80, 131, 230, 3, 101, 80, 234, 143, 9, 251, 152, 229, 228, 89, 222, 31, 135, 214, 104, 55, 68, 67, 59, 5, 51])
|
||||
spki: null,
|
||||
pkcs8: null
|
||||
}
|
||||
},
|
||||
'AES-GCM': {
|
||||
|
@ -629,6 +637,7 @@ make.crypto = {
|
|||
}
|
||||
},
|
||||
presets: {
|
||||
raw: new Uint8Array([122, 94, 39, 230, 46, 23, 151, 80, 131, 230, 3, 101, 80, 234, 143, 9, 251, 152, 229, 228, 89, 222, 31, 135, 214, 104, 55, 68, 67, 59, 5, 51]),
|
||||
jwk: [
|
||||
{
|
||||
kty: 'oct',
|
||||
|
@ -637,7 +646,8 @@ make.crypto = {
|
|||
ext: true
|
||||
}
|
||||
],
|
||||
raw: new Uint8Array([122, 94, 39, 230, 46, 23, 151, 80, 131, 230, 3, 101, 80, 234, 143, 9, 251, 152, 229, 228, 89, 222, 31, 135, 214, 104, 55, 68, 67, 59, 5, 51])
|
||||
spki: null,
|
||||
pkcs8: null
|
||||
}
|
||||
},
|
||||
'AES-KW': {
|
||||
|
@ -675,6 +685,7 @@ make.crypto = {
|
|||
}
|
||||
},
|
||||
presets: {
|
||||
raw: new Uint8Array([122, 94, 39, 230, 46, 23, 151, 80, 131, 230, 3, 101, 80, 234, 143, 9, 251, 152, 229, 228, 89, 222, 31, 135, 214, 104, 55, 68, 67, 59, 5, 51]),
|
||||
jwk: [
|
||||
{
|
||||
kty: 'oct',
|
||||
|
@ -683,7 +694,8 @@ make.crypto = {
|
|||
ext: true
|
||||
}
|
||||
],
|
||||
raw: new Uint8Array([122, 94, 39, 230, 46, 23, 151, 80, 131, 230, 3, 101, 80, 234, 143, 9, 251, 152, 229, 228, 89, 222, 31, 135, 214, 104, 55, 68, 67, 59, 5, 51])
|
||||
spki: null,
|
||||
pkcs8: null
|
||||
}
|
||||
},
|
||||
'HMAC': {
|
||||
|
@ -719,13 +731,15 @@ make.crypto = {
|
|||
return this.alg()
|
||||
},
|
||||
presets: {
|
||||
raw: new Uint8Array([122, 94, 39, 230, 46, 23, 151, 80, 131, 230, 3, 101, 80, 234, 143, 9, 251, 152, 229, 228, 89, 222, 31, 135, 214, 104, 55, 68, 67, 59, 5, 51]),
|
||||
jwk: {
|
||||
kty: 'oct',
|
||||
k: 'KfKY5nueRX7eBrOddn9IerHLv1r-T7qpggaCF3MfSR4',
|
||||
alg: 'HS256',
|
||||
ext: true
|
||||
},
|
||||
raw: new Uint8Array([122, 94, 39, 230, 46, 23, 151, 80, 131, 230, 3, 101, 80, 234, 143, 9, 251, 152, 229, 228, 89, 222, 31, 135, 214, 104, 55, 68, 67, 59, 5, 51])
|
||||
spki: null,
|
||||
pkcs8: null
|
||||
}
|
||||
},
|
||||
'HKDF': {
|
||||
|
@ -773,6 +787,9 @@ make.crypto = {
|
|||
return {
|
||||
}
|
||||
},
|
||||
generateKey: () => {
|
||||
return this.alg()
|
||||
},
|
||||
deriveBits: function () {
|
||||
return Object.assign(
|
||||
this.alg(),
|
||||
|
@ -789,7 +806,10 @@ make.crypto = {
|
|||
return this.deriveBits()
|
||||
},
|
||||
presets: {
|
||||
raw: crypto.getRandomValues(new Uint8Array(16))
|
||||
raw: crypto.getRandomValues(new Uint8Array(16)),
|
||||
jwk: null,
|
||||
spki: null,
|
||||
pkcs8: null
|
||||
}
|
||||
},
|
||||
'DH': {
|
||||
|
@ -825,10 +845,19 @@ make.crypto = {
|
|||
this.generateKey(),
|
||||
key
|
||||
)
|
||||
},
|
||||
presets: {
|
||||
raw: null,
|
||||
jwk: null,
|
||||
spki: null,
|
||||
pkcs8: null
|
||||
}
|
||||
}
|
||||
},
|
||||
randomAlgorithm: () => {
|
||||
return make.crypto.algorithms[random.item(Object.keys(make.crypto.algorithms))]
|
||||
},
|
||||
getRandomCandidate: (alg) => {
|
||||
return make.crypto.randomAlgorithm(make.crypto.algorithmNames[random.item(alg.keyUsages)])
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue