@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
 
@@ -12,7 +12,7 @@
12
12
  * {
13
13
  * name : string, // unique identifier
14
14
  * version? : string, // semver - defaults to '0.0.0' when absent
15
- * type? : string, // taxonomy - must match /^(fw|sde|lib)\.[a-z][\w.]*$/ when present
15
+ * type? : string, // taxonomy - must match /^(fw|sd|sde|sdc|lib|app)\.[a-z][\w.]*$/ when present
16
16
  * dependencies : string[], // names (or 'name@version' specs) of required modules
17
17
  * factory : function, // called with resolved dependency instances as args
18
18
  * }
@@ -34,17 +34,19 @@
34
34
  const SEMVER_RE = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[\w.-]+)?(?:\+[\w.-]+)?$/;
35
35
 
36
36
  /**
37
- * Type taxonomy regex : `fw.<sub>`, `sd.<sub>`, `sde.<sub>`, `sdc.<sub>`, `lib.<sub>`.
37
+ * Type taxonomy regex : `fw.<sub>`, `sd.<sub>`, `sde.<sub>`, `sdc.<sub>`,
38
+ * `lib.<sub>`, `app.<sub>`.
38
39
  *
39
40
  * - `fw.*` : framework modules (`@awacloud/fw`).
40
41
  * - `sd.*` : shared SDE/SDC modules (`@awacloud/sd-common`).
41
42
  * - `sde.*` : multi-app desktop specifics (`@awacloud/sde-core`).
42
43
  * - `sdc.*` : mono-app container specifics (`@awacloud/sdc-core`).
43
44
  * - `lib.*` : standalone libraries (e.g. `lib.video_codec`).
45
+ * - `app.*` : an application's own modules (e.g. `app.notes.store`).
44
46
  *
45
47
  * @private
46
48
  */
47
- const TYPE_RE = /^(fw|sd|sde|sdc|lib)\.[a-z][\w.]*$/;
49
+ const TYPE_RE = /^(fw|sd|sde|sdc|lib|app)\.[a-z][\w.]*$/;
48
50
 
49
51
  /**
50
52
  * Default version when a module descriptor omits `version`.
@@ -53,36 +55,74 @@ const TYPE_RE = /^(fw|sd|sde|sdc|lib)\.[a-z][\w.]*$/;
53
55
  const DEFAULT_VERSION = '0.0.0';
54
56
 
55
57
  /**
56
- * Compare two semver strings.
58
+ * Compare two semver strings by SemVer 2.0.0 § 11 precedence.
57
59
  *
58
- * Implements the ordering :
59
- * - numeric major.minor.patch
60
- * - any pre-release < no pre-release (1.0.0-beta < 1.0.0)
61
- * - pre-release sorted lexicographically (1.0.0-alpha < 1.0.0-beta)
60
+ * - build metadata (`+…`) is ignored;
61
+ * - major.minor.patch compare numerically;
62
+ * - a version with a pre-release sorts below the same version without one
63
+ * (1.0.0-beta < 1.0.0);
64
+ * - pre-releases compare identifier by identifier (split on `.`): numeric
65
+ * identifiers numerically, alphanumeric ones in ASCII order, a numeric
66
+ * identifier below an alphanumeric one, and a shorter set below a longer
67
+ * one when all the preceding identifiers are equal
68
+ * (1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-beta.2 < 1.0.0-beta.11).
62
69
  *
63
- * Sufficient for picking the highest version at register time. For range
64
- * matching (`^`, `~`, `>=`), use the standalone `semver` module.
70
+ * Self-contained (no module-scope helper): `runtimeSource` inlines it into a
71
+ * worker by `toString()`. For range matching (`^`, `~`, `>=`), use the
72
+ * standalone `semver` module.
65
73
  *
66
74
  * @param {string} a Semver string.
67
75
  * @param {string} b Semver string.
68
- * @returns {number} -1 if a < b, 0 if equal, 1 if a > b.
76
+ * @returns {number} -1 if a < b, 0 if equal precedence, 1 if a > b.
69
77
  * @private
70
78
  */
71
79
  function semverCompare(a, b) {
72
- const [coreA, preA = ''] = a.split('-', 2);
73
- const [coreB, preB = ''] = b.split('-', 2);
74
- const partsA = coreA.split('.');
75
- const partsB = coreB.split('.');
80
+ const split = (v) => {
81
+ const plus = v.indexOf('+');
82
+ const noBuild = plus === -1 ? v : v.slice(0, plus);
83
+ const dash = noBuild.indexOf('-');
84
+ return dash === -1
85
+ ? { core: noBuild, pre: '' }
86
+ : { core: noBuild.slice(0, dash), pre: noBuild.slice(dash + 1) };
87
+ };
88
+ const va = split(a);
89
+ const vb = split(b);
90
+ const partsA = va.core.split('.');
91
+ const partsB = vb.core.split('.');
76
92
  for (let i = 0; i < 3; i++) {
77
93
  const na = +partsA[i] || 0;
78
94
  const nb = +partsB[i] || 0;
79
95
  if (na !== nb) return na < nb ? -1 : 1;
80
96
  }
81
97
  // pre-release < release
82
- if (preA && !preB) return -1;
83
- if (!preA && preB) return 1;
84
- if (preA === preB) return 0;
85
- return preA < preB ? -1 : 1;
98
+ if (va.pre && !vb.pre) return -1;
99
+ if (!va.pre && vb.pre) return 1;
100
+ if (va.pre === vb.pre) return 0;
101
+ const idsA = va.pre.split('.');
102
+ const idsB = vb.pre.split('.');
103
+ const len = Math.max(idsA.length, idsB.length);
104
+ for (let i = 0; i < len; i++) {
105
+ if (i >= idsA.length) return -1;
106
+ if (i >= idsB.length) return 1;
107
+ const x = idsA[i];
108
+ const y = idsB[i];
109
+ if (x === y) continue;
110
+ const nx = /^\d+$/.test(x);
111
+ const ny = /^\d+$/.test(y);
112
+ if (nx && ny) {
113
+ // Digit strings of any length, compared as integers without a
114
+ // Number conversion (no precision loss past 2^53).
115
+ const dx = x.replace(/^0+(?=\d)/, '');
116
+ const dy = y.replace(/^0+(?=\d)/, '');
117
+ if (dx.length !== dy.length) return dx.length < dy.length ? -1 : 1;
118
+ if (dx !== dy) return dx < dy ? -1 : 1;
119
+ continue;
120
+ }
121
+ if (nx) return -1;
122
+ if (ny) return 1;
123
+ return x < y ? -1 : 1;
124
+ }
125
+ return 0;
86
126
  }
87
127
 
88
128
  /**
@@ -547,10 +587,15 @@ export class ModuleRuntime {
547
587
  /**
548
588
  * List registered module definitions matching the given filter.
549
589
  *
590
+ * The result is read-only: a frozen array of frozen copies of the
591
+ * definitions (their `dependencies` a frozen copy too), so a caller
592
+ * cannot edit the registry through it (BL-469). A copy is not the
593
+ * registered object: compare by `name` and `version`, not identity.
594
+ *
550
595
  * Linear scan ; acceptable for the typical module count (≪ 1000).
551
596
  *
552
597
  * @param {ListFilter} [filter={}]
553
- * @returns {ModuleDefinition[]}
598
+ * @returns {ReadonlyArray<Readonly<ModuleDefinition>>}
554
599
  */
555
600
  list(filter = {}) {
556
601
  const out = [];
@@ -571,19 +616,21 @@ export class ModuleRuntime {
571
616
  if (def.type !== fType) continue;
572
617
  }
573
618
  }
574
- out.push(def);
619
+ /** @type {Record<string, any>} */
620
+ const view = { ...def };
621
+ if (Array.isArray(def.dependencies)) view.dependencies = Object.freeze(def.dependencies.slice());
622
+ out.push(Object.freeze(/** @type {ModuleDefinition} */ (view)));
575
623
  }
576
624
  }
577
- return out;
625
+ return Object.freeze(out);
578
626
  }
579
627
 
580
628
  /**
581
629
  * Passive, read-only view of the module registry.
582
630
  *
583
- * Companion of {@link ModuleRuntime#list}, which returns the **live**
584
- * `ModuleDefinition` objects (their `factory`, and a `dependencies` array a
585
- * caller can splice in place). `snapshot` instead returns frozen metadata
586
- * rows: enumeration for a devtools registry view without handing out a
631
+ * Companion of {@link ModuleRuntime#list}, which returns frozen copies
632
+ * of the `ModuleDefinition` objects (their `factory` included).
633
+ * `snapshot` instead returns frozen metadata rows: enumeration for a devtools registry view without handing out a
587
634
  * write channel into registry state, and without the side effect of
588
635
  * `resolve()` — which is a full instantiate, not a peek.
589
636
  *
@@ -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
 
@@ -18,6 +18,13 @@
18
18
  * run the user-supplied `terminate` callback) before delegating to the native
19
19
  * `terminate`.
20
20
  *
21
+ * **Confinement** (`revoke`, `lockdown`): after `workerFw` has built the
22
+ * context and before the user function runs, the named globals are removed
23
+ * from every owner on the global's prototype chain, then `lockdown()` freezes
24
+ * the worker's realm. What `workerFw` resolved is the explicit grant; the user
25
+ * function meets the confined realm. `lockdown` makes the worker a MODULE
26
+ * worker: a static `import` of `sanity/lockdown.js` runs before the body, so no
27
+ * top-level await delays the message handler.
21
28
  */
22
29
 
23
30
  /**
@@ -37,6 +44,16 @@
37
44
  * `workerFw` as its third parameter. Must be JSON-serialisable.
38
45
  * @property {Function} [terminate] - Callback invoked during cleanup, just
39
46
  * before the native `Worker.terminate()` call. Defaults to a no-op.
47
+ * @property {string[]} [revoke] - Global names to remove inside the
48
+ * worker before `workerFn` runs (e.g. `['fetch', 'XMLHttpRequest',
49
+ * 'WebSocket']`), from every object of the global's prototype chain that owns
50
+ * them. A name still reachable afterwards throws in the worker (its `error`
51
+ * event): confinement fails closed.
52
+ * @property {boolean|{url: string}} [lockdown] - Run `lockdown()` inside the
53
+ * worker before `workerFn` (after `revoke`). `true` imports the
54
+ * `sanity/lockdown.js` that sits next to this file; `{ url }` names it by an
55
+ * absolute URL (a bundled or re-hosted build). The worker becomes a module
56
+ * worker, where `importScripts` does not exist.
40
57
  */
41
58
 
42
59
  /**
@@ -92,6 +109,59 @@ export function createWorkerRuntime(ENV, runtime, runtimeSource, log, logFn) {
92
109
 
93
110
  const DEFAULT_WORKER_MODULES = [];
94
111
 
112
+ /** A global name `revoke` accepts. */
113
+ const IDENT_RE = /^[A-Za-z_$][\w$]*$/;
114
+
115
+ /**
116
+ * Worker-side: remove each name from every owner on the global's
117
+ * prototype chain, then require it to be gone. Stringified into the worker
118
+ * code, so it is self-contained.
119
+ *
120
+ * @param {string[]} names
121
+ * @returns {void}
122
+ */
123
+ const REVOKE_GLOBALS = function(names) {
124
+ for (const name of names) {
125
+ for (let o = globalThis; o; o = Object.getPrototypeOf(o)) {
126
+ if (Object.prototype.hasOwnProperty.call(o, name)) {
127
+ try { delete o[name]; } catch (_e) { /* reported below */ }
128
+ }
129
+ }
130
+ if (name in globalThis) throw new Error('createWorker: could not revoke "' + name + '"');
131
+ }
132
+ };
133
+
134
+ /**
135
+ * Validate the confinement options on the main thread.
136
+ *
137
+ * @param {Object} opts - The caller's options.
138
+ * @returns {{revoke: string[], lockdownUrl: (string|null)}}
139
+ * @throws {TypeError} on a malformed `revoke` or `lockdown`.
140
+ */
141
+ const confinementOf = function(opts) {
142
+ let revoke = [];
143
+ if (opts.revoke !== undefined) {
144
+ if (!Array.isArray(opts.revoke) || !opts.revoke.every((n) => typeof n === 'string' && IDENT_RE.test(n))) {
145
+ throw new TypeError('createWorker: revoke must be an array of global names');
146
+ }
147
+ revoke = opts.revoke.slice();
148
+ }
149
+ let lockdownUrl = null;
150
+ const l = opts.lockdown;
151
+ if (l === true) {
152
+ lockdownUrl = new URL('../sanity/lockdown.js', import.meta.url).href;
153
+ } else if (l && typeof l === 'object') {
154
+ try {
155
+ lockdownUrl = new URL(String(l.url)).href;
156
+ } catch (e) {
157
+ throw new TypeError('createWorker: lockdown.url must be an absolute URL', { cause: e });
158
+ }
159
+ } else if (l !== undefined && l !== false) {
160
+ throw new TypeError('createWorker: lockdown must be true, false or { url }');
161
+ }
162
+ return { revoke, lockdownUrl };
163
+ };
164
+
95
165
  /**
96
166
  * Default worker-side framework bootstrap.
97
167
  *
@@ -184,10 +254,11 @@ export function createWorkerRuntime(ENV, runtime, runtimeSource, log, logFn) {
184
254
  args: Array.isArray(safeOptions.args) ? safeOptions.args : [],
185
255
  terminate: typeof safeOptions.terminate === 'function' ? safeOptions.terminate : function(){},
186
256
  };
257
+ const confine = confinementOf(safeOptions);
187
258
 
188
259
  const serialized = runtime.serialize(normalizedOptions.dependencies);
189
260
  const argsRaw = JSON.stringify(normalizedOptions.args);
190
- const logger = ENV.LOG ? `(${logFn})(${ENV.DEV.toString()}, self);` : ``;
261
+ const logger = ENV.LOG ? `(${logFn})(${ENV.DEV === true}, self);` : ``;
191
262
 
192
263
  // Specs exposed to workerFw: use the user's **original** specs
193
264
  // (`normalizedOptions.dependencies`) rather than `serialized.list`,
@@ -199,7 +270,13 @@ export function createWorkerRuntime(ENV, runtime, runtimeSource, log, logFn) {
199
270
  // on the worker side works correctly.
200
271
  const exposedSpecsLiteral = JSON.stringify(normalizedOptions.dependencies);
201
272
 
202
- const code = logger + `
273
+ const lockImport = confine.lockdownUrl
274
+ ? `import { lockdown as __fwLockdown } from ${JSON.stringify(confine.lockdownUrl)};\n`
275
+ : '';
276
+ const confineCode = (confine.revoke.length ? `(${REVOKE_GLOBALS.toString()})(${JSON.stringify(confine.revoke)});` : '')
277
+ + (confine.lockdownUrl ? '__fwLockdown();' : '');
278
+
279
+ const code = lockImport + logger + `
203
280
  ${runtimeSource}
204
281
 
205
282
  const runtime = new ModuleRuntime();
@@ -210,13 +287,15 @@ export function createWorkerRuntime(ENV, runtime, runtimeSource, log, logFn) {
210
287
 
211
288
  runtime.context = (${normalizedOptions.workerFw.toString()})(runtime, ${exposedSpecsLiteral}, ${argsRaw});
212
289
 
290
+ ${confineCode}
291
+
213
292
  (${workerFn.toString()})( runtime.context );
214
293
  `;
215
294
 
216
295
  const blobUrl = URL.createObjectURL(new Blob([code], {type: 'text/javascript'}));
217
296
  let worker;
218
297
  try {
219
- worker = new Worker(blobUrl);
298
+ worker = confine.lockdownUrl ? new Worker(blobUrl, { type: 'module' }) : new Worker(blobUrl);
220
299
  } catch (err) {
221
300
  URL.revokeObjectURL(blobUrl);
222
301
  throw err;
@@ -1,8 +1,10 @@
1
- # NIST conformance — `fw/core/crypto` module
1
+ # NIST conformance — the `crypto` tier of `@awacloud/fw`
2
2
 
3
3
  State as of the current commit. Test vectors are executed on every
4
- build via `bun test src/crypto/` (**3 853 tests + 7 skip
5
- gated `CRYPTO_FULL`**, 0 failures, 41 files; ~180 s).
4
+ build via `bun test src/crypto/` (measured 2026-11-06: **4 967 tests + 7
5
+ skip gated `CRYPTO_FULL`**, 0 failures, 76 files; ~210 s). This page covers
6
+ the pure-JS tier; the WebCrypto and wasm tiers have their own pages under
7
+ `docs/api/crypto/`.
6
8
 
7
9
 
8
10
  ## Legend
@@ -17,37 +19,37 @@ gated `CRYPTO_FULL`**, 0 failures, 41 files; ~180 s).
17
19
 
18
20
  | Standard | Algorithm | Module | Status | Vectors |
19
21
  |---|---|---|---|---|
20
- | FIPS 197 | AES-128/192/256 | [aes.js](cipher/aes.js) | ✅ | FIPS-197 App. B/C + **ACVP-AES-ECB-1.0** (254 AFT/2138 sub-sample, 6 MCT chains × 100 outer × 1000 inner — iter0 + iter99 byte-exact); **`api.fn` constant-time by default** (masked-lookup S-box anti-cache-timing); fast T-table opt-in via `api.ttable.fn`; `api.bitsliced.fn` deprecated alias of `api.fn` — see [aes.acvp.md](cipher/aes.acvp.md) |
22
+ | FIPS 197 | AES-128/192/256 | [aes.js](cipher/aes.js) | ✅ | FIPS-197 App. B/C + **ACVP-AES-ECB-1.0** (254 AFT/2138 sub-sample, 6 MCT chains × 100 outer × 1000 inner — iter0 + iter99 byte-exact); **`api.fn` constant-time by default** (bitsliced core, anti-cache-timing); fast T-table opt-in via `api.ttable.fn` — see [aes.acvp.md](cipher/aes.acvp.md) |
21
23
  | FIPS 180-4 | SHA-224 | [sha224.js](hash/sha224.js) | ✅ | FIPS-180 + **ACVP-SHA2-224-1.0** (24 AFT/512 incl. bit-level non-byte-aligned + 1 MCT standard × 100 outer × 1000 inner byte-exact) — see [sha224.acvp.md](hash/sha224.acvp.md) |
22
24
  | FIPS 180-4 | SHA-256 | [sha256.js](hash/sha256.js) | ✅ | FIPS-180 App. B 1-3 (incl. 1M×"a") + **ACVP-SHA2-256-1.0** (67 AFT/512 sub-sample over lengths 1720..12144 bits + 1 MCT alternate × 100 outer × 1000 inner byte-exact) — see [sha256.acvp.md](hash/sha256.acvp.md) |
23
25
  | FIPS 180-4 | SHA-384 | [sha384.js](hash/sha384.js) | ✅ | FIPS-180 + **ACVP-SHA2-384-1.0** (24 AFT/1024 incl. bit-level + 1 MCT standard × 100 outer × 1000 inner byte-exact) — see [sha384.acvp.md](hash/sha384.acvp.md) |
24
- | FIPS 180-4 | SHA-512 | [sha512.js](hash/sha512.js) | ✅ | FIPS-180 + **ACVP-SHA2-512-1.0** (67 AFT/1024 + 1 MCT alternate × 100 outer × 1000 inner byte-exact); iteration A2 exposes `_internal.makeSha(init, outWords)` builder for the truncated variants — see [sha512.acvp.md](hash/sha512.acvp.md) |
26
+ | FIPS 180-4 | SHA-512 | [sha512.js](hash/sha512.js) | ✅ | FIPS-180 + **ACVP-SHA2-512-1.0** (67 AFT/1024 + 1 MCT alternate × 100 outer × 1000 inner byte-exact); `internalOf(sha512).makeSha(init, outWords)` builder (the internal slot) for the truncated variants — see [sha512.acvp.md](hash/sha512.acvp.md) |
25
27
  | FIPS 180-4 §5.3.6.1 | SHA-512/224 | [sha512_224.js](hash/sha512_224.js) | ✅ | **ACVP-SHA2-512-224-1.0** (74/146 byte-aligned AFT sub-sample + 1 MCT standard × 100 outer × 1000 inner byte-exact); IV derived by independent computation (FIPS §5.3.6); HMAC-compatible — see [sha512_224.acvp.md](hash/sha512_224.acvp.md) |
26
28
  | FIPS 180-4 §5.3.6.2 | SHA-512/256 | [sha512_256.js](hash/sha512_256.js) | ✅ | **ACVP-SHA2-512-256-1.0** (53/1024 byte-aligned AFT sub-sample + 1 MCT alternate × 100 outer × 1000 inner byte-exact); IV derived then cross-checked against OpenSSL (the widely circulated incorrect IV `c84d6b74` corrected to `c84c64c2`); HMAC-compatible — see [sha512_256.acvp.md](hash/sha512_256.acvp.md) |
27
29
  | FIPS 202 | SHA3-224/256/384/512 | [sha3.js](hash/sha3.js) | ✅ | FIPS 202 + NIST KAT 200×0xa3 + **ACVP-SHA3-{224,256,384,512}-2.0** (AFT byte-aligned sub-sample 15+16+13+13 + 4 MCT standard × 100 outer × 1000 inner — SHA3-256 100/100 byte-exact, others iter0+iter99) — see [sha3.acvp.md](hash/sha3.acvp.md) |
28
30
  | FIPS 202 | SHAKE128 / SHAKE256 | [sha3.js](hash/sha3.js) | ✅ | NIST CAVP + **ACVP-SHAKE-{128,256}-FIPS202** (AFT byte-aligned in/out 29 + 6, outLen variable, multi-block squeeze validated) — see [sha3.acvp.md](hash/sha3.acvp.md) |
29
- | FIPS 198-1 | HMAC-SHA-2 + HMAC-SHA-3 + HMAC-SHA-512/{224,256} | [hmac.js](hash/hmac.js) | ✅ | RFC 4231 + **ACVP-HMAC-SHA2-{224,256,384,512}-2.0** (4 × 35 AFT/150) + **ACVP-HMAC-SHA3-{224,256,384,512}-2.0** (4 × 31 AFT/150, **iteration B1**) + **ACVP-HMAC-SHA2-512-{224,256}-2.0** (2 × 31 AFT/150, **iteration B2**) — see [hmac.acvp.md](hash/hmac.acvp.md) |
30
- | FIPS 186-5 §6 | ECDSA (P-{224,256,384,521} + K-curves) | [ecc.js](pkc/ecc.js) | ✅ | round-trip + CAVP P-256/SHA-256 SigVer; **deterministic k RFC 6979** by default + **ACVP**: KeyGen-FIPS186-5 (24/72 validator `Q==d·G`), **KeyVer-FIPS186-5 (12/12 full §A.4.2 validation, C1)**, SigVer-FIPS186-5 (8 sub-samples), **DetECDSA-SigGen-FIPS186-5 (16 byte-exact RFC 6979 over 4 NIST pairs incl. P-521+SHA-512, C2)**; **strict mode `verify({strict:true})` + low-s canonicalization `sign({strict:true})` + RFC 6979 hash-decoupling `sign({hashForK})` (C3)** — see [ecc.acvp.md](pkc/ecc.acvp.md) |
31
+ | FIPS 198-1 | HMAC-SHA-2 + HMAC-SHA-3 + HMAC-SHA-512/{224,256} | [hmac.js](hash/hmac.js) | ✅ | RFC 4231 + **ACVP-HMAC-SHA2-{224,256,384,512}-2.0** (4 × 35 AFT/150) + **ACVP-HMAC-SHA3-{224,256,384,512}-2.0** (4 × 31 AFT/150) + **ACVP-HMAC-SHA2-512-{224,256}-2.0** (2 × 31 AFT/150) — see [hmac.acvp.md](hash/hmac.acvp.md) |
32
+ | FIPS 186-5 §6 | ECDSA (P-{224,256,384,521} + K-curves) | [ecc.js](pkc/ecc.js) | ✅ | round-trip + CAVP P-256/SHA-256 SigVer; **deterministic k RFC 6979** by default + **ACVP**: KeyGen-FIPS186-5 (24/72 validator `Q==d·G`), **KeyVer-FIPS186-5 (12/12 full §A.4.2 validation)**, SigVer-FIPS186-5 (8 sub-samples), **DetECDSA-SigGen-FIPS186-5 (16 byte-exact RFC 6979 over 4 NIST pairs incl. P-521+SHA-512)**; **strict mode `verify({strict:true})` + low-s canonicalization `sign({strict:true})` + RFC 6979 hash-decoupling `sign({hashForK})`** — see [ecc.acvp.md](pkc/ecc.acvp.md) |
31
33
  | FIPS 186-5 §A.1.3 | RSA keygen (probable primes) | [rsaKeygen.js](utils/rsaKeygen.js) | ✅ | sieve < 2000 + Miller-Rabin (k=5 at 1024 bits, Table B.1), top-2 bits forced, `\|p−q\| > 2^(nlen/2−100)`, `d > 2^(nlen/2)`, CRT output (dp, dq, qInv); round-trip OAEP-SHA-256 on a 2048-bit key + **RSA-KeyGen-FIPS186-5** (15/15 validator-style vectors: MR on p,q, byte-exact dmp1/dmq1/iqmp via `_inverseModAny(e, lcm(p−1,q−1))` over 3 nlen × 5 ACVP methods); `provable`/auxiliary methods not implemented (P3) — see [rsaKeygen.acvp.md](utils/rsaKeygen.acvp.md) |
32
34
  | FIPS 203 | ML-KEM-512/768/1024 | [ml_kem.js](pkc/ml_kem.js) | ✅ | KAT Wycheproof (keygen + encaps byte-exact) + round-trip 512/768/1024 + implicit reject + **ACVP**: ML-KEM-keyGen-FIPS203 (9/75 sub-samples first/mid/last × 3 paramSets), ML-KEM-encapDecap-FIPS203 (9 encap + 9 decap sub-samples + 30/30 decapKeyCheck §7.3 hash-consistency + 30/30 encapKeyCheck §7.2 modulus-q) — see [ml_kem.acvp.md](pkc/ml_kem.acvp.md) |
33
- | FIPS 204 | ML-DSA-44/65/87 | [ml_dsa.js](pkc/ml_dsa.js) | ✅ | Wycheproof KAT byte-exact (keygen ML-DSA-65 + sign deterministic + verify) + **ACVP**: ML-DSA-keyGen-FIPS204 (9/75 sub-samples × 3 paramSets), ML-DSA-sigGen-FIPS204 external+pure (18 byte-exact), ML-DSA-sigVer-FIPS204 external+pure (45/45 mix valid/invalid) + **HashML-DSA iteration E3**: `signPh/verifyPh` 12 hashAlg supported (9 SigGen + 45 SigVer ACVP byte-exact) + **internal interface** (`_internal.signInternal/verifyInternal` 9 ACVP) + **externalMu** (`_internal.signWithMu/verifyWithMu` 9 ACVP) — see [ml_dsa.acvp.md](pkc/ml_dsa.acvp.md) |
34
- | FIPS 205 | SLH-DSA-{SHAKE,SHA2}-{128,192,256}{f,s} | [slh_dsa.js](pkc/slh_dsa.js) | ✅ | 12 variants byte-exact against @noble/post-quantum 0.6.1 — §11.1 (SHAKE) + §11.2 (SHA-2); **ACVP**: SLH-DSA-keyGen-FIPS205 (36/120), SLH-DSA-sigGen-FIPS205 external+pure 128f (2 byte-exact), SLH-DSA-sigVer-FIPS205 external+pure 'f' variants (15/84) + **HashSLH-DSA iteration E4**: `signPh/verifyPh` 12 hashAlg supported (2 SigGen + 12 SigVer ACVP byte-exact over 'f' variants) + **internal interface** (`_internal.signInternal/verifyInternal` 2 SigGen + 12 SigVer ACVP); externalMu not applicable to SLH-DSA (no intermediate mu in FIPS 205 §6) — see [slh_dsa.acvp.md](pkc/slh_dsa.acvp.md) |
35
+ | FIPS 204 | ML-DSA-44/65/87 | [ml_dsa.js](pkc/ml_dsa.js) | ✅ | Wycheproof KAT byte-exact (keygen ML-DSA-65 + sign deterministic + verify) + **ACVP**: ML-DSA-keyGen-FIPS204 (9/75 sub-samples × 3 paramSets), ML-DSA-sigGen-FIPS204 external+pure (18 byte-exact), ML-DSA-sigVer-FIPS204 external+pure (45/45 mix valid/invalid) + **HashML-DSA**: `signPh/verifyPh` 12 hashAlg supported (9 SigGen + 45 SigVer ACVP byte-exact) + **internal interface** (`internalOf(variant).signInternal/verifyInternal` 9 ACVP) + **externalMu** (`internalOf(variant).signWithMu/verifyWithMu` 9 ACVP) — see [ml_dsa.acvp.md](pkc/ml_dsa.acvp.md) |
36
+ | FIPS 205 | SLH-DSA-{SHAKE,SHA2}-{128,192,256}{f,s} | [slh_dsa.js](pkc/slh_dsa.js) | ✅ | 12 variants byte-exact against @noble/post-quantum 0.6.1 — §11.1 (SHAKE) + §11.2 (SHA-2); **ACVP**: SLH-DSA-keyGen-FIPS205 (36/120), SLH-DSA-sigGen-FIPS205 external+pure 128f (2 byte-exact), SLH-DSA-sigVer-FIPS205 external+pure 'f' variants (15/84) + **HashSLH-DSA**: `signPh/verifyPh` 12 hashAlg supported (2 SigGen + 12 SigVer ACVP byte-exact over 'f' variants) + **internal interface** (`internalOf(variant).signInternal/verifyInternal` 2 SigGen + 12 SigVer ACVP); externalMu not applicable to SLH-DSA (no intermediate mu in FIPS 205 §6) — see [slh_dsa.acvp.md](pkc/slh_dsa.acvp.md) |
35
37
 
36
38
  ## NIST SP — modes & derivation
37
39
 
38
40
  | Standard | Algorithm | Module | Status | Vectors |
39
41
  |---|---|---|---|---|
40
42
  | SP 800-38A | AES-CTR | [ctr.js](mode/ctr.js) | ✅ | F.5.1 + **ACVP-AES-CTR-1.0** (78 AFT/150 sub-sample: 3 testGroups encrypt + 3 decrypt × AES-128/192/256, payloadLen 1..1920 bits incl. non-byte/non-block-aligned via `bitArray.clamp`) — see [ctr.acvp.md](mode/ctr.acvp.md) |
41
- | SP 800-38A | AES-CBC | [cbc.js](mode/cbc.js) | ✅ | RFC 3602 §4 (1-4) + **ACVP-AES-CBC-1.0** (144 AFT/2156 sub-sample: 12 testGroups encrypt + 12 decrypt × AES-128/192/256, multi-block tgId 25-30 full 10×ptLen) + **MCT 6/6 byte-exact** (FIPS 140-2 Annex C: tgId 37-42 × 100 outer × 1000 inner with ACVP-spec key/IV/PT transitions, **iteration D4**) — see [cbc.acvp.md](mode/cbc.acvp.md) |
42
- | SP 800-38B | AES-CMAC | [cmac.js](mode/cmac.js) | ✅ | RFC 4493 §4 + **CMAC-AES-1.0** (81 gen + 108 ver / 756 sub-sample: AES-128/192/256 × msgLen ∈ {0, 4256, 65536} × macLen ∈ {64, 88, 128}); **iteration D3**: TDES rejection (`blockSize !== 16` → DEPRECATED warning per SP 800-131A §2.4) + `truncatedMac/Verify` API that enforces `tagLen ∈ [32, 128]` (SP 800-38B §6.4) — see [cmac.acvp.md](mode/cmac.acvp.md) |
43
- | SP 800-38D | AES-GCM (128/192/256) | [gcm.js](mode/gcm.js) | ✅ | McGrew-Viega §B **TC 1-18 complete** (TC 1-6 AES-128, TC 7-12 AES-192 [D1], TC 13-18 AES-256 [TC 13/14 baseline + TC 15-18 D1] cross-checked against Node libcrypto) + **ACVP-AES-GCM-1.0** (60/60 AFT 100% AES-128); all 3 keyLen × {empty, AAD, multi-block, 96/64/480-bit IV} byte-exact — see [gcm.acvp.md](mode/gcm.acvp.md) |
43
+ | SP 800-38A | AES-CBC | [cbc.js](mode/cbc.js) | ✅ | RFC 3602 §4 (1-4) + **ACVP-AES-CBC-1.0** (144 AFT/2156 sub-sample: 12 testGroups encrypt + 12 decrypt × AES-128/192/256, multi-block tgId 25-30 full 10×ptLen) + **MCT 6/6 byte-exact** (FIPS 140-2 Annex C: tgId 37-42 × 100 outer × 1000 inner with ACVP-spec key/IV/PT transitions) — see [cbc.acvp.md](mode/cbc.acvp.md) |
44
+ | SP 800-38B | AES-CMAC | [cmac.js](mode/cmac.js) | ✅ | RFC 4493 §4 + **CMAC-AES-1.0** (81 gen + 108 ver / 756 sub-sample: AES-128/192/256 × msgLen ∈ {0, 4256, 65536} × macLen ∈ {64, 88, 128}); TDES rejection (`blockSize !== 16` → DEPRECATED warning per SP 800-131A §2.4) + `truncatedMac/Verify` API that enforces `tagLen ∈ [32, 128]` (SP 800-38B §6.4) — see [cmac.acvp.md](mode/cmac.acvp.md) |
45
+ | SP 800-38D | AES-GCM (128/192/256) | [gcm.js](mode/gcm.js) | ✅ | McGrew-Viega §B **TC 1-18 complete** (TC 1-6 AES-128, TC 7-12 AES-192, TC 13-18 AES-256 [TC 13/14 baseline + TC 15-18] cross-checked against Node libcrypto) + **ACVP-AES-GCM-1.0** (60/60 AFT 100% AES-128); all 3 keyLen × {empty, AAD, multi-block, 96/64/480-bit IV} byte-exact — see [gcm.acvp.md](mode/gcm.acvp.md) |
44
46
  | SP 800-38D | GMAC | [gcm.js](mode/gcm.js#L212) | ✅ | round-trip vs GCM + **ACVP-AES-GMAC-1.0** (60/60 AFT 100%: AES-128 × ivLen ∈ {96, 120} × aadLen ∈ {0, 120} × tagLen ∈ {32, 128}; decrypt includes 7 `testPassed=false` cases) — see [gcm.acvp.md](mode/gcm.acvp.md) |
45
- | SP 800-38F | KW (RFC 3394) | [kw.js](mode/kw.js) | ✅ | RFC 3394 §4.1-4.6 + **ACVP-AES-KW-1.0** (108/3600 cipher-direction sub-sample: AES-128/192/256 × 6 payloadLen); **iteration D2**: `wrapInverseCipher`/`unwrapInverseCipher` explicit reject (NOT-IMPLEMENTED, SP 800-38F §6.3) + TDES rejection (`blockSize !== 16` → DEPRECATED warning per SP 800-131A §2.4) — see [kw.acvp.md](mode/kw.acvp.md) |
47
+ | SP 800-38F | KW (RFC 3394) | [kw.js](mode/kw.js) | ✅ | RFC 3394 §4.1-4.6 + **ACVP-AES-KW-1.0** (108/3600 cipher-direction sub-sample: AES-128/192/256 × 6 payloadLen); `wrapInverseCipher`/`unwrapInverseCipher` explicit reject (NOT-IMPLEMENTED, SP 800-38F §6.3) + TDES rejection (`blockSize !== 16` → DEPRECATED warning per SP 800-131A §2.4) — see [kw.acvp.md](mode/kw.acvp.md) |
46
48
  | SP 800-38F | KWP (RFC 5649) | [kw.js](mode/kw.js) | ✅ | RFC 5649 §6 + **ACVP-AES-KWP-1.0** (108/3600 cipher-direction sub-sample 3/group: AES-128/192/256 × 6 payloadLen ∈ {8, 1280, 2152, 2176, 3040, 4096} bits; single-semi-block fast path via payloadLen=8; decrypt includes 10 `testPassed=false` cases rejected by the constant-time IV+length+padding check) — see [kw.acvp.md](mode/kw.acvp.md) |
47
- | SP 800-132 | PBKDF2 (10 PRF families) | [pbkdf2.js](hash/pbkdf2.js) | ✅ | RFC 7914 (HMAC-SHA-256) + **PBKDF-1.0** (25/50 sub-sample: HMAC-SHA-224) + **B4 cross-check Python `hashlib`** (9 families × 5 vectors = 45 vectors: SHA-2-{256,384,512}, SHA-512/{224,256}, SHA-3-{224,256,384,512}); **default count = 600 000** (OWASP 2023), warn if < 100 000 — see [pbkdf2.acvp.md](hash/pbkdf2.acvp.md) |
48
- | SP 800-56C Rev. 2 | HKDF (RFC 5869) | [hkdf.js](hash/hkdf.js) | ✅ | RFC 5869 App. A.1-A.3 + **KDA-HKDF-Sp800-56Cr1** (240 SHA-2 + 180 SHA-3/SHA-512-truncated **B3**) + **KDA-HKDF-Sp800-56Cr2 hybrid single** (40 vectors `IKM=Z‖T` **B3**) + **KDA-HKDF-Sp800-56Cr2 hybrid multi-expansion** (20 vectors / 56 expand iterations **B3**); **10 HMAC families** validated byte-exact — see [hkdf.acvp.md](hash/hkdf.acvp.md) |
49
- | SP 800-90A | CTR_DRBG-AES-256 (no df) | [random.js](utils/random.js) | ✅ | strict §10.2 implementation + **KAT power-on** (NIST CAVP `drbgvectors_pr_false` COUNT=0) + **ctrDRBG-1.0** (30/240 sub-sample 100% of the supported variant: tg7 predRes=True + tg15 predRes=False, AES-256 no-df, returnedBitsLen=4096 bits, instantiate→{reSeed\|generate ± predRes-reseed} sequence byte-exact); auto-reseed at 2^32 < 2^48; AES-128/192, TDES, derFunc=true not implemented (P3) — see [random.acvp.md](utils/random.acvp.md) |
50
- | SP 800-90B | RCT + APT (continuous health tests) | [random.js](utils/random.js) | ✅ | RCT (C=4, α=2^-20, H=8) §4.4.1 + APT (W=512, C=13) §4.4.2; state persisted across calls; "dead source" latch §4.5; applied to every buffer drawn from `crypto.getRandomValues` |
49
+ | SP 800-132 | PBKDF2 (10 PRF families) | [pbkdf2.js](hash/pbkdf2.js) | ✅ | RFC 7914 (HMAC-SHA-256) + **PBKDF-1.0** (25/50 sub-sample: HMAC-SHA-224) + **cross-check Python `hashlib`** (9 families × 5 vectors = 45 vectors: SHA-2-{256,384,512}, SHA-512/{224,256}, SHA-3-{224,256,384,512}); **default count = 600 000** (OWASP 2023), warn if < 100 000 — see [pbkdf2.acvp.md](hash/pbkdf2.acvp.md) |
50
+ | SP 800-56C Rev. 2 | HKDF (RFC 5869) | [hkdf.js](hash/hkdf.js) | ✅ | RFC 5869 App. A.1-A.3 + **KDA-HKDF-Sp800-56Cr1** (240 SHA-2 + 180 SHA-3/SHA-512-truncated) + **KDA-HKDF-Sp800-56Cr2 hybrid single** (40 vectors `IKM=Z‖T`) + **KDA-HKDF-Sp800-56Cr2 hybrid multi-expansion** (20 vectors / 56 expand iterations); **10 HMAC families** validated byte-exact — see [hkdf.acvp.md](hash/hkdf.acvp.md) |
51
+ | SP 800-90A | CTR_DRBG-AES-256 (no df) | [random.js](utils/random.js) | ✅ | strict §10.2 implementation + **KAT power-on** (NIST CAVP `drbgvectors_pr_false` COUNT=0) + **ctrDRBG-1.0** (30/240 sub-sample 100% of the supported variant: tg7 predRes=True + tg15 predRes=False, AES-256 no-df, returnedBitsLen=4096 bits, instantiate→{reSeed\|generate ± predRes-reseed} sequence byte-exact); auto-reseed at 2^32 < 2^48; AES-128 and AES-192 (`aesKeyBits`) and the derivation function (`df: true`, `Block_Cipher_df`) are implemented and unit-tested, outside the ACVP sub-sample; TDES not implemented — see [random.acvp.md](utils/random.acvp.md) |
52
+ | SP 800-90B | RCT + APT (continuous health tests) | [random.js](utils/random.js) | ✅ | RCT (C=4, α=2^-20, H=8) §4.4.1 + APT (W=512, C=13) §4.4.2; state persisted across calls; "dead source" latch §4.5; applied to the entropy the DRBG draws (`random.drbg()`); the direct API (`random.bytes`, `words`, `float`, `int`) reads `crypto.getRandomValues` without these tests |
51
53
  | SP 800-90C | RBG construction | [random.js](utils/random.js) | ⚠️ | entropy source = `crypto.getRandomValues` (validated OS NRBG); CTR_DRBG df not implemented (no-df only — full-entropy source assumed); KAT power-on against the official NIST CAVP vector (see SP 800-90A row) — FIPS 140-3 validation remains the responsibility of a CMVP lab |
52
54
 
53
55
  ## Complementary RFCs (interop / outside NIST)
@@ -55,8 +57,8 @@ gated `CRYPTO_FULL`**, 0 failures, 41 files; ~180 s).
55
57
  | Standard | Algorithm | Module | Status | Vectors |
56
58
  |---|---|---|---|---|
57
59
  | RFC 7748 | X25519 | [x25519.js](pkc/x25519.js) | ⚠️ | RFC 7748 §5.2 (test vectors 1+2 + iterative 1/1000 + 1M under CRYPTO_FULL) + §5 clamping/MSB-mask + §6.1 ECDH + low-order u (u=0/1/p-1 → 0) + DH symmetry stress — see [x25519.acvp.md](pkc/x25519.acvp.md) |
58
- | FIPS 186-5 §7 + RFC 8032 | Ed25519 (PureEdDSA + ph + ctx) | [ed25519.js](pkc/ed25519.js) | ✅ | RFC 8032 §7.1 (1-3) + **ACVP** EDDSA-{KeyGen, KeyVer, SigGen, SigVer}-1.0 pure (3+4+3+5) + **preHash iteration E1** (SigGen 3 sub-samples ph + SigVer 5 ph) + **Ed25519ctx iteration E1** (`signCtx/verifyCtx` round-trip + dom2 binding tests) + **Ed448 explicit reject iteration E2** (`ed25519.ed448.{keyPair,sign,verify,signPh,verifyPh}` returns false + warn NOT-IMPLEMENTED, 6 stubs tested); native Ed448 implementation not implemented (edwards448 curve + SHAKE-256, create a separate ed448.js if required) — see [ed25519.acvp.md](pkc/ed25519.acvp.md) |
59
- | FIPS 186-5 §5.4 + SP 800-56B §6.4 + RFC 8017 | RSA-OAEP / RSA-PSS / RSADP | [rsa.js](pkc/rsa.js) | ✅ | RFC 8017 Ex. 1 + **RSA-DecryptionPrimitive-Sp800-56Br2** (90/90: 3 modulo × 2 keyMode; 66 byte-exact `pt` + 24 domain-check) + **RSA-SigVer-FIPS186-4** (36/72 PSS-SHA224 sub-sample); **CRT** auto-enabled; OAEP decrypt constant-time (anti-Manger) + **RSA blinding Chaum/Pollard iteration F1** (anti-timing, enabled by default on `_rsadp`; `c → c · r^e mod n` then `m → m · r^-1`; covers Boneh-Brumley 2003; opt-out via `_internal.rsadp(p, c, {blinding:false})`); PKCS#1 v1.5 and PSS-SHA3/SHAKE not implemented (P3) — see [rsa.acvp.md](pkc/rsa.acvp.md) |
60
+ | FIPS 186-5 §7 + RFC 8032 | Ed25519 (PureEdDSA + ph + ctx) | [ed25519.js](pkc/ed25519.js) | ✅ | RFC 8032 §7.1 (1-3) + **ACVP** EDDSA-{KeyGen, KeyVer, SigGen, SigVer}-1.0 pure (3+4+3+5) + **preHash** (SigGen 3 sub-samples ph + SigVer 5 ph) + **Ed25519ctx** (`signCtx/verifyCtx` round-trip + dom2 binding tests) + **Ed448 explicit reject** (`ed25519.ed448.{keyPair,sign,verify,signPh,verifyPh}` returns false + warn NOT-IMPLEMENTED, 6 stubs tested); native Ed448 implementation not implemented (edwards448 curve + SHAKE-256, create a separate ed448.js if required) — see [ed25519.acvp.md](pkc/ed25519.acvp.md) |
61
+ | FIPS 186-5 §5.4 + SP 800-56B §6.4 + RFC 8017 | RSA-OAEP / RSA-PSS / RSADP | [rsa.js](pkc/rsa.js) | ✅ | RFC 8017 Ex. 1 + **RSA-DecryptionPrimitive-Sp800-56Br2** (90/90: 3 modulo × 2 keyMode; 66 byte-exact `pt` + 24 domain-check) + **RSA-SigVer-FIPS186-4** (36/72 PSS-SHA224 sub-sample); **CRT** auto-enabled; OAEP decrypt constant-time (anti-Manger) + **RSA blinding Chaum/Pollard** (anti-timing, enabled by default on `_rsadp`; `c → c · r^e mod n` then `m → m · r^-1`; covers Boneh-Brumley 2003; opt-out via `internalOf(rsa).rsadp(p, c, {blinding:false})`); PKCS#1 v1.5 and PSS-SHA3/SHAKE not implemented (P3) — see [rsa.acvp.md](pkc/rsa.acvp.md) |
60
62
  | RFC 5915 | EC private key (PKCS#8 / SEC1) | [keyformat.js](utils/keyformat.js) | ⚠️ | round-trip P-256/384/521 |
61
63
  | RFC 8410 | Ed25519/X25519 PKCS#8 + SPKI | [keyformat.js](utils/keyformat.js) | ⚠️ | RFC 8410 §10.1/§10.3 |
62
64
  | RFC 8439 | ChaCha20 | [chacha20.js](cipher/chacha20.js) | ⚠️ | RFC 8439 §2.3.2 + §2.4.2 + §A.1 (5 KAT block) + §A.2 (3 KAT encrypt) + multi-block/concat + 513-byte involution — see [chacha20.acvp.md](cipher/chacha20.acvp.md) |
@@ -74,6 +76,9 @@ gated `CRYPTO_FULL`**, 0 failures, 41 files; ~180 s).
74
76
  ## Operational vigilance points
75
77
 
76
78
  1. **Entropy source** — `random.js` exclusively uses `crypto.getRandomValues`.
79
+ It is not the only consumer of it: `pkc/hybridKem.js` (default keygen and
80
+ encapsulation randomness), `utils/uuid.js` and the wasm tier draw from
81
+ `crypto.getRandomValues` directly, outside the DRBG and its health tests.
77
82
  `Math.random` and `crypto.randomUUID` are blocked by [sanity/base.js](../sanity/base.js).
78
83
  2. **Constant-time comparisons** — `bitArray.equal`, `cmac.verify`,
79
84
  `gcm.decrypt`, `chacha20poly1305.decrypt`, `poly1305.verify`,
@@ -84,7 +89,8 @@ gated `CRYPTO_FULL`**, 0 failures, 41 files; ~180 s).
84
89
  comparisons are short-circuit-free.
85
90
  3. **Authentication failure** — the AEAD modes (`gcm`, `chacha20poly1305`,
86
91
  `kw`) **never** release the plaintext on an invalid tag:
87
- they return `false` after `console.error('CORRUPT:')`.
92
+ they return `false` after a `console.warn('CORRUPT:')` (a failed check
93
+ is an expected outcome; see the log levels below).
88
94
  6. **GCM — nonce reuse** — reusing an IV for two distinct
89
95
  encryptions under the same key is **catastrophic** (loss of
90
96
  the GHASH authentication key + XOR leak of the plaintexts). The
@@ -97,13 +103,19 @@ gated `CRYPTO_FULL`**, 0 failures, 41 files; ~180 s).
97
103
  8. **PBKDF2 — iterations** — default raised to 600 000 (OWASP 2023). Any
98
104
  call with a `count` < 100 000 emits `WEAK:` to the console.
99
105
  4. **No exception thrown** — by convention, every cryptographic error
100
- logs via `console.warn`/`console.error` then returns `false`.
106
+ logs via `console.warn`/`console.error` then returns `false`. **Log
107
+ level**: a verify or an authenticated decrypt that returns `false` (tag
108
+ mismatch, signature that does not verify, OAEP or key-unwrap failure) is
109
+ an expected outcome and logs `CORRUPT` at **warn** level, in every tier;
110
+ `console.error` is kept for alarms the caller did not ask about — nonce
111
+ reuse caught by a tracker, a dead entropy source (RCT/APT), `BUG`, and a
112
+ real fault of the platform or of the wasm runtime.
101
113
  5. **Worker serialization** — every `factory()` is pure and
102
114
  `factory.toString()` remains valid for transport to a Worker.
103
115
 
104
116
  ---
105
117
 
106
- ## Security by default (Iteration I2)
118
+ ## Security by default
107
119
 
108
120
  Module policy: **fail-closed** on every deprecated, unimplemented,
109
121
  or intrinsically unsafe path. Rather than silently offering
@@ -112,15 +124,15 @@ the module **explicitly refuses** via `console.warn(...)` + `return false`.
112
124
  Warnings are typed: `DEPRECATED`, `UNSAFE`, `NOT-IMPLEMENTED`,
113
125
  `LIMIT-EXCEEDED`, `WEAK`, `CORRUPT`, `INVALID`, `BUG`.
114
126
 
115
- ### Explicitly rejected algorithms (`return false` + typed warning)
127
+ ### Algorithms not offered
116
128
 
117
129
  | Family | Export | Type | Justification |
118
130
  |---|---|---|---|
119
- | RSA | `pkcs1v15Sign` / `pkcs1v15Verify` | `DEPRECATED` | SP 800-131A Rev.2 Table 5 (Nov. 2019) — deprecates v1.5 sign |
120
- | RSA | `pkcs1v15Encrypt` / `pkcs1v15Decrypt` | `DEPRECATED|UNSAFE` | Bleichenbacher 2006 padding oracle |
121
- | Argon2 | `hashD` (Argon2d) | `UNSAFE` | RFC 9106 §4 — vulnerable to cache-timing (data-dependent addressing) |
122
- | Argon2 | `hashI` (Argon2i) | `DEPRECATED` | Alwen-Blocki 2016 — reduced GPU/ASIC resistance |
123
- | ChaCha20 | `xchacha20()` | `NOT-IMPLEMENTED` | Draft-irtf-cfrg-xchacha not finalized; specialized use (libsodium) |
131
+ | RSA | PKCS #1 v1.5 signature | — | SP 800-131A Rev.2 Table 5 (Nov. 2019) — deprecates v1.5 sign |
132
+ | RSA | PKCS #1 v1.5 encryption | — | Bleichenbacher 2006 padding oracle |
133
+ | Argon2 | Argon2d | — | RFC 9106 §4 — vulnerable to cache-timing (data-dependent addressing) |
134
+ | Argon2 | Argon2i | — | Alwen-Blocki 2016 — reduced GPU/ASIC resistance |
135
+ | ChaCha20 | XChaCha20 | — | Draft-irtf-cfrg-xchacha not finalized; specialized use (libsodium) |
124
136
  | KW | `wrapInverseCipher` / `unwrapInverseCipher` | `NOT-IMPLEMENTED` | SP 800-38F §6.3 inverse-cipher out of scope (rare TPM usage) |
125
137
  | HMAC-SHA-1 | (not exposed) | — | SP 800-131A §5 — not implemented; factory does not expose `sha1` |
126
138
  | MD-5 | (not exposed) | — | SP 800-131A §5 — not implemented |
@@ -139,8 +151,8 @@ Warnings are typed: `DEPRECATED`, `UNSAFE`, `NOT-IMPLEMENTED`,
139
151
  | `mode/gcm.js` | `gcm.nonceTracker(prf)` (opt-in) | `CORRUPT` | refuses in-process IV reuse (`Set` of seen nonces) |
140
152
  | `mode/chacha20poly1305.js` | `nonceTracker(key)` (opt-in) | `CORRUPT` | same as GCM; Poly1305 does not cryptographically detect reuse |
141
153
  | `pkc/x25519.js` | `isLowOrderPoint(u)` (opt-in helper) | — | RFC 7748 §6.1 — 7 documented LOPs, constant-time comparison |
142
- | `pkc/rsa.js` | `_rsadp` blinding Chaum/Pollard (default true) | — | Boneh-Brumley 2003 anti-timing ; opt-out `_internal.rsadp(p, c, {blinding:false})` |
143
- | `cipher/aes.js` | `fn(key)` constant-time **by default**; T-table opt-in via `ttable.fn(key)` | — | constant-time-by-default masked-lookup S-box, anti-cache-timing (Bernstein 2005); fast T-table reserved for trusted hosts |
154
+ | `pkc/rsa.js` | `_rsadp` blinding Chaum/Pollard (default true) | — | Boneh-Brumley 2003 anti-timing ; opt-out `internalOf(rsa).rsadp(p, c, {blinding:false})` |
155
+ | `cipher/aes.js` | `fn(key)` constant-time **by default**; T-table opt-in via `ttable.fn(key)` | — | constant-time-by-default bitsliced core, anti-cache-timing (Bernstein 2005); fast T-table reserved for trusted hosts |
144
156
  | `hash/argon2.js` | salt < 8 bytes | `INVALID` | RFC 9106 §3.1 — salt minimum |
145
157
  | `hash/pbkdf2.js` | `count < 100 000` | `WEAK` | OWASP 2023 |
146
158
  | `utils/random.js` | RCT + APT continuous health-tests SP 800-90B | `CORRUPT` | latched-dead flag stops all generation if entropy is suspect |
@@ -170,7 +182,7 @@ depending on the machine.
170
182
 
171
183
  *Special cases (prohibitive cost vs. value)*:
172
184
  - **SLH-DSA sigGen full (624 vectors)** — signing costs minutes/op for the
173
- `s` variants, estimated total in hours. Sub-sample E4 validates the path.
185
+ `s` variants, estimated total in hours. A sub-sample validates the path.
174
186
  - **LDT SHA-2 ≥ 2 GiB** (tcId 515-517 and 384/512 equivalents) — extra
175
187
  cost with no additional information vs 1 GiB (64-bit counter already validated).
176
188
 
@@ -208,7 +220,7 @@ coverage gain:
208
220
  cross-check Python `hashlib` over 9 HMAC families. Cryptographic
209
221
  coverage already broad via cross-check.
210
222
  - **`hash/sha3`**: 110/600+ AFT per variant. MCT already **100/100
211
- byte-exact full** (Iteration H2). Full AFT would only add intermediate
223
+ byte-exact full**. Full AFT would only add intermediate
212
224
  lengths.
213
225
  - **`hash/sha2*` (224/256/384/512/512_224/512_256)**: 24-73 / 146-1024
214
226
  AFT per variant (regular-stride sub-sample + min/max anchors). LDT
@@ -224,7 +236,7 @@ coverage gain:
224
236
  - **`utils/rsaKeygen`**: 15/15 **full**.
225
237
 
226
238
  Enabling full coverage of all this under `CRYPTO_FULL=1` is
227
- technically feasible (follow the H3 PQC pattern: synchronous `readFileSync`
239
+ technically feasible (follow the PQC pattern: synchronous `readFileSync`
228
240
  of the ACVP JSON) but would not yield any new cryptographic
229
241
  discovery for an estimated CI cost of +10-20 min.
230
242
 
@@ -243,7 +255,8 @@ The warning types emitted by the module follow a strict convention
243
255
  PBKDF2 iter < 100k, etc.).
244
256
  - `INVALID` — malformed input (size, structure, range).
245
257
  - `CORRUPT` — runtime tampering detection (tag mismatch, RCT
246
- fail, nonce reuse).
258
+ fail, nonce reuse). A failed check returning `false` logs it at warn
259
+ level; nonce reuse and RCT/APT failures log it at error level.
247
260
  - `BUG` — internal inconsistency (should not happen, signals an
248
261
  invocation bug).
249
262
  - `NOT READY` — expected state not initialized (DRBG not instantiated).
@@ -9,7 +9,7 @@
9
9
 
10
10
  ## Implemented algorithm
11
11
 
12
- Block cipher AES-128 / AES-192 / AES-256 (single-block primitive). API: `aes.factory().fn(key, full=true)` → `{encrypt(block), decrypt(block)?}`. **`api.fn` is the constant-time default** (masked-lookup S-box); the fast T-table path is **opt-in** via `api.ttable.fn`. `api.bitsliced.fn` is a deprecated alias of `api.fn`. The key is passed as 32-bit words (4 / 6 / 8 integers). `full=false` only computes the encryption schedule (memory savings for one-way modes such as CTR/GCM). Error (invalid `key size`/`block size`) → `false` + `console.warn`. S-box/MixCols tables are precomputed at factory time; `factory().toString()` remains Worker-serializable.
12
+ Block cipher AES-128 / AES-192 / AES-256 (single-block primitive). API: `aes.factory().fn(key, full=true)` → `{encrypt(block), decrypt(block)?}`. **`api.fn` is the constant-time default** (bitsliced core); the fast T-table path is **opt-in** via `api.ttable.fn`. `api.bitsliced.fn` is a deprecated alias of `api.fn`. The key is passed as 32-bit words (4 / 6 / 8 integers). `full=false` only computes the encryption schedule (memory savings for one-way modes such as CTR/GCM). Error (invalid `key size`/`block size`) → `false` + `console.warn`. The T-table path's tables are precomputed at factory time (the constant-time path reads none); `factory().toString()` remains Worker-serializable.
13
13
 
14
14
  This module provides the **block primitive**; ECB, CBC, CTR, GCM, KW, etc. are implemented in `mode/`.
15
15
 
@@ -19,8 +19,7 @@ This module provides the **block primitive**; ECB, CBC, CTR, GCM, KW, etc. are i
19
19
 
20
20
  > **All vectors below are executed 2× via `describe.each`** — once on the
21
21
  > **constant-time default** path `api.fn` and once on the **T-table opt-in**
22
- > path `api.ttable.fn`. Both produce byte-identical output
23
- > (`api.bitsliced.fn` is a deprecated alias of `api.fn`).
22
+ > path `api.ttable.fn`. Both produce byte-identical output.
24
23
 
25
24
  | Source | Reference | Test (`describe` / `test`) | Property verified |
26
25
  |---|---|---|---|
@@ -46,7 +45,7 @@ The ACVP AES-ECB suite enumerates 36 testGroups (24 structural AFT + 6 PT-variab
46
45
  - [x] **Long-chain stability** — MCT guarantees no arithmetic degradation appears over 100,000 consecutive ops per chain (× 6 chains).
47
46
  - [x] **Edge cases** — invalid key (3 words), invalid block (3 words) → `false` + `console.warn`.
48
47
  - [x] **`full=false`**: `decrypt` not exposed.
49
- - [x] **Side-channel resistance (timing)** — **the default path `api.fn` is now constant-time**: SubBytes via masked-lookup S-box (256 uniform reads per byte, branchless mask `((diff-1)>>>8) & 1`), MixColumns via branchless `xtime`; the memory access pattern is independent of the key/state (neutralizes Bernstein 2005). The fast T-table path (vulnerable to cache-timing) is **opt-in** via `api.ttable.fn`. `api.bitsliced.fn` is a **deprecated alias** of `api.fn`. Implementation: ~22 LOC `api.fn` (key schedule straight from FIPS 197 §5.2 with no pre-processed `decKey`; `_cryptCT` derives `Nr` from `keys[0]`). **Validated across the whole set of FIPS-197 App. B/C + ACVP-AES-ECB-1.0 vectors (254 AFT + 6 MCT × 100×1000) byte-exact** via `describe.each` factoring over the 2 paths (CT default + T-table). Cost of the default ~50-100× the T-table path — that's the price of security-by-default; opt into `api.ttable.fn` on a trusted, non-shared host. Byte-exact cross-consistency of `api.fn` vs `api.ttable.fn` on FIPS-197 KAT (AES-128/192/256) + 16 random blocks. **WebCrypto delegate** not wired: `globalThis.crypto.subtle` is asynchronous and does not expose a bare block primitive (only high-level AEAD `AES-GCM`/`AES-CTR`/`AES-CBC`) — the `mode/{cbc,ctr,gcm}.js` modes could eventually delegate directly to WebCrypto, out of scope for `cipher/aes.js`.
48
+ - [x] **Side-channel resistance (timing)** — **the default path `api.fn` is now constant-time**: a bitsliced core — the 16 state bytes as 8 bit-planes of 16 lanes, SubBytes as the GF(2^8) inverse x^254 on the planes (4 products, 7 squares) then the affine map, ShiftRows / MixColumns as masked rotations, InvMixColumns = MixColumns^3, round keys bitsliced at schedule time, the key expansion's SubWord through the same core; the memory access pattern is independent of the key/state (neutralizes Bernstein 2005). The fast T-table path (vulnerable to cache-timing) is **opt-in** via `api.ttable.fn`. `api.bitsliced.fn` is a **deprecated alias** of `api.fn`. Implementation: `api.fn` expands the key per FIPS 197 §5.2 with a constant-time SubWord, bitslices the round keys once, and `_bsCrypt` runs the rounds on the planes (`Nr` from the round-key count); the S-box and its inverse are checked against the tables on all 256 inputs in every lane, the constant-time expansion against the table one (`aes-bitsliced.test.js`). **Validated across the whole set of FIPS-197 App. B/C + ACVP-AES-ECB-1.0 vectors (254 AFT + 6 MCT × 100×1000) byte-exact** via `describe.each` factoring over the 2 paths (CT default + T-table). Cost of the default about 11× the T-table path (about 1.3 us a block, T21) — that's the price of security-by-default; opt into `api.ttable.fn` on a trusted, non-shared host. Byte-exact cross-consistency of `api.fn` vs `api.ttable.fn` on FIPS-197 KAT (AES-128/192/256) + 16 random blocks. **WebCrypto delegate** not wired: `globalThis.crypto.subtle` is asynchronous and does not expose a bare block primitive (only high-level AEAD `AES-GCM`/`AES-CTR`/`AES-CBC`) — the `mode/{cbc,ctr,gcm}.js` modes could eventually delegate directly to WebCrypto, out of scope for `cipher/aes.js`.
50
49
 
51
50
  ## FIPS 140-3 conformance
52
51
 
@@ -56,19 +55,19 @@ The ACVP AES-ECB suite enumerates 36 testGroups (24 structural AFT + 6 PT-variab
56
55
  | Validated key sizes | ✅ | 128 / 192 / 256 — all covered by AFT + MCT |
57
56
  | KAT power-on / self-test | ✅ | FIPS-197 App. B/C vectors executed on every `bun test`; no dedicated `selfTest()` — module init is purely table precomputation (deterministic) |
58
57
  | CT comparisons (if secret) | N/A | Low-level block module; CT comparisons are the responsibility of the modes (see `gcm.js`, `cmac.js`, `kw.js`) |
59
- | No `throw` / timing leak | ✅ | No `throw` (reviewed OK); **default path `api.fn` is constant-time** (masked-lookup S-box). The opt-in T-table path `api.ttable.fn` remains non-constant-time with respect to cache (see limitation below) |
58
+ | No `throw` / timing leak | ✅ | No `throw` (reviewed OK); **default path `api.fn` is constant-time** (bitsliced core). The opt-in T-table path `api.ttable.fn` remains non-constant-time with respect to cache (see limitation below) |
60
59
 
61
60
  ## Known limitations
62
61
 
63
- - **Cache-timing on the opt-in path `api.ttable.fn`**: classic T-table implementation (inherited from SJCL) — not safe against an attacker able to observe cache access patterns (co-tenant, browser). **The default is now safe**: `api.fn` provides a constant-time path validated byte-exact on the same FIPS-197 + ACVP-AES-ECB-1.0 vectors. Choice left to the caller: security by default (constant-time `api.fn`) or performance on a trusted host (T-table `api.ttable.fn`, ~50-100× faster). `crypto.subtle` delegation remains out of scope for `cipher/aes.js` (asynchronous API, no bare block primitive exposed by WebCrypto).
62
+ - **Cache-timing on the opt-in path `api.ttable.fn`**: classic T-table implementation (inherited from SJCL) — not safe against an attacker able to observe cache access patterns (co-tenant, browser). **The default is now safe**: `api.fn` provides a constant-time path validated byte-exact on the same FIPS-197 + ACVP-AES-ECB-1.0 vectors. Choice left to the caller: security by default (constant-time `api.fn`) or performance on a trusted host (T-table `api.ttable.fn`, about 11× faster). `crypto.subtle` delegation remains out of scope for `cipher/aes.js` (asynchronous API, no bare block primitive exposed by WebCrypto).
64
63
  - **MCT sub-sampling**: `iter0` and `iter99` validated byte-exact; the 98 intermediate iterations are not asserted byte-by-byte. Residual risk = a bug *specific to iterations 1-98* going undetected; judged negligible because (1) the chain is cumulative — a local bug would deviate `iter99`; (2) each outer iteration tests a different (key, pt) state.
65
64
  - **No Crypto Officer test**: the ACVP does not expose Crypto Officer ECB tests either; the modes (CBC, GCM…) will carry them.
66
65
 
67
66
  ## Cross-references
68
67
 
69
68
  - Module: [`cipher/aes.js`](./aes.js)
70
- - Tests: [`cipher/aes.test.js`](https://github.com/awacloud/awa/blob/main/packages/front/fw/src/crypto/cipher/aes.test.js) — **544 tests** (542 conformance tests via `describe.each` over 2 paths: CT default `api.fn` + T-table opt-in `api.ttable.fn`, same FIPS-197 + ACVP-AES-ECB-1.0 vectors byte-exact; + 2 `api.bitsliced.fn` alias tests)
71
- - Uint8Array wrappers (outside `.acvp.md` scope): [`utils/aes_ctr.js`](../utils/aes_ctr.js), [`utils/aes_modes.js`](../utils/aes_modes.js) — cover ECB+CTR / multi-mode and will be validated via the `mode/*` iterations.
69
+ - Tests: [`cipher/aes.test.js`](https://github.com/awacloud/awa/blob/main/packages/front/fw/src/crypto/cipher/aes.test.js) — **543 tests** (542 conformance tests via `describe.each` over 2 paths: CT default `api.fn` + T-table opt-in `api.ttable.fn`, same FIPS-197 + ACVP-AES-ECB-1.0 vectors byte-exact; + 1 asserting the removed `bitsliced` alias is gone)
70
+ - Uint8Array wrappers (outside `.acvp.md` scope): [`utils/aes_modes.js`](../utils/aes_modes.js) — cover ECB+CTR / multi-mode and will be validated via the `mode/*` iterations.
72
71
  - ACVP draft: `references/NIST/ACVP/src/draft-celi-acvp-symmetric.adoc`
73
72
  - Vectors: `references/NIST/ACVP-Server-1.1.0.42/gen-val/json-files/ACVP-AES-ECB-1.0/`
74
73
  - Overall conformance: [`NIST_CONFORMANCE.md`](../NIST_CONFORMANCE.md)