@awacloud/fw 0.1.0 → 1.0.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 (609) hide show
  1. package/CHANGELOG.md +125 -0
  2. package/NOTICE +8 -0
  3. package/README.md +163 -31
  4. package/dist/build/fw.core.pure.meta.json +6 -6
  5. package/dist/build/fw.core.pure.min.js +15 -12
  6. package/dist/build/fw.full.pure.meta.json +13 -7
  7. package/dist/build/fw.full.pure.min.js +45 -42
  8. package/dist/build/fw.minimal.pure.meta.json +6 -6
  9. package/dist/build/fw.minimal.pure.min.js +16 -13
  10. package/dist/build/fw.pack.compress-heavy.pure.meta.json +6 -6
  11. package/dist/build/fw.pack.compress-heavy.pure.min.js +3 -3
  12. package/dist/build/fw.pack.crypto-advanced.pure.meta.json +6 -6
  13. package/dist/build/fw.pack.crypto-advanced.pure.min.js +1 -1
  14. package/dist/build/fw.pack.crypto-basic.pure.meta.json +6 -6
  15. package/dist/build/fw.pack.crypto-basic.pure.min.js +1 -1
  16. package/dist/build/fw.pack.crypto-identity.pure.meta.json +7 -6
  17. package/dist/build/fw.pack.crypto-identity.pure.min.js +4 -4
  18. package/dist/build/fw.pwa.pure.meta.json +7 -6
  19. package/dist/build/fw.pwa.pure.min.js +38 -35
  20. package/dist/build/fw.site-interactive.pure.meta.json +6 -6
  21. package/dist/build/fw.site-interactive.pure.min.js +37 -34
  22. package/dist/build/fw.site.pure.meta.json +6 -6
  23. package/dist/build/fw.site.pure.min.js +24 -21
  24. package/dist/build/fw.spa.pure.meta.json +8 -7
  25. package/dist/build/fw.spa.pure.min.js +41 -38
  26. package/dist/build/sanity-base-classic.min.js +1 -1
  27. package/dist/build/sanity.min.js +1 -1
  28. package/dist/types/core/internal.d.ts +29 -0
  29. package/dist/types/core/internal.d.ts.map +1 -0
  30. package/dist/types/core/logger.d.ts +23 -4
  31. package/dist/types/core/logger.d.ts.map +1 -1
  32. package/dist/types/core/modules.d.ts +374 -61
  33. package/dist/types/core/modules.d.ts.map +1 -1
  34. package/dist/types/core/runtime.d.ts +10 -6
  35. package/dist/types/core/runtime.d.ts.map +1 -1
  36. package/dist/types/core/worker-helper.d.ts +35 -0
  37. package/dist/types/core/worker-helper.d.ts.map +1 -1
  38. package/dist/types/crypto/cipher/aes.d.ts +1 -7
  39. package/dist/types/crypto/cipher/aes.d.ts.map +1 -1
  40. package/dist/types/crypto/cipher/chacha20.d.ts +0 -10
  41. package/dist/types/crypto/cipher/chacha20.d.ts.map +1 -1
  42. package/dist/types/crypto/hash/argon2.d.ts +0 -15
  43. package/dist/types/crypto/hash/argon2.d.ts.map +1 -1
  44. package/dist/types/crypto/hash/blake2b.d.ts.map +1 -1
  45. package/dist/types/crypto/hash/hmac.d.ts.map +1 -1
  46. package/dist/types/crypto/hash/pbkdf2.d.ts.map +1 -1
  47. package/dist/types/crypto/hash/poly1305.d.ts.map +1 -1
  48. package/dist/types/crypto/hash/sha224.d.ts +1 -1
  49. package/dist/types/crypto/hash/sha256.d.ts +4 -13
  50. package/dist/types/crypto/hash/sha256.d.ts.map +1 -1
  51. package/dist/types/crypto/hash/sha3.d.ts.map +1 -1
  52. package/dist/types/crypto/hash/sha384.d.ts +1 -1
  53. package/dist/types/crypto/hash/sha512.d.ts +4 -13
  54. package/dist/types/crypto/hash/sha512.d.ts.map +1 -1
  55. package/dist/types/crypto/mode/cmac.d.ts +0 -6
  56. package/dist/types/crypto/mode/cmac.d.ts.map +1 -1
  57. package/dist/types/crypto/mode/ctr.d.ts +0 -6
  58. package/dist/types/crypto/mode/ctr.d.ts.map +1 -1
  59. package/dist/types/crypto/mode/gcm.d.ts +0 -9
  60. package/dist/types/crypto/mode/gcm.d.ts.map +1 -1
  61. package/dist/types/crypto/pkc/ecc.d.ts +0 -1
  62. package/dist/types/crypto/pkc/ecc.d.ts.map +1 -1
  63. package/dist/types/crypto/pkc/ed25519.d.ts +4 -25
  64. package/dist/types/crypto/pkc/ed25519.d.ts.map +1 -1
  65. package/dist/types/crypto/pkc/hybridSign.d.ts +25 -5
  66. package/dist/types/crypto/pkc/hybridSign.d.ts.map +1 -1
  67. package/dist/types/crypto/pkc/ml_dsa.d.ts +6 -26
  68. package/dist/types/crypto/pkc/ml_dsa.d.ts.map +1 -1
  69. package/dist/types/crypto/pkc/ml_kem.d.ts +0 -43
  70. package/dist/types/crypto/pkc/ml_kem.d.ts.map +1 -1
  71. package/dist/types/crypto/pkc/rsa.d.ts +0 -24
  72. package/dist/types/crypto/pkc/rsa.d.ts.map +1 -1
  73. package/dist/types/crypto/pkc/slh_dsa.d.ts +6 -16
  74. package/dist/types/crypto/pkc/slh_dsa.d.ts.map +1 -1
  75. package/dist/types/crypto/pkc/x25519.d.ts +0 -6
  76. package/dist/types/crypto/pkc/x25519.d.ts.map +1 -1
  77. package/dist/types/crypto/utils/bitArray.d.ts +0 -8
  78. package/dist/types/crypto/utils/bitArray.d.ts.map +1 -1
  79. package/dist/types/crypto/utils/jws.d.ts +6 -14
  80. package/dist/types/crypto/utils/jws.d.ts.map +1 -1
  81. package/dist/types/crypto/utils/keyformat.d.ts +52 -0
  82. package/dist/types/crypto/utils/keyformat.d.ts.map +1 -1
  83. package/dist/types/crypto/utils/random.d.ts +1 -10
  84. package/dist/types/crypto/utils/random.d.ts.map +1 -1
  85. package/dist/types/crypto/utils/rsaKeygen.d.ts +0 -10
  86. package/dist/types/crypto/utils/rsaKeygen.d.ts.map +1 -1
  87. package/dist/types/crypto/utils/uuid.d.ts.map +1 -1
  88. package/dist/types/crypto/utils/x509.d.ts +397 -0
  89. package/dist/types/crypto/utils/x509.d.ts.map +1 -0
  90. package/dist/types/crypto/wasm/argon2.d.ts +2 -1
  91. package/dist/types/crypto/wasm/argon2.d.ts.map +1 -1
  92. package/dist/types/crypto/wasm/pbkdf2.d.ts +2 -2
  93. package/dist/types/crypto/wasm/pbkdf2.d.ts.map +1 -1
  94. package/dist/types/crypto/wasm/rsa.d.ts.map +1 -1
  95. package/dist/types/crypto/wasm/runtime.d.ts +13 -0
  96. package/dist/types/crypto/wasm/runtime.d.ts.map +1 -1
  97. package/dist/types/crypto/webcrypto/aes.d.ts.map +1 -1
  98. package/dist/types/crypto/webcrypto/aeskw.d.ts.map +1 -1
  99. package/dist/types/crypto/webcrypto/digest.d.ts +0 -4
  100. package/dist/types/crypto/webcrypto/digest.d.ts.map +1 -1
  101. package/dist/types/crypto/webcrypto/rsa.d.ts.map +1 -1
  102. package/dist/types/dom/fs/fileIntake.d.ts +59 -0
  103. package/dist/types/dom/fs/fileIntake.d.ts.map +1 -0
  104. package/dist/types/dom/fs/fsAccess.d.ts.map +1 -1
  105. package/dist/types/dom/query/dnd.d.ts.map +1 -1
  106. package/dist/types/dom/query/sound.d.ts +89 -0
  107. package/dist/types/dom/query/sound.d.ts.map +1 -0
  108. package/dist/types/dom/rendering/chart.d.ts.map +1 -1
  109. package/dist/types/dom/rendering/component.d.ts +9 -3
  110. package/dist/types/dom/rendering/component.d.ts.map +1 -1
  111. package/dist/types/dom/rendering/parser.d.ts +39 -0
  112. package/dist/types/dom/rendering/parser.d.ts.map +1 -1
  113. package/dist/types/dom/rendering/render.d.ts.map +1 -1
  114. package/dist/types/dom/rendering/sanitize.d.ts +4 -0
  115. package/dist/types/dom/rendering/sanitize.d.ts.map +1 -1
  116. package/dist/types/dom/rendering/secPolicy.d.ts.map +1 -1
  117. package/dist/types/dom/rendering/styleSheet.d.ts +74 -0
  118. package/dist/types/dom/rendering/styleSheet.d.ts.map +1 -0
  119. package/dist/types/dom/rendering/template.d.ts +9 -3
  120. package/dist/types/dom/rendering/template.d.ts.map +1 -1
  121. package/dist/types/dom/rendering/themeTokens.d.ts +9 -3
  122. package/dist/types/dom/rendering/themeTokens.d.ts.map +1 -1
  123. package/dist/types/dom/rendering/uiSession-core.d.ts +9 -3
  124. package/dist/types/dom/rendering/uiSession-core.d.ts.map +1 -1
  125. package/dist/types/dom/rendering/uiSession-list.d.ts +9 -3
  126. package/dist/types/dom/rendering/uiSession-list.d.ts.map +1 -1
  127. package/dist/types/dom/rendering/uiSession.d.ts +18 -6
  128. package/dist/types/dom/rendering/uiSession.d.ts.map +1 -1
  129. package/dist/types/dom/sw/installPrompt.d.ts +89 -0
  130. package/dist/types/dom/sw/installPrompt.d.ts.map +1 -0
  131. package/dist/types/dom/sw/precache.d.ts +149 -0
  132. package/dist/types/dom/sw/precache.d.ts.map +1 -0
  133. package/dist/types/dom/sw/swUpdate.d.ts +129 -0
  134. package/dist/types/dom/sw/swUpdate.d.ts.map +1 -0
  135. package/dist/types/dom/utils/clipboard.d.ts +8 -0
  136. package/dist/types/dom/utils/clipboard.d.ts.map +1 -1
  137. package/dist/types/dom/utils/keybindings.d.ts.map +1 -1
  138. package/dist/types/dom/utils/route.d.ts.map +1 -1
  139. package/dist/types/dom/utils/ua.d.ts +2 -2
  140. package/dist/types/dom/utils/ua.d.ts.map +1 -1
  141. package/dist/types/io/calc/crc32.d.ts.map +1 -1
  142. package/dist/types/io/codec/b64.d.ts +24 -0
  143. package/dist/types/io/codec/b64.d.ts.map +1 -1
  144. package/dist/types/io/codec/cbor.d.ts +1 -0
  145. package/dist/types/io/codec/cbor.d.ts.map +1 -1
  146. package/dist/types/io/codec/hex.d.ts.map +1 -1
  147. package/dist/types/io/codec/msgpack.d.ts +1 -0
  148. package/dist/types/io/codec/msgpack.d.ts.map +1 -1
  149. package/dist/types/io/codec/url.d.ts +3 -1
  150. package/dist/types/io/codec/url.d.ts.map +1 -1
  151. package/dist/types/io/codec/utf8.d.ts.map +1 -1
  152. package/dist/types/io/compress/bitstream.d.ts +1 -1
  153. package/dist/types/io/compress/brotli.d.ts +0 -1
  154. package/dist/types/io/compress/brotli.d.ts.map +1 -1
  155. package/dist/types/io/compress/brotli_shared.d.ts +0 -4
  156. package/dist/types/io/compress/brotli_shared.d.ts.map +1 -1
  157. package/dist/types/io/compress/deflate.d.ts +14 -1
  158. package/dist/types/io/compress/deflate.d.ts.map +1 -1
  159. package/dist/types/io/compress/gzip.d.ts +4 -0
  160. package/dist/types/io/compress/gzip.d.ts.map +1 -1
  161. package/dist/types/io/compress/huffman.d.ts +7 -0
  162. package/dist/types/io/compress/huffman.d.ts.map +1 -1
  163. package/dist/types/io/compress/lz4.d.ts +4 -2
  164. package/dist/types/io/compress/lz4.d.ts.map +1 -1
  165. package/dist/types/io/compress/lz77.d.ts +17 -0
  166. package/dist/types/io/compress/lz77.d.ts.map +1 -1
  167. package/dist/types/io/compress/lzw.d.ts +2 -0
  168. package/dist/types/io/compress/lzw.d.ts.map +1 -1
  169. package/dist/types/io/compress/zip.d.ts.map +1 -1
  170. package/dist/types/io/compress/zlib.d.ts +9 -2
  171. package/dist/types/io/compress/zlib.d.ts.map +1 -1
  172. package/dist/types/io/math/linalg.d.ts.map +1 -1
  173. package/dist/types/process/rpc.d.ts.map +1 -1
  174. package/dist/types/process/workerPool.d.ts.map +1 -1
  175. package/dist/types/sanity/base.d.ts +12 -2
  176. package/dist/types/sanity/base.d.ts.map +1 -1
  177. package/dist/types/sanity/lockdown.d.ts +6 -5
  178. package/dist/types/sanity/lockdown.d.ts.map +1 -1
  179. package/dist/types/sanity/wasm-gate.d.ts +1 -1
  180. package/docs/README.md +17 -10
  181. package/docs/api/README.md +5 -5
  182. package/docs/api/core/logger.md +2 -1
  183. package/docs/api/core/modules.md +3 -3
  184. package/docs/api/core/runtime.md +9 -9
  185. package/docs/api/core/worker-helper.md +12 -2
  186. package/docs/api/crypto/README.md +1 -1
  187. package/docs/api/crypto/cipher/README.md +2 -2
  188. package/docs/api/crypto/cipher/aes.md +5 -10
  189. package/docs/api/crypto/cipher/chacha20.md +3 -8
  190. package/docs/api/crypto/hash/README.md +5 -5
  191. package/docs/api/crypto/hash/adf.md +21 -11
  192. package/docs/api/crypto/hash/argon2.md +3 -12
  193. package/docs/api/crypto/hash/blake2b.md +12 -14
  194. package/docs/api/crypto/hash/pbkdf2.md +1 -1
  195. package/docs/api/crypto/hash/sha224.md +2 -2
  196. package/docs/api/crypto/hash/sha256.md +4 -4
  197. package/docs/api/crypto/hash/sha3.md +2 -2
  198. package/docs/api/crypto/hash/sha384.md +1 -1
  199. package/docs/api/crypto/hash/sha512.md +5 -5
  200. package/docs/api/crypto/hash/sha512_224.md +1 -1
  201. package/docs/api/crypto/hash/sha512_256.md +1 -1
  202. package/docs/api/crypto/mode/README.md +3 -3
  203. package/docs/api/crypto/mode/cbc.md +2 -2
  204. package/docs/api/crypto/mode/chacha20poly1305.md +1 -1
  205. package/docs/api/crypto/mode/cmac.md +4 -4
  206. package/docs/api/crypto/mode/ctr.md +2 -3
  207. package/docs/api/crypto/mode/gcm.md +5 -5
  208. package/docs/api/crypto/mode/kw.md +4 -4
  209. package/docs/api/crypto/pkc/README.md +8 -8
  210. package/docs/api/crypto/pkc/ecc.md +19 -17
  211. package/docs/api/crypto/pkc/ed25519.md +10 -15
  212. package/docs/api/crypto/pkc/hybridKem.md +8 -2
  213. package/docs/api/crypto/pkc/hybridSign.md +34 -7
  214. package/docs/api/crypto/pkc/ml_dsa.md +20 -19
  215. package/docs/api/crypto/pkc/ml_kem.md +3 -3
  216. package/docs/api/crypto/pkc/rsa.md +7 -9
  217. package/docs/api/crypto/pkc/slh_dsa.md +12 -12
  218. package/docs/api/crypto/pkc/x25519.md +5 -4
  219. package/docs/api/crypto/utils/README.md +7 -7
  220. package/docs/api/crypto/utils/aes_modes.md +2 -5
  221. package/docs/api/crypto/utils/asn1.md +25 -16
  222. package/docs/api/crypto/utils/jws.md +6 -4
  223. package/docs/api/crypto/utils/keyformat.md +24 -15
  224. package/docs/api/crypto/utils/pad.md +1 -1
  225. package/docs/api/crypto/utils/pem.md +3 -3
  226. package/docs/api/crypto/utils/random.md +3 -4
  227. package/docs/api/crypto/utils/rsaKeygen.md +2 -2
  228. package/docs/api/crypto/utils/totp.md +2 -2
  229. package/docs/api/crypto/utils/uuid.md +5 -5
  230. package/docs/api/crypto/utils/x509.md +124 -0
  231. package/docs/api/crypto/wasm/aes.md +1 -1
  232. package/docs/api/crypto/wasm/argon2.md +6 -4
  233. package/docs/api/crypto/wasm/ml_kem.md +1 -0
  234. package/docs/api/crypto/wasm/pbkdf2.md +8 -8
  235. package/docs/api/crypto/wasm/rsa.md +1 -1
  236. package/docs/api/crypto/wasm/runtime.md +27 -10
  237. package/docs/api/crypto/webcrypto/aes.md +1 -1
  238. package/docs/api/crypto/webcrypto/aeskw.md +2 -2
  239. package/docs/api/crypto/webcrypto/digest.md +3 -5
  240. package/docs/api/crypto/webcrypto/ecc.md +1 -1
  241. package/docs/api/crypto/webcrypto/ed25519.md +1 -1
  242. package/docs/api/crypto/webcrypto/rsa.md +3 -2
  243. package/docs/api/crypto/webcrypto/x25519.md +1 -1
  244. package/docs/api/dom/README.md +6 -1
  245. package/docs/api/dom/fs/README.md +1 -0
  246. package/docs/api/dom/fs/fileIntake.md +120 -0
  247. package/docs/api/dom/fs/fsAccess.md +1 -0
  248. package/docs/api/dom/fs/indexedDB.md +1 -1
  249. package/docs/api/dom/fs/storage.md +1 -1
  250. package/docs/api/dom/query/README.md +2 -1
  251. package/docs/api/dom/query/dnd.md +4 -1
  252. package/docs/api/dom/query/dom.md +5 -0
  253. package/docs/api/dom/query/sound.md +103 -0
  254. package/docs/api/dom/rendering/README.md +4 -3
  255. package/docs/api/dom/rendering/chart.md +5 -4
  256. package/docs/api/dom/rendering/component.md +25 -3
  257. package/docs/api/dom/rendering/parser.md +5 -2
  258. package/docs/api/dom/rendering/reactiveBind.md +1 -1
  259. package/docs/api/dom/rendering/render.md +2 -2
  260. package/docs/api/dom/rendering/sanitize.md +10 -2
  261. package/docs/api/dom/rendering/secPolicy.md +4 -4
  262. package/docs/api/dom/rendering/styleSheet.md +85 -0
  263. package/docs/api/dom/rendering/template.md +20 -5
  264. package/docs/api/dom/rendering/themeTokens.md +6 -3
  265. package/docs/api/dom/rendering/uiSession.md +18 -5
  266. package/docs/api/dom/rendering/virtualScroll.md +2 -2
  267. package/docs/api/dom/sensors/geolocation.md +1 -1
  268. package/docs/api/dom/sw/README.md +7 -1
  269. package/docs/api/dom/sw/cache.md +2 -1
  270. package/docs/api/dom/sw/installPrompt.md +111 -0
  271. package/docs/api/dom/sw/precache.md +124 -0
  272. package/docs/api/dom/sw/serviceWorker.md +4 -2
  273. package/docs/api/dom/sw/swUpdate.md +112 -0
  274. package/docs/api/dom/utils/clipboard.md +56 -5
  275. package/docs/api/dom/utils/entropyCollector.md +1 -1
  276. package/docs/api/dom/utils/keybindings.md +17 -2
  277. package/docs/api/dom/utils/leaderElection.md +2 -2
  278. package/docs/api/dom/utils/route.md +1 -0
  279. package/docs/api/dom/utils/ua.md +15 -10
  280. package/docs/api/io/calc/crc32.md +4 -1
  281. package/docs/api/io/codec/README.md +2 -2
  282. package/docs/api/io/codec/b64.md +31 -2
  283. package/docs/api/io/codec/buffer.md +1 -1
  284. package/docs/api/io/codec/cbor.md +6 -4
  285. package/docs/api/io/codec/csv.md +178 -178
  286. package/docs/api/io/codec/hex.md +10 -2
  287. package/docs/api/io/codec/msgpack.md +4 -3
  288. package/docs/api/io/codec/url.md +4 -3
  289. package/docs/api/io/codec/utf8.md +3 -3
  290. package/docs/api/io/compress/bitstream.md +6 -3
  291. package/docs/api/io/compress/brotli.md +36 -4
  292. package/docs/api/io/compress/brotli_shared.md +1 -1
  293. package/docs/api/io/compress/deflate.md +42 -34
  294. package/docs/api/io/compress/gzip.md +26 -6
  295. package/docs/api/io/compress/huffman.md +2 -1
  296. package/docs/api/io/compress/lz4.md +5 -3
  297. package/docs/api/io/compress/lz77.md +26 -3
  298. package/docs/api/io/compress/lzw.md +13 -8
  299. package/docs/api/io/compress/zip.md +36 -10
  300. package/docs/api/io/compress/zlib.md +21 -5
  301. package/docs/api/io/math/linalg.md +1 -1
  302. package/docs/api/io/utils/valid.md +1 -1
  303. package/docs/api/process/rpc.md +3 -2
  304. package/docs/api/process/workerPool.md +1 -1
  305. package/docs/api/sanity/base.md +9 -5
  306. package/docs/api/sanity/lockdown.md +7 -6
  307. package/docs/api/surface.json +12311 -0
  308. package/docs/api/typed.md +5 -3
  309. package/docs/dev/README.md +2 -0
  310. package/docs/dev/bench.md +76 -0
  311. package/docs/dev/crypto-references.md +54 -0
  312. package/docs/dev/provenance.md +30 -7
  313. package/docs/dev/publishing.md +7 -7
  314. package/docs/dev/runtime.md +1 -1
  315. package/docs/dev/testing.md +13 -0
  316. package/docs/evidence/l4-evidence.md +86 -0
  317. package/docs/evidence/pqc-hybrid-evidence.md +7 -6
  318. package/docs/guide/README.md +1 -0
  319. package/docs/guide/_QUICK_REF.md +5 -5
  320. package/docs/guide/doc-format.md +4 -3
  321. package/docs/guide/integrations-hmr.md +1 -1
  322. package/docs/guide/module-creation-workflow.md +8 -8
  323. package/docs/guide/rendering-pipeline.md +11 -4
  324. package/docs/guide/security.md +7 -5
  325. package/docs/guide/stability.md +123 -0
  326. package/docs/guide/tutorial-todo.md +20 -8
  327. package/docs/guide/typescript.md +9 -0
  328. package/docs/guide/worker-confinement.md +30 -17
  329. package/docs/notes/lz77-deflate-factorization.md +3 -3
  330. package/docs/tools/README.md +1 -1
  331. package/docs/tools/bundler.md +3 -3
  332. package/docs/tools/codegen.md +1 -1
  333. package/docs/tools/standalone.md +0 -1
  334. package/fw.config.json +2 -2
  335. package/integrations/_shared/catalog.generated.json +7 -1
  336. package/integrations/_shared/core.js +1 -1
  337. package/integrations/astro/index.js +1 -1
  338. package/integrations/eslint/README.md +7 -1
  339. package/integrations/nextjs/index.js +1 -1
  340. package/integrations/nodejs/README.md +3 -3
  341. package/integrations/turbopack/index.js +2 -2
  342. package/integrations/typedoc/categorize.js +1 -1
  343. package/integrations/typedoc/typedoc.json +2 -1
  344. package/integrations/vite/index.js +2 -2
  345. package/integrations/vite/vite-env.d.ts +7 -4
  346. package/integrations/webpack/index.js +3 -3
  347. package/package.json +76 -10
  348. package/src/core/internal.js +31 -0
  349. package/src/core/logger.js +95 -23
  350. package/src/core/modules.js +17 -8
  351. package/src/core/readyState.js +1 -1
  352. package/src/core/runtime.js +74 -27
  353. package/src/core/worker-helper.js +83 -4
  354. package/src/crypto/NIST_CONFORMANCE.md +47 -34
  355. package/src/crypto/cipher/aes.acvp.md +7 -8
  356. package/src/crypto/cipher/aes.js +280 -229
  357. package/src/crypto/cipher/chacha20.acvp.md +6 -7
  358. package/src/crypto/cipher/chacha20.js +91 -61
  359. package/src/crypto/hash/adf.js +1 -1
  360. package/src/crypto/hash/argon2.acvp.md +11 -15
  361. package/src/crypto/hash/argon2.js +9 -24
  362. package/src/crypto/hash/blake2b.js +157 -125
  363. package/src/crypto/hash/hkdf.acvp.md +15 -15
  364. package/src/crypto/hash/hkdf.js +1 -1
  365. package/src/crypto/hash/hmac.acvp.md +10 -12
  366. package/src/crypto/hash/hmac.js +5 -1
  367. package/src/crypto/hash/pbkdf2.acvp.md +13 -13
  368. package/src/crypto/hash/pbkdf2.js +36 -8
  369. package/src/crypto/hash/poly1305.acvp.md +10 -6
  370. package/src/crypto/hash/poly1305.js +171 -50
  371. package/src/crypto/hash/sha224.acvp.md +3 -3
  372. package/src/crypto/hash/sha224.js +4 -4
  373. package/src/crypto/hash/sha256.acvp.md +2 -2
  374. package/src/crypto/hash/sha256.js +514 -50
  375. package/src/crypto/hash/sha3.acvp.md +9 -9
  376. package/src/crypto/hash/sha3.js +127 -71
  377. package/src/crypto/hash/sha384.acvp.md +3 -3
  378. package/src/crypto/hash/sha384.js +4 -4
  379. package/src/crypto/hash/sha512.acvp.md +7 -8
  380. package/src/crypto/hash/sha512.js +107 -108
  381. package/src/crypto/hash/sha512_224.acvp.md +6 -6
  382. package/src/crypto/hash/sha512_224.js +2 -2
  383. package/src/crypto/hash/sha512_256.acvp.md +6 -6
  384. package/src/crypto/hash/sha512_256.js +2 -2
  385. package/src/crypto/mode/cbc.acvp.md +2 -2
  386. package/src/crypto/mode/cbc.js +1 -1
  387. package/src/crypto/mode/chacha20poly1305.acvp.md +6 -6
  388. package/src/crypto/mode/chacha20poly1305.js +3 -3
  389. package/src/crypto/mode/cmac.acvp.md +5 -5
  390. package/src/crypto/mode/cmac.js +8 -8
  391. package/src/crypto/mode/ctr.acvp.md +2 -2
  392. package/src/crypto/mode/ctr.js +1 -3
  393. package/src/crypto/mode/gcm.acvp.md +6 -6
  394. package/src/crypto/mode/gcm.js +7 -7
  395. package/src/crypto/mode/kw.acvp.md +4 -4
  396. package/src/crypto/mode/kw.js +5 -5
  397. package/src/crypto/pkc/ecc.acvp.md +13 -13
  398. package/src/crypto/pkc/ecc.js +9 -11
  399. package/src/crypto/pkc/ed25519.acvp.md +30 -34
  400. package/src/crypto/pkc/ed25519.js +453 -94
  401. package/src/crypto/pkc/hybrid-kat.provenance.md +4 -4
  402. package/src/crypto/pkc/hybridSign.js +103 -24
  403. package/src/crypto/pkc/ml_dsa.acvp.md +18 -18
  404. package/src/crypto/pkc/ml_dsa.js +29 -32
  405. package/src/crypto/pkc/ml_kem.acvp.md +7 -7
  406. package/src/crypto/pkc/ml_kem.js +15 -21
  407. package/src/crypto/pkc/rsa.acvp.md +11 -15
  408. package/src/crypto/pkc/rsa.js +7 -44
  409. package/src/crypto/pkc/slh_dsa.acvp.md +16 -16
  410. package/src/crypto/pkc/slh_dsa.js +16 -18
  411. package/src/crypto/pkc/x25519.acvp.md +13 -10
  412. package/src/crypto/pkc/x25519.js +273 -29
  413. package/src/crypto/utils/aes_modes.acvp.md +1 -2
  414. package/src/crypto/utils/aes_modes.js +2 -2
  415. package/src/crypto/utils/asn1-oid.js +1 -1
  416. package/src/crypto/utils/asn1.js +1 -1
  417. package/src/crypto/utils/bitArray.js +33 -48
  418. package/src/crypto/utils/bn.js +1 -1
  419. package/src/crypto/utils/jws.js +37 -41
  420. package/src/crypto/utils/keyformat.js +181 -2
  421. package/src/crypto/utils/pem.js +1 -1
  422. package/src/crypto/utils/random.acvp.md +5 -5
  423. package/src/crypto/utils/random.js +845 -846
  424. package/src/crypto/utils/rsaKeygen.acvp.md +3 -2
  425. package/src/crypto/utils/rsaKeygen.js +6 -6
  426. package/src/crypto/utils/totp.js +1 -1
  427. package/src/crypto/utils/uuid.acvp.md +5 -5
  428. package/src/crypto/utils/uuid.js +11 -10
  429. package/src/crypto/utils/x509.js +591 -0
  430. package/src/crypto/wasm/aes.js +1 -1
  431. package/src/crypto/wasm/aes.scalar.wasm +0 -0
  432. package/src/crypto/wasm/argon2.js +17 -1
  433. package/src/crypto/wasm/argon2.scalar.wasm +0 -0
  434. package/src/crypto/wasm/blake2b.scalar.wasm +0 -0
  435. package/src/crypto/wasm/blake2b.simd.wasm +0 -0
  436. package/src/crypto/wasm/chacha20poly1305.scalar.wasm +0 -0
  437. package/src/crypto/wasm/chacha20poly1305.simd.wasm +0 -0
  438. package/src/crypto/wasm/cmac.scalar.wasm +0 -0
  439. package/src/crypto/wasm/ecc.js +3 -3
  440. package/src/crypto/wasm/ecc.scalar.wasm +0 -0
  441. package/src/crypto/wasm/ed25519.js +1 -1
  442. package/src/crypto/wasm/ed25519.scalar.wasm +0 -0
  443. package/src/crypto/wasm/hkdf.scalar.wasm +0 -0
  444. package/src/crypto/wasm/hmac.scalar.wasm +0 -0
  445. package/src/crypto/wasm/ml_dsa.js +2 -2
  446. package/src/crypto/wasm/ml_dsa.scalar.wasm +0 -0
  447. package/src/crypto/wasm/ml_dsa.simd.wasm +0 -0
  448. package/src/crypto/wasm/ml_kem.js +2 -2
  449. package/src/crypto/wasm/ml_kem.scalar.wasm +0 -0
  450. package/src/crypto/wasm/ml_kem.simd.wasm +0 -0
  451. package/src/crypto/wasm/pbkdf2.js +8 -6
  452. package/src/crypto/wasm/pbkdf2.scalar.wasm +0 -0
  453. package/src/crypto/wasm/rsa.js +6 -5
  454. package/src/crypto/wasm/rsa.scalar.wasm +0 -0
  455. package/src/crypto/wasm/runtime.js +84 -17
  456. package/src/crypto/wasm/sha2.scalar.wasm +0 -0
  457. package/src/crypto/wasm/sha3.scalar.wasm +0 -0
  458. package/src/crypto/wasm/sha3.simd.wasm +0 -0
  459. package/src/crypto/wasm/slh_dsa.js +1 -1
  460. package/src/crypto/wasm/slh_dsa.scalar.wasm +0 -0
  461. package/src/crypto/wasm/x25519.js +1 -1
  462. package/src/crypto/wasm/x25519.scalar.wasm +0 -0
  463. package/src/crypto/webcrypto/aes.js +8 -2
  464. package/src/crypto/webcrypto/aeskw.js +7 -2
  465. package/src/crypto/webcrypto/digest.js +1 -15
  466. package/src/crypto/webcrypto/ecc.js +2 -2
  467. package/src/crypto/webcrypto/ed25519.js +2 -2
  468. package/src/crypto/webcrypto/hmac.js +2 -2
  469. package/src/crypto/webcrypto/rsa.js +7 -2
  470. package/src/crypto/webcrypto/x25519.js +2 -2
  471. package/src/dom/display/animate.js +1 -1
  472. package/src/dom/display/fullscreen.js +1 -1
  473. package/src/dom/fs/download.js +1 -1
  474. package/src/dom/fs/fileIntake.js +192 -0
  475. package/src/dom/fs/fsAccess.js +2 -3
  476. package/src/dom/fs/indexedDB.js +1 -1
  477. package/src/dom/fs/remoteStore.js +1 -1
  478. package/src/dom/fs/storage.js +1 -1
  479. package/src/dom/lifecycle/idle.js +1 -1
  480. package/src/dom/lifecycle/visibility.js +1 -1
  481. package/src/dom/lifecycle/wakeLock.js +1 -1
  482. package/src/dom/net/ajax.js +1 -1
  483. package/src/dom/net/network.js +1 -1
  484. package/src/dom/net/sse.js +1 -1
  485. package/src/dom/net/webrtc.js +1 -1
  486. package/src/dom/net/ws.js +1 -1
  487. package/src/dom/query/dnd.js +56 -4
  488. package/src/dom/query/dom.js +1 -1
  489. package/src/dom/query/events.js +1 -1
  490. package/src/dom/query/gesture.js +1 -1
  491. package/src/dom/query/media.js +1 -1
  492. package/src/dom/query/sound.js +333 -0
  493. package/src/dom/rendering/chart.js +736 -663
  494. package/src/dom/rendering/component.js +25 -14
  495. package/src/dom/rendering/devtools.js +2 -2
  496. package/src/dom/rendering/parser.js +155 -12
  497. package/src/dom/rendering/render.js +14 -4
  498. package/src/dom/rendering/sanitize.js +11 -4
  499. package/src/dom/rendering/secPolicy.js +6 -4
  500. package/src/dom/rendering/styleSheet.js +217 -0
  501. package/src/dom/rendering/template.js +72 -13
  502. package/src/dom/rendering/themeTokens.js +542 -522
  503. package/src/dom/rendering/uiSession-core.js +51 -6
  504. package/src/dom/rendering/uiSession-direct.js +1 -1
  505. package/src/dom/rendering/uiSession-list.js +4 -4
  506. package/src/dom/rendering/uiSession.js +1 -1
  507. package/src/dom/rendering/virtualScroll.js +341 -341
  508. package/src/dom/sensors/battery.js +1 -1
  509. package/src/dom/sensors/geolocation.js +1 -1
  510. package/src/dom/sensors/networkInfo.js +1 -1
  511. package/src/dom/sensors/sensors.js +1 -1
  512. package/src/dom/sw/backgroundSync.js +1 -1
  513. package/src/dom/sw/cache.js +1 -1
  514. package/src/dom/sw/installPrompt.js +151 -0
  515. package/src/dom/sw/precache.js +257 -0
  516. package/src/dom/sw/push.js +1 -1
  517. package/src/dom/sw/sharedWorker.js +1 -1
  518. package/src/dom/sw/swUpdate.js +239 -0
  519. package/src/dom/utils/a11y.js +1 -1
  520. package/src/dom/utils/clipboard.js +56 -6
  521. package/src/dom/utils/entropyCollector.js +1 -1
  522. package/src/dom/utils/focus.js +1 -1
  523. package/src/dom/utils/form.js +1 -1
  524. package/src/dom/utils/keybindings.js +600 -574
  525. package/src/dom/utils/leaderElection.js +1 -1
  526. package/src/dom/utils/notifications.js +1 -1
  527. package/src/dom/utils/permissions.js +107 -107
  528. package/src/dom/utils/route.js +14 -2
  529. package/src/dom/utils/ua.js +42 -28
  530. package/src/dom/utils/webauthn.js +1 -1
  531. package/src/io/binary/reader.js +1 -1
  532. package/src/io/binary/writer.js +1 -1
  533. package/src/io/calc/bigint.js +1 -1
  534. package/src/io/calc/crc32.js +28 -2
  535. package/src/io/calc/easing.js +514 -514
  536. package/src/io/codec/b64.js +189 -52
  537. package/src/io/codec/base32.js +1 -1
  538. package/src/io/codec/base58.js +1 -1
  539. package/src/io/codec/buffer.js +1 -1
  540. package/src/io/codec/cbor.js +111 -18
  541. package/src/io/codec/csv.js +1 -1
  542. package/src/io/codec/hex.js +51 -6
  543. package/src/io/codec/mime.js +1 -1
  544. package/src/io/codec/msgpack.js +47 -6
  545. package/src/io/codec/url.js +24 -7
  546. package/src/io/codec/utf8.js +5 -3
  547. package/src/io/codec/xml.js +1 -1
  548. package/src/io/compress/bitstream.js +2 -2
  549. package/src/io/compress/brotli.js +663 -163
  550. package/src/io/compress/brotli_dict.js +1 -1
  551. package/src/io/compress/brotli_dict_words.js +1 -1
  552. package/src/io/compress/brotli_frame.js +1 -1
  553. package/src/io/compress/brotli_shared.js +7 -7
  554. package/src/io/compress/deflate.js +87 -53
  555. package/src/io/compress/gzip.js +187 -74
  556. package/src/io/compress/huffman.js +24 -1
  557. package/src/io/compress/lz4.js +45 -7
  558. package/src/io/compress/lz77.js +148 -63
  559. package/src/io/compress/lzw.js +35 -19
  560. package/src/io/compress/zip.js +862 -815
  561. package/src/io/compress/zlib.js +87 -7
  562. package/src/io/i18n/i18n.js +1 -1
  563. package/src/io/math/fixed-point.js +1 -1
  564. package/src/io/math/geom.js +1 -1
  565. package/src/io/math/interp.js +1 -1
  566. package/src/io/math/linalg.js +10 -4
  567. package/src/io/math/stats.js +1 -1
  568. package/src/io/structures/btree.js +1 -1
  569. package/src/io/structures/heap.js +1 -1
  570. package/src/io/structures/lruCache.js +1 -1
  571. package/src/io/structures/ringBuffer.js +1 -1
  572. package/src/io/structures/tree-walker.js +1 -1
  573. package/src/io/structures/trie.js +1 -1
  574. package/src/io/sync/abort.js +1 -1
  575. package/src/io/sync/atomics.js +1 -1
  576. package/src/io/sync/cancellable.js +1 -1
  577. package/src/io/sync/channel.js +1 -1
  578. package/src/io/sync/mutex.js +1 -1
  579. package/src/io/sync/semaphore.js +1 -1
  580. package/src/io/sync/tokenBucket.js +1 -1
  581. package/src/io/text/ansi.js +1 -1
  582. package/src/io/text/html-entities.js +1 -1
  583. package/src/io/time/date.js +1 -1
  584. package/src/io/timing/clock.js +1 -1
  585. package/src/io/timing/rateLimit.js +1 -1
  586. package/src/io/timing/scheduler.js +1 -1
  587. package/src/io/utils/errors.js +1 -1
  588. package/src/io/utils/eventBus.js +1 -1
  589. package/src/io/utils/signal.js +1 -1
  590. package/src/io/utils/valid.js +1 -1
  591. package/src/main.js +1 -1
  592. package/src/process/message.js +1 -1
  593. package/src/process/rpc.js +7 -3
  594. package/src/process/workerPool.js +11 -4
  595. package/src/sanity/base.js +85 -39
  596. package/src/sanity/lockdown-apply.js +3 -3
  597. package/src/sanity/lockdown.js +58 -32
  598. package/src/sanity/wasm-gate.js +2 -2
  599. package/src/typed.js +7 -3
  600. package/third-party/NOTICE-brotli-dictionary.txt +69 -0
  601. package/third-party/NOTICE-fw-wasm-crypto.txt +576 -0
  602. package/third-party/NOTICE-whatwg-entities.txt +44 -0
  603. package/types/registry.generated.d.ts +7 -1
  604. package/types/typed.d.ts +7 -3
  605. package/dist/types/crypto/utils/aes_ctr.d.ts +0 -84
  606. package/dist/types/crypto/utils/aes_ctr.d.ts.map +0 -1
  607. package/docs/api/crypto/utils/aes_ctr.md +0 -71
  608. package/src/crypto/utils/aes_ctr.acvp.md +0 -67
  609. package/src/crypto/utils/aes_ctr.js +0 -134
@@ -1,4 +1,4 @@
1
- // Copyright (c) 2026 AwaCloud SAS
1
+ // Copyright (c) 2026 AwaCloud SAS
2
2
  // Author: Matthieu Bouilloux
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
 
@@ -16,14 +16,16 @@
16
16
  * the ESM factory, JSDoc, tests and every later change are this project's own
17
17
  * work. See docs/dev/provenance.md.
18
18
  *
19
- * S-box and MixColumns tables are precomputed once at factory time.
19
+ * The T-table path's tables are precomputed once at factory time; the
20
+ * constant-time path reads none of them.
20
21
  *
21
- * ⚠️ **Cache-timing caveat** - the **default** `api.fn` path is now the
22
- * constant-time implementation: SubBytes runs through a masked-lookup S-box
23
- * (256 uniform reads per byte) so the memory access pattern is independent of
24
- * the AES key/state. This is secure-by-default against Bernstein-style
25
- * cache-timing attacks (Bernstein 2005, « Cache-timing attacks on AES ») at
26
- * a cost of ~50-100× the throughput of the T-table path.
22
+ * ⚠️ **Cache-timing caveat** - the **default** `api.fn` path is the
23
+ * constant-time implementation: a bitsliced AES (8 bit-planes of 16 lanes,
24
+ * SubBytes as the GF(2^8) inverse computed on the planes), with no table read
25
+ * and no branch depending on the key or the state - the key expansion
26
+ * included. This is secure-by-default against Bernstein-style cache-timing
27
+ * attacks (Bernstein 2005, « Cache-timing attacks on AES ») at a cost of
28
+ * about 11× the time of the T-table path (about 1.3 us a block on Bun / Node).
27
29
  *
28
30
  * The fast T-table scheduler (5 T-tables, ~5 KB, one indexed lookup per
29
31
  * SubBytes ∘ MixColumns) is **opt-in** via `aes.ttable.fn(...)`. It is
@@ -32,9 +34,6 @@
32
34
  * Use it only when the execution environment is not shared/hostile, or prefer
33
35
  * WebCrypto (`crypto.subtle` - hardware AES-NI when available) for bulk work.
34
36
  *
35
- * `aes.bitsliced.fn(...)` is retained as a **deprecated alias** of `aes.fn`
36
- * (both are constant-time now) for back-compat; prefer `aes.fn` directly.
37
- *
38
37
  * Block primitive returns `false` on invalid block length - every caller
39
38
  * mode (CBC/CTR/GCM/CMAC/KW) treats a `false` result as failure (early
40
39
  * return). Do not chain raw `crypt()` output without checking.
@@ -59,9 +58,8 @@
59
58
  /**
60
59
  * Object returned by `aes.factory()`.
61
60
  * @typedef {object} AesAPI
62
- * @property {AesKeyScheduler} fn Constant-time (masked-lookup) key scheduler — **default**.
61
+ * @property {AesKeyScheduler} fn Constant-time (bitsliced) key scheduler — **default**.
63
62
  * @property {{ fn: AesKeyScheduler }} ttable T-table key scheduler (fast, NOT constant-time, opt-in).
64
- * @property {{ fn: AesKeyScheduler }} bitsliced Deprecated alias of `fn`.
65
63
  */
66
64
 
67
65
  export const aes = {
@@ -175,229 +173,282 @@ export const aes = {
175
173
  return out;
176
174
  }
177
175
 
178
- // ── Constant-time S-box (Iteration F2 of the FIPS 140-3 upgrade plan) ──
176
+ // ── Constant-time core: bitsliced AES ──
179
177
  //
180
- // The opt-in `crypt` (T-table) path uses 5 T-tables (~5 KB) for
181
- // SubBytes ∘ MixColumns. T-table lookups leak the AES state via
182
- // cache-timing : an attacker observing cache-miss latencies can
183
- // recover the key (cf. Bernstein 2005 « Cache-timing attacks on AES »).
178
+ // The 16 state bytes live as 8 bit-planes: plane k holds bit k of every
179
+ // byte, byte i (FIPS 197 column-major index, row + 4 * column) in bit i
180
+ // of a 16-bit lane mask. Every step is a fixed sequence of bitwise
181
+ // operations on the planes — no table read and no branch depends on a
182
+ // key or data byte, so the memory access pattern and the instruction
183
+ // stream are the same for every input (the property the T-table path
184
+ // lacks, Bernstein 2005).
184
185
  //
185
- // `_sboxCT(b, sbox)` performs a *constant-time* table read by scanning
186
- // all 256 entries and masking them with `b == i ? 0xFF : 0x00`. The
187
- // mask is derived without branching : `diff = i XOR b`, then
188
- // `isZero = ((diff - 1) >>> 8) & 1` returns 1 iff `diff === 0`
189
- // (since `diff ∈ [0, 255]` ; only `diff === 0` borrows into bit 8 of
190
- // `diff - 1`). Yields a uniform memory access pattern independent of `b`.
186
+ // SubBytes inverse in GF(2^8) (x^254: 4 products, 7 squares,
187
+ // reduction by x^8 + x^4 + x^3 + x + 1), then the affine map
188
+ // ShiftRows per row, a rotation of that row's lanes
189
+ // MixColumns r = c ^ t ^ xtime(c ^ c'), c' the next row, t the column sum
190
+ // InvMixColumns MixColumns^3 (MixColumns has order 4)
191
191
  //
192
- // Cost : ~1024 ops per S-box (vs 1 T-table lookup) → AES-128 block ~50×
193
- // slower, AES-256 block ~70× slower. Acceptable for opt-in use cases :
194
- // long-lived secret keys in shared-cache environments (cloud VMs,
195
- // serverless), low-volume cryptographic operations (key wrapping,
196
- // signature scheme inner blocks). This is the **default** `aes.fn`
197
- // path; the fast T-table path is opt-in via `aes.ttable.fn(key)`.
198
- function _sboxCT(b, sbox) {
199
- let result = 0;
200
- const bx = b & 0xff;
201
- for (let i = 0; i < 256; i++) {
202
- // mask = 0xFF if i == bx, else 0x00 - branchless.
203
- // ((diff - 1) >>> 8) & 1 == 1 iff diff == 0 (since diff in [0, 255]).
204
- const diff = (i ^ bx) >>> 0;
205
- const isZero = ((diff - 1) >>> 8) & 1;
206
- const mask = (-isZero) & 0xff;
207
- result |= sbox[i] & mask;
208
- }
209
- return result & 0xff;
192
+ // Derived from FIPS 197 alone; checked against the tables on every input.
193
+
194
+ const LANES = 0xffff;
195
+
196
+ // GF(2^8) product and square of every lane, unrolled (out may alias an input):
197
+ // the 64 partial products, then x^k = x^(k-4) + x^(k-5) + x^(k-7) + x^(k-8)
198
+ // folds the degrees 14..8 down. Generated, then checked on every input.
199
+ function _bsMul(a, b, out) {
200
+ const a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5], a6 = a[6], a7 = a[7];
201
+ const b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5], b6 = b[6], b7 = b[7];
202
+ let p0 = (a0 & b0);
203
+ let p1 = (a0 & b1) ^ (a1 & b0);
204
+ let p2 = (a0 & b2) ^ (a1 & b1) ^ (a2 & b0);
205
+ let p3 = (a0 & b3) ^ (a1 & b2) ^ (a2 & b1) ^ (a3 & b0);
206
+ let p4 = (a0 & b4) ^ (a1 & b3) ^ (a2 & b2) ^ (a3 & b1) ^ (a4 & b0);
207
+ let p5 = (a0 & b5) ^ (a1 & b4) ^ (a2 & b3) ^ (a3 & b2) ^ (a4 & b1) ^ (a5 & b0);
208
+ let p6 = (a0 & b6) ^ (a1 & b5) ^ (a2 & b4) ^ (a3 & b3) ^ (a4 & b2) ^ (a5 & b1) ^ (a6 & b0);
209
+ let p7 = (a0 & b7) ^ (a1 & b6) ^ (a2 & b5) ^ (a3 & b4) ^ (a4 & b3) ^ (a5 & b2) ^ (a6 & b1) ^ (a7 & b0);
210
+ let p8 = (a1 & b7) ^ (a2 & b6) ^ (a3 & b5) ^ (a4 & b4) ^ (a5 & b3) ^ (a6 & b2) ^ (a7 & b1);
211
+ let p9 = (a2 & b7) ^ (a3 & b6) ^ (a4 & b5) ^ (a5 & b4) ^ (a6 & b3) ^ (a7 & b2);
212
+ let p10 = (a3 & b7) ^ (a4 & b6) ^ (a5 & b5) ^ (a6 & b4) ^ (a7 & b3);
213
+ let p11 = (a4 & b7) ^ (a5 & b6) ^ (a6 & b5) ^ (a7 & b4);
214
+ let p12 = (a5 & b7) ^ (a6 & b6) ^ (a7 & b5);
215
+ let p13 = (a6 & b7) ^ (a7 & b6);
216
+ let p14 = (a7 & b7);
217
+ p10 ^= p14; p9 ^= p14; p7 ^= p14; p6 ^= p14;
218
+ p9 ^= p13; p8 ^= p13; p6 ^= p13; p5 ^= p13;
219
+ p8 ^= p12; p7 ^= p12; p5 ^= p12; p4 ^= p12;
220
+ p7 ^= p11; p6 ^= p11; p4 ^= p11; p3 ^= p11;
221
+ p6 ^= p10; p5 ^= p10; p3 ^= p10; p2 ^= p10;
222
+ p5 ^= p9; p4 ^= p9; p2 ^= p9; p1 ^= p9;
223
+ p4 ^= p8; p3 ^= p8; p1 ^= p8; p0 ^= p8;
224
+ out[0] = p0;
225
+ out[1] = p1;
226
+ out[2] = p2;
227
+ out[3] = p3;
228
+ out[4] = p4;
229
+ out[5] = p5;
230
+ out[6] = p6;
231
+ out[7] = p7;
210
232
  }
211
233
 
212
- // GF(2^8) multiplication-by-2 (xtime) - already constant-time
213
- // (bitwise ops only ; `(b >> 7) * 283` produces 0 or 283 without
214
- // branching since `b >> 7` is 0 or 1).
215
- function _xtime(b) {
216
- return ((b << 1) ^ ((b >> 7) * 0x1b)) & 0xff;
234
+ function _bsSq(a, out) {
235
+ const a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5], a6 = a[6], a7 = a[7];
236
+ out[0] = a0 ^ a4 ^ a6;
237
+ out[1] = a4 ^ a6 ^ a7;
238
+ out[2] = a1 ^ a5;
239
+ out[3] = a4 ^ a5 ^ a6 ^ a7;
240
+ out[4] = a2 ^ a4 ^ a7;
241
+ out[5] = a5 ^ a6;
242
+ out[6] = a3 ^ a5;
243
+ out[7] = a6 ^ a7;
217
244
  }
218
245
 
219
- // MixColumns on a single column (4 bytes), constant-time.
220
- function _mixColumnCT(c0, c1, c2, c3) {
221
- const t = c0 ^ c1 ^ c2 ^ c3;
222
- const r0 = c0 ^ t ^ _xtime(c0 ^ c1);
223
- const r1 = c1 ^ t ^ _xtime(c1 ^ c2);
224
- const r2 = c2 ^ t ^ _xtime(c2 ^ c3);
225
- const r3 = c3 ^ t ^ _xtime(c3 ^ c0);
226
- return [r0, r1, r2, r3];
246
+ const _x2 = new Int32Array(8), _x3 = new Int32Array(8), _x12 = new Int32Array(8), _acc = new Int32Array(8), _aff = new Int32Array(8);
247
+
248
+ /** x^254 of every lane (the inverse, 0 for 0), in place. */
249
+ function _bsInv(x) {
250
+ _bsSq(x, _x2); // x^2
251
+ _bsMul(_x2, x, _x3); // x^3
252
+ _bsSq(_x3, _x12); // x^6
253
+ _bsSq(_x12, _x12); // x^12
254
+ _bsMul(_x12, _x3, _acc); // x^15
255
+ _bsSq(_acc, _acc); // x^30
256
+ _bsSq(_acc, _acc); // x^60
257
+ _bsSq(_acc, _acc); // x^120
258
+ _bsSq(_acc, _acc); // x^240
259
+ _bsMul(_acc, _x12, _acc); // x^252
260
+ _bsMul(_acc, _x2, x); // x^254
227
261
  }
228
262
 
229
- // Inverse MixColumns column.
230
- function _invMixColumnCT(c0, c1, c2, c3) {
231
- // First apply Mixcolumns once, then forward MixColumns 3 more
232
- // times - equivalent to the inverse via tower-field expansion :
233
- // InvMixCol(c) = MixCol(c) ⊕ xtime²(c⊕c²) ⊕ xtime(...).
234
- // We implement directly via the standard 0x0e/0x0b/0x0d/0x09 GF
235
- // multiplications.
236
- const m02 = _xtime;
237
- const m04 = (b) => m02(m02(b));
238
- const m08 = (b) => m02(m04(b));
239
- const m09 = (b) => m08(b) ^ b;
240
- const m0b = (b) => m08(b) ^ m02(b) ^ b;
241
- const m0d = (b) => m08(b) ^ m04(b) ^ b;
242
- const m0e = (b) => m08(b) ^ m04(b) ^ m02(b);
243
- return [
244
- (m0e(c0) ^ m0b(c1) ^ m0d(c2) ^ m09(c3)) & 0xff,
245
- (m09(c0) ^ m0e(c1) ^ m0b(c2) ^ m0d(c3)) & 0xff,
246
- (m0d(c0) ^ m09(c1) ^ m0e(c2) ^ m0b(c3)) & 0xff,
247
- (m0b(c0) ^ m0d(c1) ^ m09(c2) ^ m0e(c3)) & 0xff,
248
- ];
263
+ /** SubBytes on the planes, in place: inverse, then the affine map (c = 0x63). */
264
+ function _bsSubPlanes(s) {
265
+ _bsInv(s);
266
+ for (let k = 0; k < 8; k++) _aff[k] = s[k];
267
+ for (let k = 0; k < 8; k++) {
268
+ s[k] = _aff[k] ^ _aff[(k + 4) & 7] ^ _aff[(k + 5) & 7] ^ _aff[(k + 6) & 7] ^ _aff[(k + 7) & 7]
269
+ ^ ((0x63 >> k) & 1 ? LANES : 0);
270
+ }
249
271
  }
250
272
 
251
- // Constant-time AES encrypt/decrypt over a 4-word (16-byte) block.
252
- // Operates byte-per-byte through the standard FIPS 197 algorithm using
253
- // `_sboxCT` for SubBytes ; ShiftRows is a permutation, MixColumns uses
254
- // `_xtime` (branchless), AddRoundKey is XOR.
255
- function _cryptCT(input, dir, keys) {
256
- if (input.length !== 4) {
257
- console.warn('[crypto] INVALID: aes: invalid block size');
258
- return false;
273
+ /** InvSubBytes on the planes, in place: the inverse affine map (d = 0x05), then the inverse. */
274
+ function _bsInvSubPlanes(s) {
275
+ for (let k = 0; k < 8; k++) _aff[k] = s[k];
276
+ for (let k = 0; k < 8; k++) {
277
+ s[k] = _aff[(k + 2) & 7] ^ _aff[(k + 5) & 7] ^ _aff[(k + 7) & 7] ^ ((0x05 >> k) & 1 ? LANES : 0);
259
278
  }
260
- const sbox = tables[0][4];
261
- const sboxInv = tables[1][4];
262
- const sb = dir ? sboxInv : sbox;
263
- const enc = !dir;
264
-
265
- // Unpack input (4 × 32-bit big-endian words) → 16 bytes (column-major).
266
- // Per FIPS 197 §3.4 : state[i, j] = input[i + 4*j].
267
- const state = new Uint8Array(16);
268
- for (let j = 0; j < 4; j++) {
269
- const w = input[j];
270
- state[j * 4 ] = (w >>> 24) & 0xff;
271
- state[j * 4 + 1] = (w >>> 16) & 0xff;
272
- state[j * 4 + 2] = (w >>> 8) & 0xff;
273
- state[j * 4 + 3] = w & 0xff;
279
+ _bsInv(s);
280
+ }
281
+
282
+ /** ShiftRows (inv = false) or InvShiftRows: row r's lanes rotated by r columns. */
283
+ function _bsShift(s, inv) {
284
+ for (let k = 0; k < 8; k++) {
285
+ const x = s[k];
286
+ let y = x & 0x1111;
287
+ for (let r = 1; r < 4; r++) {
288
+ const m = 0x1111 << r;
289
+ const v = x & m;
290
+ const n = 4 * r;
291
+ const rot = inv ? (v << n) | (v >>> (16 - n)) : (v >>> n) | (v << (16 - n));
292
+ y |= rot & m;
293
+ }
294
+ s[k] = y;
274
295
  }
296
+ }
275
297
 
276
- // Build a byte-level **straight** FIPS 197 §5.3 key schedule from
277
- // `keys[0]` (the encryption schedule). The decrypt path uses the
278
- // standard straight-inverse algorithm (InvShiftRows / InvSubBytes
279
- // / AddRoundKey / InvMixColumns) per FIPS 197 §5.3 - no need for
280
- // the `decKey` pre-processed by InvMixColumns⁻¹ via T-tables.
281
- // `dir` only branches encrypt vs decrypt (cf. `if (enc)`
282
- // below) ; the same schedule is used for both.
283
- const encWords = keys[0];
284
- const Nr = encWords.length / 4 - 1; // 10/12/14 for AES-128/192/256
285
- const ks = new Uint8Array(encWords.length * 4);
286
- for (let i = 0; i < encWords.length; i++) {
287
- ks[i * 4 ] = (encWords[i] >>> 24) & 0xff;
288
- ks[i * 4 + 1] = (encWords[i] >>> 16) & 0xff;
289
- ks[i * 4 + 2] = (encWords[i] >>> 8) & 0xff;
290
- ks[i * 4 + 3] = encWords[i] & 0xff;
298
+ const _c1 = new Int32Array(8), _u = new Int32Array(8);
299
+
300
+ /** MixColumns on the planes, in place. */
301
+ function _bsMix(s) {
302
+ for (let k = 0; k < 8; k++) {
303
+ const x = s[k];
304
+ const x1 = ((x >>> 1) & 0x7777) | ((x & 0x1111) << 3); // the next row's byte, per column
305
+ const x2 = ((x1 >>> 1) & 0x7777) | ((x1 & 0x1111) << 3);
306
+ const x3 = ((x2 >>> 1) & 0x7777) | ((x2 & 0x1111) << 3);
307
+ _c1[k] = x ^ x1 ^ x2 ^ x3; // t: the column sum
308
+ _u[k] = x ^ x1;
291
309
  }
310
+ const u = _u;
311
+ // s ^ t ^ xtime(u); xtime: shift up a bit, fold bit 8 back as 0x1b
312
+ const xt0 = u[7], xt1 = u[0] ^ u[7], xt2 = u[1], xt3 = u[2] ^ u[7];
313
+ const xt4 = u[3] ^ u[7], xt5 = u[4], xt6 = u[5], xt7 = u[6];
314
+ s[0] ^= _c1[0] ^ xt0; s[1] ^= _c1[1] ^ xt1; s[2] ^= _c1[2] ^ xt2; s[3] ^= _c1[3] ^ xt3;
315
+ s[4] ^= _c1[4] ^ xt4; s[5] ^= _c1[5] ^ xt5; s[6] ^= _c1[6] ^ xt6; s[7] ^= _c1[7] ^ xt7;
316
+ }
292
317
 
293
- if (enc) {
294
- // AddRoundKey(0)
295
- for (let i = 0; i < 16; i++) state[i] ^= ks[i];
296
- // Rounds 1..Nr-1
297
- for (let r = 1; r < Nr; r++) {
298
- // SubBytes
299
- for (let i = 0; i < 16; i++) state[i] = _sboxCT(state[i], sb);
300
- // ShiftRows : row k cyclic-shift by k positions.
301
- const tmp = new Uint8Array(state);
302
- for (let row = 0; row < 4; row++) {
303
- for (let col = 0; col < 4; col++) {
304
- state[col * 4 + row] = tmp[((col + row) & 3) * 4 + row];
305
- }
306
- }
307
- // MixColumns
308
- for (let col = 0; col < 4; col++) {
309
- const o = col * 4;
310
- const m = _mixColumnCT(state[o], state[o + 1], state[o + 2], state[o + 3]);
311
- state[o ] = m[0];
312
- state[o + 1] = m[1];
313
- state[o + 2] = m[2];
314
- state[o + 3] = m[3];
315
- }
316
- // AddRoundKey(r)
317
- for (let i = 0; i < 16; i++) state[i] ^= ks[r * 16 + i];
318
+ function _bsInvMix(s) { _bsMix(s); _bsMix(s); _bsMix(s); }
319
+
320
+ /** 4 big-endian words → planes (out). */
321
+ function _bsPack(words, out) {
322
+ out.fill(0);
323
+ for (let c = 0; c < 4; c++) {
324
+ const w = words[c];
325
+ for (let r = 0; r < 4; r++) {
326
+ const byte = (w >>> (24 - 8 * r)) & 0xff;
327
+ const lane = r + 4 * c;
328
+ for (let k = 0; k < 8; k++) out[k] |= ((byte >>> k) & 1) << lane;
318
329
  }
319
- // Final round (no MixColumns)
320
- for (let i = 0; i < 16; i++) state[i] = _sboxCT(state[i], sb);
321
- {
322
- const tmp = new Uint8Array(state);
323
- for (let row = 0; row < 4; row++) {
324
- for (let col = 0; col < 4; col++) {
325
- state[col * 4 + row] = tmp[((col + row) & 3) * 4 + row];
326
- }
327
- }
330
+ }
331
+ }
332
+
333
+ /** Planes → 4 big-endian words (signed, as the T-table path returns them). */
334
+ function _bsUnpack(s) {
335
+ const out = [0, 0, 0, 0];
336
+ for (let c = 0; c < 4; c++) {
337
+ let w = 0;
338
+ for (let r = 0; r < 4; r++) {
339
+ const lane = r + 4 * c;
340
+ let byte = 0;
341
+ for (let k = 0; k < 8; k++) byte |= ((s[k] >>> lane) & 1) << k;
342
+ w |= byte << (24 - 8 * r);
328
343
  }
329
- for (let i = 0; i < 16; i++) state[i] ^= ks[Nr * 16 + i];
330
- } else {
331
- // AddRoundKey(Nr)
332
- for (let i = 0; i < 16; i++) state[i] ^= ks[Nr * 16 + i];
333
- // Rounds Nr-1..1
334
- for (let r = Nr - 1; r >= 1; r--) {
335
- // InvShiftRows : row k cyclic-shift by -k positions.
336
- const tmp = new Uint8Array(state);
337
- for (let row = 0; row < 4; row++) {
338
- for (let col = 0; col < 4; col++) {
339
- state[col * 4 + row] = tmp[((col - row + 4) & 3) * 4 + row];
340
- }
341
- }
342
- // InvSubBytes
343
- for (let i = 0; i < 16; i++) state[i] = _sboxCT(state[i], sb);
344
- // AddRoundKey(r)
345
- for (let i = 0; i < 16; i++) state[i] ^= ks[r * 16 + i];
346
- // InvMixColumns
347
- for (let col = 0; col < 4; col++) {
348
- const o = col * 4;
349
- const m = _invMixColumnCT(state[o], state[o + 1], state[o + 2], state[o + 3]);
350
- state[o ] = m[0];
351
- state[o + 1] = m[1];
352
- state[o + 2] = m[2];
353
- state[o + 3] = m[3];
354
- }
344
+ out[c] = w;
345
+ }
346
+ return out;
347
+ }
348
+
349
+ const _state = new Int32Array(8);
350
+
351
+ /** SubWord of the key expansion, through the bitsliced S-box (column 0's lanes). */
352
+ function _subWordCT(w) {
353
+ _bsPack([w, 0, 0, 0], _state);
354
+ _bsSubPlanes(_state);
355
+ return _bsUnpack(_state)[0];
356
+ }
357
+
358
+ /**
359
+ * FIPS 197 §5.2 key expansion with a constant-time SubWord.
360
+ * @param {number[]} key 4/6/8 words
361
+ * @returns {number[]} 4 * (Nr + 1) words
362
+ */
363
+ function _expandKeyCT(key) {
364
+ const n = key.length;
365
+ const w = key.slice(0);
366
+ let rcon = 1; // public: the round constants depend on nothing secret
367
+ for (let i = n; i < 4 * n + 28; i++) {
368
+ let tmp = w[i - 1];
369
+ if (i % n === 0) {
370
+ tmp = _subWordCT(tmp << 8 | tmp >>> 24) ^ rcon << 24;
371
+ rcon = rcon << 1 ^ (rcon >> 7) * 283;
372
+ } else if (n === 8 && i % n === 4) {
373
+ tmp = _subWordCT(tmp);
355
374
  }
356
- // Final inverse round (no InvMixColumns)
357
- {
358
- const tmp = new Uint8Array(state);
359
- for (let row = 0; row < 4; row++) {
360
- for (let col = 0; col < 4; col++) {
361
- state[col * 4 + row] = tmp[((col - row + 4) & 3) * 4 + row];
362
- }
363
- }
375
+ w[i] = w[i - n] ^ tmp;
376
+ }
377
+ return w;
378
+ }
379
+
380
+ /** The table-driven expansion (`ttable`'s), kept for the equality test. */
381
+ function _expandKeyTable(key) {
382
+ const sbox = tables[0][4];
383
+ const n = key.length;
384
+ const w = key.slice(0);
385
+ let rcon = 1;
386
+ for (let i = n; i < 4 * n + 28; i++) {
387
+ let tmp = w[i - 1];
388
+ if (i % n === 0 || (n === 8 && i % n === 4)) {
389
+ tmp = sbox[tmp >>> 24] << 24 ^ sbox[tmp >> 16 & 255] << 16 ^ sbox[tmp >> 8 & 255] << 8 ^ sbox[tmp & 255];
390
+ if (i % n === 0) { tmp = tmp << 8 ^ tmp >>> 24 ^ rcon << 24; rcon = rcon << 1 ^ (rcon >> 7) * 283; }
364
391
  }
365
- for (let i = 0; i < 16; i++) state[i] = _sboxCT(state[i], sb);
366
- for (let i = 0; i < 16; i++) state[i] ^= ks[i];
392
+ w[i] = w[i - n] ^ tmp;
367
393
  }
394
+ return w;
395
+ }
368
396
 
369
- // Pack 16 bytes back to 4 × 32-bit words.
370
- const out = [0, 0, 0, 0];
371
- for (let j = 0; j < 4; j++) {
372
- out[j] = (state[j * 4] << 24) | (state[j * 4 + 1] << 16) |
373
- (state[j * 4 + 2] << 8) | state[j * 4 + 3];
397
+ /** Round keys as planes: Nr + 1 arrays of 8. */
398
+ function _bsRoundKeys(words) {
399
+ const rk = [];
400
+ for (let r = 0; r < words.length / 4; r++) {
401
+ const p = new Int32Array(8);
402
+ _bsPack(words.slice(4 * r, 4 * r + 4), p);
403
+ rk.push(p);
374
404
  }
375
- return out;
405
+ return rk;
406
+ }
407
+
408
+ const _addKey = (s, k) => { for (let i = 0; i < 8; i++) s[i] ^= k[i]; };
409
+
410
+ /** One block, encrypt (dir 0) or decrypt (dir 1), on bitsliced round keys. */
411
+ function _bsCrypt(input, dir, rk) {
412
+ if (!input || input.length !== 4) {
413
+ console.warn('[crypto] INVALID: aes: invalid block size');
414
+ return false;
415
+ }
416
+ const s = _state;
417
+ const nr = rk.length - 1;
418
+ _bsPack(input, s);
419
+ if (!dir) {
420
+ _addKey(s, rk[0]);
421
+ for (let r = 1; r < nr; r++) {
422
+ _bsSubPlanes(s); _bsShift(s, false); _bsMix(s); _addKey(s, rk[r]);
423
+ }
424
+ _bsSubPlanes(s); _bsShift(s, false); _addKey(s, rk[nr]);
425
+ } else {
426
+ _addKey(s, rk[nr]);
427
+ for (let r = nr - 1; r >= 1; r--) {
428
+ _bsShift(s, true); _bsInvSubPlanes(s); _addKey(s, rk[r]); _bsInvMix(s);
429
+ }
430
+ _bsShift(s, true); _bsInvSubPlanes(s); _addKey(s, rk[0]);
431
+ }
432
+ return _bsUnpack(s);
376
433
  }
377
434
 
435
+ const _bsEncrypt = (input, rk) => _bsCrypt(input, 0, rk);
436
+
378
437
  const api = {};
379
438
 
380
439
  /**
381
440
  * Schedule an AES key — **constant-time default**.
382
441
  *
383
- * Block encrypt/decrypt are routed through `_cryptCT`, which performs
384
- * SubBytes via a **masked-lookup** S-box (256 uniform reads per byte)
385
- * instead of T-table indexed lookups. This neutralises Bernstein-style
386
- * cache-timing leaks on the AES key, making this path secure by
387
- * default in shared-cache environments (cloud VM, serverless,
388
- * hyper-thread).
389
- *
390
- * Cost : ~50-100× slower than the opt-in `api.ttable.fn`. NOT a
391
- * substitute for AES-NI (use WebCrypto when available - see
392
- * aes.acvp.md F2). For high-throughput work on a trusted host, opt in
393
- * to the fast T-table path via `api.ttable.fn`.
394
- *
395
- * The key schedule itself uses the T-table SubBytes during expansion :
396
- * acceptable because key expansion runs once per session, not per
397
- * block, so per-block cache-timing on the schedule is irrelevant.
442
+ * Encrypt / decrypt run through the bitsliced core: no table read and
443
+ * no branch depends on the key or the data, the key expansion
444
+ * included (its SubWord goes through the same core). About 11x the
445
+ * T-table path's time per block — about 1.3 us — against
446
+ * cache-timing attacks the T-table path does not resist (shared caches:
447
+ * cloud VM, serverless, hyper-threads). For bulk work on a trusted host,
448
+ * `api.ttable.fn` is faster; WebCrypto (AES-NI) faster still.
398
449
  *
399
450
  * @param {Array} input_key 4/6/8 32-bit words (AES-128/192/256).
400
- * @param {boolean} [full=true] If false, only the encryption schedule is built.
451
+ * @param {boolean} [full=true] If false, only `encrypt` is returned.
401
452
  * @returns {{encrypt:Function, decrypt?:Function}|false}
402
453
  */
403
454
  api.fn = function (input_key, full = true) {
@@ -406,28 +457,9 @@ export const aes = {
406
457
  console.warn('[crypto] INVALID: aes: invalid key size');
407
458
  return false;
408
459
  }
409
- // Build the standard FIPS 197 §5.2 key schedule. `_cryptCT`
410
- // only reads `keys[0]` (straight encKey) - no `decKey`
411
- // pre-processed by InvMixColumns⁻¹, so the inverse T-table
412
- // step present in `api.ttable.fn` is not needed.
413
- const sbox = tables[0][4];
414
- const encKey = input_key.slice(0);
415
- let rcon = 1, i, tmp;
416
- for (i = keyLen; i < 4 * keyLen + 28; i++) {
417
- tmp = encKey[i - 1];
418
- if (i % keyLen === 0 || (keyLen === 8 && i % keyLen === 4)) {
419
- tmp = sbox[tmp >>> 24] << 24 ^ sbox[tmp >> 16 & 255] << 16
420
- ^ sbox[tmp >> 8 & 255] << 8 ^ sbox[tmp & 255];
421
- if (i % keyLen === 0) {
422
- tmp = tmp << 8 ^ tmp >>> 24 ^ rcon << 24;
423
- rcon = rcon << 1 ^ (rcon >> 7) * 283;
424
- }
425
- }
426
- encKey[i] = encKey[i - keyLen] ^ tmp;
427
- }
428
- const key = [encKey];
429
- const ret = { encrypt(data) { return _cryptCT(data, 0, key); } };
430
- if (full) ret.decrypt = (data) => _cryptCT(data, 1, key);
460
+ const rk = _bsRoundKeys(_expandKeyCT(input_key));
461
+ const ret = { encrypt(data) { return _bsCrypt(data, 0, rk); } };
462
+ if (full) ret.decrypt = (data) => _bsCrypt(data, 1, rk);
431
463
  return ret;
432
464
  };
433
465
 
@@ -503,9 +535,28 @@ export const aes = {
503
535
  }
504
536
  };
505
537
 
506
- // Deprecated alias of `api.fn` (both are constant-time now). Kept one
507
- // cycle for back-compat; prefer `aes.fn` directly.
508
- api.bitsliced = { fn: api.fn };
538
+ // Test-only internals, in the internal slot (core/internal.js): not API.
539
+ Object.defineProperty(api, Symbol.for('@awacloud/fw/internal'), { value: {
540
+ sbox: tables[0][4],
541
+ sboxInv: tables[1][4],
542
+ /** Bitsliced SubBytes of 16 bytes (lane i = byte i). */
543
+ bsSub(bytes) {
544
+ const p = new Int32Array(8);
545
+ for (let i = 0; i < 16; i++) for (let k = 0; k < 8; k++) p[k] |= ((bytes[i] >>> k) & 1) << i;
546
+ _bsSubPlanes(p);
547
+ return Uint8Array.from({ length: 16 }, (_, i) => { let v = 0; for (let k = 0; k < 8; k++) v |= ((p[k] >>> i) & 1) << k; return v; });
548
+ },
549
+ /** Bitsliced InvSubBytes of 16 bytes. */
550
+ bsInvSub(bytes) {
551
+ const p = new Int32Array(8);
552
+ for (let i = 0; i < 16; i++) for (let k = 0; k < 8; k++) p[k] |= ((bytes[i] >>> k) & 1) << i;
553
+ _bsInvSubPlanes(p);
554
+ return Uint8Array.from({ length: 16 }, (_, i) => { let v = 0; for (let k = 0; k < 8; k++) v |= ((p[k] >>> i) & 1) << k; return v; });
555
+ },
556
+ expandKey: _expandKeyCT,
557
+ expandKeyTable: _expandKeyTable,
558
+ bsEncrypt: _bsEncrypt,
559
+ } });
509
560
 
510
561
  return /** @type {AesAPI} */ (/** @type {any} */ (api));
511
562
  }