@openwallet-foundation/askar-shared 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +191 -0
- package/README.md +44 -0
- package/build/askar/Askar.d.ts +437 -0
- package/build/askar/Askar.js +3 -0
- package/build/askar/Askar.js.map +1 -0
- package/build/askar/index.d.ts +2 -0
- package/build/askar/index.js +19 -0
- package/build/askar/index.js.map +1 -0
- package/build/askar/register.d.ts +5 -0
- package/build/askar/register.js +8 -0
- package/build/askar/register.js.map +1 -0
- package/build/crypto/AeadParams.d.ts +9 -0
- package/build/crypto/AeadParams.js +11 -0
- package/build/crypto/AeadParams.js.map +1 -0
- package/build/crypto/CryptoBox.d.ts +24 -0
- package/build/crypto/CryptoBox.js +23 -0
- package/build/crypto/CryptoBox.js.map +1 -0
- package/build/crypto/Ecdh1PU.d.ts +58 -0
- package/build/crypto/Ecdh1PU.js +77 -0
- package/build/crypto/Ecdh1PU.js.map +1 -0
- package/build/crypto/EcdhEs.d.ts +46 -0
- package/build/crypto/EcdhEs.js +64 -0
- package/build/crypto/EcdhEs.js.map +1 -0
- package/build/crypto/EncryptedBuffer.d.ts +20 -0
- package/build/crypto/EncryptedBuffer.js +36 -0
- package/build/crypto/EncryptedBuffer.js.map +1 -0
- package/build/crypto/Jwk.d.ts +18 -0
- package/build/crypto/Jwk.js +24 -0
- package/build/crypto/Jwk.js.map +1 -0
- package/build/crypto/Key.d.ts +73 -0
- package/build/crypto/Key.js +101 -0
- package/build/crypto/Key.js.map +1 -0
- package/build/crypto/handles.d.ts +46 -0
- package/build/crypto/handles.js +123 -0
- package/build/crypto/handles.js.map +1 -0
- package/build/crypto/index.d.ts +8 -0
- package/build/crypto/index.js +25 -0
- package/build/crypto/index.js.map +1 -0
- package/build/enums/EntryOperation.d.ts +5 -0
- package/build/enums/EntryOperation.js +10 -0
- package/build/enums/EntryOperation.js.map +1 -0
- package/build/enums/KeyAlgorithm.d.ts +20 -0
- package/build/enums/KeyAlgorithm.js +38 -0
- package/build/enums/KeyAlgorithm.js.map +1 -0
- package/build/enums/KeyBackend.d.ts +6 -0
- package/build/enums/KeyBackend.js +24 -0
- package/build/enums/KeyBackend.js.map +1 -0
- package/build/enums/KeyMethod.d.ts +4 -0
- package/build/enums/KeyMethod.js +9 -0
- package/build/enums/KeyMethod.js.map +1 -0
- package/build/enums/LogLevel.d.ts +9 -0
- package/build/enums/LogLevel.js +14 -0
- package/build/enums/LogLevel.js.map +1 -0
- package/build/enums/SignatureAlgorithm.d.ts +6 -0
- package/build/enums/SignatureAlgorithm.js +11 -0
- package/build/enums/SignatureAlgorithm.js.map +1 -0
- package/build/enums/index.d.ts +5 -0
- package/build/enums/index.js +22 -0
- package/build/enums/index.js.map +1 -0
- package/build/error.d.ts +12 -0
- package/build/error.js +21 -0
- package/build/error.js.map +1 -0
- package/build/index.d.ts +6 -0
- package/build/index.js +23 -0
- package/build/index.js.map +1 -0
- package/build/migration.d.ts +10 -0
- package/build/migration.js +11 -0
- package/build/migration.js.map +1 -0
- package/build/store/Entry.d.ts +21 -0
- package/build/store/Entry.js +38 -0
- package/build/store/Entry.js.map +1 -0
- package/build/store/EntryList.d.ts +17 -0
- package/build/store/EntryList.js +40 -0
- package/build/store/EntryList.js.map +1 -0
- package/build/store/KeyEntry.d.ts +23 -0
- package/build/store/KeyEntry.js +40 -0
- package/build/store/KeyEntry.js.map +1 -0
- package/build/store/KeyEntryList.d.ts +15 -0
- package/build/store/KeyEntryList.js +33 -0
- package/build/store/KeyEntryList.js.map +1 -0
- package/build/store/OpenSession.d.ts +14 -0
- package/build/store/OpenSession.js +27 -0
- package/build/store/OpenSession.js.map +1 -0
- package/build/store/Scan.d.ts +28 -0
- package/build/store/Scan.js +67 -0
- package/build/store/Scan.js.map +1 -0
- package/build/store/Session.d.ts +86 -0
- package/build/store/Session.js +182 -0
- package/build/store/Session.js.map +1 -0
- package/build/store/Store.d.ts +58 -0
- package/build/store/Store.js +87 -0
- package/build/store/Store.js.map +1 -0
- package/build/store/StoreKeyMethod.d.ts +11 -0
- package/build/store/StoreKeyMethod.js +20 -0
- package/build/store/StoreKeyMethod.js.map +1 -0
- package/build/store/index.d.ts +9 -0
- package/build/store/index.js +26 -0
- package/build/store/index.js.map +1 -0
- package/package.json +36 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./register"), exports);
|
|
18
|
+
__exportStar(require("./Askar"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/askar/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA0B;AAC1B,0CAAuB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerAskar = exports.askar = void 0;
|
|
4
|
+
const registerAskar = (options) => {
|
|
5
|
+
exports.askar = options.askar;
|
|
6
|
+
};
|
|
7
|
+
exports.registerAskar = registerAskar;
|
|
8
|
+
//# sourceMappingURL=register.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register.js","sourceRoot":"","sources":["../../src/askar/register.ts"],"names":[],"mappings":";;;AAIO,MAAM,aAAa,GAAG,CAAC,OAAyB,EAAE,EAAE;IACzD,aAAK,GAAG,OAAO,CAAC,KAAK,CAAA;AACvB,CAAC,CAAA;AAFY,QAAA,aAAa,iBAEzB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AeadParams = void 0;
|
|
4
|
+
class AeadParams {
|
|
5
|
+
constructor({ nonceLength, tagLength }) {
|
|
6
|
+
this.nonceLength = nonceLength;
|
|
7
|
+
this.tagLength = tagLength;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.AeadParams = AeadParams;
|
|
11
|
+
//# sourceMappingURL=AeadParams.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AeadParams.js","sourceRoot":"","sources":["../../src/crypto/AeadParams.ts"],"names":[],"mappings":";;;AAKA,MAAa,UAAU;IAIrB,YAAmB,EAAE,WAAW,EAAE,SAAS,EAAqB;QAC9D,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;CACF;AARD,gCAQC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Key } from './Key';
|
|
2
|
+
export declare class CryptoBox {
|
|
3
|
+
static randomNonce(): Uint8Array;
|
|
4
|
+
static cryptoBox({ recipientKey, senderKey, message, nonce, }: {
|
|
5
|
+
recipientKey: Key;
|
|
6
|
+
senderKey: Key;
|
|
7
|
+
message: Uint8Array;
|
|
8
|
+
nonce: Uint8Array;
|
|
9
|
+
}): Uint8Array;
|
|
10
|
+
static open({ recipientKey, senderKey, message, nonce, }: {
|
|
11
|
+
recipientKey: Key;
|
|
12
|
+
senderKey: Key;
|
|
13
|
+
message: Uint8Array;
|
|
14
|
+
nonce: Uint8Array;
|
|
15
|
+
}): Uint8Array;
|
|
16
|
+
static seal({ recipientKey, message }: {
|
|
17
|
+
recipientKey: Key;
|
|
18
|
+
message: Uint8Array;
|
|
19
|
+
}): Uint8Array;
|
|
20
|
+
static sealOpen({ recipientKey, ciphertext }: {
|
|
21
|
+
recipientKey: Key;
|
|
22
|
+
ciphertext: Uint8Array;
|
|
23
|
+
}): Uint8Array;
|
|
24
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CryptoBox = void 0;
|
|
4
|
+
const askar_1 = require("../askar");
|
|
5
|
+
class CryptoBox {
|
|
6
|
+
static randomNonce() {
|
|
7
|
+
return askar_1.askar.keyCryptoBoxRandomNonce();
|
|
8
|
+
}
|
|
9
|
+
static cryptoBox({ recipientKey, senderKey, message, nonce, }) {
|
|
10
|
+
return askar_1.askar.keyCryptoBox({ nonce, message, senderKey, recipientKey });
|
|
11
|
+
}
|
|
12
|
+
static open({ recipientKey, senderKey, message, nonce, }) {
|
|
13
|
+
return askar_1.askar.keyCryptoBoxOpen({ nonce, message, senderKey, recipientKey });
|
|
14
|
+
}
|
|
15
|
+
static seal({ recipientKey, message }) {
|
|
16
|
+
return askar_1.askar.keyCryptoBoxSeal({ message, localKeyHandle: recipientKey.handle });
|
|
17
|
+
}
|
|
18
|
+
static sealOpen({ recipientKey, ciphertext }) {
|
|
19
|
+
return askar_1.askar.keyCryptoBoxSealOpen({ ciphertext, localKeyHandle: recipientKey.handle });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.CryptoBox = CryptoBox;
|
|
23
|
+
//# sourceMappingURL=CryptoBox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CryptoBox.js","sourceRoot":"","sources":["../../src/crypto/CryptoBox.ts"],"names":[],"mappings":";;;AAEA,oCAAgC;AAEhC,MAAa,SAAS;IACb,MAAM,CAAC,WAAW;QACvB,OAAO,aAAK,CAAC,uBAAuB,EAAE,CAAA;IACxC,CAAC;IAEM,MAAM,CAAC,SAAS,CAAC,EACtB,YAAY,EACZ,SAAS,EACT,OAAO,EACP,KAAK,GAMN;QACC,OAAO,aAAK,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC,CAAA;IACxE,CAAC;IAEM,MAAM,CAAC,IAAI,CAAC,EACjB,YAAY,EACZ,SAAS,EACT,OAAO,EACP,KAAK,GAMN;QACC,OAAO,aAAK,CAAC,gBAAgB,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC,CAAA;IAC5E,CAAC;IAEM,MAAM,CAAC,IAAI,CAAC,EAAE,YAAY,EAAE,OAAO,EAA8C;QACtF,OAAO,aAAK,CAAC,gBAAgB,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,YAAY,CAAC,MAAM,EAAE,CAAC,CAAA;IACjF,CAAC;IAEM,MAAM,CAAC,QAAQ,CAAC,EAAE,YAAY,EAAE,UAAU,EAAiD;QAChG,OAAO,aAAK,CAAC,oBAAoB,CAAC,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,CAAC,MAAM,EAAE,CAAC,CAAA;IACxF,CAAC;CACF;AAxCD,8BAwCC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { KeyAlgorithm } from '../enums';
|
|
2
|
+
import { Key } from './Key';
|
|
3
|
+
export declare class Ecdh1PU {
|
|
4
|
+
private algId;
|
|
5
|
+
private apu;
|
|
6
|
+
private apv;
|
|
7
|
+
constructor({ apv, apu, algId }: {
|
|
8
|
+
algId: Uint8Array;
|
|
9
|
+
apu: Uint8Array;
|
|
10
|
+
apv: Uint8Array;
|
|
11
|
+
});
|
|
12
|
+
deriveKey({ encryptionAlgorithm, ephemeralKey, recipientKey, senderKey, receive, ccTag, }: {
|
|
13
|
+
encryptionAlgorithm: KeyAlgorithm;
|
|
14
|
+
ephemeralKey: Key;
|
|
15
|
+
recipientKey: Key;
|
|
16
|
+
senderKey: Key;
|
|
17
|
+
receive: boolean;
|
|
18
|
+
ccTag?: Uint8Array;
|
|
19
|
+
}): Key;
|
|
20
|
+
encryptDirect({ encryptionAlgorithm, recipientKey, ephemeralKey, senderKey, message, aad, nonce, }: {
|
|
21
|
+
encryptionAlgorithm: KeyAlgorithm;
|
|
22
|
+
ephemeralKey: Key;
|
|
23
|
+
recipientKey: Key;
|
|
24
|
+
senderKey: Key;
|
|
25
|
+
message: Uint8Array;
|
|
26
|
+
aad?: Uint8Array;
|
|
27
|
+
nonce?: Uint8Array;
|
|
28
|
+
}): import("./EncryptedBuffer").EncryptedBuffer;
|
|
29
|
+
decryptDirect({ nonce, encryptionAlgorithm, recipientKey, ephemeralKey, senderKey, ciphertext, tag, aad, }: {
|
|
30
|
+
encryptionAlgorithm: KeyAlgorithm;
|
|
31
|
+
ephemeralKey: Key;
|
|
32
|
+
recipientKey: Key;
|
|
33
|
+
senderKey: Key;
|
|
34
|
+
ciphertext: Uint8Array;
|
|
35
|
+
nonce: Uint8Array;
|
|
36
|
+
tag: Uint8Array;
|
|
37
|
+
aad?: Uint8Array;
|
|
38
|
+
}): Uint8Array;
|
|
39
|
+
senderWrapKey({ keyWrappingAlgorithm, ephemeralKey, recipientKey, senderKey, cek, ccTag, }: {
|
|
40
|
+
keyWrappingAlgorithm: KeyAlgorithm;
|
|
41
|
+
ephemeralKey: Key;
|
|
42
|
+
recipientKey: Key;
|
|
43
|
+
senderKey: Key;
|
|
44
|
+
cek: Key;
|
|
45
|
+
ccTag: Uint8Array;
|
|
46
|
+
}): import("./EncryptedBuffer").EncryptedBuffer;
|
|
47
|
+
receiverUnwrapKey({ keyWrappingAlgorithm, encryptionAlgorithm, recipientKey, ephemeralKey, senderKey, ciphertext, nonce, tag, ccTag, }: {
|
|
48
|
+
keyWrappingAlgorithm: KeyAlgorithm;
|
|
49
|
+
encryptionAlgorithm: KeyAlgorithm;
|
|
50
|
+
ephemeralKey: Key;
|
|
51
|
+
recipientKey: Key;
|
|
52
|
+
senderKey: Key;
|
|
53
|
+
ciphertext: Uint8Array;
|
|
54
|
+
nonce?: Uint8Array;
|
|
55
|
+
tag?: Uint8Array;
|
|
56
|
+
ccTag: Uint8Array;
|
|
57
|
+
}): Key;
|
|
58
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Ecdh1PU = void 0;
|
|
4
|
+
const askar_1 = require("../askar");
|
|
5
|
+
const Key_1 = require("./Key");
|
|
6
|
+
class Ecdh1PU {
|
|
7
|
+
constructor({ apv, apu, algId }) {
|
|
8
|
+
this.algId = algId;
|
|
9
|
+
this.apu = apu;
|
|
10
|
+
this.apv = apv;
|
|
11
|
+
}
|
|
12
|
+
deriveKey({ encryptionAlgorithm, ephemeralKey, recipientKey, senderKey, receive, ccTag, }) {
|
|
13
|
+
return new Key_1.Key(askar_1.askar.keyDeriveEcdh1pu({
|
|
14
|
+
algId: this.algId,
|
|
15
|
+
receive,
|
|
16
|
+
apv: this.apv,
|
|
17
|
+
apu: this.apu,
|
|
18
|
+
algorithm: encryptionAlgorithm,
|
|
19
|
+
ephemeralKey: ephemeralKey,
|
|
20
|
+
recipientKey: recipientKey,
|
|
21
|
+
senderKey: senderKey,
|
|
22
|
+
ccTag,
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
encryptDirect({ encryptionAlgorithm, recipientKey, ephemeralKey, senderKey, message, aad, nonce, }) {
|
|
26
|
+
const derived = this.deriveKey({
|
|
27
|
+
encryptionAlgorithm: encryptionAlgorithm,
|
|
28
|
+
ephemeralKey,
|
|
29
|
+
recipientKey,
|
|
30
|
+
senderKey,
|
|
31
|
+
receive: false,
|
|
32
|
+
});
|
|
33
|
+
const encryptedBuffer = derived.aeadEncrypt({ message, aad, nonce });
|
|
34
|
+
derived.handle.free();
|
|
35
|
+
return encryptedBuffer;
|
|
36
|
+
}
|
|
37
|
+
decryptDirect({ nonce, encryptionAlgorithm, recipientKey, ephemeralKey, senderKey, ciphertext, tag, aad, }) {
|
|
38
|
+
const derived = this.deriveKey({
|
|
39
|
+
encryptionAlgorithm: encryptionAlgorithm,
|
|
40
|
+
ephemeralKey,
|
|
41
|
+
recipientKey,
|
|
42
|
+
senderKey,
|
|
43
|
+
receive: true,
|
|
44
|
+
});
|
|
45
|
+
const encryptedBuffer = derived.aeadDecrypt({ tag, nonce, ciphertext, aad });
|
|
46
|
+
derived.handle.free();
|
|
47
|
+
return encryptedBuffer;
|
|
48
|
+
}
|
|
49
|
+
senderWrapKey({ keyWrappingAlgorithm, ephemeralKey, recipientKey, senderKey, cek, ccTag, }) {
|
|
50
|
+
const derived = this.deriveKey({
|
|
51
|
+
encryptionAlgorithm: keyWrappingAlgorithm,
|
|
52
|
+
ephemeralKey,
|
|
53
|
+
recipientKey,
|
|
54
|
+
senderKey,
|
|
55
|
+
receive: false,
|
|
56
|
+
ccTag,
|
|
57
|
+
});
|
|
58
|
+
const encryptedBuffer = derived.wrapKey({ other: cek });
|
|
59
|
+
derived.handle.free();
|
|
60
|
+
return encryptedBuffer;
|
|
61
|
+
}
|
|
62
|
+
receiverUnwrapKey({ keyWrappingAlgorithm, encryptionAlgorithm, recipientKey, ephemeralKey, senderKey, ciphertext, nonce, tag, ccTag, }) {
|
|
63
|
+
const derived = this.deriveKey({
|
|
64
|
+
encryptionAlgorithm: keyWrappingAlgorithm,
|
|
65
|
+
ephemeralKey,
|
|
66
|
+
recipientKey,
|
|
67
|
+
receive: true,
|
|
68
|
+
senderKey,
|
|
69
|
+
ccTag,
|
|
70
|
+
});
|
|
71
|
+
const encryptedBuffer = derived.unwrapKey({ tag, nonce, ciphertext, algorithm: encryptionAlgorithm });
|
|
72
|
+
derived.handle.free();
|
|
73
|
+
return encryptedBuffer;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.Ecdh1PU = Ecdh1PU;
|
|
77
|
+
//# sourceMappingURL=Ecdh1PU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Ecdh1PU.js","sourceRoot":"","sources":["../../src/crypto/Ecdh1PU.ts"],"names":[],"mappings":";;;AAAA,oCAAgC;AAEhC,+BAA2B;AAE3B,MAAa,OAAO;IAKlB,YAAmB,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAA2D;QAC7F,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;IAChB,CAAC;IAEM,SAAS,CAAC,EACf,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,OAAO,EACP,KAAK,GAQN;QACC,OAAO,IAAI,SAAG,CACZ,aAAK,CAAC,gBAAgB,CAAC;YACrB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,OAAO;YACP,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,SAAS,EAAE,mBAAmB;YAC9B,YAAY,EAAE,YAAY;YAC1B,YAAY,EAAE,YAAY;YAC1B,SAAS,EAAE,SAAS;YACpB,KAAK;SACN,CAAC,CACH,CAAA;IACH,CAAC;IAEM,aAAa,CAAC,EACnB,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,OAAO,EACP,GAAG,EACH,KAAK,GASN;QACC,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC;YAC7B,mBAAmB,EAAE,mBAAmB;YACxC,YAAY;YACZ,YAAY;YACZ,SAAS;YACT,OAAO,EAAE,KAAK;SACf,CAAC,CAAA;QACF,MAAM,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AG,IAAI,CAAC,SAAS,CAAC;YAC7B,mBAAmB,EAAE,oBAAoB;YACzC,YAAY;YACZ,YAAY;YACZ,OAAO,EAAE,IAAI;YACb,SAAS;YACT,KAAK;SACN,CAAC,CAAA;QACF,MAAM,eAAe,GAAG,OAAO,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,mBAAmB,EAAE,CAAC,CAAA;QACrG,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAA;QACrB,OAAO,eAAe,CAAA;IACxB,CAAC;CACF;AAlKD,0BAkKC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { KeyAlgorithm } from '../enums';
|
|
2
|
+
import { Jwk } from './Jwk';
|
|
3
|
+
import { Key } from './Key';
|
|
4
|
+
export declare class EcdhEs {
|
|
5
|
+
private algId;
|
|
6
|
+
private apu;
|
|
7
|
+
private apv;
|
|
8
|
+
constructor({ apv, apu, algId }: {
|
|
9
|
+
algId: Uint8Array;
|
|
10
|
+
apu: Uint8Array;
|
|
11
|
+
apv: Uint8Array;
|
|
12
|
+
});
|
|
13
|
+
private deriveKey;
|
|
14
|
+
encryptDirect({ encryptionAlgorithm, recipientKey, ephemeralKey, message, aad, nonce, }: {
|
|
15
|
+
encryptionAlgorithm: KeyAlgorithm;
|
|
16
|
+
ephemeralKey: Key | Jwk;
|
|
17
|
+
recipientKey: Key | Jwk;
|
|
18
|
+
message: Uint8Array;
|
|
19
|
+
aad?: Uint8Array;
|
|
20
|
+
nonce?: Uint8Array;
|
|
21
|
+
}): import("./EncryptedBuffer").EncryptedBuffer;
|
|
22
|
+
decryptDirect({ nonce, encryptionAlgorithm, recipientKey, ciphertext, ephemeralKey, tag, aad, }: {
|
|
23
|
+
encryptionAlgorithm: KeyAlgorithm;
|
|
24
|
+
ephemeralKey: Key | Jwk;
|
|
25
|
+
recipientKey: Key | Jwk;
|
|
26
|
+
ciphertext: Uint8Array;
|
|
27
|
+
nonce: Uint8Array;
|
|
28
|
+
tag: Uint8Array;
|
|
29
|
+
aad?: Uint8Array;
|
|
30
|
+
}): Uint8Array;
|
|
31
|
+
senderWrapKey({ keyWrappingAlgorithm, ephemeralKey, recipientKey, cek, }: {
|
|
32
|
+
keyWrappingAlgorithm: KeyAlgorithm;
|
|
33
|
+
ephemeralKey: Key;
|
|
34
|
+
recipientKey: Key;
|
|
35
|
+
cek: Key;
|
|
36
|
+
}): import("./EncryptedBuffer").EncryptedBuffer;
|
|
37
|
+
receiverUnwrapKey({ recipientKey, keyWrappingAlgorithm, ephemeralKey, encryptionAlgorithm, ciphertext, nonce, tag, }: {
|
|
38
|
+
keyWrappingAlgorithm: KeyAlgorithm;
|
|
39
|
+
encryptionAlgorithm: KeyAlgorithm;
|
|
40
|
+
ephemeralKey: Key;
|
|
41
|
+
recipientKey: Key;
|
|
42
|
+
ciphertext: Uint8Array;
|
|
43
|
+
nonce?: Uint8Array;
|
|
44
|
+
tag?: Uint8Array;
|
|
45
|
+
}): Key;
|
|
46
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EcdhEs = void 0;
|
|
4
|
+
const askar_1 = require("../askar");
|
|
5
|
+
const Jwk_1 = require("./Jwk");
|
|
6
|
+
const Key_1 = require("./Key");
|
|
7
|
+
class EcdhEs {
|
|
8
|
+
constructor({ apv, apu, algId }) {
|
|
9
|
+
this.algId = algId;
|
|
10
|
+
this.apu = apu;
|
|
11
|
+
this.apv = apv;
|
|
12
|
+
}
|
|
13
|
+
deriveKey({ encryptionAlgorithm, ephemeralKey, recipientKey, receive, }) {
|
|
14
|
+
return new Key_1.Key(askar_1.askar.keyDeriveEcdhEs({
|
|
15
|
+
algId: this.algId,
|
|
16
|
+
receive,
|
|
17
|
+
apv: this.apv,
|
|
18
|
+
apu: this.apu,
|
|
19
|
+
algorithm: encryptionAlgorithm,
|
|
20
|
+
ephemeralKey,
|
|
21
|
+
recipientKey,
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
24
|
+
encryptDirect({ encryptionAlgorithm, recipientKey, ephemeralKey, message, aad, nonce, }) {
|
|
25
|
+
const eKey = ephemeralKey instanceof Jwk_1.Jwk ? Key_1.Key.fromJwk({ jwk: ephemeralKey }) : ephemeralKey;
|
|
26
|
+
const rKey = recipientKey instanceof Jwk_1.Jwk ? Key_1.Key.fromJwk({ jwk: recipientKey }) : recipientKey;
|
|
27
|
+
const derived = this.deriveKey({ encryptionAlgorithm, ephemeralKey: eKey, recipientKey: rKey, receive: false });
|
|
28
|
+
const encryptedBuffer = derived.aeadEncrypt({ message, aad, nonce });
|
|
29
|
+
derived.handle.free();
|
|
30
|
+
return encryptedBuffer;
|
|
31
|
+
}
|
|
32
|
+
decryptDirect({ nonce, encryptionAlgorithm, recipientKey, ciphertext, ephemeralKey, tag, aad, }) {
|
|
33
|
+
const eKey = ephemeralKey instanceof Jwk_1.Jwk ? Key_1.Key.fromJwk({ jwk: ephemeralKey }) : ephemeralKey;
|
|
34
|
+
const rKey = recipientKey instanceof Jwk_1.Jwk ? Key_1.Key.fromJwk({ jwk: recipientKey }) : recipientKey;
|
|
35
|
+
const derived = this.deriveKey({ encryptionAlgorithm, ephemeralKey: eKey, recipientKey: rKey, receive: true });
|
|
36
|
+
const encryptedBuffer = derived.aeadDecrypt({ tag, nonce, ciphertext, aad });
|
|
37
|
+
derived.handle.free();
|
|
38
|
+
return encryptedBuffer;
|
|
39
|
+
}
|
|
40
|
+
senderWrapKey({ keyWrappingAlgorithm, ephemeralKey, recipientKey, cek, }) {
|
|
41
|
+
const derived = this.deriveKey({
|
|
42
|
+
encryptionAlgorithm: keyWrappingAlgorithm,
|
|
43
|
+
ephemeralKey,
|
|
44
|
+
recipientKey,
|
|
45
|
+
receive: false,
|
|
46
|
+
});
|
|
47
|
+
const encryptedBuffer = derived.wrapKey({ other: cek });
|
|
48
|
+
derived.handle.free();
|
|
49
|
+
return encryptedBuffer;
|
|
50
|
+
}
|
|
51
|
+
receiverUnwrapKey({ recipientKey, keyWrappingAlgorithm, ephemeralKey, encryptionAlgorithm, ciphertext, nonce, tag, }) {
|
|
52
|
+
const derived = this.deriveKey({
|
|
53
|
+
encryptionAlgorithm: keyWrappingAlgorithm,
|
|
54
|
+
ephemeralKey,
|
|
55
|
+
recipientKey,
|
|
56
|
+
receive: true,
|
|
57
|
+
});
|
|
58
|
+
const encryptedBuffer = derived.unwrapKey({ tag, nonce, ciphertext, algorithm: encryptionAlgorithm });
|
|
59
|
+
derived.handle.free();
|
|
60
|
+
return encryptedBuffer;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.EcdhEs = EcdhEs;
|
|
64
|
+
//# sourceMappingURL=EcdhEs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EcdhEs.js","sourceRoot":"","sources":["../../src/crypto/EcdhEs.ts"],"names":[],"mappings":";;;AAEA,oCAAgC;AAEhC,+BAA2B;AAC3B,+BAA2B;AAE3B,MAAa,MAAM;IAKjB,YAAmB,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAA2D;QAC7F,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;IAChB,CAAC;IAEO,SAAS,CAAC,EAChB,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,OAAO,GAMR;QACC,OAAO,IAAI,SAAG,CACZ,aAAK,CAAC,eAAe,CAAC;YACpB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,OAAO;YACP,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,SAAS,EAAE,mBAAmB;YAC9B,YAAY;YACZ,YAAY;SACb,CAAC,CACH,CAAA;IACH,CAAC;IAEM,aAAa,CAAC,EACnB,mBAAmB,EACn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ePos: number;
|
|
5
|
+
};
|
|
6
|
+
export declare class EncryptedBuffer {
|
|
7
|
+
private buffer;
|
|
8
|
+
private tagPos;
|
|
9
|
+
private noncePos;
|
|
10
|
+
constructor({ noncePos, tagPos, buffer }: EncryptedBufferOptions);
|
|
11
|
+
get ciphertextWithTag(): Uint8Array;
|
|
12
|
+
get ciphertext(): Uint8Array;
|
|
13
|
+
get nonce(): Uint8Array;
|
|
14
|
+
get tag(): Uint8Array;
|
|
15
|
+
get parts(): {
|
|
16
|
+
ciphertext: Uint8Array;
|
|
17
|
+
tag: Uint8Array;
|
|
18
|
+
nonce: Uint8Array;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EncryptedBuffer = void 0;
|
|
4
|
+
class EncryptedBuffer {
|
|
5
|
+
constructor({ noncePos, tagPos, buffer }) {
|
|
6
|
+
this.buffer = buffer;
|
|
7
|
+
this.tagPos = tagPos;
|
|
8
|
+
this.noncePos = noncePos;
|
|
9
|
+
}
|
|
10
|
+
get ciphertextWithTag() {
|
|
11
|
+
const p = this.noncePos;
|
|
12
|
+
return this.buffer.slice(0, p);
|
|
13
|
+
}
|
|
14
|
+
get ciphertext() {
|
|
15
|
+
const p = this.tagPos;
|
|
16
|
+
return this.buffer.slice(0, p);
|
|
17
|
+
}
|
|
18
|
+
get nonce() {
|
|
19
|
+
const p = this.noncePos;
|
|
20
|
+
return this.buffer.slice(p);
|
|
21
|
+
}
|
|
22
|
+
get tag() {
|
|
23
|
+
const p1 = this.tagPos;
|
|
24
|
+
const p2 = this.noncePos;
|
|
25
|
+
return this.buffer.slice(p1, p2);
|
|
26
|
+
}
|
|
27
|
+
get parts() {
|
|
28
|
+
return {
|
|
29
|
+
ciphertext: this.ciphertext,
|
|
30
|
+
tag: this.tag,
|
|
31
|
+
nonce: this.nonce,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.EncryptedBuffer = EncryptedBuffer;
|
|
36
|
+
//# sourceMappingURL=EncryptedBuffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EncryptedBuffer.js","sourceRoot":"","sources":["../../src/crypto/EncryptedBuffer.ts"],"names":[],"mappings":";;;AAMA,MAAa,eAAe;IAK1B,YAAmB,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAA0B;QACrE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAC1B,CAAC;IAED,IAAW,iBAAiB;QAC1B,MAAM,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAA;QACvB,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IAChC,CAAC;IAED,IAAW,UAAU;QACnB,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAA;QACrB,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IAChC,CAAC;IAED,IAAW,KAAK;QACd,MAAM,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAA;QACvB,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAC7B,CAAC;IAED,IAAW,GAAG;QACZ,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,CAAA;QACtB,MAAM,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAA;QACxB,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;IAClC,CAAC;IAED,IAAW,KAAK;QACd,OAAO;YACL,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB,CAAA;IACH,CAAC;CACF;AAvCD,0CAuCC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type JwkProps = {
|
|
2
|
+
kty: string;
|
|
3
|
+
crv: string;
|
|
4
|
+
x: string;
|
|
5
|
+
d?: string;
|
|
6
|
+
y?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare class Jwk {
|
|
9
|
+
kty: string;
|
|
10
|
+
crv: string;
|
|
11
|
+
x: string;
|
|
12
|
+
d?: string;
|
|
13
|
+
y?: string;
|
|
14
|
+
constructor({ kty, crv, x, d, y }: JwkProps);
|
|
15
|
+
static fromJson(jwk: JwkProps): Jwk;
|
|
16
|
+
static fromString(str: string): Jwk;
|
|
17
|
+
toUint8Array(): Uint8Array;
|
|
18
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Jwk = void 0;
|
|
4
|
+
const buffer_1 = require("buffer");
|
|
5
|
+
class Jwk {
|
|
6
|
+
constructor({ kty, crv, x, d, y }) {
|
|
7
|
+
this.kty = kty;
|
|
8
|
+
this.crv = crv;
|
|
9
|
+
this.x = x;
|
|
10
|
+
this.d = d;
|
|
11
|
+
this.y = y;
|
|
12
|
+
}
|
|
13
|
+
static fromJson(jwk) {
|
|
14
|
+
return new Jwk(jwk);
|
|
15
|
+
}
|
|
16
|
+
static fromString(str) {
|
|
17
|
+
return new Jwk(JSON.parse(str));
|
|
18
|
+
}
|
|
19
|
+
toUint8Array() {
|
|
20
|
+
return Uint8Array.from(buffer_1.Buffer.from(JSON.stringify(this)));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.Jwk = Jwk;
|
|
24
|
+
//# sourceMappingURL=Jwk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Jwk.js","sourceRoot":"","sources":["../../src/crypto/Jwk.ts"],"names":[],"mappings":";;;AAAA,mCAA+B;AAU/B,MAAa,GAAG;IAOd,YAAmB,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAY;QAChD,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,CAAC,GAAG,CAAC,CAAA;QACV,IAAI,CAAC,CAAC,GAAG,CAAC,CAAA;QACV,IAAI,CAAC,CAAC,GAAG,CAAC,CAAA;IACZ,CAAC;IAEM,MAAM,CAAC,QAAQ,CAAC,GAAa;QAClC,OAAO,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;IACrB,CAAC;IAEM,MAAM,CAAC,UAAU,CAAC,GAAW;QAClC,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAa,CAAC,CAAA;IAC7C,CAAC;IAEM,YAAY;QACjB,OAAO,UAAU,CAAC,IAAI,CAAC,eAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAC3D,CAAC;CACF;AA1BD,kBA0BC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { KeyAlgorithm, SignatureAlgorithm } from '../enums';
|
|
2
|
+
import type { KeyBackend } from '../enums';
|
|
3
|
+
import type { LocalKeyHandle } from './handles';
|
|
4
|
+
import { KeyMethod } from '../enums';
|
|
5
|
+
import { Jwk } from './Jwk';
|
|
6
|
+
export declare class Key {
|
|
7
|
+
private localKeyHandle;
|
|
8
|
+
constructor(handle: LocalKeyHandle);
|
|
9
|
+
static generate(algorithm: KeyAlgorithm, keyBackend?: KeyBackend, ephemeral?: boolean): Key;
|
|
10
|
+
static fromSeed({ method, algorithm, seed, }: {
|
|
11
|
+
algorithm: KeyAlgorithm;
|
|
12
|
+
seed: Uint8Array;
|
|
13
|
+
method?: KeyMethod;
|
|
14
|
+
}): Key;
|
|
15
|
+
static fromSecretBytes(options: {
|
|
16
|
+
algorithm: KeyAlgorithm;
|
|
17
|
+
secretKey: Uint8Array;
|
|
18
|
+
}): Key;
|
|
19
|
+
static fromPublicBytes(options: {
|
|
20
|
+
algorithm: KeyAlgorithm;
|
|
21
|
+
publicKey: Uint8Array;
|
|
22
|
+
}): Key;
|
|
23
|
+
static fromJwk(options: {
|
|
24
|
+
jwk: Jwk;
|
|
25
|
+
}): Key;
|
|
26
|
+
convertkey(options: {
|
|
27
|
+
algorithm: KeyAlgorithm;
|
|
28
|
+
}): Key;
|
|
29
|
+
keyFromKeyExchange({ algorithm, publicKey }: {
|
|
30
|
+
algorithm: KeyAlgorithm;
|
|
31
|
+
publicKey: Key;
|
|
32
|
+
}): Key;
|
|
33
|
+
get handle(): LocalKeyHandle;
|
|
34
|
+
get algorithm(): KeyAlgorithm;
|
|
35
|
+
get ephemeral(): boolean;
|
|
36
|
+
get publicBytes(): Uint8Array;
|
|
37
|
+
get secretBytes(): Uint8Array;
|
|
38
|
+
get jwkPublic(): Jwk;
|
|
39
|
+
get jwkSecret(): Jwk;
|
|
40
|
+
get jwkThumbprint(): string;
|
|
41
|
+
get aeadParams(): import("./AeadParams").AeadParams;
|
|
42
|
+
get aeadRandomNonce(): Uint8Array;
|
|
43
|
+
aeadEncrypt(options: {
|
|
44
|
+
message: Uint8Array;
|
|
45
|
+
nonce?: Uint8Array;
|
|
46
|
+
aad?: Uint8Array;
|
|
47
|
+
}): import("./EncryptedBuffer").EncryptedBuffer;
|
|
48
|
+
aeadDecrypt(options: {
|
|
49
|
+
ciphertext: Uint8Array;
|
|
50
|
+
nonce: Uint8Array;
|
|
51
|
+
tag?: Uint8Array;
|
|
52
|
+
aad?: Uint8Array;
|
|
53
|
+
}): Uint8Array;
|
|
54
|
+
signMessage(options: {
|
|
55
|
+
message: Uint8Array;
|
|
56
|
+
sigType?: SignatureAlgorithm;
|
|
57
|
+
}): Uint8Array;
|
|
58
|
+
verifySignature(options: {
|
|
59
|
+
message: Uint8Array;
|
|
60
|
+
signature: Uint8Array;
|
|
61
|
+
sigType?: SignatureAlgorithm;
|
|
62
|
+
}): boolean;
|
|
63
|
+
wrapKey({ other, nonce }: {
|
|
64
|
+
other: Key;
|
|
65
|
+
nonce?: Uint8Array;
|
|
66
|
+
}): import("./EncryptedBuffer").EncryptedBuffer;
|
|
67
|
+
unwrapKey(options: {
|
|
68
|
+
algorithm: KeyAlgorithm;
|
|
69
|
+
tag?: Uint8Array;
|
|
70
|
+
ciphertext: Uint8Array;
|
|
71
|
+
nonce?: Uint8Array;
|
|
72
|
+
}): Key;
|
|
73
|
+
}
|