@thangnm.nip/arouter 0.1.3 → 0.1.4

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.
Files changed (147) hide show
  1. package/.next/standalone/.next/BUILD_ID +1 -1
  2. package/.next/standalone/.next/app-path-routes-manifest.json +9 -9
  3. package/.next/standalone/.next/build-manifest.json +2 -2
  4. package/.next/standalone/.next/server/app/(dashboard)/mitm/page_client-reference-manifest.js +1 -1
  5. package/.next/standalone/.next/server/app/(dashboard)/page_client-reference-manifest.js +1 -1
  6. package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  7. package/.next/standalone/.next/server/app/_global-error.html +2 -2
  8. package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
  9. package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  10. package/.next/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  11. package/.next/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  12. package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  13. package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  14. package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  15. package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  16. package/.next/standalone/.next/server/app/_not-found.html +1 -1
  17. package/.next/standalone/.next/server/app/_not-found.rsc +3 -3
  18. package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
  19. package/.next/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  20. package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +3 -3
  21. package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  22. package/.next/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  23. package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  24. package/.next/standalone/.next/server/app/api/cli-tools/antigravity-mitm/alias/route_client-reference-manifest.js +1 -1
  25. package/.next/standalone/.next/server/app/api/cli-tools/antigravity-mitm/console-logs/route_client-reference-manifest.js +1 -1
  26. package/.next/standalone/.next/server/app/api/cli-tools/antigravity-mitm/route_client-reference-manifest.js +1 -1
  27. package/.next/standalone/.next/server/app/api/cli-tools/antigravity-mitm/settings/route_client-reference-manifest.js +1 -1
  28. package/.next/standalone/.next/server/app/api/cli-tools/claude-settings/route_client-reference-manifest.js +1 -1
  29. package/.next/standalone/.next/server/app/api/cli-tools/codex-settings/route_client-reference-manifest.js +1 -1
  30. package/.next/standalone/.next/server/app/api/cli-tools/copilot-settings/route_client-reference-manifest.js +1 -1
  31. package/.next/standalone/.next/server/app/api/cli-tools/droid-settings/route_client-reference-manifest.js +1 -1
  32. package/.next/standalone/.next/server/app/api/cli-tools/openclaw-settings/route_client-reference-manifest.js +1 -1
  33. package/.next/standalone/.next/server/app/api/cli-tools/opencode-settings/route_client-reference-manifest.js +1 -1
  34. package/.next/standalone/.next/server/app/api/keys/[id]/route_client-reference-manifest.js +1 -1
  35. package/.next/standalone/.next/server/app/api/keys/route_client-reference-manifest.js +1 -1
  36. package/.next/standalone/.next/server/app/api/locale/route_client-reference-manifest.js +1 -1
  37. package/.next/standalone/.next/server/app/api/models/alias/route_client-reference-manifest.js +1 -1
  38. package/.next/standalone/.next/server/app/api/models/route_client-reference-manifest.js +1 -1
  39. package/.next/standalone/.next/server/app/api/providers/route_client-reference-manifest.js +1 -1
  40. package/.next/standalone/.next/server/app/api/settings/route_client-reference-manifest.js +1 -1
  41. package/.next/standalone/.next/server/app/api/version/route_client-reference-manifest.js +1 -1
  42. package/.next/standalone/.next/server/app/index.html +1 -1
  43. package/.next/standalone/.next/server/app/index.rsc +4 -4
  44. package/.next/standalone/.next/server/app/index.segments/!KGRhc2hib2FyZCk/__PAGE__.segment.rsc +1 -1
  45. package/.next/standalone/.next/server/app/index.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  46. package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +4 -4
  47. package/.next/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  48. package/.next/standalone/.next/server/app/index.segments/_index.segment.rsc +3 -3
  49. package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  50. package/.next/standalone/.next/server/app/mitm.html +1 -1
  51. package/.next/standalone/.next/server/app/mitm.rsc +5 -5
  52. package/.next/standalone/.next/server/app/mitm.segments/!KGRhc2hib2FyZCk/mitm/__PAGE__.segment.rsc +2 -2
  53. package/.next/standalone/.next/server/app/mitm.segments/!KGRhc2hib2FyZCk/mitm.segment.rsc +1 -1
  54. package/.next/standalone/.next/server/app/mitm.segments/!KGRhc2hib2FyZCk.segment.rsc +2 -2
  55. package/.next/standalone/.next/server/app/mitm.segments/_full.segment.rsc +5 -5
  56. package/.next/standalone/.next/server/app/mitm.segments/_head.segment.rsc +1 -1
  57. package/.next/standalone/.next/server/app/mitm.segments/_index.segment.rsc +3 -3
  58. package/.next/standalone/.next/server/app/mitm.segments/_tree.segment.rsc +1 -1
  59. package/.next/standalone/.next/server/app-paths-manifest.json +9 -9
  60. package/.next/standalone/.next/server/chunks/411.js +1 -1
  61. package/.next/standalone/.next/server/pages/404.html +1 -1
  62. package/.next/standalone/.next/server/pages/500.html +2 -2
  63. package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
  64. package/.next/standalone/.next/server/server-reference-manifest.json +1 -1
  65. package/.next/standalone/.next/static/chunks/{702-67d57e0cdf85676e.js → 702-0864796c00fc702e.js} +1 -1
  66. package/.next/standalone/node_modules/node-forge/LICENSE +331 -0
  67. package/.next/standalone/node_modules/node-forge/README.md +2071 -0
  68. package/.next/standalone/node_modules/node-forge/dist/forge.all.min.js +2 -0
  69. package/.next/standalone/node_modules/node-forge/dist/forge.all.min.js.map +1 -0
  70. package/.next/standalone/node_modules/node-forge/dist/forge.min.js +2 -0
  71. package/.next/standalone/node_modules/node-forge/dist/forge.min.js.map +1 -0
  72. package/.next/standalone/node_modules/node-forge/dist/prime.worker.min.js +2 -0
  73. package/.next/standalone/node_modules/node-forge/dist/prime.worker.min.js.map +1 -0
  74. package/.next/standalone/node_modules/node-forge/flash/swf/SocketPool.swf +0 -0
  75. package/.next/standalone/node_modules/node-forge/lib/aes.js +1091 -0
  76. package/.next/standalone/node_modules/node-forge/lib/aesCipherSuites.js +282 -0
  77. package/.next/standalone/node_modules/node-forge/lib/asn1-validator.js +91 -0
  78. package/.next/standalone/node_modules/node-forge/lib/asn1.js +1503 -0
  79. package/.next/standalone/node_modules/node-forge/lib/baseN.js +186 -0
  80. package/.next/standalone/node_modules/node-forge/lib/cipher.js +230 -0
  81. package/.next/standalone/node_modules/node-forge/lib/cipherModes.js +999 -0
  82. package/.next/standalone/node_modules/node-forge/lib/des.js +496 -0
  83. package/.next/standalone/node_modules/node-forge/lib/ed25519.js +1072 -0
  84. package/.next/standalone/node_modules/node-forge/lib/forge.js +13 -0
  85. package/.next/standalone/node_modules/node-forge/lib/form.js +149 -0
  86. package/.next/standalone/node_modules/node-forge/lib/hmac.js +146 -0
  87. package/.next/standalone/node_modules/node-forge/lib/http.js +1346 -0
  88. package/.next/standalone/node_modules/node-forge/lib/index.all.js +16 -0
  89. package/.next/standalone/node_modules/node-forge/lib/index.js +33 -0
  90. package/.next/standalone/node_modules/node-forge/lib/jsbn.js +1264 -0
  91. package/.next/standalone/node_modules/node-forge/lib/kem.js +168 -0
  92. package/.next/standalone/node_modules/node-forge/lib/log.js +319 -0
  93. package/.next/standalone/node_modules/node-forge/lib/md.all.js +13 -0
  94. package/.next/standalone/node_modules/node-forge/lib/md.js +11 -0
  95. package/.next/standalone/node_modules/node-forge/lib/md5.js +289 -0
  96. package/.next/standalone/node_modules/node-forge/lib/mgf.js +12 -0
  97. package/.next/standalone/node_modules/node-forge/lib/mgf1.js +57 -0
  98. package/.next/standalone/node_modules/node-forge/lib/oids.js +179 -0
  99. package/.next/standalone/node_modules/node-forge/lib/pbe.js +1023 -0
  100. package/.next/standalone/node_modules/node-forge/lib/pbkdf2.js +211 -0
  101. package/.next/standalone/node_modules/node-forge/lib/pem.js +237 -0
  102. package/.next/standalone/node_modules/node-forge/lib/pkcs1.js +276 -0
  103. package/.next/standalone/node_modules/node-forge/lib/pkcs12.js +1078 -0
  104. package/.next/standalone/node_modules/node-forge/lib/pkcs7.js +1260 -0
  105. package/.next/standalone/node_modules/node-forge/lib/pkcs7asn1.js +410 -0
  106. package/.next/standalone/node_modules/node-forge/lib/pki.js +102 -0
  107. package/.next/standalone/node_modules/node-forge/lib/prime.js +297 -0
  108. package/.next/standalone/node_modules/node-forge/lib/prime.worker.js +168 -0
  109. package/.next/standalone/node_modules/node-forge/lib/prng.js +419 -0
  110. package/.next/standalone/node_modules/node-forge/lib/pss.js +241 -0
  111. package/.next/standalone/node_modules/node-forge/lib/random.js +191 -0
  112. package/.next/standalone/node_modules/node-forge/lib/rc2.js +410 -0
  113. package/.next/standalone/node_modules/node-forge/lib/rsa.js +1949 -0
  114. package/.next/standalone/node_modules/node-forge/lib/sha1.js +319 -0
  115. package/.next/standalone/node_modules/node-forge/lib/sha256.js +327 -0
  116. package/.next/standalone/node_modules/node-forge/lib/sha512.js +561 -0
  117. package/.next/standalone/node_modules/node-forge/lib/socket.js +287 -0
  118. package/.next/standalone/node_modules/node-forge/lib/ssh.js +236 -0
  119. package/.next/standalone/node_modules/node-forge/lib/tls.js +4282 -0
  120. package/.next/standalone/node_modules/node-forge/lib/tlssocket.js +249 -0
  121. package/.next/standalone/node_modules/node-forge/lib/util.js +2652 -0
  122. package/.next/standalone/node_modules/node-forge/lib/x509.js +3242 -0
  123. package/.next/standalone/node_modules/node-forge/lib/xhr.js +738 -0
  124. package/.next/standalone/node_modules/node-forge/package.json +123 -0
  125. package/.next/standalone/node_modules/node-machine-id/.babelrc +26 -0
  126. package/.next/standalone/node_modules/node-machine-id/.eslintignore +2 -0
  127. package/.next/standalone/node_modules/node-machine-id/.eslintrc +140 -0
  128. package/.next/standalone/node_modules/node-machine-id/.flowconfig +9 -0
  129. package/.next/standalone/node_modules/node-machine-id/LICENSE +21 -0
  130. package/.next/standalone/node_modules/node-machine-id/README.md +84 -0
  131. package/.next/standalone/node_modules/node-machine-id/dist/index.js +1 -0
  132. package/.next/standalone/node_modules/node-machine-id/index.js +80 -0
  133. package/.next/standalone/node_modules/node-machine-id/package.json +74 -0
  134. package/.next/standalone/node_modules/node-machine-id/tests/index.js +45 -0
  135. package/.next/standalone/node_modules/node-machine-id/types/index.d.ts +17 -0
  136. package/.next/standalone/node_modules/node-machine-id/webpack.config.babel.js +59 -0
  137. package/.next/standalone/package.json +1 -1
  138. package/.next/standalone/src/mitm/cert/generate.js +32 -0
  139. package/.next/standalone/src/mitm/cert/install.js +176 -0
  140. package/.next/standalone/src/mitm/cert/rootCA.js +173 -0
  141. package/.next/standalone/src/mitm/dns/dnsConfig.js +216 -0
  142. package/.next/standalone/src/mitm/logger.js +8 -0
  143. package/.next/standalone/src/mitm/manager.js +603 -0
  144. package/.next/standalone/src/mitm/paths.js +16 -0
  145. package/package.json +1 -1
  146. /package/.next/standalone/.next/static/{oQBK39Yf5Nkr7-_ESoUO2 → DkVxg6bby4SUixuq1vdO8}/_buildManifest.js +0 -0
  147. /package/.next/standalone/.next/static/{oQBK39Yf5Nkr7-_ESoUO2 → DkVxg6bby4SUixuq1vdO8}/_ssgManifest.js +0 -0
@@ -0,0 +1,410 @@
1
+ /**
2
+ * Javascript implementation of ASN.1 validators for PKCS#7 v1.5.
3
+ *
4
+ * @author Dave Longley
5
+ * @author Stefan Siegl
6
+ *
7
+ * Copyright (c) 2012-2015 Digital Bazaar, Inc.
8
+ * Copyright (c) 2012 Stefan Siegl <stesie@brokenpipe.de>
9
+ *
10
+ * The ASN.1 representation of PKCS#7 is as follows
11
+ * (see RFC #2315 for details, http://www.ietf.org/rfc/rfc2315.txt):
12
+ *
13
+ * A PKCS#7 message consists of a ContentInfo on root level, which may
14
+ * contain any number of further ContentInfo nested into it.
15
+ *
16
+ * ContentInfo ::= SEQUENCE {
17
+ * contentType ContentType,
18
+ * content [0] EXPLICIT ANY DEFINED BY contentType OPTIONAL
19
+ * }
20
+ *
21
+ * ContentType ::= OBJECT IDENTIFIER
22
+ *
23
+ * EnvelopedData ::= SEQUENCE {
24
+ * version Version,
25
+ * recipientInfos RecipientInfos,
26
+ * encryptedContentInfo EncryptedContentInfo
27
+ * }
28
+ *
29
+ * EncryptedData ::= SEQUENCE {
30
+ * version Version,
31
+ * encryptedContentInfo EncryptedContentInfo
32
+ * }
33
+ *
34
+ * id-signedData OBJECT IDENTIFIER ::= { iso(1) member-body(2)
35
+ * us(840) rsadsi(113549) pkcs(1) pkcs7(7) 2 }
36
+ *
37
+ * SignedData ::= SEQUENCE {
38
+ * version INTEGER,
39
+ * digestAlgorithms DigestAlgorithmIdentifiers,
40
+ * contentInfo ContentInfo,
41
+ * certificates [0] IMPLICIT Certificates OPTIONAL,
42
+ * crls [1] IMPLICIT CertificateRevocationLists OPTIONAL,
43
+ * signerInfos SignerInfos
44
+ * }
45
+ *
46
+ * SignerInfos ::= SET OF SignerInfo
47
+ *
48
+ * SignerInfo ::= SEQUENCE {
49
+ * version Version,
50
+ * issuerAndSerialNumber IssuerAndSerialNumber,
51
+ * digestAlgorithm DigestAlgorithmIdentifier,
52
+ * authenticatedAttributes [0] IMPLICIT Attributes OPTIONAL,
53
+ * digestEncryptionAlgorithm DigestEncryptionAlgorithmIdentifier,
54
+ * encryptedDigest EncryptedDigest,
55
+ * unauthenticatedAttributes [1] IMPLICIT Attributes OPTIONAL
56
+ * }
57
+ *
58
+ * EncryptedDigest ::= OCTET STRING
59
+ *
60
+ * Attributes ::= SET OF Attribute
61
+ *
62
+ * Attribute ::= SEQUENCE {
63
+ * attrType OBJECT IDENTIFIER,
64
+ * attrValues SET OF AttributeValue
65
+ * }
66
+ *
67
+ * AttributeValue ::= ANY
68
+ *
69
+ * Version ::= INTEGER
70
+ *
71
+ * RecipientInfos ::= SET OF RecipientInfo
72
+ *
73
+ * EncryptedContentInfo ::= SEQUENCE {
74
+ * contentType ContentType,
75
+ * contentEncryptionAlgorithm ContentEncryptionAlgorithmIdentifier,
76
+ * encryptedContent [0] IMPLICIT EncryptedContent OPTIONAL
77
+ * }
78
+ *
79
+ * ContentEncryptionAlgorithmIdentifier ::= AlgorithmIdentifier
80
+ *
81
+ * The AlgorithmIdentifier contains an Object Identifier (OID) and parameters
82
+ * for the algorithm, if any. In the case of AES and DES3, there is only one,
83
+ * the IV.
84
+ *
85
+ * AlgorithmIdentifer ::= SEQUENCE {
86
+ * algorithm OBJECT IDENTIFIER,
87
+ * parameters ANY DEFINED BY algorithm OPTIONAL
88
+ * }
89
+ *
90
+ * EncryptedContent ::= OCTET STRING
91
+ *
92
+ * RecipientInfo ::= SEQUENCE {
93
+ * version Version,
94
+ * issuerAndSerialNumber IssuerAndSerialNumber,
95
+ * keyEncryptionAlgorithm KeyEncryptionAlgorithmIdentifier,
96
+ * encryptedKey EncryptedKey
97
+ * }
98
+ *
99
+ * IssuerAndSerialNumber ::= SEQUENCE {
100
+ * issuer Name,
101
+ * serialNumber CertificateSerialNumber
102
+ * }
103
+ *
104
+ * CertificateSerialNumber ::= INTEGER
105
+ *
106
+ * KeyEncryptionAlgorithmIdentifier ::= AlgorithmIdentifier
107
+ *
108
+ * EncryptedKey ::= OCTET STRING
109
+ */
110
+ var forge = require('./forge');
111
+ require('./asn1');
112
+ require('./util');
113
+
114
+ // shortcut for ASN.1 API
115
+ var asn1 = forge.asn1;
116
+
117
+ // shortcut for PKCS#7 API
118
+ var p7v = module.exports = forge.pkcs7asn1 = forge.pkcs7asn1 || {};
119
+ forge.pkcs7 = forge.pkcs7 || {};
120
+ forge.pkcs7.asn1 = p7v;
121
+
122
+ var contentInfoValidator = {
123
+ name: 'ContentInfo',
124
+ tagClass: asn1.Class.UNIVERSAL,
125
+ type: asn1.Type.SEQUENCE,
126
+ constructed: true,
127
+ value: [{
128
+ name: 'ContentInfo.ContentType',
129
+ tagClass: asn1.Class.UNIVERSAL,
130
+ type: asn1.Type.OID,
131
+ constructed: false,
132
+ capture: 'contentType'
133
+ }, {
134
+ name: 'ContentInfo.content',
135
+ tagClass: asn1.Class.CONTEXT_SPECIFIC,
136
+ type: 0,
137
+ constructed: true,
138
+ optional: true,
139
+ captureAsn1: 'content'
140
+ }]
141
+ };
142
+ p7v.contentInfoValidator = contentInfoValidator;
143
+
144
+ var encryptedContentInfoValidator = {
145
+ name: 'EncryptedContentInfo',
146
+ tagClass: asn1.Class.UNIVERSAL,
147
+ type: asn1.Type.SEQUENCE,
148
+ constructed: true,
149
+ value: [{
150
+ name: 'EncryptedContentInfo.contentType',
151
+ tagClass: asn1.Class.UNIVERSAL,
152
+ type: asn1.Type.OID,
153
+ constructed: false,
154
+ capture: 'contentType'
155
+ }, {
156
+ name: 'EncryptedContentInfo.contentEncryptionAlgorithm',
157
+ tagClass: asn1.Class.UNIVERSAL,
158
+ type: asn1.Type.SEQUENCE,
159
+ constructed: true,
160
+ value: [{
161
+ name: 'EncryptedContentInfo.contentEncryptionAlgorithm.algorithm',
162
+ tagClass: asn1.Class.UNIVERSAL,
163
+ type: asn1.Type.OID,
164
+ constructed: false,
165
+ capture: 'encAlgorithm'
166
+ }, {
167
+ name: 'EncryptedContentInfo.contentEncryptionAlgorithm.parameter',
168
+ tagClass: asn1.Class.UNIVERSAL,
169
+ captureAsn1: 'encParameter'
170
+ }]
171
+ }, {
172
+ name: 'EncryptedContentInfo.encryptedContent',
173
+ tagClass: asn1.Class.CONTEXT_SPECIFIC,
174
+ type: 0,
175
+ /* The PKCS#7 structure output by OpenSSL somewhat differs from what
176
+ * other implementations do generate.
177
+ *
178
+ * OpenSSL generates a structure like this:
179
+ * SEQUENCE {
180
+ * ...
181
+ * [0]
182
+ * 26 DA 67 D2 17 9C 45 3C B1 2A A8 59 2F 29 33 38
183
+ * C3 C3 DF 86 71 74 7A 19 9F 40 D0 29 BE 85 90 45
184
+ * ...
185
+ * }
186
+ *
187
+ * Whereas other implementations (and this PKCS#7 module) generate:
188
+ * SEQUENCE {
189
+ * ...
190
+ * [0] {
191
+ * OCTET STRING
192
+ * 26 DA 67 D2 17 9C 45 3C B1 2A A8 59 2F 29 33 38
193
+ * C3 C3 DF 86 71 74 7A 19 9F 40 D0 29 BE 85 90 45
194
+ * ...
195
+ * }
196
+ * }
197
+ *
198
+ * In order to support both, we just capture the context specific
199
+ * field here. The OCTET STRING bit is removed below.
200
+ */
201
+ capture: 'encryptedContent',
202
+ captureAsn1: 'encryptedContentAsn1'
203
+ }]
204
+ };
205
+
206
+ p7v.envelopedDataValidator = {
207
+ name: 'EnvelopedData',
208
+ tagClass: asn1.Class.UNIVERSAL,
209
+ type: asn1.Type.SEQUENCE,
210
+ constructed: true,
211
+ value: [{
212
+ name: 'EnvelopedData.Version',
213
+ tagClass: asn1.Class.UNIVERSAL,
214
+ type: asn1.Type.INTEGER,
215
+ constructed: false,
216
+ capture: 'version'
217
+ }, {
218
+ name: 'EnvelopedData.RecipientInfos',
219
+ tagClass: asn1.Class.UNIVERSAL,
220
+ type: asn1.Type.SET,
221
+ constructed: true,
222
+ captureAsn1: 'recipientInfos'
223
+ }].concat(encryptedContentInfoValidator)
224
+ };
225
+
226
+ p7v.encryptedDataValidator = {
227
+ name: 'EncryptedData',
228
+ tagClass: asn1.Class.UNIVERSAL,
229
+ type: asn1.Type.SEQUENCE,
230
+ constructed: true,
231
+ value: [{
232
+ name: 'EncryptedData.Version',
233
+ tagClass: asn1.Class.UNIVERSAL,
234
+ type: asn1.Type.INTEGER,
235
+ constructed: false,
236
+ capture: 'version'
237
+ }].concat(encryptedContentInfoValidator)
238
+ };
239
+
240
+ var signerValidator = {
241
+ name: 'SignerInfo',
242
+ tagClass: asn1.Class.UNIVERSAL,
243
+ type: asn1.Type.SEQUENCE,
244
+ constructed: true,
245
+ value: [{
246
+ name: 'SignerInfo.version',
247
+ tagClass: asn1.Class.UNIVERSAL,
248
+ type: asn1.Type.INTEGER,
249
+ constructed: false
250
+ }, {
251
+ name: 'SignerInfo.issuerAndSerialNumber',
252
+ tagClass: asn1.Class.UNIVERSAL,
253
+ type: asn1.Type.SEQUENCE,
254
+ constructed: true,
255
+ value: [{
256
+ name: 'SignerInfo.issuerAndSerialNumber.issuer',
257
+ tagClass: asn1.Class.UNIVERSAL,
258
+ type: asn1.Type.SEQUENCE,
259
+ constructed: true,
260
+ captureAsn1: 'issuer'
261
+ }, {
262
+ name: 'SignerInfo.issuerAndSerialNumber.serialNumber',
263
+ tagClass: asn1.Class.UNIVERSAL,
264
+ type: asn1.Type.INTEGER,
265
+ constructed: false,
266
+ capture: 'serial'
267
+ }]
268
+ }, {
269
+ name: 'SignerInfo.digestAlgorithm',
270
+ tagClass: asn1.Class.UNIVERSAL,
271
+ type: asn1.Type.SEQUENCE,
272
+ constructed: true,
273
+ value: [{
274
+ name: 'SignerInfo.digestAlgorithm.algorithm',
275
+ tagClass: asn1.Class.UNIVERSAL,
276
+ type: asn1.Type.OID,
277
+ constructed: false,
278
+ capture: 'digestAlgorithm'
279
+ }, {
280
+ name: 'SignerInfo.digestAlgorithm.parameter',
281
+ tagClass: asn1.Class.UNIVERSAL,
282
+ constructed: false,
283
+ captureAsn1: 'digestParameter',
284
+ optional: true
285
+ }]
286
+ }, {
287
+ name: 'SignerInfo.authenticatedAttributes',
288
+ tagClass: asn1.Class.CONTEXT_SPECIFIC,
289
+ type: 0,
290
+ constructed: true,
291
+ optional: true,
292
+ capture: 'authenticatedAttributes'
293
+ }, {
294
+ name: 'SignerInfo.digestEncryptionAlgorithm',
295
+ tagClass: asn1.Class.UNIVERSAL,
296
+ type: asn1.Type.SEQUENCE,
297
+ constructed: true,
298
+ capture: 'signatureAlgorithm'
299
+ }, {
300
+ name: 'SignerInfo.encryptedDigest',
301
+ tagClass: asn1.Class.UNIVERSAL,
302
+ type: asn1.Type.OCTETSTRING,
303
+ constructed: false,
304
+ capture: 'signature'
305
+ }, {
306
+ name: 'SignerInfo.unauthenticatedAttributes',
307
+ tagClass: asn1.Class.CONTEXT_SPECIFIC,
308
+ type: 1,
309
+ constructed: true,
310
+ optional: true,
311
+ capture: 'unauthenticatedAttributes'
312
+ }]
313
+ };
314
+
315
+ p7v.signedDataValidator = {
316
+ name: 'SignedData',
317
+ tagClass: asn1.Class.UNIVERSAL,
318
+ type: asn1.Type.SEQUENCE,
319
+ constructed: true,
320
+ value: [{
321
+ name: 'SignedData.Version',
322
+ tagClass: asn1.Class.UNIVERSAL,
323
+ type: asn1.Type.INTEGER,
324
+ constructed: false,
325
+ capture: 'version'
326
+ }, {
327
+ name: 'SignedData.DigestAlgorithms',
328
+ tagClass: asn1.Class.UNIVERSAL,
329
+ type: asn1.Type.SET,
330
+ constructed: true,
331
+ captureAsn1: 'digestAlgorithms'
332
+ },
333
+ contentInfoValidator,
334
+ {
335
+ name: 'SignedData.Certificates',
336
+ tagClass: asn1.Class.CONTEXT_SPECIFIC,
337
+ type: 0,
338
+ optional: true,
339
+ captureAsn1: 'certificates'
340
+ }, {
341
+ name: 'SignedData.CertificateRevocationLists',
342
+ tagClass: asn1.Class.CONTEXT_SPECIFIC,
343
+ type: 1,
344
+ optional: true,
345
+ captureAsn1: 'crls'
346
+ }, {
347
+ name: 'SignedData.SignerInfos',
348
+ tagClass: asn1.Class.UNIVERSAL,
349
+ type: asn1.Type.SET,
350
+ capture: 'signerInfos',
351
+ optional: true,
352
+ value: [signerValidator]
353
+ }]
354
+ };
355
+
356
+ p7v.recipientInfoValidator = {
357
+ name: 'RecipientInfo',
358
+ tagClass: asn1.Class.UNIVERSAL,
359
+ type: asn1.Type.SEQUENCE,
360
+ constructed: true,
361
+ value: [{
362
+ name: 'RecipientInfo.version',
363
+ tagClass: asn1.Class.UNIVERSAL,
364
+ type: asn1.Type.INTEGER,
365
+ constructed: false,
366
+ capture: 'version'
367
+ }, {
368
+ name: 'RecipientInfo.issuerAndSerial',
369
+ tagClass: asn1.Class.UNIVERSAL,
370
+ type: asn1.Type.SEQUENCE,
371
+ constructed: true,
372
+ value: [{
373
+ name: 'RecipientInfo.issuerAndSerial.issuer',
374
+ tagClass: asn1.Class.UNIVERSAL,
375
+ type: asn1.Type.SEQUENCE,
376
+ constructed: true,
377
+ captureAsn1: 'issuer'
378
+ }, {
379
+ name: 'RecipientInfo.issuerAndSerial.serialNumber',
380
+ tagClass: asn1.Class.UNIVERSAL,
381
+ type: asn1.Type.INTEGER,
382
+ constructed: false,
383
+ capture: 'serial'
384
+ }]
385
+ }, {
386
+ name: 'RecipientInfo.keyEncryptionAlgorithm',
387
+ tagClass: asn1.Class.UNIVERSAL,
388
+ type: asn1.Type.SEQUENCE,
389
+ constructed: true,
390
+ value: [{
391
+ name: 'RecipientInfo.keyEncryptionAlgorithm.algorithm',
392
+ tagClass: asn1.Class.UNIVERSAL,
393
+ type: asn1.Type.OID,
394
+ constructed: false,
395
+ capture: 'encAlgorithm'
396
+ }, {
397
+ name: 'RecipientInfo.keyEncryptionAlgorithm.parameter',
398
+ tagClass: asn1.Class.UNIVERSAL,
399
+ constructed: false,
400
+ captureAsn1: 'encParameter',
401
+ optional: true
402
+ }]
403
+ }, {
404
+ name: 'RecipientInfo.encryptedKey',
405
+ tagClass: asn1.Class.UNIVERSAL,
406
+ type: asn1.Type.OCTETSTRING,
407
+ constructed: false,
408
+ capture: 'encKey'
409
+ }]
410
+ };
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Javascript implementation of a basic Public Key Infrastructure, including
3
+ * support for RSA public and private keys.
4
+ *
5
+ * @author Dave Longley
6
+ *
7
+ * Copyright (c) 2010-2013 Digital Bazaar, Inc.
8
+ */
9
+ var forge = require('./forge');
10
+ require('./asn1');
11
+ require('./oids');
12
+ require('./pbe');
13
+ require('./pem');
14
+ require('./pbkdf2');
15
+ require('./pkcs12');
16
+ require('./pss');
17
+ require('./rsa');
18
+ require('./util');
19
+ require('./x509');
20
+
21
+ // shortcut for asn.1 API
22
+ var asn1 = forge.asn1;
23
+
24
+ /* Public Key Infrastructure (PKI) implementation. */
25
+ var pki = module.exports = forge.pki = forge.pki || {};
26
+
27
+ /**
28
+ * NOTE: THIS METHOD IS DEPRECATED. Use pem.decode() instead.
29
+ *
30
+ * Converts PEM-formatted data to DER.
31
+ *
32
+ * @param pem the PEM-formatted data.
33
+ *
34
+ * @return the DER-formatted data.
35
+ */
36
+ pki.pemToDer = function(pem) {
37
+ var msg = forge.pem.decode(pem)[0];
38
+ if(msg.procType && msg.procType.type === 'ENCRYPTED') {
39
+ throw new Error('Could not convert PEM to DER; PEM is encrypted.');
40
+ }
41
+ return forge.util.createBuffer(msg.body);
42
+ };
43
+
44
+ /**
45
+ * Converts an RSA private key from PEM format.
46
+ *
47
+ * @param pem the PEM-formatted private key.
48
+ *
49
+ * @return the private key.
50
+ */
51
+ pki.privateKeyFromPem = function(pem) {
52
+ var msg = forge.pem.decode(pem)[0];
53
+
54
+ if(msg.type !== 'PRIVATE KEY' && msg.type !== 'RSA PRIVATE KEY') {
55
+ var error = new Error('Could not convert private key from PEM; PEM ' +
56
+ 'header type is not "PRIVATE KEY" or "RSA PRIVATE KEY".');
57
+ error.headerType = msg.type;
58
+ throw error;
59
+ }
60
+ if(msg.procType && msg.procType.type === 'ENCRYPTED') {
61
+ throw new Error('Could not convert private key from PEM; PEM is encrypted.');
62
+ }
63
+
64
+ // convert DER to ASN.1 object
65
+ var obj = asn1.fromDer(msg.body);
66
+
67
+ return pki.privateKeyFromAsn1(obj);
68
+ };
69
+
70
+ /**
71
+ * Converts an RSA private key to PEM format.
72
+ *
73
+ * @param key the private key.
74
+ * @param maxline the maximum characters per line, defaults to 64.
75
+ *
76
+ * @return the PEM-formatted private key.
77
+ */
78
+ pki.privateKeyToPem = function(key, maxline) {
79
+ // convert to ASN.1, then DER, then PEM-encode
80
+ var msg = {
81
+ type: 'RSA PRIVATE KEY',
82
+ body: asn1.toDer(pki.privateKeyToAsn1(key)).getBytes()
83
+ };
84
+ return forge.pem.encode(msg, {maxline: maxline});
85
+ };
86
+
87
+ /**
88
+ * Converts a PrivateKeyInfo to PEM format.
89
+ *
90
+ * @param pki the PrivateKeyInfo.
91
+ * @param maxline the maximum characters per line, defaults to 64.
92
+ *
93
+ * @return the PEM-formatted private key.
94
+ */
95
+ pki.privateKeyInfoToPem = function(pki, maxline) {
96
+ // convert to DER, then PEM-encode
97
+ var msg = {
98
+ type: 'PRIVATE KEY',
99
+ body: asn1.toDer(pki).getBytes()
100
+ };
101
+ return forge.pem.encode(msg, {maxline: maxline});
102
+ };