bantou 0.1.1 → 0.2.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.
Files changed (515) hide show
  1. package/.output/nitro.json +13 -0
  2. package/.output/public/_nuxt/BmGsA4i2.js +1 -0
  3. package/.output/public/_nuxt/D_G6gzEa.js +1 -0
  4. package/.output/public/_nuxt/builds/latest.json +1 -0
  5. package/.output/public/_nuxt/builds/meta/1a8fc623-6671-445b-bdd3-c3d073520a3a.json +1 -0
  6. package/.output/public/_nuxt/entry.CZSvzYhH.css +1 -0
  7. package/.output/public/_nuxt/error-404.C3wqHTJz.css +1 -0
  8. package/.output/public/_nuxt/error-500.D6rBzoDj.css +1 -0
  9. package/.output/public/_nuxt/pdFQkwM_.js +4 -0
  10. package/.output/server/chunks/_/error-500.mjs +20 -0
  11. package/.output/server/chunks/_/error-500.mjs.map +1 -0
  12. package/.output/server/chunks/nitro/nitro.mjs +5870 -0
  13. package/.output/server/chunks/nitro/nitro.mjs.map +1 -0
  14. package/.output/server/chunks/routes/mcp.mjs +22 -0
  15. package/.output/server/chunks/routes/mcp.mjs.map +1 -0
  16. package/.output/server/chunks/routes/renderer.mjs +462 -0
  17. package/.output/server/chunks/routes/renderer.mjs.map +1 -0
  18. package/.output/server/chunks/virtual/_virtual_spa-template.mjs +4 -0
  19. package/.output/server/chunks/virtual/_virtual_spa-template.mjs.map +1 -0
  20. package/.output/server/chunks/virtual/precomputed.mjs +4 -0
  21. package/.output/server/chunks/virtual/precomputed.mjs.map +1 -0
  22. package/.output/server/index.mjs +18 -0
  23. package/.output/server/index.mjs.map +1 -0
  24. package/.output/server/node_modules/@babel/parser/lib/index.js +14657 -0
  25. package/.output/server/node_modules/@babel/parser/package.json +50 -0
  26. package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js +64 -0
  27. package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js +16 -0
  28. package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/mcp-server.js +32 -0
  29. package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js +246 -0
  30. package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/package.json +1 -0
  31. package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js +41 -0
  32. package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js +429 -0
  33. package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js +971 -0
  34. package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/requestBody.js +58 -0
  35. package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sseKeepAlive.js +13 -0
  36. package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.js +961 -0
  37. package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js +228 -0
  38. package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js +51 -0
  39. package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.js +57 -0
  40. package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js +1137 -0
  41. package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js +92 -0
  42. package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/uriTemplate.js +239 -0
  43. package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js +2065 -0
  44. package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js +87 -0
  45. package/.output/server/node_modules/@modelcontextprotocol/sdk/package.json +165 -0
  46. package/.output/server/node_modules/@parcel/watcher-wasm/index.mjs +349 -0
  47. package/.output/server/node_modules/@parcel/watcher-wasm/package.json +44 -0
  48. package/.output/server/node_modules/@parcel/watcher-wasm/watcher.wasm +0 -0
  49. package/.output/server/node_modules/@parcel/watcher-wasm/wrapper.js +88 -0
  50. package/.output/server/node_modules/@unagents/messenger-broker/dist/index.mjs +12 -0
  51. package/.output/server/node_modules/@unagents/messenger-broker/dist/shared/messenger-broker.B8W77sqB.mjs +1177 -0
  52. package/.output/server/node_modules/@unagents/messenger-broker/package.json +37 -0
  53. package/.output/server/node_modules/@unagents/messenger-client/dist/index.mjs +9 -0
  54. package/.output/server/node_modules/@unagents/messenger-client/dist/shared/messenger-client.CfQVmH_Z.mjs +975 -0
  55. package/.output/server/node_modules/@unagents/messenger-client/dist/shared/messenger-client.CoDKzubj.mjs +1000 -0
  56. package/.output/server/node_modules/@unagents/messenger-client/package.json +37 -0
  57. package/.output/server/node_modules/@unagents/messenger-protocol/dist/index.mjs +103 -0
  58. package/.output/server/node_modules/@unagents/messenger-protocol/package.json +29 -0
  59. package/.output/server/node_modules/@vue/compiler-core/dist/compiler-core.cjs.prod.js +6802 -0
  60. package/.output/server/node_modules/@vue/compiler-core/package.json +58 -0
  61. package/.output/server/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.prod.js +729 -0
  62. package/.output/server/node_modules/@vue/compiler-dom/package.json +57 -0
  63. package/.output/server/node_modules/@vue/compiler-ssr/dist/compiler-ssr.cjs.js +1420 -0
  64. package/.output/server/node_modules/@vue/compiler-ssr/package.json +34 -0
  65. package/.output/server/node_modules/@vue/reactivity/dist/reactivity.cjs.prod.js +1933 -0
  66. package/.output/server/node_modules/@vue/reactivity/package.json +55 -0
  67. package/.output/server/node_modules/@vue/runtime-core/dist/runtime-core.cjs.prod.js +7085 -0
  68. package/.output/server/node_modules/@vue/runtime-core/package.json +52 -0
  69. package/.output/server/node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.prod.js +1917 -0
  70. package/.output/server/node_modules/@vue/runtime-dom/package.json +60 -0
  71. package/.output/server/node_modules/@vue/server-renderer/dist/server-renderer.cjs.prod.js +951 -0
  72. package/.output/server/node_modules/@vue/server-renderer/package.json +53 -0
  73. package/.output/server/node_modules/@vue/shared/dist/shared.cjs.prod.js +655 -0
  74. package/.output/server/node_modules/@vue/shared/package.json +47 -0
  75. package/.output/server/node_modules/ajv/dist/ajv.js +50 -0
  76. package/.output/server/node_modules/ajv/dist/compile/codegen/code.js +156 -0
  77. package/.output/server/node_modules/ajv/dist/compile/codegen/index.js +697 -0
  78. package/.output/server/node_modules/ajv/dist/compile/codegen/scope.js +143 -0
  79. package/.output/server/node_modules/ajv/dist/compile/errors.js +123 -0
  80. package/.output/server/node_modules/ajv/dist/compile/index.js +242 -0
  81. package/.output/server/node_modules/ajv/dist/compile/names.js +28 -0
  82. package/.output/server/node_modules/ajv/dist/compile/ref_error.js +12 -0
  83. package/.output/server/node_modules/ajv/dist/compile/resolve.js +155 -0
  84. package/.output/server/node_modules/ajv/dist/compile/rules.js +26 -0
  85. package/.output/server/node_modules/ajv/dist/compile/util.js +178 -0
  86. package/.output/server/node_modules/ajv/dist/compile/validate/applicability.js +19 -0
  87. package/.output/server/node_modules/ajv/dist/compile/validate/boolSchema.js +50 -0
  88. package/.output/server/node_modules/ajv/dist/compile/validate/dataType.js +203 -0
  89. package/.output/server/node_modules/ajv/dist/compile/validate/defaults.js +35 -0
  90. package/.output/server/node_modules/ajv/dist/compile/validate/index.js +520 -0
  91. package/.output/server/node_modules/ajv/dist/compile/validate/keyword.js +124 -0
  92. package/.output/server/node_modules/ajv/dist/compile/validate/subschema.js +81 -0
  93. package/.output/server/node_modules/ajv/dist/core.js +618 -0
  94. package/.output/server/node_modules/ajv/dist/refs/data.json +13 -0
  95. package/.output/server/node_modules/ajv/dist/refs/json-schema-draft-07.json +151 -0
  96. package/.output/server/node_modules/ajv/dist/runtime/equal.js +7 -0
  97. package/.output/server/node_modules/ajv/dist/runtime/ucs2length.js +24 -0
  98. package/.output/server/node_modules/ajv/dist/runtime/uri.js +6 -0
  99. package/.output/server/node_modules/ajv/dist/runtime/validation_error.js +11 -0
  100. package/.output/server/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +49 -0
  101. package/.output/server/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +106 -0
  102. package/.output/server/node_modules/ajv/dist/vocabularies/applicator/allOf.js +23 -0
  103. package/.output/server/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +12 -0
  104. package/.output/server/node_modules/ajv/dist/vocabularies/applicator/contains.js +95 -0
  105. package/.output/server/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +85 -0
  106. package/.output/server/node_modules/ajv/dist/vocabularies/applicator/if.js +66 -0
  107. package/.output/server/node_modules/ajv/dist/vocabularies/applicator/index.js +44 -0
  108. package/.output/server/node_modules/ajv/dist/vocabularies/applicator/items.js +52 -0
  109. package/.output/server/node_modules/ajv/dist/vocabularies/applicator/items2020.js +30 -0
  110. package/.output/server/node_modules/ajv/dist/vocabularies/applicator/not.js +26 -0
  111. package/.output/server/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +60 -0
  112. package/.output/server/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +75 -0
  113. package/.output/server/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +12 -0
  114. package/.output/server/node_modules/ajv/dist/vocabularies/applicator/properties.js +54 -0
  115. package/.output/server/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +38 -0
  116. package/.output/server/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +13 -0
  117. package/.output/server/node_modules/ajv/dist/vocabularies/code.js +131 -0
  118. package/.output/server/node_modules/ajv/dist/vocabularies/core/id.js +10 -0
  119. package/.output/server/node_modules/ajv/dist/vocabularies/core/index.js +16 -0
  120. package/.output/server/node_modules/ajv/dist/vocabularies/core/ref.js +122 -0
  121. package/.output/server/node_modules/ajv/dist/vocabularies/discriminator/index.js +104 -0
  122. package/.output/server/node_modules/ajv/dist/vocabularies/discriminator/types.js +9 -0
  123. package/.output/server/node_modules/ajv/dist/vocabularies/draft7.js +17 -0
  124. package/.output/server/node_modules/ajv/dist/vocabularies/format/format.js +92 -0
  125. package/.output/server/node_modules/ajv/dist/vocabularies/format/index.js +6 -0
  126. package/.output/server/node_modules/ajv/dist/vocabularies/metadata.js +18 -0
  127. package/.output/server/node_modules/ajv/dist/vocabularies/validation/const.js +25 -0
  128. package/.output/server/node_modules/ajv/dist/vocabularies/validation/enum.js +48 -0
  129. package/.output/server/node_modules/ajv/dist/vocabularies/validation/index.js +33 -0
  130. package/.output/server/node_modules/ajv/dist/vocabularies/validation/limitItems.js +24 -0
  131. package/.output/server/node_modules/ajv/dist/vocabularies/validation/limitLength.js +27 -0
  132. package/.output/server/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +27 -0
  133. package/.output/server/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +24 -0
  134. package/.output/server/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +26 -0
  135. package/.output/server/node_modules/ajv/dist/vocabularies/validation/pattern.js +33 -0
  136. package/.output/server/node_modules/ajv/dist/vocabularies/validation/required.js +79 -0
  137. package/.output/server/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +64 -0
  138. package/.output/server/node_modules/ajv/package.json +126 -0
  139. package/.output/server/node_modules/ajv-formats/dist/formats.js +208 -0
  140. package/.output/server/node_modules/ajv-formats/dist/index.js +37 -0
  141. package/.output/server/node_modules/ajv-formats/dist/limit.js +69 -0
  142. package/.output/server/node_modules/ajv-formats/package.json +74 -0
  143. package/.output/server/node_modules/consola/dist/chunks/prompt.mjs +280 -0
  144. package/.output/server/node_modules/consola/dist/core.mjs +512 -0
  145. package/.output/server/node_modules/consola/dist/index.mjs +651 -0
  146. package/.output/server/node_modules/consola/dist/shared/consola.DRwqZj3T.mjs +72 -0
  147. package/.output/server/node_modules/consola/dist/shared/consola.DXBYu-KD.mjs +288 -0
  148. package/.output/server/node_modules/consola/dist/utils.mjs +54 -0
  149. package/.output/server/node_modules/consola/package.json +136 -0
  150. package/.output/server/node_modules/content-type/index.js +225 -0
  151. package/.output/server/node_modules/content-type/package.json +42 -0
  152. package/.output/server/node_modules/cookie-es/dist/index.mjs +268 -0
  153. package/.output/server/node_modules/cookie-es/package.json +46 -0
  154. package/.output/server/node_modules/crossws/dist/_chunks/_request.mjs +83 -0
  155. package/.output/server/node_modules/crossws/dist/_chunks/adapter.mjs +234 -0
  156. package/.output/server/node_modules/crossws/dist/_chunks/error.mjs +7 -0
  157. package/.output/server/node_modules/crossws/dist/_chunks/libs/ws.mjs +6 -0
  158. package/.output/server/node_modules/crossws/dist/_chunks/node.mjs +220 -0
  159. package/.output/server/node_modules/crossws/dist/_chunks/peer.mjs +208 -0
  160. package/.output/server/node_modules/crossws/dist/adapters/node.mjs +1 -0
  161. package/.output/server/node_modules/crossws/package.json +115 -0
  162. package/.output/server/node_modules/defu/dist/defu.mjs +69 -0
  163. package/.output/server/node_modules/defu/package.json +48 -0
  164. package/.output/server/node_modules/destr/dist/index.mjs +72 -0
  165. package/.output/server/node_modules/destr/package.json +47 -0
  166. package/.output/server/node_modules/devalue/index.js +17 -0
  167. package/.output/server/node_modules/devalue/package.json +39 -0
  168. package/.output/server/node_modules/devalue/src/base64.js +60 -0
  169. package/.output/server/node_modules/devalue/src/constants.js +12 -0
  170. package/.output/server/node_modules/devalue/src/operations.js +221 -0
  171. package/.output/server/node_modules/devalue/src/parse.js +279 -0
  172. package/.output/server/node_modules/devalue/src/stringify.js +433 -0
  173. package/.output/server/node_modules/devalue/src/uneval.js +698 -0
  174. package/.output/server/node_modules/devalue/src/utils.js +190 -0
  175. package/.output/server/node_modules/entities/dist/commonjs/decode-codepoint.js +77 -0
  176. package/.output/server/node_modules/entities/dist/commonjs/decode.js +568 -0
  177. package/.output/server/node_modules/entities/dist/commonjs/generated/decode-data-html.js +7 -0
  178. package/.output/server/node_modules/entities/dist/commonjs/generated/decode-data-xml.js +7 -0
  179. package/.output/server/node_modules/entities/dist/commonjs/internal/bin-trie-flags.js +21 -0
  180. package/.output/server/node_modules/entities/dist/commonjs/internal/decode-shared.js +31 -0
  181. package/.output/server/node_modules/entities/dist/commonjs/package.json +3 -0
  182. package/.output/server/node_modules/entities/package.json +120 -0
  183. package/.output/server/node_modules/estree-walker/dist/umd/estree-walker.js +344 -0
  184. package/.output/server/node_modules/estree-walker/package.json +37 -0
  185. package/.output/server/node_modules/fast-deep-equal/index.js +46 -0
  186. package/.output/server/node_modules/fast-deep-equal/package.json +61 -0
  187. package/.output/server/node_modules/fast-uri/index.js +711 -0
  188. package/.output/server/node_modules/fast-uri/lib/schemes.js +272 -0
  189. package/.output/server/node_modules/fast-uri/lib/utils.js +799 -0
  190. package/.output/server/node_modules/fast-uri/package.json +68 -0
  191. package/.output/server/node_modules/get-port-please/dist/index.mjs +430 -0
  192. package/.output/server/node_modules/get-port-please/package.json +39 -0
  193. package/.output/server/node_modules/h3/dist/index.mjs +2498 -0
  194. package/.output/server/node_modules/h3/package.json +75 -0
  195. package/.output/server/node_modules/hookable/dist/index.mjs +257 -0
  196. package/.output/server/node_modules/hookable/package.json +54 -0
  197. package/.output/server/node_modules/http-shutdown/index.js +85 -0
  198. package/.output/server/node_modules/http-shutdown/package.json +32 -0
  199. package/.output/server/node_modules/iron-webcrypto/dist/index.js +298 -0
  200. package/.output/server/node_modules/iron-webcrypto/package.json +72 -0
  201. package/.output/server/node_modules/is-extglob/index.js +20 -0
  202. package/.output/server/node_modules/is-extglob/package.json +69 -0
  203. package/.output/server/node_modules/is-glob/index.js +150 -0
  204. package/.output/server/node_modules/is-glob/package.json +81 -0
  205. package/.output/server/node_modules/jiti/dist/jiti.cjs +1 -0
  206. package/.output/server/node_modules/jiti/lib/jiti.mjs +29 -0
  207. package/.output/server/node_modules/jiti/package.json +146 -0
  208. package/.output/server/node_modules/json-schema-traverse/index.js +93 -0
  209. package/.output/server/node_modules/json-schema-traverse/package.json +43 -0
  210. package/.output/server/node_modules/listhen/dist/chunks/xdg-open.mjs +1069 -0
  211. package/.output/server/node_modules/listhen/dist/index.mjs +19 -0
  212. package/.output/server/node_modules/listhen/dist/shared/listhen.tqe5I1Rl.mjs +1040 -0
  213. package/.output/server/node_modules/listhen/package.json +84 -0
  214. package/.output/server/node_modules/napi-wasm/index.mjs +1371 -0
  215. package/.output/server/node_modules/napi-wasm/package.json +33 -0
  216. package/.output/server/node_modules/node-forge/lib/aes.js +1091 -0
  217. package/.output/server/node_modules/node-forge/lib/aesCipherSuites.js +282 -0
  218. package/.output/server/node_modules/node-forge/lib/asn1-validator.js +91 -0
  219. package/.output/server/node_modules/node-forge/lib/asn1.js +1522 -0
  220. package/.output/server/node_modules/node-forge/lib/baseN.js +186 -0
  221. package/.output/server/node_modules/node-forge/lib/cipher.js +230 -0
  222. package/.output/server/node_modules/node-forge/lib/cipherModes.js +1027 -0
  223. package/.output/server/node_modules/node-forge/lib/des.js +496 -0
  224. package/.output/server/node_modules/node-forge/lib/ed25519.js +1091 -0
  225. package/.output/server/node_modules/node-forge/lib/forge.js +13 -0
  226. package/.output/server/node_modules/node-forge/lib/hmac.js +146 -0
  227. package/.output/server/node_modules/node-forge/lib/index.js +33 -0
  228. package/.output/server/node_modules/node-forge/lib/jsbn.js +1294 -0
  229. package/.output/server/node_modules/node-forge/lib/kem.js +168 -0
  230. package/.output/server/node_modules/node-forge/lib/log.js +319 -0
  231. package/.output/server/node_modules/node-forge/lib/md.all.js +13 -0
  232. package/.output/server/node_modules/node-forge/lib/md.js +11 -0
  233. package/.output/server/node_modules/node-forge/lib/md5.js +289 -0
  234. package/.output/server/node_modules/node-forge/lib/mgf.js +12 -0
  235. package/.output/server/node_modules/node-forge/lib/mgf1.js +57 -0
  236. package/.output/server/node_modules/node-forge/lib/oids.js +180 -0
  237. package/.output/server/node_modules/node-forge/lib/pbe.js +1029 -0
  238. package/.output/server/node_modules/node-forge/lib/pbkdf2.js +211 -0
  239. package/.output/server/node_modules/node-forge/lib/pem.js +413 -0
  240. package/.output/server/node_modules/node-forge/lib/pkcs1.js +276 -0
  241. package/.output/server/node_modules/node-forge/lib/pkcs12.js +1081 -0
  242. package/.output/server/node_modules/node-forge/lib/pkcs7.js +1260 -0
  243. package/.output/server/node_modules/node-forge/lib/pkcs7asn1.js +410 -0
  244. package/.output/server/node_modules/node-forge/lib/pki.js +102 -0
  245. package/.output/server/node_modules/node-forge/lib/prime.js +297 -0
  246. package/.output/server/node_modules/node-forge/lib/prng.js +419 -0
  247. package/.output/server/node_modules/node-forge/lib/pss.js +241 -0
  248. package/.output/server/node_modules/node-forge/lib/random.js +191 -0
  249. package/.output/server/node_modules/node-forge/lib/rc2.js +410 -0
  250. package/.output/server/node_modules/node-forge/lib/rsa.js +2014 -0
  251. package/.output/server/node_modules/node-forge/lib/sha1.js +319 -0
  252. package/.output/server/node_modules/node-forge/lib/sha256.js +327 -0
  253. package/.output/server/node_modules/node-forge/lib/sha512.js +561 -0
  254. package/.output/server/node_modules/node-forge/lib/ssh.js +236 -0
  255. package/.output/server/node_modules/node-forge/lib/tls.js +4334 -0
  256. package/.output/server/node_modules/node-forge/lib/util.js +2652 -0
  257. package/.output/server/node_modules/node-forge/lib/x509.js +3257 -0
  258. package/.output/server/node_modules/node-forge/package.json +123 -0
  259. package/.output/server/node_modules/node-mock-http/dist/_polyfill/buffer/node.mjs +1 -0
  260. package/.output/server/node_modules/node-mock-http/dist/_polyfill/events/node.mjs +1 -0
  261. package/.output/server/node_modules/node-mock-http/dist/index.mjs +1 -0
  262. package/.output/server/node_modules/node-mock-http/package.json +63 -0
  263. package/.output/server/node_modules/nostics/dist/formatters/ansi.mjs +19 -0
  264. package/.output/server/node_modules/nostics/dist/index.mjs +194 -0
  265. package/.output/server/node_modules/nostics/package.json +126 -0
  266. package/.output/server/node_modules/pathe/dist/index.mjs +19 -0
  267. package/.output/server/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs +249 -0
  268. package/.output/server/node_modules/pathe/package.json +61 -0
  269. package/.output/server/node_modules/picomatch/index.js +17 -0
  270. package/.output/server/node_modules/picomatch/lib/constants.js +184 -0
  271. package/.output/server/node_modules/picomatch/lib/parse.js +1425 -0
  272. package/.output/server/node_modules/picomatch/lib/picomatch.js +361 -0
  273. package/.output/server/node_modules/picomatch/lib/scan.js +403 -0
  274. package/.output/server/node_modules/picomatch/lib/utils.js +72 -0
  275. package/.output/server/node_modules/picomatch/package.json +83 -0
  276. package/.output/server/node_modules/radix3/dist/index.mjs +262 -0
  277. package/.output/server/node_modules/radix3/package.json +52 -0
  278. package/.output/server/node_modules/source-map-js/lib/array-set.js +121 -0
  279. package/.output/server/node_modules/source-map-js/lib/base64-vlq.js +140 -0
  280. package/.output/server/node_modules/source-map-js/lib/base64.js +67 -0
  281. package/.output/server/node_modules/source-map-js/lib/binary-search.js +111 -0
  282. package/.output/server/node_modules/source-map-js/lib/mapping-list.js +79 -0
  283. package/.output/server/node_modules/source-map-js/lib/quick-sort.js +141 -0
  284. package/.output/server/node_modules/source-map-js/lib/source-map-consumer.js +1236 -0
  285. package/.output/server/node_modules/source-map-js/lib/source-map-generator.js +446 -0
  286. package/.output/server/node_modules/source-map-js/lib/source-node.js +420 -0
  287. package/.output/server/node_modules/source-map-js/lib/util.js +594 -0
  288. package/.output/server/node_modules/source-map-js/package.json +71 -0
  289. package/.output/server/node_modules/source-map-js/source-map.js +8 -0
  290. package/.output/server/node_modules/std-env/dist/index.mjs +1 -0
  291. package/.output/server/node_modules/std-env/package.json +43 -0
  292. package/.output/server/node_modules/tinyclip/dist/index.js +143 -0
  293. package/.output/server/node_modules/tinyclip/package.json +48 -0
  294. package/.output/server/node_modules/ufo/dist/index.mjs +645 -0
  295. package/.output/server/node_modules/ufo/package.json +48 -0
  296. package/.output/server/node_modules/uncrypto/dist/crypto.node.mjs +16 -0
  297. package/.output/server/node_modules/uncrypto/package.json +60 -0
  298. package/.output/server/node_modules/unhead/dist/client.mjs +22 -0
  299. package/.output/server/node_modules/unhead/dist/legacy.mjs +33 -0
  300. package/.output/server/node_modules/unhead/dist/minify.mjs +183 -0
  301. package/.output/server/node_modules/unhead/dist/parser.mjs +518 -0
  302. package/.output/server/node_modules/unhead/dist/plugins.mjs +782 -0
  303. package/.output/server/node_modules/unhead/dist/server.mjs +99 -0
  304. package/.output/server/node_modules/unhead/dist/shared/unhead.BEmVMkeA.mjs +673 -0
  305. package/.output/server/node_modules/unhead/dist/shared/unhead.Bf_fPVYA.mjs +6 -0
  306. package/.output/server/node_modules/unhead/dist/shared/unhead.Bm4Y6XQI.mjs +17 -0
  307. package/.output/server/node_modules/unhead/dist/shared/unhead.C5Bksi2B.mjs +49 -0
  308. package/.output/server/node_modules/unhead/dist/shared/unhead.CGPOfp5O.mjs +32 -0
  309. package/.output/server/node_modules/unhead/dist/shared/unhead.CHEy9ana.mjs +7 -0
  310. package/.output/server/node_modules/unhead/dist/shared/unhead.C_7zwq8E.mjs +11 -0
  311. package/.output/server/node_modules/unhead/dist/shared/unhead.CaeaMM5q.mjs +19 -0
  312. package/.output/server/node_modules/unhead/dist/shared/unhead.D7HkBzZn.mjs +59 -0
  313. package/.output/server/node_modules/unhead/dist/shared/unhead.D9VfQWNo.mjs +240 -0
  314. package/.output/server/node_modules/unhead/dist/shared/unhead.DD4N5B4k.mjs +224 -0
  315. package/.output/server/node_modules/unhead/dist/shared/unhead.DGl9jcjg.mjs +196 -0
  316. package/.output/server/node_modules/unhead/dist/shared/unhead.DJuZwX9c.mjs +400 -0
  317. package/.output/server/node_modules/unhead/dist/shared/unhead.DkxnqlHC.mjs +264 -0
  318. package/.output/server/node_modules/unhead/dist/shared/unhead.DspMpm6y.mjs +48 -0
  319. package/.output/server/node_modules/unhead/dist/shared/unhead.o8j9utSy.mjs +208 -0
  320. package/.output/server/node_modules/unhead/dist/stream/client.mjs +33 -0
  321. package/.output/server/node_modules/unhead/dist/stream/iife.mjs +2 -0
  322. package/.output/server/node_modules/unhead/dist/stream/server.mjs +446 -0
  323. package/.output/server/node_modules/unhead/dist/utils.mjs +7 -0
  324. package/.output/server/node_modules/unhead/package.json +179 -0
  325. package/.output/server/node_modules/untun/dist/_chunks/cloudflared.mjs +179 -0
  326. package/.output/server/node_modules/untun/dist/_chunks/log.mjs +27 -0
  327. package/.output/server/node_modules/untun/dist/index.mjs +47 -0
  328. package/.output/server/node_modules/untun/package.json +44 -0
  329. package/.output/server/node_modules/uqr/dist/index.mjs +739 -0
  330. package/.output/server/node_modules/uqr/package.json +69 -0
  331. package/.output/server/node_modules/vue/dist/vue.cjs.js +80 -0
  332. package/.output/server/node_modules/vue/dist/vue.cjs.prod.js +66 -0
  333. package/.output/server/node_modules/vue/index.js +7 -0
  334. package/.output/server/node_modules/vue/index.mjs +1 -0
  335. package/.output/server/node_modules/vue/package.json +112 -0
  336. package/.output/server/node_modules/vue/server-renderer/index.mjs +1 -0
  337. package/.output/server/node_modules/vue-bundle-renderer/dist/runtime.mjs +687 -0
  338. package/.output/server/node_modules/vue-bundle-renderer/package.json +66 -0
  339. package/.output/server/node_modules/zod/index.js +7 -0
  340. package/.output/server/node_modules/zod/package.json +147 -0
  341. package/.output/server/node_modules/zod/v3/ZodError.js +143 -0
  342. package/.output/server/node_modules/zod/v3/errors.js +9 -0
  343. package/.output/server/node_modules/zod/v3/external.js +6 -0
  344. package/.output/server/node_modules/zod/v3/helpers/errorUtil.js +6 -0
  345. package/.output/server/node_modules/zod/v3/helpers/parseUtil.js +109 -0
  346. package/.output/server/node_modules/zod/v3/helpers/typeAliases.js +1 -0
  347. package/.output/server/node_modules/zod/v3/helpers/util.js +133 -0
  348. package/.output/server/node_modules/zod/v3/index.js +4 -0
  349. package/.output/server/node_modules/zod/v3/locales/en.js +109 -0
  350. package/.output/server/node_modules/zod/v3/package.json +7 -0
  351. package/.output/server/node_modules/zod/v3/types.js +3697 -0
  352. package/.output/server/node_modules/zod/v4/classic/checks.js +1 -0
  353. package/.output/server/node_modules/zod/v4/classic/coerce.js +17 -0
  354. package/.output/server/node_modules/zod/v4/classic/compat.js +31 -0
  355. package/.output/server/node_modules/zod/v4/classic/deep-partial.js +13 -0
  356. package/.output/server/node_modules/zod/v4/classic/errors.js +57 -0
  357. package/.output/server/node_modules/zod/v4/classic/external.js +17 -0
  358. package/.output/server/node_modules/zod/v4/classic/from-json-schema.js +881 -0
  359. package/.output/server/node_modules/zod/v4/classic/in-out.js +36 -0
  360. package/.output/server/node_modules/zod/v4/classic/index.js +4 -0
  361. package/.output/server/node_modules/zod/v4/classic/iso.js +15 -0
  362. package/.output/server/node_modules/zod/v4/classic/package.json +7 -0
  363. package/.output/server/node_modules/zod/v4/classic/parse.js +16 -0
  364. package/.output/server/node_modules/zod/v4/classic/schemas.js +1535 -0
  365. package/.output/server/node_modules/zod/v4/core/api.js +1107 -0
  366. package/.output/server/node_modules/zod/v4/core/checks.js +516 -0
  367. package/.output/server/node_modules/zod/v4/core/compile.js +1866 -0
  368. package/.output/server/node_modules/zod/v4/core/core.js +141 -0
  369. package/.output/server/node_modules/zod/v4/core/doc.js +38 -0
  370. package/.output/server/node_modules/zod/v4/core/errors.js +267 -0
  371. package/.output/server/node_modules/zod/v4/core/index.js +19 -0
  372. package/.output/server/node_modules/zod/v4/core/json-schema-generator.js +99 -0
  373. package/.output/server/node_modules/zod/v4/core/json-schema-processors.js +843 -0
  374. package/.output/server/node_modules/zod/v4/core/json-schema.js +1 -0
  375. package/.output/server/node_modules/zod/v4/core/memoizer.js +311 -0
  376. package/.output/server/node_modules/zod/v4/core/package.json +7 -0
  377. package/.output/server/node_modules/zod/v4/core/parse.js +175 -0
  378. package/.output/server/node_modules/zod/v4/core/regexes.js +156 -0
  379. package/.output/server/node_modules/zod/v4/core/registries.js +51 -0
  380. package/.output/server/node_modules/zod/v4/core/schemas.js +2636 -0
  381. package/.output/server/node_modules/zod/v4/core/to-json-schema.js +651 -0
  382. package/.output/server/node_modules/zod/v4/core/util.js +873 -0
  383. package/.output/server/node_modules/zod/v4/core/versions.js +5 -0
  384. package/.output/server/node_modules/zod/v4/core/visit.js +169 -0
  385. package/.output/server/node_modules/zod/v4/index.js +4 -0
  386. package/.output/server/node_modules/zod/v4/locales/ar.js +111 -0
  387. package/.output/server/node_modules/zod/v4/locales/az.js +110 -0
  388. package/.output/server/node_modules/zod/v4/locales/be.js +168 -0
  389. package/.output/server/node_modules/zod/v4/locales/bg.js +125 -0
  390. package/.output/server/node_modules/zod/v4/locales/bn.js +113 -0
  391. package/.output/server/node_modules/zod/v4/locales/ca.js +112 -0
  392. package/.output/server/node_modules/zod/v4/locales/ckb.js +133 -0
  393. package/.output/server/node_modules/zod/v4/locales/cs.js +116 -0
  394. package/.output/server/node_modules/zod/v4/locales/da.js +120 -0
  395. package/.output/server/node_modules/zod/v4/locales/de.js +113 -0
  396. package/.output/server/node_modules/zod/v4/locales/el.js +112 -0
  397. package/.output/server/node_modules/zod/v4/locales/en.js +125 -0
  398. package/.output/server/node_modules/zod/v4/locales/eo.js +114 -0
  399. package/.output/server/node_modules/zod/v4/locales/es.js +136 -0
  400. package/.output/server/node_modules/zod/v4/locales/fa.js +119 -0
  401. package/.output/server/node_modules/zod/v4/locales/fi.js +117 -0
  402. package/.output/server/node_modules/zod/v4/locales/fr-CA.js +112 -0
  403. package/.output/server/node_modules/zod/v4/locales/fr.js +129 -0
  404. package/.output/server/node_modules/zod/v4/locales/gu.js +113 -0
  405. package/.output/server/node_modules/zod/v4/locales/he.js +221 -0
  406. package/.output/server/node_modules/zod/v4/locales/hi.js +111 -0
  407. package/.output/server/node_modules/zod/v4/locales/hr.js +126 -0
  408. package/.output/server/node_modules/zod/v4/locales/hu.js +113 -0
  409. package/.output/server/node_modules/zod/v4/locales/hy.js +158 -0
  410. package/.output/server/node_modules/zod/v4/locales/id.js +111 -0
  411. package/.output/server/node_modules/zod/v4/locales/index.js +63 -0
  412. package/.output/server/node_modules/zod/v4/locales/is.js +114 -0
  413. package/.output/server/node_modules/zod/v4/locales/it.js +113 -0
  414. package/.output/server/node_modules/zod/v4/locales/ja.js +112 -0
  415. package/.output/server/node_modules/zod/v4/locales/ka.js +117 -0
  416. package/.output/server/node_modules/zod/v4/locales/kh.js +5 -0
  417. package/.output/server/node_modules/zod/v4/locales/km.js +115 -0
  418. package/.output/server/node_modules/zod/v4/locales/kn.js +116 -0
  419. package/.output/server/node_modules/zod/v4/locales/ko.js +116 -0
  420. package/.output/server/node_modules/zod/v4/locales/lt.js +207 -0
  421. package/.output/server/node_modules/zod/v4/locales/mk.js +114 -0
  422. package/.output/server/node_modules/zod/v4/locales/ms.js +112 -0
  423. package/.output/server/node_modules/zod/v4/locales/ne.js +111 -0
  424. package/.output/server/node_modules/zod/v4/locales/nl.js +115 -0
  425. package/.output/server/node_modules/zod/v4/locales/nn.js +113 -0
  426. package/.output/server/node_modules/zod/v4/locales/no.js +113 -0
  427. package/.output/server/node_modules/zod/v4/locales/ota.js +114 -0
  428. package/.output/server/node_modules/zod/v4/locales/package.json +7 -0
  429. package/.output/server/node_modules/zod/v4/locales/pl.js +114 -0
  430. package/.output/server/node_modules/zod/v4/locales/ps.js +119 -0
  431. package/.output/server/node_modules/zod/v4/locales/pt-BR.js +143 -0
  432. package/.output/server/node_modules/zod/v4/locales/pt.js +142 -0
  433. package/.output/server/node_modules/zod/v4/locales/ro.js +122 -0
  434. package/.output/server/node_modules/zod/v4/locales/ru.js +168 -0
  435. package/.output/server/node_modules/zod/v4/locales/sk.js +116 -0
  436. package/.output/server/node_modules/zod/v4/locales/sl.js +114 -0
  437. package/.output/server/node_modules/zod/v4/locales/sv.js +115 -0
  438. package/.output/server/node_modules/zod/v4/locales/ta.js +115 -0
  439. package/.output/server/node_modules/zod/v4/locales/tg.js +117 -0
  440. package/.output/server/node_modules/zod/v4/locales/th.js +115 -0
  441. package/.output/server/node_modules/zod/v4/locales/tk.js +107 -0
  442. package/.output/server/node_modules/zod/v4/locales/tr.js +110 -0
  443. package/.output/server/node_modules/zod/v4/locales/ua.js +5 -0
  444. package/.output/server/node_modules/zod/v4/locales/uk.js +113 -0
  445. package/.output/server/node_modules/zod/v4/locales/ur.js +115 -0
  446. package/.output/server/node_modules/zod/v4/locales/uz.js +113 -0
  447. package/.output/server/node_modules/zod/v4/locales/vi.js +113 -0
  448. package/.output/server/node_modules/zod/v4/locales/yo.js +112 -0
  449. package/.output/server/node_modules/zod/v4/locales/zh-CN.js +114 -0
  450. package/.output/server/node_modules/zod/v4/locales/zh-TW.js +112 -0
  451. package/.output/server/node_modules/zod/v4/mini/checks.js +1 -0
  452. package/.output/server/node_modules/zod/v4/mini/coerce.js +22 -0
  453. package/.output/server/node_modules/zod/v4/mini/deep-partial.js +13 -0
  454. package/.output/server/node_modules/zod/v4/mini/external.js +16 -0
  455. package/.output/server/node_modules/zod/v4/mini/in-out.js +36 -0
  456. package/.output/server/node_modules/zod/v4/mini/iso.js +34 -0
  457. package/.output/server/node_modules/zod/v4/mini/package.json +7 -0
  458. package/.output/server/node_modules/zod/v4/mini/parse.js +1 -0
  459. package/.output/server/node_modules/zod/v4/mini/schemas.js +1002 -0
  460. package/.output/server/node_modules/zod/v4/package.json +7 -0
  461. package/.output/server/node_modules/zod/v4-mini/index.js +3 -0
  462. package/.output/server/node_modules/zod/v4-mini/package.json +7 -0
  463. package/.output/server/node_modules/zod-to-json-schema/dist/esm/Options.js +46 -0
  464. package/.output/server/node_modules/zod-to-json-schema/dist/esm/Refs.js +22 -0
  465. package/.output/server/node_modules/zod-to-json-schema/dist/esm/errorMessages.js +14 -0
  466. package/.output/server/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js +8 -0
  467. package/.output/server/node_modules/zod-to-json-schema/dist/esm/index.js +40 -0
  468. package/.output/server/node_modules/zod-to-json-schema/dist/esm/package.json +1 -0
  469. package/.output/server/node_modules/zod-to-json-schema/dist/esm/parseDef.js +62 -0
  470. package/.output/server/node_modules/zod-to-json-schema/dist/esm/parseTypes.js +1 -0
  471. package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/any.js +17 -0
  472. package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/array.js +26 -0
  473. package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js +49 -0
  474. package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js +5 -0
  475. package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js +4 -0
  476. package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js +4 -0
  477. package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/date.js +46 -0
  478. package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/default.js +7 -0
  479. package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js +7 -0
  480. package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js +6 -0
  481. package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js +52 -0
  482. package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js +21 -0
  483. package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/map.js +26 -0
  484. package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js +16 -0
  485. package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/never.js +11 -0
  486. package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/null.js +10 -0
  487. package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js +33 -0
  488. package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/number.js +52 -0
  489. package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/object.js +72 -0
  490. package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js +21 -0
  491. package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js +20 -0
  492. package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js +4 -0
  493. package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js +4 -0
  494. package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/record.js +61 -0
  495. package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/set.js +20 -0
  496. package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/string.js +352 -0
  497. package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js +32 -0
  498. package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js +6 -0
  499. package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/union.js +80 -0
  500. package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js +4 -0
  501. package/.output/server/node_modules/zod-to-json-schema/dist/esm/selectParser.js +105 -0
  502. package/.output/server/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js +87 -0
  503. package/.output/server/node_modules/zod-to-json-schema/package.json +85 -0
  504. package/.output/server/package.json +64 -0
  505. package/README.md +226 -23
  506. package/bin/bantou.mjs +33 -0
  507. package/package.json +18 -8
  508. package/protocol/PROTOCOL.md +26 -0
  509. package/protocol/protocol.json +92 -0
  510. package/dist/cap.js +0 -7
  511. package/dist/cli.js +0 -27
  512. package/dist/config.js +0 -23
  513. package/dist/daemon.js +0 -23
  514. package/dist/session.js +0 -7
  515. package/dist/workspace.js +0 -8
@@ -0,0 +1,1027 @@
1
+ /**
2
+ * Supported cipher modes.
3
+ *
4
+ * @author Dave Longley
5
+ *
6
+ * Copyright (c) 2010-2014 Digital Bazaar, Inc.
7
+ */
8
+ var forge = require('./forge');
9
+ require('./util');
10
+
11
+ forge.cipher = forge.cipher || {};
12
+
13
+ // supported cipher modes
14
+ var modes = module.exports = forge.cipher.modes = forge.cipher.modes || {};
15
+
16
+ /** Electronic codebook (ECB) (Don't use this; it's not secure) **/
17
+
18
+ modes.ecb = function(options) {
19
+ options = options || {};
20
+ this.name = 'ECB';
21
+ this.cipher = options.cipher;
22
+ this.blockSize = options.blockSize || 16;
23
+ this._ints = this.blockSize / 4;
24
+ this._inBlock = new Array(this._ints);
25
+ this._outBlock = new Array(this._ints);
26
+ };
27
+
28
+ modes.ecb.prototype.start = function(options) {};
29
+
30
+ modes.ecb.prototype.encrypt = function(input, output, finish) {
31
+ // not enough input to encrypt
32
+ if(input.length() < this.blockSize && !(finish && input.length() > 0)) {
33
+ return true;
34
+ }
35
+
36
+ // get next block
37
+ for(var i = 0; i < this._ints; ++i) {
38
+ this._inBlock[i] = input.getInt32();
39
+ }
40
+
41
+ // encrypt block
42
+ this.cipher.encrypt(this._inBlock, this._outBlock);
43
+
44
+ // write output
45
+ for(var i = 0; i < this._ints; ++i) {
46
+ output.putInt32(this._outBlock[i]);
47
+ }
48
+ };
49
+
50
+ modes.ecb.prototype.decrypt = function(input, output, finish) {
51
+ // not enough input to decrypt
52
+ if(input.length() < this.blockSize && !(finish && input.length() > 0)) {
53
+ return true;
54
+ }
55
+
56
+ // get next block
57
+ for(var i = 0; i < this._ints; ++i) {
58
+ this._inBlock[i] = input.getInt32();
59
+ }
60
+
61
+ // decrypt block
62
+ this.cipher.decrypt(this._inBlock, this._outBlock);
63
+
64
+ // write output
65
+ for(var i = 0; i < this._ints; ++i) {
66
+ output.putInt32(this._outBlock[i]);
67
+ }
68
+ };
69
+
70
+ modes.ecb.prototype.pad = function(input, options) {
71
+ // add PKCS#7 padding to block (each pad byte is the
72
+ // value of the number of pad bytes)
73
+ var padding = (input.length() === this.blockSize ?
74
+ this.blockSize : (this.blockSize - input.length()));
75
+ input.fillWithByte(padding, padding);
76
+ return true;
77
+ };
78
+
79
+ modes.ecb.prototype.unpad = function(output, options) {
80
+ // check for error: input data not a multiple of blockSize
81
+ if(options.overflow > 0) {
82
+ return false;
83
+ }
84
+
85
+ // nothing to unpad, e.g. the caller already read all output
86
+ var len = output.length();
87
+ if(len === 0) {
88
+ return true;
89
+ }
90
+
91
+ // ensure padding byte count is valid
92
+ var count = output.at(len - 1);
93
+ if(count === 0 || count > this.blockSize || count > len) {
94
+ return false;
95
+ }
96
+
97
+ // ensure all padding bytes match the padding count (RFC 5652 6.3)
98
+ for(var i = 2; i <= count; ++i) {
99
+ if(output.at(len - i) !== count) {
100
+ return false;
101
+ }
102
+ }
103
+
104
+ // trim off padding bytes
105
+ output.truncate(count);
106
+ return true;
107
+ };
108
+
109
+ /** Cipher-block Chaining (CBC) **/
110
+
111
+ modes.cbc = function(options) {
112
+ options = options || {};
113
+ this.name = 'CBC';
114
+ this.cipher = options.cipher;
115
+ this.blockSize = options.blockSize || 16;
116
+ this._ints = this.blockSize / 4;
117
+ this._inBlock = new Array(this._ints);
118
+ this._outBlock = new Array(this._ints);
119
+ };
120
+
121
+ modes.cbc.prototype.start = function(options) {
122
+ // Note: legacy support for using IV residue (has security flaws)
123
+ // if IV is null, reuse block from previous processing
124
+ if(options.iv === null) {
125
+ // must have a previous block
126
+ if(!this._prev) {
127
+ throw new Error('Invalid IV parameter.');
128
+ }
129
+ this._iv = this._prev.slice(0);
130
+ } else if(!('iv' in options)) {
131
+ throw new Error('Invalid IV parameter.');
132
+ } else {
133
+ // save IV as "previous" block
134
+ this._iv = transformIV(options.iv, this.blockSize);
135
+ this._prev = this._iv.slice(0);
136
+ }
137
+ };
138
+
139
+ modes.cbc.prototype.encrypt = function(input, output, finish) {
140
+ // not enough input to encrypt
141
+ if(input.length() < this.blockSize && !(finish && input.length() > 0)) {
142
+ return true;
143
+ }
144
+
145
+ // get next block
146
+ // CBC XOR's IV (or previous block) with plaintext
147
+ for(var i = 0; i < this._ints; ++i) {
148
+ this._inBlock[i] = this._prev[i] ^ input.getInt32();
149
+ }
150
+
151
+ // encrypt block
152
+ this.cipher.encrypt(this._inBlock, this._outBlock);
153
+
154
+ // write output, save previous block
155
+ for(var i = 0; i < this._ints; ++i) {
156
+ output.putInt32(this._outBlock[i]);
157
+ }
158
+ this._prev = this._outBlock;
159
+ };
160
+
161
+ modes.cbc.prototype.decrypt = function(input, output, finish) {
162
+ // not enough input to decrypt
163
+ if(input.length() < this.blockSize && !(finish && input.length() > 0)) {
164
+ return true;
165
+ }
166
+
167
+ // get next block
168
+ for(var i = 0; i < this._ints; ++i) {
169
+ this._inBlock[i] = input.getInt32();
170
+ }
171
+
172
+ // decrypt block
173
+ this.cipher.decrypt(this._inBlock, this._outBlock);
174
+
175
+ // write output, save previous ciphered block
176
+ // CBC XOR's IV (or previous block) with ciphertext
177
+ for(var i = 0; i < this._ints; ++i) {
178
+ output.putInt32(this._prev[i] ^ this._outBlock[i]);
179
+ }
180
+ this._prev = this._inBlock.slice(0);
181
+ };
182
+
183
+ modes.cbc.prototype.pad = function(input, options) {
184
+ // add PKCS#7 padding to block (each pad byte is the
185
+ // value of the number of pad bytes)
186
+ var padding = (input.length() === this.blockSize ?
187
+ this.blockSize : (this.blockSize - input.length()));
188
+ input.fillWithByte(padding, padding);
189
+ return true;
190
+ };
191
+
192
+ modes.cbc.prototype.unpad = function(output, options) {
193
+ // check for error: input data not a multiple of blockSize
194
+ if(options.overflow > 0) {
195
+ return false;
196
+ }
197
+
198
+ // nothing to unpad, e.g. the caller already read all output
199
+ var len = output.length();
200
+ if(len === 0) {
201
+ return true;
202
+ }
203
+
204
+ // ensure padding byte count is valid
205
+ var count = output.at(len - 1);
206
+ if(count === 0 || count > this.blockSize || count > len) {
207
+ return false;
208
+ }
209
+
210
+ // ensure all padding bytes match the padding count (RFC 5652 6.3)
211
+ for(var i = 2; i <= count; ++i) {
212
+ if(output.at(len - i) !== count) {
213
+ return false;
214
+ }
215
+ }
216
+
217
+ // trim off padding bytes
218
+ output.truncate(count);
219
+ return true;
220
+ };
221
+
222
+ /** Cipher feedback (CFB) **/
223
+
224
+ modes.cfb = function(options) {
225
+ options = options || {};
226
+ this.name = 'CFB';
227
+ this.cipher = options.cipher;
228
+ this.blockSize = options.blockSize || 16;
229
+ this._ints = this.blockSize / 4;
230
+ this._inBlock = null;
231
+ this._outBlock = new Array(this._ints);
232
+ this._partialBlock = new Array(this._ints);
233
+ this._partialOutput = forge.util.createBuffer();
234
+ this._partialBytes = 0;
235
+ };
236
+
237
+ modes.cfb.prototype.start = function(options) {
238
+ if(!('iv' in options)) {
239
+ throw new Error('Invalid IV parameter.');
240
+ }
241
+ // use IV as first input
242
+ this._iv = transformIV(options.iv, this.blockSize);
243
+ this._inBlock = this._iv.slice(0);
244
+ this._partialBytes = 0;
245
+ };
246
+
247
+ modes.cfb.prototype.encrypt = function(input, output, finish) {
248
+ // not enough input to encrypt
249
+ var inputLength = input.length();
250
+ if(inputLength === 0) {
251
+ return true;
252
+ }
253
+
254
+ // encrypt block
255
+ this.cipher.encrypt(this._inBlock, this._outBlock);
256
+
257
+ // handle full block
258
+ if(this._partialBytes === 0 && inputLength >= this.blockSize) {
259
+ // XOR input with output, write input as output
260
+ for(var i = 0; i < this._ints; ++i) {
261
+ this._inBlock[i] = input.getInt32() ^ this._outBlock[i];
262
+ output.putInt32(this._inBlock[i]);
263
+ }
264
+ return;
265
+ }
266
+
267
+ // handle partial block
268
+ var partialBytes = (this.blockSize - inputLength) % this.blockSize;
269
+ if(partialBytes > 0) {
270
+ partialBytes = this.blockSize - partialBytes;
271
+ }
272
+
273
+ // XOR input with output, write input as partial output
274
+ this._partialOutput.clear();
275
+ for(var i = 0; i < this._ints; ++i) {
276
+ this._partialBlock[i] = input.getInt32() ^ this._outBlock[i];
277
+ this._partialOutput.putInt32(this._partialBlock[i]);
278
+ }
279
+
280
+ if(partialBytes > 0) {
281
+ // block still incomplete, restore input buffer
282
+ input.read -= this.blockSize;
283
+ } else {
284
+ // block complete, update input block
285
+ for(var i = 0; i < this._ints; ++i) {
286
+ this._inBlock[i] = this._partialBlock[i];
287
+ }
288
+ }
289
+
290
+ // skip any previous partial bytes
291
+ if(this._partialBytes > 0) {
292
+ this._partialOutput.getBytes(this._partialBytes);
293
+ }
294
+
295
+ if(partialBytes > 0 && !finish) {
296
+ output.putBytes(this._partialOutput.getBytes(
297
+ partialBytes - this._partialBytes));
298
+ this._partialBytes = partialBytes;
299
+ return true;
300
+ }
301
+
302
+ output.putBytes(this._partialOutput.getBytes(
303
+ inputLength - this._partialBytes));
304
+ this._partialBytes = 0;
305
+ };
306
+
307
+ modes.cfb.prototype.decrypt = function(input, output, finish) {
308
+ // not enough input to decrypt
309
+ var inputLength = input.length();
310
+ if(inputLength === 0) {
311
+ return true;
312
+ }
313
+
314
+ // encrypt block (CFB always uses encryption mode)
315
+ this.cipher.encrypt(this._inBlock, this._outBlock);
316
+
317
+ // handle full block
318
+ if(this._partialBytes === 0 && inputLength >= this.blockSize) {
319
+ // XOR input with output, write input as output
320
+ for(var i = 0; i < this._ints; ++i) {
321
+ this._inBlock[i] = input.getInt32();
322
+ output.putInt32(this._inBlock[i] ^ this._outBlock[i]);
323
+ }
324
+ return;
325
+ }
326
+
327
+ // handle partial block
328
+ var partialBytes = (this.blockSize - inputLength) % this.blockSize;
329
+ if(partialBytes > 0) {
330
+ partialBytes = this.blockSize - partialBytes;
331
+ }
332
+
333
+ // XOR input with output, write input as partial output
334
+ this._partialOutput.clear();
335
+ for(var i = 0; i < this._ints; ++i) {
336
+ this._partialBlock[i] = input.getInt32();
337
+ this._partialOutput.putInt32(this._partialBlock[i] ^ this._outBlock[i]);
338
+ }
339
+
340
+ if(partialBytes > 0) {
341
+ // block still incomplete, restore input buffer
342
+ input.read -= this.blockSize;
343
+ } else {
344
+ // block complete, update input block
345
+ for(var i = 0; i < this._ints; ++i) {
346
+ this._inBlock[i] = this._partialBlock[i];
347
+ }
348
+ }
349
+
350
+ // skip any previous partial bytes
351
+ if(this._partialBytes > 0) {
352
+ this._partialOutput.getBytes(this._partialBytes);
353
+ }
354
+
355
+ if(partialBytes > 0 && !finish) {
356
+ output.putBytes(this._partialOutput.getBytes(
357
+ partialBytes - this._partialBytes));
358
+ this._partialBytes = partialBytes;
359
+ return true;
360
+ }
361
+
362
+ output.putBytes(this._partialOutput.getBytes(
363
+ inputLength - this._partialBytes));
364
+ this._partialBytes = 0;
365
+ };
366
+
367
+ /** Output feedback (OFB) **/
368
+
369
+ modes.ofb = function(options) {
370
+ options = options || {};
371
+ this.name = 'OFB';
372
+ this.cipher = options.cipher;
373
+ this.blockSize = options.blockSize || 16;
374
+ this._ints = this.blockSize / 4;
375
+ this._inBlock = null;
376
+ this._outBlock = new Array(this._ints);
377
+ this._partialOutput = forge.util.createBuffer();
378
+ this._partialBytes = 0;
379
+ };
380
+
381
+ modes.ofb.prototype.start = function(options) {
382
+ if(!('iv' in options)) {
383
+ throw new Error('Invalid IV parameter.');
384
+ }
385
+ // use IV as first input
386
+ this._iv = transformIV(options.iv, this.blockSize);
387
+ this._inBlock = this._iv.slice(0);
388
+ this._partialBytes = 0;
389
+ };
390
+
391
+ modes.ofb.prototype.encrypt = function(input, output, finish) {
392
+ // not enough input to encrypt
393
+ var inputLength = input.length();
394
+ if(input.length() === 0) {
395
+ return true;
396
+ }
397
+
398
+ // encrypt block (OFB always uses encryption mode)
399
+ this.cipher.encrypt(this._inBlock, this._outBlock);
400
+
401
+ // handle full block
402
+ if(this._partialBytes === 0 && inputLength >= this.blockSize) {
403
+ // XOR input with output and update next input
404
+ for(var i = 0; i < this._ints; ++i) {
405
+ output.putInt32(input.getInt32() ^ this._outBlock[i]);
406
+ this._inBlock[i] = this._outBlock[i];
407
+ }
408
+ return;
409
+ }
410
+
411
+ // handle partial block
412
+ var partialBytes = (this.blockSize - inputLength) % this.blockSize;
413
+ if(partialBytes > 0) {
414
+ partialBytes = this.blockSize - partialBytes;
415
+ }
416
+
417
+ // XOR input with output
418
+ this._partialOutput.clear();
419
+ for(var i = 0; i < this._ints; ++i) {
420
+ this._partialOutput.putInt32(input.getInt32() ^ this._outBlock[i]);
421
+ }
422
+
423
+ if(partialBytes > 0) {
424
+ // block still incomplete, restore input buffer
425
+ input.read -= this.blockSize;
426
+ } else {
427
+ // block complete, update input block
428
+ for(var i = 0; i < this._ints; ++i) {
429
+ this._inBlock[i] = this._outBlock[i];
430
+ }
431
+ }
432
+
433
+ // skip any previous partial bytes
434
+ if(this._partialBytes > 0) {
435
+ this._partialOutput.getBytes(this._partialBytes);
436
+ }
437
+
438
+ if(partialBytes > 0 && !finish) {
439
+ output.putBytes(this._partialOutput.getBytes(
440
+ partialBytes - this._partialBytes));
441
+ this._partialBytes = partialBytes;
442
+ return true;
443
+ }
444
+
445
+ output.putBytes(this._partialOutput.getBytes(
446
+ inputLength - this._partialBytes));
447
+ this._partialBytes = 0;
448
+ };
449
+
450
+ modes.ofb.prototype.decrypt = modes.ofb.prototype.encrypt;
451
+
452
+ /** Counter (CTR) **/
453
+
454
+ modes.ctr = function(options) {
455
+ options = options || {};
456
+ this.name = 'CTR';
457
+ this.cipher = options.cipher;
458
+ this.blockSize = options.blockSize || 16;
459
+ this._ints = this.blockSize / 4;
460
+ this._inBlock = null;
461
+ this._outBlock = new Array(this._ints);
462
+ this._partialOutput = forge.util.createBuffer();
463
+ this._partialBytes = 0;
464
+ };
465
+
466
+ modes.ctr.prototype.start = function(options) {
467
+ if(!('iv' in options)) {
468
+ throw new Error('Invalid IV parameter.');
469
+ }
470
+ // use IV as first input
471
+ this._iv = transformIV(options.iv, this.blockSize);
472
+ this._inBlock = this._iv.slice(0);
473
+ this._partialBytes = 0;
474
+ };
475
+
476
+ modes.ctr.prototype.encrypt = function(input, output, finish) {
477
+ // not enough input to encrypt
478
+ var inputLength = input.length();
479
+ if(inputLength === 0) {
480
+ return true;
481
+ }
482
+
483
+ // encrypt block (CTR always uses encryption mode)
484
+ this.cipher.encrypt(this._inBlock, this._outBlock);
485
+
486
+ // handle full block
487
+ if(this._partialBytes === 0 && inputLength >= this.blockSize) {
488
+ // XOR input with output
489
+ for(var i = 0; i < this._ints; ++i) {
490
+ output.putInt32(input.getInt32() ^ this._outBlock[i]);
491
+ }
492
+ } else {
493
+ // handle partial block
494
+ var partialBytes = (this.blockSize - inputLength) % this.blockSize;
495
+ if(partialBytes > 0) {
496
+ partialBytes = this.blockSize - partialBytes;
497
+ }
498
+
499
+ // XOR input with output
500
+ this._partialOutput.clear();
501
+ for(var i = 0; i < this._ints; ++i) {
502
+ this._partialOutput.putInt32(input.getInt32() ^ this._outBlock[i]);
503
+ }
504
+
505
+ if(partialBytes > 0) {
506
+ // block still incomplete, restore input buffer
507
+ input.read -= this.blockSize;
508
+ }
509
+
510
+ // skip any previous partial bytes
511
+ if(this._partialBytes > 0) {
512
+ this._partialOutput.getBytes(this._partialBytes);
513
+ }
514
+
515
+ if(partialBytes > 0 && !finish) {
516
+ output.putBytes(this._partialOutput.getBytes(
517
+ partialBytes - this._partialBytes));
518
+ this._partialBytes = partialBytes;
519
+ return true;
520
+ }
521
+
522
+ output.putBytes(this._partialOutput.getBytes(
523
+ inputLength - this._partialBytes));
524
+ this._partialBytes = 0;
525
+ }
526
+
527
+ // block complete, increment counter (input block)
528
+ inc32(this._inBlock);
529
+ };
530
+
531
+ modes.ctr.prototype.decrypt = modes.ctr.prototype.encrypt;
532
+
533
+ /** Galois/Counter Mode (GCM) **/
534
+
535
+ modes.gcm = function(options) {
536
+ options = options || {};
537
+ this.name = 'GCM';
538
+ this.cipher = options.cipher;
539
+ this.blockSize = options.blockSize || 16;
540
+ this._ints = this.blockSize / 4;
541
+ this._inBlock = new Array(this._ints);
542
+ this._outBlock = new Array(this._ints);
543
+ this._partialOutput = forge.util.createBuffer();
544
+ this._partialBytes = 0;
545
+
546
+ // R is actually this value concatenated with 120 more zero bits, but
547
+ // we only XOR against R so the other zeros have no effect -- we just
548
+ // apply this value to the first integer in a block
549
+ this._R = 0xE1000000;
550
+ };
551
+
552
+ modes.gcm.prototype.start = function(options) {
553
+ if(!('iv' in options)) {
554
+ throw new Error('Invalid IV parameter.');
555
+ }
556
+ // ensure IV is a byte buffer
557
+ var iv = forge.util.createBuffer(options.iv);
558
+
559
+ // no ciphered data processed yet
560
+ this._cipherLength = 0;
561
+
562
+ // default additional data is none
563
+ var additionalData;
564
+ if('additionalData' in options) {
565
+ additionalData = forge.util.createBuffer(options.additionalData);
566
+ } else {
567
+ additionalData = forge.util.createBuffer();
568
+ }
569
+
570
+ // default tag length is 128 bits
571
+ if(options.tagLength !== undefined && options.tagLength !== null) {
572
+ this._tagLength = Number(options.tagLength);
573
+ } else {
574
+ this._tagLength = 128;
575
+ }
576
+ // NIST SP-800-38D 5.2.1.2
577
+ if([128, 120, 112, 104, 96, 64, 32].indexOf(this._tagLength) === -1) {
578
+ throw new Error('Invalid tag length.');
579
+ }
580
+
581
+ // if tag is given, ensure tag matches tag length
582
+ this._tag = null;
583
+ if(options.decrypt) {
584
+ // save tag to check later
585
+ this._tag = forge.util.createBuffer(options.tag).getBytes();
586
+ if(this._tag.length !== (this._tagLength / 8)) {
587
+ throw new Error('Authentication tag does not match tag length.');
588
+ }
589
+ }
590
+
591
+ // create tmp storage for hash calculation
592
+ this._hashBlock = new Array(this._ints);
593
+
594
+ // no tag generated yet
595
+ this.tag = null;
596
+
597
+ // generate hash subkey
598
+ // (apply block cipher to "zero" block)
599
+ this._hashSubkey = new Array(this._ints);
600
+ this.cipher.encrypt([0, 0, 0, 0], this._hashSubkey);
601
+
602
+ // generate table M
603
+ // use 4-bit tables (32 component decomposition of a 16 byte value)
604
+ // 8-bit tables take more space and are known to have security
605
+ // vulnerabilities (in native implementations)
606
+ this.componentBits = 4;
607
+ this._m = this.generateHashTable(this._hashSubkey, this.componentBits);
608
+
609
+ // Note: support IV length different from 96 bits? (only supporting
610
+ // 96 bits is recommended by NIST SP-800-38D)
611
+ // generate J_0
612
+ var ivLength = iv.length();
613
+ if(ivLength === 12) {
614
+ // 96-bit IV
615
+ this._j0 = [iv.getInt32(), iv.getInt32(), iv.getInt32(), 1];
616
+ } else {
617
+ // IV is NOT 96-bits
618
+ this._j0 = [0, 0, 0, 0];
619
+ while(iv.length() > 0) {
620
+ this._j0 = this.ghash(
621
+ this._hashSubkey, this._j0,
622
+ [iv.getInt32(), iv.getInt32(), iv.getInt32(), iv.getInt32()]);
623
+ }
624
+ this._j0 = this.ghash(
625
+ this._hashSubkey, this._j0, [0, 0].concat(from64To32(ivLength * 8)));
626
+ }
627
+
628
+ // generate ICB (initial counter block)
629
+ this._inBlock = this._j0.slice(0);
630
+ inc32(this._inBlock);
631
+ this._partialBytes = 0;
632
+
633
+ // consume authentication data
634
+ additionalData = forge.util.createBuffer(additionalData);
635
+ // save additional data length as a BE 64-bit number
636
+ this._aDataLength = from64To32(additionalData.length() * 8);
637
+ // pad additional data to 128 bit (16 byte) block size
638
+ var overflow = additionalData.length() % this.blockSize;
639
+ if(overflow) {
640
+ additionalData.fillWithByte(0, this.blockSize - overflow);
641
+ }
642
+ this._s = [0, 0, 0, 0];
643
+ while(additionalData.length() > 0) {
644
+ this._s = this.ghash(this._hashSubkey, this._s, [
645
+ additionalData.getInt32(),
646
+ additionalData.getInt32(),
647
+ additionalData.getInt32(),
648
+ additionalData.getInt32()
649
+ ]);
650
+ }
651
+ };
652
+
653
+ modes.gcm.prototype.encrypt = function(input, output, finish) {
654
+ // not enough input to encrypt
655
+ var inputLength = input.length();
656
+ if(inputLength === 0) {
657
+ return true;
658
+ }
659
+
660
+ // encrypt block
661
+ this.cipher.encrypt(this._inBlock, this._outBlock);
662
+
663
+ // handle full block
664
+ if(this._partialBytes === 0 && inputLength >= this.blockSize) {
665
+ // XOR input with output
666
+ for(var i = 0; i < this._ints; ++i) {
667
+ output.putInt32(this._outBlock[i] ^= input.getInt32());
668
+ }
669
+ this._cipherLength += this.blockSize;
670
+ } else {
671
+ // handle partial block
672
+ var partialBytes = (this.blockSize - inputLength) % this.blockSize;
673
+ if(partialBytes > 0) {
674
+ partialBytes = this.blockSize - partialBytes;
675
+ }
676
+
677
+ // XOR input with output
678
+ this._partialOutput.clear();
679
+ for(var i = 0; i < this._ints; ++i) {
680
+ this._partialOutput.putInt32(input.getInt32() ^ this._outBlock[i]);
681
+ }
682
+
683
+ if(partialBytes <= 0 || finish) {
684
+ // handle overflow prior to hashing
685
+ if(finish) {
686
+ // get block overflow
687
+ var overflow = inputLength % this.blockSize;
688
+ this._cipherLength += overflow;
689
+ // truncate for hash function
690
+ this._partialOutput.truncate(this.blockSize - overflow);
691
+ } else {
692
+ this._cipherLength += this.blockSize;
693
+ }
694
+
695
+ // get output block for hashing
696
+ for(var i = 0; i < this._ints; ++i) {
697
+ this._outBlock[i] = this._partialOutput.getInt32();
698
+ }
699
+ this._partialOutput.read -= this.blockSize;
700
+ }
701
+
702
+ // skip any previous partial bytes
703
+ if(this._partialBytes > 0) {
704
+ this._partialOutput.getBytes(this._partialBytes);
705
+ }
706
+
707
+ if(partialBytes > 0 && !finish) {
708
+ // block still incomplete, restore input buffer, get partial output,
709
+ // and return early
710
+ input.read -= this.blockSize;
711
+ output.putBytes(this._partialOutput.getBytes(
712
+ partialBytes - this._partialBytes));
713
+ this._partialBytes = partialBytes;
714
+ return true;
715
+ }
716
+
717
+ output.putBytes(this._partialOutput.getBytes(
718
+ inputLength - this._partialBytes));
719
+ this._partialBytes = 0;
720
+ }
721
+
722
+ // update hash block S
723
+ this._s = this.ghash(this._hashSubkey, this._s, this._outBlock);
724
+
725
+ // increment counter (input block)
726
+ inc32(this._inBlock);
727
+ };
728
+
729
+ modes.gcm.prototype.decrypt = function(input, output, finish) {
730
+ // not enough input to decrypt
731
+ var inputLength = input.length();
732
+ if(inputLength < this.blockSize && !(finish && inputLength > 0)) {
733
+ return true;
734
+ }
735
+
736
+ // encrypt block (GCM always uses encryption mode)
737
+ this.cipher.encrypt(this._inBlock, this._outBlock);
738
+
739
+ // increment counter (input block)
740
+ inc32(this._inBlock);
741
+
742
+ // update hash block S
743
+ this._hashBlock[0] = input.getInt32();
744
+ this._hashBlock[1] = input.getInt32();
745
+ this._hashBlock[2] = input.getInt32();
746
+ this._hashBlock[3] = input.getInt32();
747
+ this._s = this.ghash(this._hashSubkey, this._s, this._hashBlock);
748
+
749
+ // XOR hash input with output
750
+ for(var i = 0; i < this._ints; ++i) {
751
+ output.putInt32(this._outBlock[i] ^ this._hashBlock[i]);
752
+ }
753
+
754
+ // increment cipher data length
755
+ if(inputLength < this.blockSize) {
756
+ this._cipherLength += inputLength % this.blockSize;
757
+ } else {
758
+ this._cipherLength += this.blockSize;
759
+ }
760
+ };
761
+
762
+ modes.gcm.prototype.afterFinish = function(output, options) {
763
+ var rval = true;
764
+
765
+ // handle overflow
766
+ if(options.decrypt && options.overflow) {
767
+ output.truncate(this.blockSize - options.overflow);
768
+ }
769
+
770
+ // handle authentication tag
771
+ this.tag = forge.util.createBuffer();
772
+
773
+ // concatenate additional data length with cipher length
774
+ var lengths = this._aDataLength.concat(from64To32(this._cipherLength * 8));
775
+
776
+ // include lengths in hash
777
+ this._s = this.ghash(this._hashSubkey, this._s, lengths);
778
+
779
+ // do GCTR(J_0, S)
780
+ var tag = [];
781
+ this.cipher.encrypt(this._j0, tag);
782
+ for(var i = 0; i < this._ints; ++i) {
783
+ this.tag.putInt32(this._s[i] ^ tag[i]);
784
+ }
785
+
786
+ // trim tag to length
787
+ this.tag.truncate(this.tag.length() % (this._tagLength / 8));
788
+
789
+ // check authentication tag
790
+ if(options.decrypt && this.tag.bytes() !== this._tag) {
791
+ rval = false;
792
+ }
793
+
794
+ return rval;
795
+ };
796
+
797
+ /**
798
+ * See NIST SP-800-38D 6.3 (Algorithm 1). This function performs Galois
799
+ * field multiplication. The field, GF(2^128), is defined by the polynomial:
800
+ *
801
+ * x^128 + x^7 + x^2 + x + 1
802
+ *
803
+ * Which is represented in little-endian binary form as: 11100001 (0xe1). When
804
+ * the value of a coefficient is 1, a bit is set. The value R, is the
805
+ * concatenation of this value and 120 zero bits, yielding a 128-bit value
806
+ * which matches the block size.
807
+ *
808
+ * This function will multiply two elements (vectors of bytes), X and Y, in
809
+ * the field GF(2^128). The result is initialized to zero. For each bit of
810
+ * X (out of 128), x_i, if x_i is set, then the result is multiplied (XOR'd)
811
+ * by the current value of Y. For each bit, the value of Y will be raised by
812
+ * a power of x (multiplied by the polynomial x). This can be achieved by
813
+ * shifting Y once to the right. If the current value of Y, prior to being
814
+ * multiplied by x, has 0 as its LSB, then it is a 127th degree polynomial.
815
+ * Otherwise, we must divide by R after shifting to find the remainder.
816
+ *
817
+ * @param x the first block to multiply by the second.
818
+ * @param y the second block to multiply by the first.
819
+ *
820
+ * @return the block result of the multiplication.
821
+ */
822
+ modes.gcm.prototype.multiply = function(x, y) {
823
+ var z_i = [0, 0, 0, 0];
824
+ var v_i = y.slice(0);
825
+
826
+ // calculate Z_128 (block has 128 bits)
827
+ for(var i = 0; i < 128; ++i) {
828
+ // if x_i is 0, Z_{i+1} = Z_i (unchanged)
829
+ // else Z_{i+1} = Z_i ^ V_i
830
+ // get x_i by finding 32-bit int position, then left shift 1 by remainder
831
+ var x_i = x[(i / 32) | 0] & (1 << (31 - i % 32));
832
+ if(x_i) {
833
+ z_i[0] ^= v_i[0];
834
+ z_i[1] ^= v_i[1];
835
+ z_i[2] ^= v_i[2];
836
+ z_i[3] ^= v_i[3];
837
+ }
838
+
839
+ // if LSB(V_i) is 1, V_i = V_i >> 1
840
+ // else V_i = (V_i >> 1) ^ R
841
+ this.pow(v_i, v_i);
842
+ }
843
+
844
+ return z_i;
845
+ };
846
+
847
+ modes.gcm.prototype.pow = function(x, out) {
848
+ // if LSB(x) is 1, x = x >>> 1
849
+ // else x = (x >>> 1) ^ R
850
+ var lsb = x[3] & 1;
851
+
852
+ // always do x >>> 1:
853
+ // starting with the rightmost integer, shift each integer to the right
854
+ // one bit, pulling in the bit from the integer to the left as its top
855
+ // most bit (do this for the last 3 integers)
856
+ for(var i = 3; i > 0; --i) {
857
+ out[i] = (x[i] >>> 1) | ((x[i - 1] & 1) << 31);
858
+ }
859
+ // shift the first integer normally
860
+ out[0] = x[0] >>> 1;
861
+
862
+ // if lsb was not set, then polynomial had a degree of 127 and doesn't
863
+ // need to divided; otherwise, XOR with R to find the remainder; we only
864
+ // need to XOR the first integer since R technically ends w/120 zero bits
865
+ if(lsb) {
866
+ out[0] ^= this._R;
867
+ }
868
+ };
869
+
870
+ modes.gcm.prototype.tableMultiply = function(x) {
871
+ // assumes 4-bit tables are used
872
+ var z = [0, 0, 0, 0];
873
+ for(var i = 0; i < 32; ++i) {
874
+ var idx = (i / 8) | 0;
875
+ var x_i = (x[idx] >>> ((7 - (i % 8)) * 4)) & 0xF;
876
+ var ah = this._m[i][x_i];
877
+ z[0] ^= ah[0];
878
+ z[1] ^= ah[1];
879
+ z[2] ^= ah[2];
880
+ z[3] ^= ah[3];
881
+ }
882
+ return z;
883
+ };
884
+
885
+ /**
886
+ * A continuing version of the GHASH algorithm that operates on a single
887
+ * block. The hash block, last hash value (Ym) and the new block to hash
888
+ * are given.
889
+ *
890
+ * @param h the hash block.
891
+ * @param y the previous value for Ym, use [0, 0, 0, 0] for a new hash.
892
+ * @param x the block to hash.
893
+ *
894
+ * @return the hashed value (Ym).
895
+ */
896
+ modes.gcm.prototype.ghash = function(h, y, x) {
897
+ y[0] ^= x[0];
898
+ y[1] ^= x[1];
899
+ y[2] ^= x[2];
900
+ y[3] ^= x[3];
901
+ return this.tableMultiply(y);
902
+ //return this.multiply(y, h);
903
+ };
904
+
905
+ /**
906
+ * Precomputes a table for multiplying against the hash subkey. This
907
+ * mechanism provides a substantial speed increase over multiplication
908
+ * performed without a table. The table-based multiplication this table is
909
+ * for solves X * H by multiplying each component of X by H and then
910
+ * composing the results together using XOR.
911
+ *
912
+ * This function can be used to generate tables with different bit sizes
913
+ * for the components, however, this implementation assumes there are
914
+ * 32 components of X (which is a 16 byte vector), therefore each component
915
+ * takes 4-bits (so the table is constructed with bits=4).
916
+ *
917
+ * @param h the hash subkey.
918
+ * @param bits the bit size for a component.
919
+ */
920
+ modes.gcm.prototype.generateHashTable = function(h, bits) {
921
+ // TODO: There are further optimizations that would use only the
922
+ // first table M_0 (or some variant) along with a remainder table;
923
+ // this can be explored in the future
924
+ var multiplier = 8 / bits;
925
+ var perInt = 4 * multiplier;
926
+ var size = 16 * multiplier;
927
+ var m = new Array(size);
928
+ for(var i = 0; i < size; ++i) {
929
+ var tmp = [0, 0, 0, 0];
930
+ var idx = (i / perInt) | 0;
931
+ var shft = ((perInt - 1 - (i % perInt)) * bits);
932
+ tmp[idx] = (1 << (bits - 1)) << shft;
933
+ m[i] = this.generateSubHashTable(this.multiply(tmp, h), bits);
934
+ }
935
+ return m;
936
+ };
937
+
938
+ /**
939
+ * Generates a table for multiplying against the hash subkey for one
940
+ * particular component (out of all possible component values).
941
+ *
942
+ * @param mid the pre-multiplied value for the middle key of the table.
943
+ * @param bits the bit size for a component.
944
+ */
945
+ modes.gcm.prototype.generateSubHashTable = function(mid, bits) {
946
+ // compute the table quickly by minimizing the number of
947
+ // POW operations -- they only need to be performed for powers of 2,
948
+ // all other entries can be composed from those powers using XOR
949
+ var size = 1 << bits;
950
+ var half = size >>> 1;
951
+ var m = new Array(size);
952
+ m[half] = mid.slice(0);
953
+ var i = half >>> 1;
954
+ while(i > 0) {
955
+ // raise m0[2 * i] and store in m0[i]
956
+ this.pow(m[2 * i], m[i] = []);
957
+ i >>= 1;
958
+ }
959
+ i = 2;
960
+ while(i < half) {
961
+ for(var j = 1; j < i; ++j) {
962
+ var m_i = m[i];
963
+ var m_j = m[j];
964
+ m[i + j] = [
965
+ m_i[0] ^ m_j[0],
966
+ m_i[1] ^ m_j[1],
967
+ m_i[2] ^ m_j[2],
968
+ m_i[3] ^ m_j[3]
969
+ ];
970
+ }
971
+ i *= 2;
972
+ }
973
+ m[0] = [0, 0, 0, 0];
974
+ /* Note: We could avoid storing these by doing composition during multiply
975
+ calculate top half using composition by speed is preferred. */
976
+ for(i = half + 1; i < size; ++i) {
977
+ var c = m[i ^ half];
978
+ m[i] = [mid[0] ^ c[0], mid[1] ^ c[1], mid[2] ^ c[2], mid[3] ^ c[3]];
979
+ }
980
+ return m;
981
+ };
982
+
983
+ /** Utility functions */
984
+
985
+ function transformIV(iv, blockSize) {
986
+ if(typeof iv === 'string') {
987
+ // convert iv string into byte buffer
988
+ iv = forge.util.createBuffer(iv);
989
+ }
990
+
991
+ if(forge.util.isArray(iv) && iv.length > 4) {
992
+ // convert iv byte array into byte buffer
993
+ var tmp = iv;
994
+ iv = forge.util.createBuffer();
995
+ for(var i = 0; i < tmp.length; ++i) {
996
+ iv.putByte(tmp[i]);
997
+ }
998
+ }
999
+
1000
+ if(iv.length() < blockSize) {
1001
+ throw new Error(
1002
+ 'Invalid IV length; got ' + iv.length() +
1003
+ ' bytes and expected ' + blockSize + ' bytes.');
1004
+ }
1005
+
1006
+ if(!forge.util.isArray(iv)) {
1007
+ // convert iv byte buffer into 32-bit integer array
1008
+ var ints = [];
1009
+ var blocks = blockSize / 4;
1010
+ for(var i = 0; i < blocks; ++i) {
1011
+ ints.push(iv.getInt32());
1012
+ }
1013
+ iv = ints;
1014
+ }
1015
+
1016
+ return iv;
1017
+ }
1018
+
1019
+ function inc32(block) {
1020
+ // increment last 32 bits of block only
1021
+ block[block.length - 1] = (block[block.length - 1] + 1) & 0xFFFFFFFF;
1022
+ }
1023
+
1024
+ function from64To32(num) {
1025
+ // convert 64-bit number to two BE Int32s
1026
+ return [(num / 0x100000000) | 0, num & 0xFFFFFFFF];
1027
+ }