rename encrypt/decrypt to wrap/unwrap in *Wrap
ci/woodpecker/manual/test Pipeline was successful

This commit is contained in:
2024-09-09 22:49:42 +02:00
parent c49f3b84bf
commit 9de49c228d
8 changed files with 42 additions and 42 deletions
+6 -6
View File
@@ -17,17 +17,17 @@ export default class PrivateWrap {
return crypto.subtle.generateKey(consts.ECDH, extractable, ['deriveKey']) as Promise<CryptoKeyPair>
}
public static async encrypt(data: CryptoKey, pubkey: CryptoKey): Promise<PrivateWrap> {
log.trace('encrypt')
public static async wrap(data: CryptoKey, pubkey: CryptoKey): Promise<PrivateWrap> {
log.trace('wrap')
const tmp_keypair = await PrivateWrap.gen()
const kd = await ecdh(tmp_keypair.privateKey, pubkey, DHusage.wrap)
const box = await SecretWrap.encrypt(data, kd)
const box = await SecretWrap.wrap(data, kd)
return new this(box, tmp_keypair.publicKey)
}
public async decrypt(privkey: CryptoKey): Promise<CryptoKey | null> {
log.trace('decrypt')
public async unwrap(privkey: CryptoKey): Promise<CryptoKey | null> {
log.trace('unwrap')
const kd = await ecdh(privkey, this.pubkey, DHusage.wrap)
return this.box.decrypt(kd)
return this.box.unwrap(kd)
}
public async toString(): Promise<string> {