@darkbio/crypto 0.18.0 → 0.19.1

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/dist/cwt.d.ts CHANGED
@@ -1,9 +1,7 @@
1
1
  import { Codec, Decodable, Encodable } from './cbor.js';
2
2
  import * as xdsa from "./xdsa.js";
3
3
  import * as xhpke from "./xhpke.js";
4
- /**
5
- * Debug port state per RFC 9711 Section 4.2.9.
6
- */
4
+ /** The debug port state, per RFC 9711 Section 4.2.9. */
7
5
  export declare enum DebugState {
8
6
  /** Debug is currently enabled. */
9
7
  Enabled = 0,
@@ -11,14 +9,19 @@ export declare enum DebugState {
11
9
  Disabled = 1,
12
10
  /** Debug was disabled at boot and has not been enabled since. */
13
11
  DisabledSinceBoot = 2,
14
- /** Debug is disabled and cannot be re-enabled. */
12
+ /**
13
+ * All debug has been disabled since boot. End users and developers cannot
14
+ * re-enable it, but the manufacturer identified by `oemid` may do so. The
15
+ * `oemid` claim must be present, and the application must enforce this.
16
+ */
15
17
  DisabledPermanently = 3,
16
- /** All debug, including DMA-based, is permanently disabled. */
18
+ /**
19
+ * All debug facilities are permanently disabled, including manufacturer
20
+ * facilities, and none can be re-enabled.
21
+ */
17
22
  DisabledFullyPermanently = 4
18
23
  }
19
- /**
20
- * Token intended purpose per RFC 9711 Section 4.3.3.
21
- */
24
+ /** The token's intended purpose, per RFC 9711 Section 4.3.3. */
22
25
  export declare enum IntendedUse {
23
26
  /** General-purpose attestation. */
24
27
  Generic = 1,
@@ -32,9 +35,11 @@ export declare enum IntendedUse {
32
35
  ProofOfPossession = 5
33
36
  }
34
37
  /**
35
- * An OEM identifier in one of the three forms RFC 9711 allows, an IANA
36
- * private enterprise number, a 3 byte IEEE organisationally unique identifier
37
- * or a 16 byte random identifier.
38
+ * An OEM identifier in one of the three forms RFC 9711 allows:
39
+ *
40
+ * - `pen`, an IANA private enterprise number
41
+ * - `ieee`, a 3-byte IEEE organizationally unique identifier
42
+ * - `random`, a 16-byte random identifier
38
43
  */
39
44
  export type Oemid = {
40
45
  pen: bigint;
@@ -46,16 +51,21 @@ export type Oemid = {
46
51
  /** Codec of an OEM identifier, an unsigned integer or 3 or 16 bytes. */
47
52
  export declare const oemid: Codec<Oemid>;
48
53
  /**
49
- * Codec of a version, the text wrapped in a one element array as RFC 9711
54
+ * Codec of a version, the text wrapped in a one-element array as RFC 9711
50
55
  * has it. The optional scheme element is not supported.
51
56
  */
52
57
  export declare const version: Codec<string>;
53
58
  /**
54
- * Codec of a confirmation, a public key the token's subject holds, wrapped in
55
- * a COSE_Key of exactly the key type and the key bytes (RFC 8747).
59
+ * Codec of a confirmation, a public key the token's subject holds (RFC 8747).
60
+ * The key is wrapped in a COSE_Key of exactly the key type and the key bytes.
61
+ *
62
+ * A verified token authenticates this key binding, but does not prove that
63
+ * the presenter holds the matching secret key. Applications must check that
64
+ * separately using their protocol's proof-of-possession mechanism.
56
65
  *
57
66
  * @param algorithm - The COSE algorithm identifier of the key type
58
67
  * @param key - The codec of the key
68
+ * @returns The codec
59
69
  */
60
70
  export declare function confirmation<K>(algorithm: number, key: Codec<K>): Codec<K>;
61
71
  /**
@@ -69,91 +79,141 @@ export declare const claims: {
69
79
  subject: import('./cbor.js').Field<string>;
70
80
  /** The audience, the recipients the token is meant for (key 3). */
71
81
  audience: import('./cbor.js').Field<string>;
72
- /** The expiration, Unix seconds the token is valid until, exclusive (key 4). */
82
+ /**
83
+ * The expiration time in seconds since the Unix epoch. The token is
84
+ * rejected at or after it (key 4).
85
+ */
73
86
  expiration: import('./cbor.js').Field<bigint>;
74
- /** The not before time, Unix seconds the token is valid from (key 5). */
87
+ /**
88
+ * The not-before time in seconds since the Unix epoch. The token is
89
+ * rejected before it (key 5).
90
+ */
75
91
  notBefore: import('./cbor.js').Field<bigint>;
76
- /** The issue time, Unix seconds the token was issued (key 6). */
92
+ /** The issue time in seconds since the Unix epoch (key 6). */
77
93
  issuedAt: import('./cbor.js').Field<bigint>;
78
- /** The token identifier, unique to the token (key 7). */
94
+ /** The token identifier, opaque bytes unique to the token (key 7). */
79
95
  tokenId: import('./cbor.js').Field<Uint8Array<ArrayBufferLike>>;
80
- /** The confirmation, an xDSA public key the subject holds (key 8). */
96
+ /**
97
+ * The confirmation, an xDSA public key the subject holds (key 8). A
98
+ * verified token does not prove that the presenter holds the secret key.
99
+ */
81
100
  confirmXdsa: import('./cbor.js').Field<xdsa.PublicKey>;
82
- /** The confirmation, an xHPKE public key the subject holds (key 8). */
101
+ /**
102
+ * The confirmation, an xHPKE public key the subject holds (key 8). A
103
+ * verified token does not prove that the presenter holds the secret key.
104
+ */
83
105
  confirmXhpke: import('./cbor.js').Field<xhpke.PublicKey>;
84
- /** The Entity Attestation Token claims of RFC 9711. */
106
+ /**
107
+ * The Entity Attestation Token claims of RFC 9711.
108
+ *
109
+ * These declare the claims and check their wire representations.
110
+ * Applications must evaluate the claims against their attestation policy and
111
+ * enforce RFC 9711's relationships between claims. For example, `hwModel`
112
+ * and `oemBoot` require `oemid`, `hwVersion` requires `hwModel`, and
113
+ * `swVersion` requires `swName`. {@link DebugState.DisabledPermanently} also
114
+ * requires `oemid`. {@link verify} does not check these relationships.
115
+ */
85
116
  eat: {
86
- /** Universal entity identifier (key 256). */
117
+ /**
118
+ * The universal entity identifier, a globally unique device identifier
119
+ * such as a serial number or IMEI (key 256). Its first byte is the type
120
+ * prefix of RFC 9711 Section 4.2.1.
121
+ *
122
+ * A RAND UEID uses prefix 0x01 followed by 16, 24 or 32 bytes of random
123
+ * identifier data, provisioned once for the device. The bytes are carried
124
+ * as supplied, so callers must check the prefix, length and identifier
125
+ * policy.
126
+ */
87
127
  ueid: import('./cbor.js').Field<Uint8Array<ArrayBufferLike>>;
88
- /** OEM identifier (key 258). */
128
+ /** The hardware manufacturer, in one of the {@link Oemid} forms (key 258). */
89
129
  oemid: import('./cbor.js').Field<Oemid>;
90
- /** Hardware model (key 259). */
130
+ /** The product or board model identifier, as the manufacturer defines it (key 259). */
91
131
  hwModel: import('./cbor.js').Field<Uint8Array<ArrayBufferLike>>;
92
- /** Hardware version (key 260). */
132
+ /** The hardware revision identifier (key 260). */
93
133
  hwVersion: import('./cbor.js').Field<string>;
94
- /** Seconds since boot (key 261). */
134
+ /** The number of seconds since the last boot (key 261). */
95
135
  uptime: import('./cbor.js').Field<bigint>;
96
- /** Whether the entity booted OEM authorised software (key 262). */
136
+ /** Whether every boot stage was OEM authorized, so secure boot passed (key 262). */
97
137
  oemBoot: import('./cbor.js').Field<boolean>;
98
- /** Debug state of the entity (key 263). */
138
+ /** The state of the device's debug facilities at attestation time (key 263). */
99
139
  debugStatus: import('./cbor.js').Field<DebugState>;
100
- /** Number of boots (key 267). */
140
+ /** The number of times the device has booted, never decreasing (key 267). */
101
141
  bootCount: import('./cbor.js').Field<bigint>;
102
- /** Random seed of the boot (key 268). */
142
+ /** Random bytes drawn at boot, the same in every token of one boot cycle (key 268). */
103
143
  bootSeed: import('./cbor.js').Field<Uint8Array<ArrayBufferLike>>;
104
- /** Software name (key 270). */
144
+ /** The name of the firmware or software running on the device (key 270). */
105
145
  swName: import('./cbor.js').Field<string>;
106
- /** Software version (key 271). */
146
+ /** The software version identifier (key 271). */
107
147
  swVersion: import('./cbor.js').Field<string>;
108
- /** Intended use of the token (key 275). */
148
+ /** The purpose the token was issued for (key 275). */
109
149
  intendedUse: import('./cbor.js').Field<IntendedUse>;
110
150
  };
111
151
  };
112
152
  /**
113
153
  * Issues a CWT by signing the claims with COSE Sign1.
114
154
  *
115
- * Uses the current system time as the COSE signature timestamp.
155
+ * The claims must encode as a CBOR map, such as a `cbor.map` of the
156
+ * {@link claims} fields. Uses the current system time as the COSE signature
157
+ * timestamp.
116
158
  *
117
159
  * @param claims - The claims to include in the token
118
160
  * @param signer - The xDSA secret key to sign with
119
- * @param domain - Application-specific domain separator
161
+ * @param domain - Application domain for separating protocol purposes
120
162
  * @returns The serialized CWT
163
+ * @throws CodecError if the claims do not fit their codec
164
+ * @throws If the claims do not encode as a CBOR map
121
165
  */
122
166
  export declare function issue<C>(claims: Encodable<C>, signer: xdsa.SecretKey, domain: Uint8Array): Promise<Uint8Array>;
123
167
  /**
124
168
  * Verifies a CWT's COSE signature and temporal validity, then returns the
125
169
  * decoded claims.
126
170
  *
127
- * When `now` is provided (Unix timestamp in seconds), temporal claims are
128
- * validated: nbf must be present and `nbf <= now`, and if exp is present
129
- * then `now < exp`. When `now` is undefined, temporal validation is skipped.
171
+ * When `now` is given, the `nbf` claim (key 5) must be present and
172
+ * `nbf <= now`. If the `exp` claim (key 4) is present too, `now < exp` must
173
+ * also hold. When `now` is undefined, temporal validation is skipped entirely.
130
174
  *
131
- * @param token - The serialized CWT
175
+ * The COSE signature timestamp is not checked, since temporal validity comes
176
+ * from the CWT claims. The codec determines the accepted claim schema.
177
+ * Successful verification does not establish issuer trust, enforce an
178
+ * audience, evaluate attestation policy or EAT claim relationships, or prove
179
+ * possession of a confirmation key. The application must perform those checks.
180
+ *
181
+ * @param token - The serialized CWT, bound to the codec of its claims
132
182
  * @param verifier - The xDSA public key to verify against
133
- * @param domain - Application-specific domain separator
134
- * @param now - Current Unix timestamp for temporal validation (undefined to skip)
183
+ * @param domain - Application domain for separating protocol purposes
184
+ * @param now - Time of the check in seconds since the Unix epoch, with
185
+ * fractions rounded down, or undefined to skip the time checks
135
186
  * @returns The decoded claims
187
+ * @throws If the token is malformed, does not verify for this key and
188
+ * `domain`, or fails a time check
189
+ * @throws If `now` is negative or beyond 64 bits
190
+ * @throws CodecError if the claims do not fit their codec
136
191
  */
137
192
  export declare function verify<C>(token: Decodable<C>, verifier: xdsa.PublicKey, domain: Uint8Array, now?: number | bigint): Promise<C>;
138
193
  /**
139
- * Extracts the signer's fingerprint from a CWT without verifying.
194
+ * Extracts the signer's fingerprint from a CWT without verifying the
195
+ * signature.
140
196
  *
141
- * The returned data is unauthenticated. Use this to look up the appropriate
197
+ * The fingerprint is unauthenticated. Use it to look up the appropriate
142
198
  * verification key before calling {@link verify}.
143
199
  *
144
200
  * @param token - The serialized CWT
145
- * @returns The signer fingerprint
201
+ * @returns The signer's fingerprint
202
+ * @throws If the token is malformed
146
203
  */
147
204
  export declare function signer(token: Uint8Array): Promise<xdsa.Fingerprint>;
148
205
  /**
149
- * Extracts claims from a CWT without verifying the signature.
206
+ * Extracts and decodes the claims from a CWT without verifying the signature.
150
207
  *
151
- * **Warning**: The returned payload is unauthenticated and should not be
152
- * trusted until verified with {@link verify}. Use {@link signer} to extract
153
- * the signer's fingerprint for key lookup.
208
+ * The claims are unauthenticated and must not be trusted until verified with
209
+ * {@link verify}. Use {@link signer} to extract the signer's fingerprint for
210
+ * key lookup. The one intended use of this function is self-signed key
211
+ * discovery.
154
212
  *
155
- * @param token - The serialized CWT
156
- * @returns The decoded (but unverified) claims
213
+ * @param token - The serialized CWT, bound to the codec of its claims
214
+ * @returns The decoded, unverified claims
215
+ * @throws If the token is malformed
216
+ * @throws CodecError if the claims do not fit their codec
157
217
  */
158
218
  export declare function peek<C>(token: Decodable<C>): Promise<C>;
159
219
  //# sourceMappingURL=cwt.d.ts.map
package/dist/cwt.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cwt.d.ts","sourceRoot":"","sources":["../src/cwt.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,EAUL,KAAK,KAAK,EACV,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,WAAW,CAAC;AAUnB,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AAEpC;;GAEG;AACH,oBAAY,UAAU;IACpB,kCAAkC;IAClC,OAAO,IAAI;IACX,mCAAmC;IACnC,QAAQ,IAAI;IACZ,iEAAiE;IACjE,iBAAiB,IAAI;IACrB,kDAAkD;IAClD,mBAAmB,IAAI;IACvB,+DAA+D;IAC/D,wBAAwB,IAAI;CAC7B;AAED;;GAEG;AAC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EACnB,QAAQ,EAAE,IAAI,CAAC,SAAS,EACxB,MAAM,EAAE,UAAU,EAClB,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,GACpB,OAAO,CAAC,CAAC,CAAC,CASZ;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAGzE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAG7D"}
package/dist/hkdf.d.ts CHANGED
@@ -1,34 +1,41 @@
1
1
  /**
2
- * Derive a key from secret, salt, and info using HKDF-SHA256.
2
+ * Derives a key from the secret, salt and info using HKDF-SHA256.
3
3
  *
4
- * @param secret - The input keying material
5
- * @param salt - Optional salt value (can be empty)
6
- * @param info - Optional context/application-specific info (can be empty)
7
- * @param outLen - Desired output length in bytes (max 8160)
4
+ * @param secret - The input keying material, already high entropy
5
+ * @param salt - Optional salt, empty for none
6
+ * @param info - Context the key is bound to, empty for none
7
+ * @param outLen - Length of the key in bytes, at most 8160
8
8
  * @returns The derived key
9
+ * @throws If `outLen` is not a whole number between 0 and 8160
9
10
  */
10
11
  export declare function key(secret: Uint8Array, salt: Uint8Array, info: Uint8Array, outLen: number): Promise<Uint8Array>;
11
12
  /**
12
- * Extract a pseudorandom key from secret and salt using HKDF-SHA256.
13
+ * Extracts a 32-byte pseudorandom key from the secret and salt, for use with
14
+ * {@link expand}.
13
15
  *
14
- * Only use this if you need to reuse the extracted key with multiple
15
- * expand invocations. Most scenarios should use `key` instead.
16
+ * Only use this to reuse the extracted key with multiple {@link expand} calls
17
+ * and different contexts. Most scenarios, including the derivation of multiple
18
+ * keys, should use {@link key} instead.
16
19
  *
17
- * @param secret - The input keying material
18
- * @param salt - Optional salt value (can be empty)
20
+ * @param secret - The input keying material, already high entropy
21
+ * @param salt - Optional salt, empty for none
19
22
  * @returns A 32-byte pseudorandom key
20
23
  */
21
24
  export declare function extract(secret: Uint8Array, salt: Uint8Array): Promise<Uint8Array>;
22
25
  /**
23
- * Expand a pseudorandom key with info using HKDF-SHA256.
26
+ * Derives a key from a pseudorandom key and context info, skipping the
27
+ * extraction step.
24
28
  *
25
- * The prk should have been generated by `extract` or be a uniformly
26
- * random 32-byte key.
29
+ * The pseudorandom key should come from {@link extract}, or be a uniformly
30
+ * random or pseudorandom cryptographically strong key. See RFC 5869 Section
31
+ * 3.3. Most scenarios should use {@link key} instead.
27
32
  *
28
33
  * @param prk - A 32-byte pseudorandom key
29
- * @param info - Optional context/application-specific info (can be empty)
30
- * @param outLen - Desired output length in bytes (max 8160)
34
+ * @param info - Context the key is bound to, empty for none
35
+ * @param outLen - Length of the key in bytes, at most 8160
31
36
  * @returns The derived key
37
+ * @throws If `prk` is not 32 bytes, or `outLen` is not a whole number between
38
+ * 0 and 8160
32
39
  */
33
40
  export declare function expand(prk: Uint8Array, info: Uint8Array, outLen: number): Promise<Uint8Array>;
34
41
  //# sourceMappingURL=hkdf.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hkdf.d.ts","sourceRoot":"","sources":["../src/hkdf.ts"],"names":[],"mappings":"AAcA;;;;;;;;GAQG;AACH,wBAAsB,GAAG,CACvB,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,UAAU,CAAC,CAGrB;AAED;;;;;;;;;GASG;AACH,wBAAsB,OAAO,CAC3B,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,UAAU,GACf,OAAO,CAAC,UAAU,CAAC,CAGrB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,MAAM,CAC1B,GAAG,EAAE,UAAU,EACf,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,UAAU,CAAC,CAGrB"}
1
+ {"version":3,"file":"hkdf.d.ts","sourceRoot":"","sources":["../src/hkdf.ts"],"names":[],"mappings":"AAuCA;;;;;;;;;GASG;AACH,wBAAsB,GAAG,CACvB,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,UAAU,CAAC,CAGrB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,OAAO,CAC3B,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,UAAU,GACf,OAAO,CAAC,UAAU,CAAC,CAGrB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,MAAM,CAC1B,GAAG,EAAE,UAAU,EACf,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,UAAU,CAAC,CAGrB"}
package/dist/index.d.ts CHANGED
@@ -1,9 +1,29 @@
1
+ /**
2
+ * Post-quantum cryptography for the Dark Bio ecosystem, the Rust library
3
+ * compiled to WASM behind a typed API.
4
+ *
5
+ * Signatures come from `xdsa`, encryption from `xhpke`, and `cose` wraps both
6
+ * into COSE envelopes using the Dark Bio wire profile. Payloads and
7
+ * authenticated messages are bound to a `cbor` codec, which declares their
8
+ * shape. The WASM module loads on the first call of any async function, so
9
+ * there is no separate setup step.
10
+ *
11
+ * @module
12
+ */
13
+ /** Random bytes from the runtime's secure random source. */
1
14
  export * as rand from './rand.js';
15
+ /** HKDF-SHA256 key derivation. */
2
16
  export * as hkdf from './hkdf.js';
17
+ /** Argon2id key derivation from passwords. */
3
18
  export * as argon2 from './argon2.js';
19
+ /** Typed codecs over the restricted CBOR type system. */
4
20
  export * as cbor from './cbor.js';
21
+ /** Composite ML-DSA-65 + Ed25519 digital signatures. */
5
22
  export * as xdsa from './xdsa.js';
23
+ /** X-Wing HPKE encryption. */
6
24
  export * as xhpke from './xhpke.js';
25
+ /** COSE signing and encryption with xDSA and xHPKE. */
7
26
  export * as cose from './cose.js';
27
+ /** CBOR Web Tokens on top of COSE Sign1. */
8
28
  export * as cwt from './cwt.js';
9
29
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;GAWG;AAEH,4DAA4D;AAC5D,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,kCAAkC;AAClC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,8CAA8C;AAC9C,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,yDAAyD;AACzD,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,wDAAwD;AACxD,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,8BAA8B;AAC9B,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,uDAAuD;AACvD,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,4CAA4C;AAC5C,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC"}