Allow to choose if extractable or not
ci/woodpecker/push/test Pipeline was successful

This commit is contained in:
2024-06-11 14:32:23 +02:00
parent 1e5bf39b4f
commit 5cc375bd5a
6 changed files with 26 additions and 8 deletions
+2 -2
View File
@@ -17,11 +17,11 @@ export class PrivateWrap {
private readonly pubkey: CryptoKey,
) {}
public static gen_keypair() : Promise<CryptoKeyPair> {
public static gen_keypair(extractable : boolean = true) : Promise<CryptoKeyPair> {
log.trace("generate keypair")
return crypto.subtle.generateKey(
algorithm,
true,
extractable,
["deriveKey"],
)
}
+2 -2
View File
@@ -9,14 +9,14 @@ export class SecretBox {
private readonly cipher: Uint8Array,
) {}
public static gen_key() : Promise<CryptoKey> {
public static gen_key(extractable : boolean = true) : Promise<CryptoKey> {
log.trace("generate key")
return crypto.subtle.generateKey(
{
name: "AES-GCM",
length: 256,
},
true,
extractable,
["encrypt", "decrypt"],
)
}
+2 -2
View File
@@ -12,14 +12,14 @@ export class SecretWrap {
private readonly iv: Uint8Array,
) {}
public static gen_key() : Promise<CryptoKey> {
public static gen_key(extractable : boolean = true) : Promise<CryptoKey> {
log.trace("generate key")
return crypto.subtle.generateKey(
{
name: "AES-GCM",
length: 256,
},
true,
extractable,
["wrapKey", "unwrapKey"],
)
}
+2 -2
View File
@@ -1,13 +1,13 @@
import logger from 'log'
const log = logger('crypto:signature')
export async function gen_keypair() : Promise<CryptoKeyPair> {
export async function gen_keypair(extractable : boolean = true) : Promise<CryptoKeyPair> {
return crypto.subtle.generateKey(
{
name: "ECDSA",
namedCurve: "P-521",
},
true,
extractable,
["sign", "verify"]
)
}