micro509 0.17.1 → 0.18.0
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/CHANGELOG.md +78 -6
- package/dist/crypto/crypto.d.ts +2 -3
- package/dist/crypto.d.ts +6 -0
- package/dist/der/der.d.ts +14 -4
- package/dist/der/der.js +19 -19
- package/dist/der.d.ts +26 -2
- package/dist/der.js +4 -4
- package/dist/index.d.ts +82 -15
- package/dist/index.js +19 -19
- package/dist/internal/asn1/asn1.d.ts +1 -2
- package/dist/internal/asn1/der.d.ts +1 -2
- package/dist/internal/asn1/oids.js +71 -353
- package/dist/internal/asn1/oids.js.map +1 -1
- package/dist/internal/asn1/oids.json.js +357 -0
- package/dist/internal/asn1/oids.json.js.map +1 -0
- package/dist/internal/crypto/algorithm-names.js +1 -1
- package/dist/internal/crypto/pbes2.d.ts +1 -2
- package/dist/internal/crypto/pbes2.js +70 -70
- package/dist/internal/crypto/prime-ec.js +37 -0
- package/dist/internal/crypto/prime-ec.js.map +1 -0
- package/dist/internal/crypto/rsa-pss.js +50 -50
- package/dist/internal/crypto/sig-verify.d.ts +1 -2
- package/dist/internal/crypto/sig-verify.js +60 -60
- package/dist/internal/crypto/signing.d.ts +1 -2
- package/dist/internal/crypto/signing.js +26 -26
- package/dist/internal/jose/json-data.js +108 -0
- package/dist/internal/jose/json-data.js.map +1 -0
- package/dist/internal/jose/strict-json.d.ts +1 -2
- package/dist/internal/shared/dn.d.ts +1 -2
- package/dist/internal/shared/dn.js +1 -1
- package/dist/internal/shared/ip.d.ts +1 -2
- package/dist/internal/verify/name-constraints-engine.js +64 -64
- package/dist/internal/verify/policy-engine.js +1 -1
- package/dist/internal/verify/verify-path.d.ts +1 -2
- package/dist/internal/verify/verify-path.js +19 -19
- package/dist/internal/x509/directory-name.js +10 -10
- package/dist/internal/x509/extension-errors.d.ts +1 -2
- package/dist/internal/x509/extension-registry.js +18 -18
- package/dist/internal/x509/general-name-profile.js +9 -9
- package/dist/internal/x509/general-name.js +32 -32
- package/dist/internal/x509/name-fields.js +1 -1
- package/dist/jose/base64url.d.ts +4 -0
- package/dist/jose/base64url.js +14 -0
- package/dist/jose/base64url.js.map +1 -0
- package/dist/jose/errors.d.ts +9 -3
- package/dist/jose/errors.js.map +1 -1
- package/dist/jose/jwe.d.ts +64 -0
- package/dist/jose/jwe.js +188 -0
- package/dist/jose/jwe.js.map +1 -0
- package/dist/jose/jwks.d.ts +38 -10
- package/dist/jose/jwks.js +156 -96
- package/dist/jose/jwks.js.map +1 -1
- package/dist/jose/jws.d.ts +8 -6
- package/dist/jose/jws.js +216 -170
- package/dist/jose/jws.js.map +1 -1
- package/dist/jose/jwt.d.ts +8 -2
- package/dist/jose/jwt.js +98 -98
- package/dist/jose/remote-jwks.d.ts +1 -2
- package/dist/jose/remote-jwks.js +106 -108
- package/dist/jose/remote-jwks.js.map +1 -1
- package/dist/jose.d.ts +15 -4
- package/dist/jose.js +7 -5
- package/dist/kdf/argon2.d.ts +7 -2
- package/dist/kdf.d.ts +6 -0
- package/dist/keys/keys.d.ts +31 -6
- package/dist/keys/keys.js +315 -233
- package/dist/keys/keys.js.map +1 -1
- package/dist/keys.d.ts +11 -2
- package/dist/keys.js +2 -2
- package/dist/pem/pem.d.ts +1 -2
- package/dist/pem/pem.js +40 -25
- package/dist/pem/pem.js.map +1 -1
- package/dist/pem.d.ts +6 -0
- package/dist/pkcs/pfx.d.ts +2 -3
- package/dist/pkcs/pfx.js +142 -142
- package/dist/pkcs/pkcs12-mac.d.ts +1 -2
- package/dist/pkcs/pkcs12-mac.js +122 -122
- package/dist/pkcs/pkcs7.d.ts +14 -3
- package/dist/pkcs/pkcs7.js +268 -248
- package/dist/pkcs/pkcs7.js.map +1 -1
- package/dist/pkcs.d.ts +10 -1
- package/dist/pkcs.js +4 -4
- package/dist/result/result.d.ts +1 -2
- package/dist/result.d.ts +6 -0
- package/dist/revocation/chain.d.ts +2 -3
- package/dist/revocation/chain.js +52 -52
- package/dist/revocation/crl.d.ts +2 -3
- package/dist/revocation/crl.js +319 -319
- package/dist/revocation/crl.js.map +1 -1
- package/dist/revocation/ocsp.d.ts +2 -3
- package/dist/revocation/ocsp.js +395 -395
- package/dist/revocation/revocation.d.ts +2 -3
- package/dist/revocation/revocation.js +22 -22
- package/dist/revocation.d.ts +12 -3
- package/dist/revocation.js +4 -4
- package/dist/ssh/ssh.d.ts +2 -3
- package/dist/ssh/ssh.js +165 -170
- package/dist/ssh/ssh.js.map +1 -1
- package/dist/ssh/wire.d.ts +1 -2
- package/dist/ssh/wire.js +10 -10
- package/dist/ssh.d.ts +8 -0
- package/dist/verify/identity.d.ts +1 -2
- package/dist/verify/identity.js +31 -31
- package/dist/verify/name-constraints.d.ts +9 -2
- package/dist/verify/policy.d.ts +9 -2
- package/dist/verify/verify.d.ts +3 -4
- package/dist/verify/verify.js +121 -121
- package/dist/verify.d.ts +9 -0
- package/dist/x509/certificate.d.ts +4 -5
- package/dist/x509/certificate.js +40 -40
- package/dist/x509/csr.d.ts +3 -4
- package/dist/x509/csr.js +15 -15
- package/dist/x509/extensions.d.ts +1 -2
- package/dist/x509/extensions.js +165 -165
- package/dist/x509/extensions.js.map +1 -1
- package/dist/x509/fingerprint.d.ts +1 -2
- package/dist/x509/name-text.d.ts +1 -2
- package/dist/x509/name.d.ts +1 -2
- package/dist/x509/name.js +15 -15
- package/dist/x509/parse.d.ts +3 -4
- package/dist/x509/parse.js +423 -423
- package/dist/x509.d.ts +17 -4
- package/dist/x509.js +8 -8
- package/package.json +22 -23
- package/dist/internal/asn1/oids2.js +0 -75
- package/dist/internal/asn1/oids2.js.map +0 -1
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
// src/internal/asn1/oids.json
|
|
2
|
+
var e = {
|
|
3
|
+
$schema: "./oids.schema.json",
|
|
4
|
+
ituT: {
|
|
5
|
+
arc: "0",
|
|
6
|
+
children: { data: {
|
|
7
|
+
arc: "9",
|
|
8
|
+
children: { pss: {
|
|
9
|
+
arc: "2342",
|
|
10
|
+
children: { ucl: {
|
|
11
|
+
arc: "19200300",
|
|
12
|
+
children: { pilot: {
|
|
13
|
+
arc: "100",
|
|
14
|
+
children: { pilotAttributeType: {
|
|
15
|
+
arc: "1",
|
|
16
|
+
oids: {
|
|
17
|
+
userId: "1",
|
|
18
|
+
domainComponent: "25"
|
|
19
|
+
}
|
|
20
|
+
} }
|
|
21
|
+
} }
|
|
22
|
+
} }
|
|
23
|
+
} }
|
|
24
|
+
} }
|
|
25
|
+
},
|
|
26
|
+
iso: {
|
|
27
|
+
arc: "1",
|
|
28
|
+
children: {
|
|
29
|
+
memberBody: {
|
|
30
|
+
arc: "2",
|
|
31
|
+
children: { us: {
|
|
32
|
+
arc: "840",
|
|
33
|
+
children: {
|
|
34
|
+
rsadsi: {
|
|
35
|
+
arc: "113549",
|
|
36
|
+
children: {
|
|
37
|
+
pkcs: {
|
|
38
|
+
arc: "1",
|
|
39
|
+
children: {
|
|
40
|
+
pkcs1: {
|
|
41
|
+
arc: "1",
|
|
42
|
+
oids: {
|
|
43
|
+
rsaEncryption: "1",
|
|
44
|
+
sha1WithRSAEncryption: "5",
|
|
45
|
+
mgf1: "8",
|
|
46
|
+
rsassaPss: "10",
|
|
47
|
+
sha256WithRSAEncryption: "11",
|
|
48
|
+
sha384WithRSAEncryption: "12",
|
|
49
|
+
sha512WithRSAEncryption: "13"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
pkcs5: {
|
|
53
|
+
arc: "5",
|
|
54
|
+
oids: {
|
|
55
|
+
pbkdf2: "12",
|
|
56
|
+
pbes2: "13",
|
|
57
|
+
pbmac1: "14"
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
pkcs7: {
|
|
61
|
+
arc: "7",
|
|
62
|
+
oids: {
|
|
63
|
+
pkcs7Data: "1",
|
|
64
|
+
pkcs7SignedData: "2",
|
|
65
|
+
pkcs7EncryptedData: "6"
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
pkcs9: {
|
|
69
|
+
arc: "9",
|
|
70
|
+
oids: {
|
|
71
|
+
emailAddress: "1",
|
|
72
|
+
cmsContentType: "3",
|
|
73
|
+
cmsMessageDigest: "4",
|
|
74
|
+
extensionRequest: "14",
|
|
75
|
+
friendlyName: "20",
|
|
76
|
+
localKeyId: "21"
|
|
77
|
+
},
|
|
78
|
+
children: { certTypes: {
|
|
79
|
+
arc: "22",
|
|
80
|
+
oids: { x509CertificateBagType: "1" }
|
|
81
|
+
} }
|
|
82
|
+
},
|
|
83
|
+
pkcs12Bags: {
|
|
84
|
+
arc: "12",
|
|
85
|
+
children: { bagTypes: {
|
|
86
|
+
arc: "10",
|
|
87
|
+
children: { bags: {
|
|
88
|
+
arc: "1",
|
|
89
|
+
oids: {
|
|
90
|
+
pkcs12KeyBag: "1",
|
|
91
|
+
pkcs12CertBag: "3"
|
|
92
|
+
}
|
|
93
|
+
} }
|
|
94
|
+
} }
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
digestAlgorithm: {
|
|
99
|
+
arc: "2",
|
|
100
|
+
oids: {
|
|
101
|
+
hmacWithSHA1: "7",
|
|
102
|
+
hmacWithSHA256: "9",
|
|
103
|
+
hmacWithSHA384: "10",
|
|
104
|
+
hmacWithSHA512: "11"
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
ansiX962: {
|
|
110
|
+
arc: "10045",
|
|
111
|
+
children: {
|
|
112
|
+
keyType: {
|
|
113
|
+
arc: "2",
|
|
114
|
+
oids: { ecPublicKey: "1" }
|
|
115
|
+
},
|
|
116
|
+
curves: {
|
|
117
|
+
arc: "3",
|
|
118
|
+
children: { prime: {
|
|
119
|
+
arc: "1",
|
|
120
|
+
oids: { prime256v1: "7" }
|
|
121
|
+
} }
|
|
122
|
+
},
|
|
123
|
+
signatures: {
|
|
124
|
+
arc: "4",
|
|
125
|
+
oids: { ecdsaWithSHA1: "1" },
|
|
126
|
+
children: { sha2: {
|
|
127
|
+
arc: "3",
|
|
128
|
+
oids: {
|
|
129
|
+
ecdsaWithSHA224: "1",
|
|
130
|
+
ecdsaWithSHA256: "2",
|
|
131
|
+
ecdsaWithSHA384: "3",
|
|
132
|
+
ecdsaWithSHA512: "4"
|
|
133
|
+
}
|
|
134
|
+
} }
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
} }
|
|
140
|
+
},
|
|
141
|
+
identifiedOrganization: {
|
|
142
|
+
arc: "3",
|
|
143
|
+
children: {
|
|
144
|
+
certicom: {
|
|
145
|
+
arc: "132",
|
|
146
|
+
children: { curve: {
|
|
147
|
+
arc: "0",
|
|
148
|
+
oids: {
|
|
149
|
+
secp384r1: "34",
|
|
150
|
+
secp521r1: "35"
|
|
151
|
+
}
|
|
152
|
+
} }
|
|
153
|
+
},
|
|
154
|
+
edwardsCurveAlgs: {
|
|
155
|
+
arc: "101",
|
|
156
|
+
oids: {
|
|
157
|
+
x25519: "110",
|
|
158
|
+
x448: "111",
|
|
159
|
+
ed25519: "112",
|
|
160
|
+
ed448: "113"
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
dod: {
|
|
164
|
+
arc: "6",
|
|
165
|
+
children: { internet: {
|
|
166
|
+
arc: "1",
|
|
167
|
+
children: {
|
|
168
|
+
security: {
|
|
169
|
+
arc: "5",
|
|
170
|
+
children: {
|
|
171
|
+
mechanisms: {
|
|
172
|
+
arc: "5",
|
|
173
|
+
children: { pkix: {
|
|
174
|
+
arc: "7",
|
|
175
|
+
children: {
|
|
176
|
+
extensions: {
|
|
177
|
+
arc: "1",
|
|
178
|
+
oids: { authorityInfoAccess: "1" }
|
|
179
|
+
},
|
|
180
|
+
policyQualifiers: {
|
|
181
|
+
arc: "2",
|
|
182
|
+
oids: {
|
|
183
|
+
cpsPolicyQualifier: "1",
|
|
184
|
+
userNoticePolicyQualifier: "2"
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
extendedKeyUsage: {
|
|
188
|
+
arc: "3",
|
|
189
|
+
oids: {
|
|
190
|
+
serverAuth: "1",
|
|
191
|
+
clientAuth: "2",
|
|
192
|
+
codeSigning: "3",
|
|
193
|
+
emailProtection: "4",
|
|
194
|
+
timeStamping: "8",
|
|
195
|
+
ocspSigning: "9"
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
otherNameForms: {
|
|
199
|
+
arc: "8",
|
|
200
|
+
oids: {
|
|
201
|
+
idOnDnsSrv: "7",
|
|
202
|
+
idOnSmtpUtf8Mailbox: "9"
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
accessMethods: {
|
|
206
|
+
arc: "48",
|
|
207
|
+
oids: {
|
|
208
|
+
ocspAccessMethod: "1",
|
|
209
|
+
caIssuersAccessMethod: "2"
|
|
210
|
+
},
|
|
211
|
+
children: { ocsp: {
|
|
212
|
+
arc: "1",
|
|
213
|
+
oids: {
|
|
214
|
+
ocspBasicResponse: "1",
|
|
215
|
+
ocspNonce: "2",
|
|
216
|
+
ocspNoCheck: "5"
|
|
217
|
+
}
|
|
218
|
+
} }
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
} }
|
|
222
|
+
},
|
|
223
|
+
kerberosV5: {
|
|
224
|
+
arc: "2",
|
|
225
|
+
oids: { idPkinitSan: "2" }
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
private: {
|
|
230
|
+
arc: "4",
|
|
231
|
+
children: { enterprise: {
|
|
232
|
+
arc: "1",
|
|
233
|
+
children: { microsoft: {
|
|
234
|
+
arc: "311",
|
|
235
|
+
children: { msEnrollment: {
|
|
236
|
+
arc: "20",
|
|
237
|
+
children: { msPrincipalNameForms: {
|
|
238
|
+
arc: "2",
|
|
239
|
+
oids: { ntPrincipalName: "3" }
|
|
240
|
+
} }
|
|
241
|
+
} }
|
|
242
|
+
} }
|
|
243
|
+
} }
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
} }
|
|
247
|
+
},
|
|
248
|
+
oiw: {
|
|
249
|
+
arc: "14",
|
|
250
|
+
children: { secsig: {
|
|
251
|
+
arc: "3",
|
|
252
|
+
children: { algorithms: {
|
|
253
|
+
arc: "2",
|
|
254
|
+
oids: { sha1: "26" }
|
|
255
|
+
} }
|
|
256
|
+
} }
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
jointIsoItuT: {
|
|
263
|
+
arc: "2",
|
|
264
|
+
children: {
|
|
265
|
+
ds: {
|
|
266
|
+
arc: "5",
|
|
267
|
+
children: {
|
|
268
|
+
attributeType: {
|
|
269
|
+
arc: "4",
|
|
270
|
+
oids: {
|
|
271
|
+
commonName: "3",
|
|
272
|
+
surname: "4",
|
|
273
|
+
serialNumber: "5",
|
|
274
|
+
countryName: "6",
|
|
275
|
+
localityName: "7",
|
|
276
|
+
stateOrProvinceName: "8",
|
|
277
|
+
streetAddress: "9",
|
|
278
|
+
organizationName: "10",
|
|
279
|
+
organizationalUnitName: "11",
|
|
280
|
+
title: "12",
|
|
281
|
+
givenName: "42"
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
certificateExtension: {
|
|
285
|
+
arc: "29",
|
|
286
|
+
oids: {
|
|
287
|
+
subjectKeyIdentifier: "14",
|
|
288
|
+
keyUsage: "15",
|
|
289
|
+
subjectAltName: "17",
|
|
290
|
+
issuerAltName: "18",
|
|
291
|
+
basicConstraints: "19",
|
|
292
|
+
cRLNumber: "20",
|
|
293
|
+
cRLReason: "21",
|
|
294
|
+
invalidityDate: "24",
|
|
295
|
+
deltaCRLIndicator: "27",
|
|
296
|
+
issuingDistributionPoint: "28",
|
|
297
|
+
certificateIssuer: "29",
|
|
298
|
+
nameConstraints: "30",
|
|
299
|
+
cRLDistributionPoints: "31",
|
|
300
|
+
certificatePolicies: "32",
|
|
301
|
+
policyMappings: "33",
|
|
302
|
+
authorityKeyIdentifier: "35",
|
|
303
|
+
policyConstraints: "36",
|
|
304
|
+
extendedKeyUsage: "37",
|
|
305
|
+
freshestCRL: "46",
|
|
306
|
+
inhibitAnyPolicy: "54",
|
|
307
|
+
noRevAvail: "56"
|
|
308
|
+
},
|
|
309
|
+
children: { certificatePolicies: {
|
|
310
|
+
arc: "32",
|
|
311
|
+
oids: { anyPolicy: "0" }
|
|
312
|
+
} }
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
country: {
|
|
317
|
+
arc: "16",
|
|
318
|
+
children: { us: {
|
|
319
|
+
arc: "840",
|
|
320
|
+
children: { organization: {
|
|
321
|
+
arc: "1",
|
|
322
|
+
children: { gov: {
|
|
323
|
+
arc: "101",
|
|
324
|
+
children: { csor: {
|
|
325
|
+
arc: "3",
|
|
326
|
+
children: { nistAlgorithms: {
|
|
327
|
+
arc: "4",
|
|
328
|
+
children: {
|
|
329
|
+
aes: {
|
|
330
|
+
arc: "1",
|
|
331
|
+
oids: {
|
|
332
|
+
aes128Cbc: "2",
|
|
333
|
+
aes192Cbc: "22",
|
|
334
|
+
aes256Cbc: "42"
|
|
335
|
+
}
|
|
336
|
+
},
|
|
337
|
+
hashes: {
|
|
338
|
+
arc: "2",
|
|
339
|
+
oids: {
|
|
340
|
+
sha256: "1",
|
|
341
|
+
sha384: "2",
|
|
342
|
+
sha512: "3"
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
} }
|
|
347
|
+
} }
|
|
348
|
+
} }
|
|
349
|
+
} }
|
|
350
|
+
} }
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
export { e as default };
|
|
356
|
+
|
|
357
|
+
//# sourceMappingURL=oids.json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oids.json.js","names":["oids_default","\"arc\"","\"children\"","\"data\"","\"pss\"","\"ucl\"","\"pilot\"","\"pilotAttributeType\"","\"oids\"","\"userId\"","\"domainComponent\"","\"memberBody\"","\"us\"","\"rsadsi\"","\"pkcs\"","\"pkcs1\"","\"rsaEncryption\"","\"sha1WithRSAEncryption\"","\"mgf1\"","\"rsassaPss\"","\"sha256WithRSAEncryption\"","\"sha384WithRSAEncryption\"","\"sha512WithRSAEncryption\"","\"pkcs5\"","\"pbkdf2\"","\"pbes2\"","\"pbmac1\"","\"pkcs7\"","\"pkcs7Data\"","\"pkcs7SignedData\"","\"pkcs7EncryptedData\"","\"pkcs9\"","\"emailAddress\"","\"cmsContentType\"","\"cmsMessageDigest\"","\"extensionRequest\"","\"friendlyName\"","\"localKeyId\"","\"certTypes\"","\"x509CertificateBagType\"","\"pkcs12Bags\"","\"bagTypes\"","\"bags\"","\"pkcs12KeyBag\"","\"pkcs12CertBag\"","\"digestAlgorithm\"","\"hmacWithSHA1\"","\"hmacWithSHA256\"","\"hmacWithSHA384\"","\"hmacWithSHA512\"","\"ansiX962\"","\"keyType\"","\"ecPublicKey\"","\"curves\"","\"prime\"","\"prime256v1\"","\"signatures\"","\"ecdsaWithSHA1\"","\"sha2\"","\"ecdsaWithSHA224\"","\"ecdsaWithSHA256\"","\"ecdsaWithSHA384\"","\"ecdsaWithSHA512\"","\"identifiedOrganization\"","\"certicom\"","\"curve\"","\"secp384r1\"","\"secp521r1\"","\"edwardsCurveAlgs\"","\"x25519\"","\"x448\"","\"ed25519\"","\"ed448\"","\"dod\"","\"internet\"","\"security\"","\"mechanisms\"","\"pkix\"","\"extensions\"","\"authorityInfoAccess\"","\"policyQualifiers\"","\"cpsPolicyQualifier\"","\"userNoticePolicyQualifier\"","\"extendedKeyUsage\"","\"serverAuth\"","\"clientAuth\"","\"codeSigning\"","\"emailProtection\"","\"timeStamping\"","\"ocspSigning\"","\"otherNameForms\"","\"idOnDnsSrv\"","\"idOnSmtpUtf8Mailbox\"","\"accessMethods\"","\"ocspAccessMethod\"","\"caIssuersAccessMethod\"","\"ocsp\"","\"ocspBasicResponse\"","\"ocspNonce\"","\"ocspNoCheck\"","\"kerberosV5\"","\"idPkinitSan\"","\"private\"","\"enterprise\"","\"microsoft\"","\"msEnrollment\"","\"msPrincipalNameForms\"","\"ntPrincipalName\"","\"oiw\"","\"secsig\"","\"algorithms\"","\"sha1\"","\"ds\"","\"attributeType\"","\"commonName\"","\"surname\"","\"serialNumber\"","\"countryName\"","\"localityName\"","\"stateOrProvinceName\"","\"streetAddress\"","\"organizationName\"","\"organizationalUnitName\"","\"title\"","\"givenName\"","\"certificateExtension\"","\"subjectKeyIdentifier\"","\"keyUsage\"","\"subjectAltName\"","\"issuerAltName\"","\"basicConstraints\"","\"cRLNumber\"","\"cRLReason\"","\"invalidityDate\"","\"deltaCRLIndicator\"","\"issuingDistributionPoint\"","\"certificateIssuer\"","\"nameConstraints\"","\"cRLDistributionPoints\"","\"certificatePolicies\"","\"policyMappings\"","\"authorityKeyIdentifier\"","\"policyConstraints\"","\"freshestCRL\"","\"inhibitAnyPolicy\"","\"noRevAvail\"","\"anyPolicy\"","\"country\"","\"organization\"","\"gov\"","\"csor\"","\"nistAlgorithms\"","\"aes\"","\"aes128Cbc\"","\"aes192Cbc\"","\"aes256Cbc\"","\"hashes\"","\"sha256\"","\"sha384\"","\"sha512\""],"sources":["../../../src/internal/asn1/oids.json"],"sourcesContent":[""],"mappings":""}
|
|
@@ -47,5 +47,4 @@ export interface Pbes2Parameters {
|
|
|
47
47
|
* @throws if the encoding is malformed, names an unsupported KDF, PRF or cipher, or carries an
|
|
48
48
|
* iteration count outside 1 to 4294967295.
|
|
49
49
|
*/
|
|
50
|
-
export declare function parsePbes2AlgorithmIdentifier(algorithmIdentifierDer: Uint8Array): Pbes2Parameters;
|
|
51
|
-
//# sourceMappingURL=pbes2.d.ts.map
|
|
50
|
+
export declare function parsePbes2AlgorithmIdentifier(algorithmIdentifierDer: Uint8Array): Pbes2Parameters;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { OIDS as l } from "../asn1/
|
|
1
|
+
import { decodeIntegerNumber as e, decodeObjectIdentifier as t, toArrayBuffer as n } from "../asn1/asn1.js";
|
|
2
|
+
import { integerFromNumber as r, nullValue as i, objectIdentifier as a, octetString as o, readSequenceChildren as s, sequence as c } from "../asn1/der.js";
|
|
3
|
+
import { OIDS as l } from "../asn1/oids.js";
|
|
4
4
|
import { getCrypto as u } from "./webcrypto.js";
|
|
5
5
|
// src/internal/crypto/pbes2.ts
|
|
6
6
|
/**
|
|
@@ -53,40 +53,40 @@ function chargeKdfBudget(e, t) {
|
|
|
53
53
|
e.remaining -= t;
|
|
54
54
|
}
|
|
55
55
|
const h = 4294967295;
|
|
56
|
-
async function derivePbkdf2Bytes(e, t,
|
|
57
|
-
assertPbkdf2IterationCount(
|
|
58
|
-
let
|
|
56
|
+
async function derivePbkdf2Bytes(e, t, r, i, a) {
|
|
57
|
+
assertPbkdf2IterationCount(r);
|
|
58
|
+
let o = await u().subtle.importKey("raw", n(e), "PBKDF2", !1, ["deriveBits"]);
|
|
59
59
|
return new Uint8Array(await u().subtle.deriveBits({
|
|
60
60
|
name: "PBKDF2",
|
|
61
|
-
salt:
|
|
62
|
-
iterations:
|
|
63
|
-
hash:
|
|
64
|
-
},
|
|
61
|
+
salt: n(t),
|
|
62
|
+
iterations: r,
|
|
63
|
+
hash: i
|
|
64
|
+
}, o, a * 8));
|
|
65
65
|
}
|
|
66
66
|
/** Encrypts `data` using PBES2 (PBKDF2 + AES-CBC) and returns ciphertext with algorithm params. */
|
|
67
67
|
async function encryptPbes2(e, t) {
|
|
68
|
-
let
|
|
69
|
-
if (assertPbkdf2IterationCount(
|
|
70
|
-
if (!(
|
|
71
|
-
let
|
|
68
|
+
let r = t.iterations ?? 1e5, i = t.salt ?? u().getRandomValues(/* @__PURE__ */ new Uint8Array(16)), a = t.iv ?? u().getRandomValues(/* @__PURE__ */ new Uint8Array(16)), o = t.cipher ?? "AES-256-CBC", s = t.prf ?? "HMAC-SHA-256";
|
|
69
|
+
if (assertPbkdf2IterationCount(r), !(i instanceof Uint8Array) || i.length < 8) throw TypeError(`Invalid salt: must be Uint8Array with length >= 8, got length ${i.length}`);
|
|
70
|
+
if (!(a instanceof Uint8Array) || a.length !== 16) throw TypeError(`Invalid IV: must be Uint8Array of exactly 16 bytes, got length ${a.length}`);
|
|
71
|
+
let c = await deriveAesKey(t.password, i, r, o, s, ["encrypt"]), l = new Uint8Array(await u().subtle.encrypt({
|
|
72
72
|
name: "AES-CBC",
|
|
73
|
-
iv:
|
|
74
|
-
},
|
|
73
|
+
iv: n(a)
|
|
74
|
+
}, c, n(e)));
|
|
75
75
|
return {
|
|
76
76
|
algorithmIdentifierDer: encodePbes2AlgorithmIdentifier({
|
|
77
|
-
iterations:
|
|
78
|
-
salt:
|
|
79
|
-
iv:
|
|
80
|
-
cipher:
|
|
81
|
-
prf:
|
|
77
|
+
iterations: r,
|
|
78
|
+
salt: i,
|
|
79
|
+
iv: a,
|
|
80
|
+
cipher: o,
|
|
81
|
+
prf: s
|
|
82
82
|
}),
|
|
83
83
|
encryptedData: l,
|
|
84
84
|
parameters: {
|
|
85
|
-
iterations:
|
|
86
|
-
salt:
|
|
87
|
-
iv:
|
|
88
|
-
cipher:
|
|
89
|
-
prf:
|
|
85
|
+
iterations: r,
|
|
86
|
+
salt: i,
|
|
87
|
+
iv: a,
|
|
88
|
+
cipher: o,
|
|
89
|
+
prf: s
|
|
90
90
|
}
|
|
91
91
|
};
|
|
92
92
|
}
|
|
@@ -95,15 +95,15 @@ async function encryptPbes2(e, t) {
|
|
|
95
95
|
* Throws on wrong password, and before derivation when the encoded iteration
|
|
96
96
|
* count exceeds what `budget` still allows.
|
|
97
97
|
*/
|
|
98
|
-
async function decryptPbes2(e, t,
|
|
99
|
-
let
|
|
100
|
-
chargeKdfBudget(
|
|
101
|
-
let
|
|
98
|
+
async function decryptPbes2(e, t, r, i = createKdfBudget(void 0)) {
|
|
99
|
+
let a = parsePbes2AlgorithmIdentifier(e);
|
|
100
|
+
chargeKdfBudget(i, a.iterations);
|
|
101
|
+
let o = await deriveAesKey(r, a.salt, a.iterations, a.cipher, a.prf, ["decrypt"]);
|
|
102
102
|
try {
|
|
103
103
|
return new Uint8Array(await u().subtle.decrypt({
|
|
104
104
|
name: "AES-CBC",
|
|
105
|
-
iv:
|
|
106
|
-
},
|
|
105
|
+
iv: n(a.iv)
|
|
106
|
+
}, o, n(t)));
|
|
107
107
|
} catch {
|
|
108
108
|
throw wrongPasswordError("Invalid password or encrypted content");
|
|
109
109
|
}
|
|
@@ -113,15 +113,15 @@ async function decryptPbes2(e, t, n, r = createKdfBudget(void 0)) {
|
|
|
113
113
|
*
|
|
114
114
|
* @throws {RangeError} if `parameters.iterations` is not an integer from 1 to 4294967295.
|
|
115
115
|
*/
|
|
116
|
-
function encodePbes2AlgorithmIdentifier(
|
|
117
|
-
assertPbkdf2IterationCount(
|
|
118
|
-
let
|
|
119
|
-
|
|
120
|
-
e
|
|
121
|
-
|
|
122
|
-
...
|
|
116
|
+
function encodePbes2AlgorithmIdentifier(e) {
|
|
117
|
+
assertPbkdf2IterationCount(e.iterations);
|
|
118
|
+
let t = resolveEncryptionProfile(e.cipher), n = resolvePrfProfile(e.prf), s = [
|
|
119
|
+
o(e.salt),
|
|
120
|
+
r(e.iterations),
|
|
121
|
+
r(t.keyLengthBytes),
|
|
122
|
+
...e.prf === "HMAC-SHA-1" ? [] : [c([a(n.oid), i()])]
|
|
123
123
|
];
|
|
124
|
-
return
|
|
124
|
+
return c([a(l.pbes2), c([c([a(l.pbkdf2), c(s)]), c([a(t.oid), o(e.iv)])])]);
|
|
125
125
|
}
|
|
126
126
|
/**
|
|
127
127
|
* Decodes a DER-encoded PBES2 AlgorithmIdentifier into structured {@linkcode Pbes2Parameters}.
|
|
@@ -129,16 +129,16 @@ function encodePbes2AlgorithmIdentifier(i) {
|
|
|
129
129
|
* @throws if the encoding is malformed, names an unsupported KDF, PRF or cipher, or carries an
|
|
130
130
|
* iteration count outside 1 to 4294967295.
|
|
131
131
|
*/
|
|
132
|
-
function parsePbes2AlgorithmIdentifier(
|
|
133
|
-
let { paramsDer:
|
|
132
|
+
function parsePbes2AlgorithmIdentifier(n) {
|
|
133
|
+
let { paramsDer: r, kdf: i, scheme: a } = parsePbes2OuterFields(n), { pbkdf2Der: o, pbkdf2Params: c } = parsePbes2KdfFields(r, i), l = c[0], u = c[1];
|
|
134
134
|
if (l === void 0 || u === void 0 || l.tag !== 4 || u.tag !== 2) throw Error("Malformed PBKDF2 params");
|
|
135
|
-
let d = c[2], f = d?.tag === 2, p = f ? c[3] : d, m =
|
|
135
|
+
let d = c[2], f = d?.tag === 2, p = f ? c[3] : d, m = r.slice(a.start - a.headerLength, a.end), g = s(m), _ = g[0], v = g[1];
|
|
136
136
|
if (_ === void 0 || v === void 0 || v.tag !== 4) throw Error("Malformed encryption scheme");
|
|
137
|
-
let y = encryptionSchemeFromOid(
|
|
137
|
+
let y = encryptionSchemeFromOid(t(_.value));
|
|
138
138
|
if (y === void 0) throw Error("Unsupported content encryption scheme");
|
|
139
139
|
if (d !== void 0 && !f && d.tag !== 48) throw Error("Malformed PBKDF2 params");
|
|
140
|
-
if (f &&
|
|
141
|
-
let b = parsePbkdf2Prf(
|
|
140
|
+
if (f && e(d.value) !== y.keyLengthBytes) throw Error("Unsupported PBKDF2 key length");
|
|
141
|
+
let b = parsePbkdf2Prf(o, p), x = e(u.value), S = new Uint8Array(l.value), C = new Uint8Array(v.value);
|
|
142
142
|
if (x < 1) throw Error(`Invalid PBES2 iterations: must be >= 1, got ${x}`);
|
|
143
143
|
if (x > 4294967295) throw Error(`Invalid PBES2 iterations: must be <= ${h}, got ${x}`);
|
|
144
144
|
if (C.length !== 16) throw Error(`Invalid PBES2 IV: must be exactly 16 bytes, got ${C.length}`);
|
|
@@ -155,10 +155,10 @@ function assertPbkdf2IterationCount(e) {
|
|
|
155
155
|
}
|
|
156
156
|
/** Extracts the KDF and encryption-scheme fields from a PBES2 AlgorithmIdentifier. */
|
|
157
157
|
function parsePbes2OuterFields(e) {
|
|
158
|
-
let
|
|
159
|
-
if (
|
|
160
|
-
if (
|
|
161
|
-
let a = e.slice(
|
|
158
|
+
let n = s(e), r = n[0], i = n[1];
|
|
159
|
+
if (r === void 0 || i === void 0) throw Error("Malformed PBES2 algorithm identifier");
|
|
160
|
+
if (t(r.value) !== l.pbes2) throw Error("Unsupported encryption algorithm");
|
|
161
|
+
let a = e.slice(i.start - i.headerLength, i.end), o = s(a), c = o[0], u = o[1];
|
|
162
162
|
if (c === void 0 || u === void 0) throw Error("Malformed PBES2 params");
|
|
163
163
|
return {
|
|
164
164
|
paramsDer: a,
|
|
@@ -166,38 +166,38 @@ function parsePbes2OuterFields(e) {
|
|
|
166
166
|
scheme: u
|
|
167
167
|
};
|
|
168
168
|
}
|
|
169
|
-
function parsePbes2KdfFields(e,
|
|
170
|
-
let
|
|
169
|
+
function parsePbes2KdfFields(e, n) {
|
|
170
|
+
let r = e.slice(n.start - n.headerLength, n.end), i = s(r), a = i[0], o = i[1];
|
|
171
171
|
if (a === void 0 || o === void 0) throw Error("Malformed KDF params");
|
|
172
|
-
if (
|
|
173
|
-
let c =
|
|
172
|
+
if (t(a.value) !== l.pbkdf2) throw Error("Unsupported KDF");
|
|
173
|
+
let c = r.slice(o.start - o.headerLength, o.end);
|
|
174
174
|
return {
|
|
175
175
|
pbkdf2Der: c,
|
|
176
|
-
pbkdf2Params:
|
|
176
|
+
pbkdf2Params: s(c)
|
|
177
177
|
};
|
|
178
178
|
}
|
|
179
179
|
/** Derives an AES-CBC `CryptoKey` from a password via PBKDF2. */
|
|
180
|
-
async function deriveAesKey(e, t,
|
|
181
|
-
let
|
|
180
|
+
async function deriveAesKey(e, t, r, i, a, o) {
|
|
181
|
+
let s = resolveEncryptionProfile(i), c = resolvePrfProfile(a), l = await u().subtle.importKey("raw", new TextEncoder().encode(e), "PBKDF2", !1, ["deriveKey"]);
|
|
182
182
|
return u().subtle.deriveKey({
|
|
183
183
|
name: "PBKDF2",
|
|
184
|
-
salt:
|
|
185
|
-
iterations:
|
|
186
|
-
hash:
|
|
184
|
+
salt: n(t),
|
|
185
|
+
iterations: r,
|
|
186
|
+
hash: c.hash
|
|
187
187
|
}, l, {
|
|
188
188
|
name: "AES-CBC",
|
|
189
|
-
length:
|
|
190
|
-
}, !1,
|
|
189
|
+
length: s.keyLengthBits
|
|
190
|
+
}, !1, o);
|
|
191
191
|
}
|
|
192
192
|
/** Parses the optional PRF AlgorithmIdentifier from PBKDF2 params. Absent means HMAC-SHA-1. */
|
|
193
|
-
function parsePbkdf2Prf(e,
|
|
194
|
-
if (
|
|
195
|
-
if (
|
|
196
|
-
let
|
|
197
|
-
if (
|
|
198
|
-
let
|
|
199
|
-
if (
|
|
200
|
-
return
|
|
193
|
+
function parsePbkdf2Prf(e, n) {
|
|
194
|
+
if (n === void 0) return "HMAC-SHA-1";
|
|
195
|
+
if (n.tag !== 48) throw Error("Malformed PBKDF2 PRF");
|
|
196
|
+
let r = s(e.slice(n.start - n.headerLength, n.end))[0];
|
|
197
|
+
if (r === void 0) throw Error("Malformed PBKDF2 PRF");
|
|
198
|
+
let i = prfFromOid(t(r.value));
|
|
199
|
+
if (i === void 0) throw Error("Unsupported PBKDF2 PRF");
|
|
200
|
+
return i;
|
|
201
201
|
}
|
|
202
202
|
/** Maps an AES-CBC OID to the encryption profile, or `undefined` if unsupported. */
|
|
203
203
|
function encryptionSchemeFromOid(e) {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { toHex as e } from "../asn1/asn1.js";
|
|
2
|
+
// src/internal/crypto/prime-ec.ts
|
|
3
|
+
/** Prime-field curve parameters and membership checks for public affine coordinates. @module */
|
|
4
|
+
/** Shared parameters, including those used to decompress SSH public points. */
|
|
5
|
+
const t = {
|
|
6
|
+
"P-256": {
|
|
7
|
+
size: 32,
|
|
8
|
+
prime: 2n ** 256n - 2n ** 224n + 2n ** 192n + 2n ** 96n - 1n,
|
|
9
|
+
b: 41058363725152142129326129780047268409114441015993725554835256314039467401291n
|
|
10
|
+
},
|
|
11
|
+
"P-384": {
|
|
12
|
+
size: 48,
|
|
13
|
+
prime: 2n ** 384n - 2n ** 128n - 2n ** 96n + 2n ** 32n - 1n,
|
|
14
|
+
b: 27580193559959705877849011840389048093056905856361568521428707301988689241309860865136260764883745107765439761230575n
|
|
15
|
+
},
|
|
16
|
+
"P-521": {
|
|
17
|
+
size: 66,
|
|
18
|
+
prime: 2n ** 521n - 1n,
|
|
19
|
+
b: 1093849038073734274511112390766805569936207598951683748994586394495953116150735016013708737573759623248592132296706313309438452531591012912142327488478985984n
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Checks fixed-width public coordinates before synchronous key selection. These curves have
|
|
24
|
+
* cofactor one; finite field coordinates satisfying the equation represent a valid public point.
|
|
25
|
+
* Signature operations and key import still run through WebCrypto.
|
|
26
|
+
*/
|
|
27
|
+
function isPrimeEcPoint(n, r, i) {
|
|
28
|
+
let { size: a, prime: o, b: s } = t[n];
|
|
29
|
+
if (r.length !== a || i.length !== a) return !1;
|
|
30
|
+
let c = BigInt(`0x${e(r)}`), l = BigInt(`0x${e(i)}`);
|
|
31
|
+
if (c >= o || l >= o) return !1;
|
|
32
|
+
let u = (((c * c - 3n) * c + s) % o + o) % o;
|
|
33
|
+
return l * l % o === u;
|
|
34
|
+
}
|
|
35
|
+
export { t as PRIME_EC_CURVES, isPrimeEcPoint };
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=prime-ec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prime-ec.js","names":["PRIME_EC_CURVES","curve","x","size","y","xValue","toHex","yValue","prime","rhs","b"],"sources":["../../../src/internal/crypto/prime-ec.ts"],"sourcesContent":["/** Prime-field curve parameters and membership checks for public affine coordinates. @module */\n\nimport { toHex } from '#micro509/internal/asn1/asn1';\n\n/** NIST prime curves used by existing key and SSH workflows. */\ntype PrimeEcCurveName = 'P-256' | 'P-384' | 'P-521';\n\n/** Public parameters of a curve with equation y² = x³ - 3x + b over its prime field. */\ninterface PrimeEcCurve {\n\treadonly size: number;\n\treadonly prime: bigint;\n\treadonly b: bigint;\n}\n\n/** Shared parameters, including those used to decompress SSH public points. */\nexport const PRIME_EC_CURVES: Readonly<Record<PrimeEcCurveName, PrimeEcCurve>> = {\n\t'P-256': {\n\t\tsize: 32,\n\t\tprime: 2n ** 256n - 2n ** 224n + 2n ** 192n + 2n ** 96n - 1n,\n\t\tb: 0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604bn,\n\t},\n\t'P-384': {\n\t\tsize: 48,\n\t\tprime: 2n ** 384n - 2n ** 128n - 2n ** 96n + 2n ** 32n - 1n,\n\t\tb: 0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aefn,\n\t},\n\t'P-521': {\n\t\tsize: 66,\n\t\tprime: 2n ** 521n - 1n,\n\t\tb: 0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00n,\n\t},\n};\n\n/**\n * Checks fixed-width public coordinates before synchronous key selection. These curves have\n * cofactor one; finite field coordinates satisfying the equation represent a valid public point.\n * Signature operations and key import still run through WebCrypto.\n */\nexport function isPrimeEcPoint(curve: PrimeEcCurveName, x: Uint8Array, y: Uint8Array): boolean {\n\tconst { size, prime, b } = PRIME_EC_CURVES[curve];\n\tif (x.length !== size || y.length !== size) return false;\n\tconst xValue = BigInt(`0x${toHex(x)}`);\n\tconst yValue = BigInt(`0x${toHex(y)}`);\n\tif (xValue >= prime || yValue >= prime) return false;\n\tconst rhs = ((((xValue * xValue - 3n) * xValue + b) % prime) + prime) % prime;\n\treturn (yValue * yValue) % prime === rhs;\n}\n"],"mappings":";;;;AAeA,MAAaA,IAAoE;CAChF,SAAS;EACR,MAAM;EACN,OAAO,MAAM,OAAO,MAAM,OAAO,MAAM,OAAO,MAAM,MAAM;EAC1D,GAAG;CACJ;CACA,SAAS;EACR,MAAM;EACN,OAAO,MAAM,OAAO,MAAM,OAAO,MAAM,MAAM,MAAM,MAAM;EACzD,GAAG;CACJ;CACA,SAAS;EACR,MAAM;EACN,OAAO,MAAM,OAAO;EACpB,GAAG;CACJ;AACD;;;;;;AAOA,SAAgB,eAAe,GAAyB,GAAe,GAAwB;CAC9F,IAAM,EAAE,SAAM,UAAO,SAAMA,EAAgBC;CAC3C,IAAIC,EAAE,WAAWC,KAAQC,EAAE,WAAWD,GAAM,OAAO;CACnD,IAAME,IAAS,OAAO,KAAKC,EAAMJ,CAAC,GAAG,GAC/BK,IAAS,OAAO,KAAKD,EAAMF,CAAC,GAAG;CACrC,IAAIC,KAAUG,KAASD,KAAUC,GAAO,OAAO;CAC/C,IAAMC,OAAUJ,IAASA,IAAS,MAAMA,IAASK,KAAKF,IAASA,KAASA;CACxE,OAAQD,IAASA,IAAUC,MAAUC;AACtC"}
|