This commit is contained in:
+6
-6
@@ -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> {
|
||||
|
||||
Reference in New Issue
Block a user