@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.
- package/CHANGELOG.md +125 -0
- package/NOTICE +8 -0
- package/README.md +163 -31
- package/dist/build/fw.core.pure.meta.json +6 -6
- package/dist/build/fw.core.pure.min.js +15 -12
- package/dist/build/fw.full.pure.meta.json +13 -7
- package/dist/build/fw.full.pure.min.js +45 -42
- package/dist/build/fw.minimal.pure.meta.json +6 -6
- package/dist/build/fw.minimal.pure.min.js +16 -13
- package/dist/build/fw.pack.compress-heavy.pure.meta.json +6 -6
- package/dist/build/fw.pack.compress-heavy.pure.min.js +3 -3
- package/dist/build/fw.pack.crypto-advanced.pure.meta.json +6 -6
- package/dist/build/fw.pack.crypto-advanced.pure.min.js +1 -1
- package/dist/build/fw.pack.crypto-basic.pure.meta.json +6 -6
- package/dist/build/fw.pack.crypto-basic.pure.min.js +1 -1
- package/dist/build/fw.pack.crypto-identity.pure.meta.json +7 -6
- package/dist/build/fw.pack.crypto-identity.pure.min.js +4 -4
- package/dist/build/fw.pwa.pure.meta.json +7 -6
- package/dist/build/fw.pwa.pure.min.js +38 -35
- package/dist/build/fw.site-interactive.pure.meta.json +6 -6
- package/dist/build/fw.site-interactive.pure.min.js +37 -34
- package/dist/build/fw.site.pure.meta.json +6 -6
- package/dist/build/fw.site.pure.min.js +24 -21
- package/dist/build/fw.spa.pure.meta.json +8 -7
- package/dist/build/fw.spa.pure.min.js +41 -38
- package/dist/build/sanity-base-classic.min.js +1 -1
- package/dist/build/sanity.min.js +1 -1
- package/dist/types/core/internal.d.ts +29 -0
- package/dist/types/core/internal.d.ts.map +1 -0
- package/dist/types/core/logger.d.ts +23 -4
- package/dist/types/core/logger.d.ts.map +1 -1
- package/dist/types/core/modules.d.ts +374 -61
- package/dist/types/core/modules.d.ts.map +1 -1
- package/dist/types/core/runtime.d.ts +10 -6
- package/dist/types/core/runtime.d.ts.map +1 -1
- package/dist/types/core/worker-helper.d.ts +35 -0
- package/dist/types/core/worker-helper.d.ts.map +1 -1
- package/dist/types/crypto/cipher/aes.d.ts +1 -7
- package/dist/types/crypto/cipher/aes.d.ts.map +1 -1
- package/dist/types/crypto/cipher/chacha20.d.ts +0 -10
- package/dist/types/crypto/cipher/chacha20.d.ts.map +1 -1
- package/dist/types/crypto/hash/argon2.d.ts +0 -15
- package/dist/types/crypto/hash/argon2.d.ts.map +1 -1
- package/dist/types/crypto/hash/blake2b.d.ts.map +1 -1
- package/dist/types/crypto/hash/hmac.d.ts.map +1 -1
- package/dist/types/crypto/hash/pbkdf2.d.ts.map +1 -1
- package/dist/types/crypto/hash/poly1305.d.ts.map +1 -1
- package/dist/types/crypto/hash/sha224.d.ts +1 -1
- package/dist/types/crypto/hash/sha256.d.ts +4 -13
- package/dist/types/crypto/hash/sha256.d.ts.map +1 -1
- package/dist/types/crypto/hash/sha3.d.ts.map +1 -1
- package/dist/types/crypto/hash/sha384.d.ts +1 -1
- package/dist/types/crypto/hash/sha512.d.ts +4 -13
- package/dist/types/crypto/hash/sha512.d.ts.map +1 -1
- package/dist/types/crypto/mode/cmac.d.ts +0 -6
- package/dist/types/crypto/mode/cmac.d.ts.map +1 -1
- package/dist/types/crypto/mode/ctr.d.ts +0 -6
- package/dist/types/crypto/mode/ctr.d.ts.map +1 -1
- package/dist/types/crypto/mode/gcm.d.ts +0 -9
- package/dist/types/crypto/mode/gcm.d.ts.map +1 -1
- package/dist/types/crypto/pkc/ecc.d.ts +0 -1
- package/dist/types/crypto/pkc/ecc.d.ts.map +1 -1
- package/dist/types/crypto/pkc/ed25519.d.ts +4 -25
- package/dist/types/crypto/pkc/ed25519.d.ts.map +1 -1
- package/dist/types/crypto/pkc/hybridSign.d.ts +25 -5
- package/dist/types/crypto/pkc/hybridSign.d.ts.map +1 -1
- package/dist/types/crypto/pkc/ml_dsa.d.ts +6 -26
- package/dist/types/crypto/pkc/ml_dsa.d.ts.map +1 -1
- package/dist/types/crypto/pkc/ml_kem.d.ts +0 -43
- package/dist/types/crypto/pkc/ml_kem.d.ts.map +1 -1
- package/dist/types/crypto/pkc/rsa.d.ts +0 -24
- package/dist/types/crypto/pkc/rsa.d.ts.map +1 -1
- package/dist/types/crypto/pkc/slh_dsa.d.ts +6 -16
- package/dist/types/crypto/pkc/slh_dsa.d.ts.map +1 -1
- package/dist/types/crypto/pkc/x25519.d.ts +0 -6
- package/dist/types/crypto/pkc/x25519.d.ts.map +1 -1
- package/dist/types/crypto/utils/bitArray.d.ts +0 -8
- package/dist/types/crypto/utils/bitArray.d.ts.map +1 -1
- package/dist/types/crypto/utils/jws.d.ts +6 -14
- package/dist/types/crypto/utils/jws.d.ts.map +1 -1
- package/dist/types/crypto/utils/keyformat.d.ts +52 -0
- package/dist/types/crypto/utils/keyformat.d.ts.map +1 -1
- package/dist/types/crypto/utils/random.d.ts +1 -10
- package/dist/types/crypto/utils/random.d.ts.map +1 -1
- package/dist/types/crypto/utils/rsaKeygen.d.ts +0 -10
- package/dist/types/crypto/utils/rsaKeygen.d.ts.map +1 -1
- package/dist/types/crypto/utils/uuid.d.ts.map +1 -1
- package/dist/types/crypto/utils/x509.d.ts +397 -0
- package/dist/types/crypto/utils/x509.d.ts.map +1 -0
- package/dist/types/crypto/wasm/argon2.d.ts +2 -1
- package/dist/types/crypto/wasm/argon2.d.ts.map +1 -1
- package/dist/types/crypto/wasm/pbkdf2.d.ts +2 -2
- package/dist/types/crypto/wasm/pbkdf2.d.ts.map +1 -1
- package/dist/types/crypto/wasm/rsa.d.ts.map +1 -1
- package/dist/types/crypto/wasm/runtime.d.ts +13 -0
- package/dist/types/crypto/wasm/runtime.d.ts.map +1 -1
- package/dist/types/crypto/webcrypto/aes.d.ts.map +1 -1
- package/dist/types/crypto/webcrypto/aeskw.d.ts.map +1 -1
- package/dist/types/crypto/webcrypto/digest.d.ts +0 -4
- package/dist/types/crypto/webcrypto/digest.d.ts.map +1 -1
- package/dist/types/crypto/webcrypto/rsa.d.ts.map +1 -1
- package/dist/types/dom/fs/fileIntake.d.ts +59 -0
- package/dist/types/dom/fs/fileIntake.d.ts.map +1 -0
- package/dist/types/dom/fs/fsAccess.d.ts.map +1 -1
- package/dist/types/dom/query/dnd.d.ts.map +1 -1
- package/dist/types/dom/query/sound.d.ts +89 -0
- package/dist/types/dom/query/sound.d.ts.map +1 -0
- package/dist/types/dom/rendering/chart.d.ts.map +1 -1
- package/dist/types/dom/rendering/component.d.ts +9 -3
- package/dist/types/dom/rendering/component.d.ts.map +1 -1
- package/dist/types/dom/rendering/parser.d.ts +39 -0
- package/dist/types/dom/rendering/parser.d.ts.map +1 -1
- package/dist/types/dom/rendering/render.d.ts.map +1 -1
- package/dist/types/dom/rendering/sanitize.d.ts +4 -0
- package/dist/types/dom/rendering/sanitize.d.ts.map +1 -1
- package/dist/types/dom/rendering/secPolicy.d.ts.map +1 -1
- package/dist/types/dom/rendering/styleSheet.d.ts +74 -0
- package/dist/types/dom/rendering/styleSheet.d.ts.map +1 -0
- package/dist/types/dom/rendering/template.d.ts +9 -3
- package/dist/types/dom/rendering/template.d.ts.map +1 -1
- package/dist/types/dom/rendering/themeTokens.d.ts +9 -3
- package/dist/types/dom/rendering/themeTokens.d.ts.map +1 -1
- package/dist/types/dom/rendering/uiSession-core.d.ts +9 -3
- package/dist/types/dom/rendering/uiSession-core.d.ts.map +1 -1
- package/dist/types/dom/rendering/uiSession-list.d.ts +9 -3
- package/dist/types/dom/rendering/uiSession-list.d.ts.map +1 -1
- package/dist/types/dom/rendering/uiSession.d.ts +18 -6
- package/dist/types/dom/rendering/uiSession.d.ts.map +1 -1
- package/dist/types/dom/sw/installPrompt.d.ts +89 -0
- package/dist/types/dom/sw/installPrompt.d.ts.map +1 -0
- package/dist/types/dom/sw/precache.d.ts +149 -0
- package/dist/types/dom/sw/precache.d.ts.map +1 -0
- package/dist/types/dom/sw/swUpdate.d.ts +129 -0
- package/dist/types/dom/sw/swUpdate.d.ts.map +1 -0
- package/dist/types/dom/utils/clipboard.d.ts +8 -0
- package/dist/types/dom/utils/clipboard.d.ts.map +1 -1
- package/dist/types/dom/utils/keybindings.d.ts.map +1 -1
- package/dist/types/dom/utils/route.d.ts.map +1 -1
- package/dist/types/dom/utils/ua.d.ts +2 -2
- package/dist/types/dom/utils/ua.d.ts.map +1 -1
- package/dist/types/io/calc/crc32.d.ts.map +1 -1
- package/dist/types/io/codec/b64.d.ts +24 -0
- package/dist/types/io/codec/b64.d.ts.map +1 -1
- package/dist/types/io/codec/cbor.d.ts +1 -0
- package/dist/types/io/codec/cbor.d.ts.map +1 -1
- package/dist/types/io/codec/hex.d.ts.map +1 -1
- package/dist/types/io/codec/msgpack.d.ts +1 -0
- package/dist/types/io/codec/msgpack.d.ts.map +1 -1
- package/dist/types/io/codec/url.d.ts +3 -1
- package/dist/types/io/codec/url.d.ts.map +1 -1
- package/dist/types/io/codec/utf8.d.ts.map +1 -1
- package/dist/types/io/compress/bitstream.d.ts +1 -1
- package/dist/types/io/compress/brotli.d.ts +0 -1
- package/dist/types/io/compress/brotli.d.ts.map +1 -1
- package/dist/types/io/compress/brotli_shared.d.ts +0 -4
- package/dist/types/io/compress/brotli_shared.d.ts.map +1 -1
- package/dist/types/io/compress/deflate.d.ts +14 -1
- package/dist/types/io/compress/deflate.d.ts.map +1 -1
- package/dist/types/io/compress/gzip.d.ts +4 -0
- package/dist/types/io/compress/gzip.d.ts.map +1 -1
- package/dist/types/io/compress/huffman.d.ts +7 -0
- package/dist/types/io/compress/huffman.d.ts.map +1 -1
- package/dist/types/io/compress/lz4.d.ts +4 -2
- package/dist/types/io/compress/lz4.d.ts.map +1 -1
- package/dist/types/io/compress/lz77.d.ts +17 -0
- package/dist/types/io/compress/lz77.d.ts.map +1 -1
- package/dist/types/io/compress/lzw.d.ts +2 -0
- package/dist/types/io/compress/lzw.d.ts.map +1 -1
- package/dist/types/io/compress/zip.d.ts.map +1 -1
- package/dist/types/io/compress/zlib.d.ts +9 -2
- package/dist/types/io/compress/zlib.d.ts.map +1 -1
- package/dist/types/io/math/linalg.d.ts.map +1 -1
- package/dist/types/process/rpc.d.ts.map +1 -1
- package/dist/types/process/workerPool.d.ts.map +1 -1
- package/dist/types/sanity/base.d.ts +12 -2
- package/dist/types/sanity/base.d.ts.map +1 -1
- package/dist/types/sanity/lockdown.d.ts +6 -5
- package/dist/types/sanity/lockdown.d.ts.map +1 -1
- package/dist/types/sanity/wasm-gate.d.ts +1 -1
- package/docs/README.md +17 -10
- package/docs/api/README.md +5 -5
- package/docs/api/core/logger.md +2 -1
- package/docs/api/core/modules.md +3 -3
- package/docs/api/core/runtime.md +9 -9
- package/docs/api/core/worker-helper.md +12 -2
- package/docs/api/crypto/README.md +1 -1
- package/docs/api/crypto/cipher/README.md +2 -2
- package/docs/api/crypto/cipher/aes.md +5 -10
- package/docs/api/crypto/cipher/chacha20.md +3 -8
- package/docs/api/crypto/hash/README.md +5 -5
- package/docs/api/crypto/hash/adf.md +21 -11
- package/docs/api/crypto/hash/argon2.md +3 -12
- package/docs/api/crypto/hash/blake2b.md +12 -14
- package/docs/api/crypto/hash/pbkdf2.md +1 -1
- package/docs/api/crypto/hash/sha224.md +2 -2
- package/docs/api/crypto/hash/sha256.md +4 -4
- package/docs/api/crypto/hash/sha3.md +2 -2
- package/docs/api/crypto/hash/sha384.md +1 -1
- package/docs/api/crypto/hash/sha512.md +5 -5
- package/docs/api/crypto/hash/sha512_224.md +1 -1
- package/docs/api/crypto/hash/sha512_256.md +1 -1
- package/docs/api/crypto/mode/README.md +3 -3
- package/docs/api/crypto/mode/cbc.md +2 -2
- package/docs/api/crypto/mode/chacha20poly1305.md +1 -1
- package/docs/api/crypto/mode/cmac.md +4 -4
- package/docs/api/crypto/mode/ctr.md +2 -3
- package/docs/api/crypto/mode/gcm.md +5 -5
- package/docs/api/crypto/mode/kw.md +4 -4
- package/docs/api/crypto/pkc/README.md +8 -8
- package/docs/api/crypto/pkc/ecc.md +19 -17
- package/docs/api/crypto/pkc/ed25519.md +10 -15
- package/docs/api/crypto/pkc/hybridKem.md +8 -2
- package/docs/api/crypto/pkc/hybridSign.md +34 -7
- package/docs/api/crypto/pkc/ml_dsa.md +20 -19
- package/docs/api/crypto/pkc/ml_kem.md +3 -3
- package/docs/api/crypto/pkc/rsa.md +7 -9
- package/docs/api/crypto/pkc/slh_dsa.md +12 -12
- package/docs/api/crypto/pkc/x25519.md +5 -4
- package/docs/api/crypto/utils/README.md +7 -7
- package/docs/api/crypto/utils/aes_modes.md +2 -5
- package/docs/api/crypto/utils/asn1.md +25 -16
- package/docs/api/crypto/utils/jws.md +6 -4
- package/docs/api/crypto/utils/keyformat.md +24 -15
- package/docs/api/crypto/utils/pad.md +1 -1
- package/docs/api/crypto/utils/pem.md +3 -3
- package/docs/api/crypto/utils/random.md +3 -4
- package/docs/api/crypto/utils/rsaKeygen.md +2 -2
- package/docs/api/crypto/utils/totp.md +2 -2
- package/docs/api/crypto/utils/uuid.md +5 -5
- package/docs/api/crypto/utils/x509.md +124 -0
- package/docs/api/crypto/wasm/aes.md +1 -1
- package/docs/api/crypto/wasm/argon2.md +6 -4
- package/docs/api/crypto/wasm/ml_kem.md +1 -0
- package/docs/api/crypto/wasm/pbkdf2.md +8 -8
- package/docs/api/crypto/wasm/rsa.md +1 -1
- package/docs/api/crypto/wasm/runtime.md +27 -10
- package/docs/api/crypto/webcrypto/aes.md +1 -1
- package/docs/api/crypto/webcrypto/aeskw.md +2 -2
- package/docs/api/crypto/webcrypto/digest.md +3 -5
- package/docs/api/crypto/webcrypto/ecc.md +1 -1
- package/docs/api/crypto/webcrypto/ed25519.md +1 -1
- package/docs/api/crypto/webcrypto/rsa.md +3 -2
- package/docs/api/crypto/webcrypto/x25519.md +1 -1
- package/docs/api/dom/README.md +6 -1
- package/docs/api/dom/fs/README.md +1 -0
- package/docs/api/dom/fs/fileIntake.md +120 -0
- package/docs/api/dom/fs/fsAccess.md +1 -0
- package/docs/api/dom/fs/indexedDB.md +1 -1
- package/docs/api/dom/fs/storage.md +1 -1
- package/docs/api/dom/query/README.md +2 -1
- package/docs/api/dom/query/dnd.md +4 -1
- package/docs/api/dom/query/dom.md +5 -0
- package/docs/api/dom/query/sound.md +103 -0
- package/docs/api/dom/rendering/README.md +4 -3
- package/docs/api/dom/rendering/chart.md +5 -4
- package/docs/api/dom/rendering/component.md +25 -3
- package/docs/api/dom/rendering/parser.md +5 -2
- package/docs/api/dom/rendering/reactiveBind.md +1 -1
- package/docs/api/dom/rendering/render.md +2 -2
- package/docs/api/dom/rendering/sanitize.md +10 -2
- package/docs/api/dom/rendering/secPolicy.md +4 -4
- package/docs/api/dom/rendering/styleSheet.md +85 -0
- package/docs/api/dom/rendering/template.md +20 -5
- package/docs/api/dom/rendering/themeTokens.md +6 -3
- package/docs/api/dom/rendering/uiSession.md +18 -5
- package/docs/api/dom/rendering/virtualScroll.md +2 -2
- package/docs/api/dom/sensors/geolocation.md +1 -1
- package/docs/api/dom/sw/README.md +7 -1
- package/docs/api/dom/sw/cache.md +2 -1
- package/docs/api/dom/sw/installPrompt.md +111 -0
- package/docs/api/dom/sw/precache.md +124 -0
- package/docs/api/dom/sw/serviceWorker.md +4 -2
- package/docs/api/dom/sw/swUpdate.md +112 -0
- package/docs/api/dom/utils/clipboard.md +56 -5
- package/docs/api/dom/utils/entropyCollector.md +1 -1
- package/docs/api/dom/utils/keybindings.md +17 -2
- package/docs/api/dom/utils/leaderElection.md +2 -2
- package/docs/api/dom/utils/route.md +1 -0
- package/docs/api/dom/utils/ua.md +15 -10
- package/docs/api/io/calc/crc32.md +4 -1
- package/docs/api/io/codec/README.md +2 -2
- package/docs/api/io/codec/b64.md +31 -2
- package/docs/api/io/codec/buffer.md +1 -1
- package/docs/api/io/codec/cbor.md +6 -4
- package/docs/api/io/codec/csv.md +178 -178
- package/docs/api/io/codec/hex.md +10 -2
- package/docs/api/io/codec/msgpack.md +4 -3
- package/docs/api/io/codec/url.md +4 -3
- package/docs/api/io/codec/utf8.md +3 -3
- package/docs/api/io/compress/bitstream.md +6 -3
- package/docs/api/io/compress/brotli.md +36 -4
- package/docs/api/io/compress/brotli_shared.md +1 -1
- package/docs/api/io/compress/deflate.md +42 -34
- package/docs/api/io/compress/gzip.md +26 -6
- package/docs/api/io/compress/huffman.md +2 -1
- package/docs/api/io/compress/lz4.md +5 -3
- package/docs/api/io/compress/lz77.md +26 -3
- package/docs/api/io/compress/lzw.md +13 -8
- package/docs/api/io/compress/zip.md +36 -10
- package/docs/api/io/compress/zlib.md +21 -5
- package/docs/api/io/math/linalg.md +1 -1
- package/docs/api/io/utils/valid.md +1 -1
- package/docs/api/process/rpc.md +3 -2
- package/docs/api/process/workerPool.md +1 -1
- package/docs/api/sanity/base.md +9 -5
- package/docs/api/sanity/lockdown.md +7 -6
- package/docs/api/surface.json +12311 -0
- package/docs/api/typed.md +5 -3
- package/docs/dev/README.md +2 -0
- package/docs/dev/bench.md +76 -0
- package/docs/dev/crypto-references.md +54 -0
- package/docs/dev/provenance.md +30 -7
- package/docs/dev/publishing.md +7 -7
- package/docs/dev/runtime.md +1 -1
- package/docs/dev/testing.md +13 -0
- package/docs/evidence/l4-evidence.md +86 -0
- package/docs/evidence/pqc-hybrid-evidence.md +7 -6
- package/docs/guide/README.md +1 -0
- package/docs/guide/_QUICK_REF.md +5 -5
- package/docs/guide/doc-format.md +4 -3
- package/docs/guide/integrations-hmr.md +1 -1
- package/docs/guide/module-creation-workflow.md +8 -8
- package/docs/guide/rendering-pipeline.md +11 -4
- package/docs/guide/security.md +7 -5
- package/docs/guide/stability.md +123 -0
- package/docs/guide/tutorial-todo.md +20 -8
- package/docs/guide/typescript.md +9 -0
- package/docs/guide/worker-confinement.md +30 -17
- package/docs/notes/lz77-deflate-factorization.md +3 -3
- package/docs/tools/README.md +1 -1
- package/docs/tools/bundler.md +3 -3
- package/docs/tools/codegen.md +1 -1
- package/docs/tools/standalone.md +0 -1
- package/fw.config.json +2 -2
- package/integrations/_shared/catalog.generated.json +7 -1
- package/integrations/_shared/core.js +1 -1
- package/integrations/astro/index.js +1 -1
- package/integrations/eslint/README.md +7 -1
- package/integrations/nextjs/index.js +1 -1
- package/integrations/nodejs/README.md +3 -3
- package/integrations/turbopack/index.js +2 -2
- package/integrations/typedoc/categorize.js +1 -1
- package/integrations/typedoc/typedoc.json +2 -1
- package/integrations/vite/index.js +2 -2
- package/integrations/vite/vite-env.d.ts +7 -4
- package/integrations/webpack/index.js +3 -3
- package/package.json +76 -10
- package/src/core/internal.js +31 -0
- package/src/core/logger.js +95 -23
- package/src/core/modules.js +17 -8
- package/src/core/readyState.js +1 -1
- package/src/core/runtime.js +74 -27
- package/src/core/worker-helper.js +83 -4
- package/src/crypto/NIST_CONFORMANCE.md +47 -34
- package/src/crypto/cipher/aes.acvp.md +7 -8
- package/src/crypto/cipher/aes.js +280 -229
- package/src/crypto/cipher/chacha20.acvp.md +6 -7
- package/src/crypto/cipher/chacha20.js +91 -61
- package/src/crypto/hash/adf.js +1 -1
- package/src/crypto/hash/argon2.acvp.md +11 -15
- package/src/crypto/hash/argon2.js +9 -24
- package/src/crypto/hash/blake2b.js +157 -125
- package/src/crypto/hash/hkdf.acvp.md +15 -15
- package/src/crypto/hash/hkdf.js +1 -1
- package/src/crypto/hash/hmac.acvp.md +10 -12
- package/src/crypto/hash/hmac.js +5 -1
- package/src/crypto/hash/pbkdf2.acvp.md +13 -13
- package/src/crypto/hash/pbkdf2.js +36 -8
- package/src/crypto/hash/poly1305.acvp.md +10 -6
- package/src/crypto/hash/poly1305.js +171 -50
- package/src/crypto/hash/sha224.acvp.md +3 -3
- package/src/crypto/hash/sha224.js +4 -4
- package/src/crypto/hash/sha256.acvp.md +2 -2
- package/src/crypto/hash/sha256.js +514 -50
- package/src/crypto/hash/sha3.acvp.md +9 -9
- package/src/crypto/hash/sha3.js +127 -71
- package/src/crypto/hash/sha384.acvp.md +3 -3
- package/src/crypto/hash/sha384.js +4 -4
- package/src/crypto/hash/sha512.acvp.md +7 -8
- package/src/crypto/hash/sha512.js +107 -108
- package/src/crypto/hash/sha512_224.acvp.md +6 -6
- package/src/crypto/hash/sha512_224.js +2 -2
- package/src/crypto/hash/sha512_256.acvp.md +6 -6
- package/src/crypto/hash/sha512_256.js +2 -2
- package/src/crypto/mode/cbc.acvp.md +2 -2
- package/src/crypto/mode/cbc.js +1 -1
- package/src/crypto/mode/chacha20poly1305.acvp.md +6 -6
- package/src/crypto/mode/chacha20poly1305.js +3 -3
- package/src/crypto/mode/cmac.acvp.md +5 -5
- package/src/crypto/mode/cmac.js +8 -8
- package/src/crypto/mode/ctr.acvp.md +2 -2
- package/src/crypto/mode/ctr.js +1 -3
- package/src/crypto/mode/gcm.acvp.md +6 -6
- package/src/crypto/mode/gcm.js +7 -7
- package/src/crypto/mode/kw.acvp.md +4 -4
- package/src/crypto/mode/kw.js +5 -5
- package/src/crypto/pkc/ecc.acvp.md +13 -13
- package/src/crypto/pkc/ecc.js +9 -11
- package/src/crypto/pkc/ed25519.acvp.md +30 -34
- package/src/crypto/pkc/ed25519.js +453 -94
- package/src/crypto/pkc/hybrid-kat.provenance.md +4 -4
- package/src/crypto/pkc/hybridSign.js +103 -24
- package/src/crypto/pkc/ml_dsa.acvp.md +18 -18
- package/src/crypto/pkc/ml_dsa.js +29 -32
- package/src/crypto/pkc/ml_kem.acvp.md +7 -7
- package/src/crypto/pkc/ml_kem.js +15 -21
- package/src/crypto/pkc/rsa.acvp.md +11 -15
- package/src/crypto/pkc/rsa.js +7 -44
- package/src/crypto/pkc/slh_dsa.acvp.md +16 -16
- package/src/crypto/pkc/slh_dsa.js +16 -18
- package/src/crypto/pkc/x25519.acvp.md +13 -10
- package/src/crypto/pkc/x25519.js +273 -29
- package/src/crypto/utils/aes_modes.acvp.md +1 -2
- package/src/crypto/utils/aes_modes.js +2 -2
- package/src/crypto/utils/asn1-oid.js +1 -1
- package/src/crypto/utils/asn1.js +1 -1
- package/src/crypto/utils/bitArray.js +33 -48
- package/src/crypto/utils/bn.js +1 -1
- package/src/crypto/utils/jws.js +37 -41
- package/src/crypto/utils/keyformat.js +181 -2
- package/src/crypto/utils/pem.js +1 -1
- package/src/crypto/utils/random.acvp.md +5 -5
- package/src/crypto/utils/random.js +845 -846
- package/src/crypto/utils/rsaKeygen.acvp.md +3 -2
- package/src/crypto/utils/rsaKeygen.js +6 -6
- package/src/crypto/utils/totp.js +1 -1
- package/src/crypto/utils/uuid.acvp.md +5 -5
- package/src/crypto/utils/uuid.js +11 -10
- package/src/crypto/utils/x509.js +591 -0
- package/src/crypto/wasm/aes.js +1 -1
- package/src/crypto/wasm/aes.scalar.wasm +0 -0
- package/src/crypto/wasm/argon2.js +17 -1
- package/src/crypto/wasm/argon2.scalar.wasm +0 -0
- package/src/crypto/wasm/blake2b.scalar.wasm +0 -0
- package/src/crypto/wasm/blake2b.simd.wasm +0 -0
- package/src/crypto/wasm/chacha20poly1305.scalar.wasm +0 -0
- package/src/crypto/wasm/chacha20poly1305.simd.wasm +0 -0
- package/src/crypto/wasm/cmac.scalar.wasm +0 -0
- package/src/crypto/wasm/ecc.js +3 -3
- package/src/crypto/wasm/ecc.scalar.wasm +0 -0
- package/src/crypto/wasm/ed25519.js +1 -1
- package/src/crypto/wasm/ed25519.scalar.wasm +0 -0
- package/src/crypto/wasm/hkdf.scalar.wasm +0 -0
- package/src/crypto/wasm/hmac.scalar.wasm +0 -0
- package/src/crypto/wasm/ml_dsa.js +2 -2
- package/src/crypto/wasm/ml_dsa.scalar.wasm +0 -0
- package/src/crypto/wasm/ml_dsa.simd.wasm +0 -0
- package/src/crypto/wasm/ml_kem.js +2 -2
- package/src/crypto/wasm/ml_kem.scalar.wasm +0 -0
- package/src/crypto/wasm/ml_kem.simd.wasm +0 -0
- package/src/crypto/wasm/pbkdf2.js +8 -6
- package/src/crypto/wasm/pbkdf2.scalar.wasm +0 -0
- package/src/crypto/wasm/rsa.js +6 -5
- package/src/crypto/wasm/rsa.scalar.wasm +0 -0
- package/src/crypto/wasm/runtime.js +84 -17
- package/src/crypto/wasm/sha2.scalar.wasm +0 -0
- package/src/crypto/wasm/sha3.scalar.wasm +0 -0
- package/src/crypto/wasm/sha3.simd.wasm +0 -0
- package/src/crypto/wasm/slh_dsa.js +1 -1
- package/src/crypto/wasm/slh_dsa.scalar.wasm +0 -0
- package/src/crypto/wasm/x25519.js +1 -1
- package/src/crypto/wasm/x25519.scalar.wasm +0 -0
- package/src/crypto/webcrypto/aes.js +8 -2
- package/src/crypto/webcrypto/aeskw.js +7 -2
- package/src/crypto/webcrypto/digest.js +1 -15
- package/src/crypto/webcrypto/ecc.js +2 -2
- package/src/crypto/webcrypto/ed25519.js +2 -2
- package/src/crypto/webcrypto/hmac.js +2 -2
- package/src/crypto/webcrypto/rsa.js +7 -2
- package/src/crypto/webcrypto/x25519.js +2 -2
- package/src/dom/display/animate.js +1 -1
- package/src/dom/display/fullscreen.js +1 -1
- package/src/dom/fs/download.js +1 -1
- package/src/dom/fs/fileIntake.js +192 -0
- package/src/dom/fs/fsAccess.js +2 -3
- package/src/dom/fs/indexedDB.js +1 -1
- package/src/dom/fs/remoteStore.js +1 -1
- package/src/dom/fs/storage.js +1 -1
- package/src/dom/lifecycle/idle.js +1 -1
- package/src/dom/lifecycle/visibility.js +1 -1
- package/src/dom/lifecycle/wakeLock.js +1 -1
- package/src/dom/net/ajax.js +1 -1
- package/src/dom/net/network.js +1 -1
- package/src/dom/net/sse.js +1 -1
- package/src/dom/net/webrtc.js +1 -1
- package/src/dom/net/ws.js +1 -1
- package/src/dom/query/dnd.js +56 -4
- package/src/dom/query/dom.js +1 -1
- package/src/dom/query/events.js +1 -1
- package/src/dom/query/gesture.js +1 -1
- package/src/dom/query/media.js +1 -1
- package/src/dom/query/sound.js +333 -0
- package/src/dom/rendering/chart.js +736 -663
- package/src/dom/rendering/component.js +25 -14
- package/src/dom/rendering/devtools.js +2 -2
- package/src/dom/rendering/parser.js +155 -12
- package/src/dom/rendering/render.js +14 -4
- package/src/dom/rendering/sanitize.js +11 -4
- package/src/dom/rendering/secPolicy.js +6 -4
- package/src/dom/rendering/styleSheet.js +217 -0
- package/src/dom/rendering/template.js +72 -13
- package/src/dom/rendering/themeTokens.js +542 -522
- package/src/dom/rendering/uiSession-core.js +51 -6
- package/src/dom/rendering/uiSession-direct.js +1 -1
- package/src/dom/rendering/uiSession-list.js +4 -4
- package/src/dom/rendering/uiSession.js +1 -1
- package/src/dom/rendering/virtualScroll.js +341 -341
- package/src/dom/sensors/battery.js +1 -1
- package/src/dom/sensors/geolocation.js +1 -1
- package/src/dom/sensors/networkInfo.js +1 -1
- package/src/dom/sensors/sensors.js +1 -1
- package/src/dom/sw/backgroundSync.js +1 -1
- package/src/dom/sw/cache.js +1 -1
- package/src/dom/sw/installPrompt.js +151 -0
- package/src/dom/sw/precache.js +257 -0
- package/src/dom/sw/push.js +1 -1
- package/src/dom/sw/sharedWorker.js +1 -1
- package/src/dom/sw/swUpdate.js +239 -0
- package/src/dom/utils/a11y.js +1 -1
- package/src/dom/utils/clipboard.js +56 -6
- package/src/dom/utils/entropyCollector.js +1 -1
- package/src/dom/utils/focus.js +1 -1
- package/src/dom/utils/form.js +1 -1
- package/src/dom/utils/keybindings.js +600 -574
- package/src/dom/utils/leaderElection.js +1 -1
- package/src/dom/utils/notifications.js +1 -1
- package/src/dom/utils/permissions.js +107 -107
- package/src/dom/utils/route.js +14 -2
- package/src/dom/utils/ua.js +42 -28
- package/src/dom/utils/webauthn.js +1 -1
- package/src/io/binary/reader.js +1 -1
- package/src/io/binary/writer.js +1 -1
- package/src/io/calc/bigint.js +1 -1
- package/src/io/calc/crc32.js +28 -2
- package/src/io/calc/easing.js +514 -514
- package/src/io/codec/b64.js +189 -52
- package/src/io/codec/base32.js +1 -1
- package/src/io/codec/base58.js +1 -1
- package/src/io/codec/buffer.js +1 -1
- package/src/io/codec/cbor.js +111 -18
- package/src/io/codec/csv.js +1 -1
- package/src/io/codec/hex.js +51 -6
- package/src/io/codec/mime.js +1 -1
- package/src/io/codec/msgpack.js +47 -6
- package/src/io/codec/url.js +24 -7
- package/src/io/codec/utf8.js +5 -3
- package/src/io/codec/xml.js +1 -1
- package/src/io/compress/bitstream.js +2 -2
- package/src/io/compress/brotli.js +663 -163
- package/src/io/compress/brotli_dict.js +1 -1
- package/src/io/compress/brotli_dict_words.js +1 -1
- package/src/io/compress/brotli_frame.js +1 -1
- package/src/io/compress/brotli_shared.js +7 -7
- package/src/io/compress/deflate.js +87 -53
- package/src/io/compress/gzip.js +187 -74
- package/src/io/compress/huffman.js +24 -1
- package/src/io/compress/lz4.js +45 -7
- package/src/io/compress/lz77.js +148 -63
- package/src/io/compress/lzw.js +35 -19
- package/src/io/compress/zip.js +862 -815
- package/src/io/compress/zlib.js +87 -7
- package/src/io/i18n/i18n.js +1 -1
- package/src/io/math/fixed-point.js +1 -1
- package/src/io/math/geom.js +1 -1
- package/src/io/math/interp.js +1 -1
- package/src/io/math/linalg.js +10 -4
- package/src/io/math/stats.js +1 -1
- package/src/io/structures/btree.js +1 -1
- package/src/io/structures/heap.js +1 -1
- package/src/io/structures/lruCache.js +1 -1
- package/src/io/structures/ringBuffer.js +1 -1
- package/src/io/structures/tree-walker.js +1 -1
- package/src/io/structures/trie.js +1 -1
- package/src/io/sync/abort.js +1 -1
- package/src/io/sync/atomics.js +1 -1
- package/src/io/sync/cancellable.js +1 -1
- package/src/io/sync/channel.js +1 -1
- package/src/io/sync/mutex.js +1 -1
- package/src/io/sync/semaphore.js +1 -1
- package/src/io/sync/tokenBucket.js +1 -1
- package/src/io/text/ansi.js +1 -1
- package/src/io/text/html-entities.js +1 -1
- package/src/io/time/date.js +1 -1
- package/src/io/timing/clock.js +1 -1
- package/src/io/timing/rateLimit.js +1 -1
- package/src/io/timing/scheduler.js +1 -1
- package/src/io/utils/errors.js +1 -1
- package/src/io/utils/eventBus.js +1 -1
- package/src/io/utils/signal.js +1 -1
- package/src/io/utils/valid.js +1 -1
- package/src/main.js +1 -1
- package/src/process/message.js +1 -1
- package/src/process/rpc.js +7 -3
- package/src/process/workerPool.js +11 -4
- package/src/sanity/base.js +85 -39
- package/src/sanity/lockdown-apply.js +3 -3
- package/src/sanity/lockdown.js +58 -32
- package/src/sanity/wasm-gate.js +2 -2
- package/src/typed.js +7 -3
- package/third-party/NOTICE-brotli-dictionary.txt +69 -0
- package/third-party/NOTICE-fw-wasm-crypto.txt +576 -0
- package/third-party/NOTICE-whatwg-entities.txt +44 -0
- package/types/registry.generated.d.ts +7 -1
- package/types/typed.d.ts +7 -3
- package/dist/types/crypto/utils/aes_ctr.d.ts +0 -84
- package/dist/types/crypto/utils/aes_ctr.d.ts.map +0 -1
- package/docs/api/crypto/utils/aes_ctr.md +0 -71
- package/src/crypto/utils/aes_ctr.acvp.md +0 -67
- package/src/crypto/utils/aes_ctr.js +0 -134
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// Copyright (c) 2026 AwaCloud SAS
|
|
2
2
|
// Author: Matthieu Bouilloux
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
|
|
@@ -31,7 +31,7 @@ import { utf8 } from '../../io/codec/utf8.js';
|
|
|
31
31
|
* @property {number} _outWords Number of 32-bit words retained in the digest.
|
|
32
32
|
* @property {number[]} _key Round constants.
|
|
33
33
|
* @property {() => Sha512Hasher} reset Reset internal state; returns `this`.
|
|
34
|
-
* @property {(data: number[]|string) => (Sha512Hasher|false)} update Absorb a bitArray
|
|
34
|
+
* @property {(data: number[]|string|Uint8Array) => (Sha512Hasher|false)} update Absorb a bitArray, a UTF-8 string or bytes (`Uint8Array`, hashed as its bytes); returns `this`, or `false` on > 2^53-1 bit overflow.
|
|
35
35
|
* @property {() => number[]} finalize Pad and emit the digest as a bitArray (truncated to `outWords`).
|
|
36
36
|
* @property {(words: ArrayLike<number>) => void} _block Compress one 32-word (1024-bit) block.
|
|
37
37
|
*/
|
|
@@ -40,8 +40,7 @@ import { utf8 } from '../../io/codec/utf8.js';
|
|
|
40
40
|
* Object returned by `sha512.factory()`.
|
|
41
41
|
* @typedef {object} Sha512API
|
|
42
42
|
* @property {new (hash?: Sha512Hasher) => Sha512Hasher} fn Streaming hasher constructor (optional arg clones an existing instance).
|
|
43
|
-
* @property {(data: number[]|string) => number[]} hash One-shot hash; returns the digest as a bitArray.
|
|
44
|
-
* @property {{ makeSha: (init: number[], outWords: number) => { fn: Function, hash: Function } }} _internal Escape hatch used by sha384/sha512_224/sha512_256 to build truncated variants.
|
|
43
|
+
* @property {(data: number[]|string|Uint8Array) => number[]} hash One-shot hash of a bitArray, a UTF-8 string or bytes; returns the digest as a bitArray.
|
|
45
44
|
*/
|
|
46
45
|
|
|
47
46
|
export const sha512 = {
|
|
@@ -83,12 +82,19 @@ export const sha512 = {
|
|
|
83
82
|
0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a, 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
|
|
84
83
|
];
|
|
85
84
|
|
|
85
|
+
// The round constants as int32 (a plain array holds the halves above
|
|
86
|
+
// 2^31 as doubles) and one message schedule shared by every block.
|
|
87
|
+
const _K32 = Int32Array.from(_KEY);
|
|
88
|
+
const _W = new Int32Array(160);
|
|
89
|
+
/** One block's 32 words, read from bytes by the `update` fast path. */
|
|
90
|
+
const _BW = new Int32Array(32);
|
|
91
|
+
|
|
86
92
|
// ── Builder for SHA-512-shaped hash modules with custom IV + truncation ──
|
|
87
93
|
//
|
|
88
94
|
// Default = SHA-512 (init = _INIT, outWords = 16 → 512-bit digest).
|
|
89
95
|
// Used by `sha512_224.js` and `sha512_256.js` (FIPS 180-4 §5.3.6.{1,2})
|
|
90
96
|
// to share the SHA-512 compression function with different IVs and a
|
|
91
|
-
// truncated final digest.
|
|
97
|
+
// truncated final digest.
|
|
92
98
|
/**
|
|
93
99
|
* Parametric SHA-512 compression factory.
|
|
94
100
|
* @param {number[]} init 16 × 32-bit IV halves (representing 8 × 64-bit lanes).
|
|
@@ -129,8 +135,32 @@ export const sha512 = {
|
|
|
129
135
|
},
|
|
130
136
|
|
|
131
137
|
update(data) {
|
|
138
|
+
if (data instanceof Uint8Array && this._buffer.length === 0 && data.length >= 128) {
|
|
139
|
+
// Bytes onto an empty buffer: the whole 128-byte blocks
|
|
140
|
+
// straight from the bytes (big-endian words), only the
|
|
141
|
+
// tail through the bitArray path below.
|
|
142
|
+
const whole = data.length - (data.length & 127);
|
|
143
|
+
if (this._length + whole * 8 > 9007199254740991) {
|
|
144
|
+
console.warn('[crypto] INVALID: sha512: cannot hash more than 2^53 - 1 bits');
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
const words = _BW;
|
|
148
|
+
for (let off = 0; off < whole; off += 128) {
|
|
149
|
+
for (let j = 0, o = off; j < 32; j++, o += 4) {
|
|
150
|
+
words[j] = (data[o] << 24) | (data[o + 1] << 16) | (data[o + 2] << 8) | data[o + 3];
|
|
151
|
+
}
|
|
152
|
+
this._block(words);
|
|
153
|
+
}
|
|
154
|
+
this._length += whole * 8;
|
|
155
|
+
if (whole === data.length) return this;
|
|
156
|
+
data = data.subarray(whole);
|
|
157
|
+
}
|
|
132
158
|
if (typeof data === 'string') {
|
|
133
159
|
data = bitArray.ui8_to_ba(utf8.toBytes(data));
|
|
160
|
+
} else if (data instanceof Uint8Array) {
|
|
161
|
+
// Bytes are hashed as bytes: without this branch a
|
|
162
|
+
// Uint8Array was read as a bitArray of 32-bit words.
|
|
163
|
+
data = bitArray.ui8_to_ba(data);
|
|
134
164
|
}
|
|
135
165
|
const b = this._buffer = bitArray.concat(this._buffer, data);
|
|
136
166
|
const ol = this._length;
|
|
@@ -173,124 +203,93 @@ export const sha512 = {
|
|
|
173
203
|
},
|
|
174
204
|
|
|
175
205
|
_block(words) {
|
|
206
|
+
// Every value an int32 (an unsigned half above 2^31 makes
|
|
207
|
+
// JavaScriptCore compute in doubles); a 64-bit add wraps
|
|
208
|
+
// the low half and takes its carry from bit operations:
|
|
209
|
+
// carry(a, b, lo) = ((a & b) | ((a | b) & ~lo)) >>> 31.
|
|
176
210
|
const h = this._h;
|
|
177
|
-
const k =
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
211
|
+
const k = _K32;
|
|
212
|
+
const w = _W;
|
|
213
|
+
for (let j = 0; j < 32; j++) w[j] = words[j] | 0;
|
|
214
|
+
for (let i = 16; i < 80; i++) {
|
|
215
|
+
const xh = w[(i - 15) * 2], xl = w[(i - 15) * 2 + 1];
|
|
216
|
+
const g0h = ((xl << 31) | (xh >>> 1)) ^ ((xl << 24) | (xh >>> 8)) ^ (xh >>> 7);
|
|
217
|
+
const g0l = ((xh << 31) | (xl >>> 1)) ^ ((xh << 24) | (xl >>> 8)) ^ ((xh << 25) | (xl >>> 7));
|
|
218
|
+
const yh = w[(i - 2) * 2], yl = w[(i - 2) * 2 + 1];
|
|
219
|
+
const g1h = ((yl << 13) | (yh >>> 19)) ^ ((yh << 3) | (yl >>> 29)) ^ (yh >>> 6);
|
|
220
|
+
const g1l = ((yh << 13) | (yl >>> 19)) ^ ((yl << 3) | (yh >>> 29)) ^ ((yh << 26) | (yl >>> 6));
|
|
221
|
+
const w7h = w[(i - 7) * 2], w7l = w[(i - 7) * 2 + 1];
|
|
222
|
+
const w16h = w[(i - 16) * 2], w16l = w[(i - 16) * 2 + 1];
|
|
223
|
+
// g0 + w[i-7] + g1 + w[i-16]
|
|
224
|
+
const l1 = (g0l + w7l) | 0;
|
|
225
|
+
let hi = (g0h + w7h + (((g0l & w7l) | ((g0l | w7l) & ~l1)) >>> 31)) | 0;
|
|
226
|
+
const l2 = (l1 + g1l) | 0;
|
|
227
|
+
hi = (hi + g1h + (((l1 & g1l) | ((l1 | g1l) & ~l2)) >>> 31)) | 0;
|
|
228
|
+
const l3 = (l2 + w16l) | 0;
|
|
229
|
+
hi = (hi + w16h + (((l2 & w16l) | ((l2 | w16l) & ~l3)) >>> 31)) | 0;
|
|
230
|
+
w[i * 2] = hi;
|
|
231
|
+
w[i * 2 + 1] = l3;
|
|
186
232
|
}
|
|
187
233
|
|
|
188
|
-
let ah =
|
|
189
|
-
let ch =
|
|
190
|
-
let eh =
|
|
191
|
-
let gh =
|
|
192
|
-
|
|
193
|
-
let wrh;
|
|
194
|
-
let wrl;
|
|
234
|
+
let ah = h[0] | 0, al = h[1] | 0, bh = h[2] | 0, bl = h[3] | 0;
|
|
235
|
+
let ch = h[4] | 0, cl = h[5] | 0, dh = h[6] | 0, dl = h[7] | 0;
|
|
236
|
+
let eh = h[8] | 0, el = h[9] | 0, fh = h[10] | 0, fl = h[11] | 0;
|
|
237
|
+
let gh = h[12] | 0, gl = h[13] | 0, hh = h[14] | 0, hl = h[15] | 0;
|
|
195
238
|
|
|
196
239
|
for (let i = 0; i < 80; i++) {
|
|
197
|
-
if (i < 16) {
|
|
198
|
-
wrh = w[i * 2];
|
|
199
|
-
wrl = w[i * 2 + 1];
|
|
200
|
-
} else {
|
|
201
|
-
const gamma0xh = w[(i - 15) * 2];
|
|
202
|
-
const gamma0xl = w[(i - 15) * 2 + 1];
|
|
203
|
-
const gamma0h =
|
|
204
|
-
((gamma0xl << 31) | (gamma0xh >>> 1)) ^
|
|
205
|
-
((gamma0xl << 24) | (gamma0xh >>> 8)) ^
|
|
206
|
-
(gamma0xh >>> 7);
|
|
207
|
-
const gamma0l =
|
|
208
|
-
((gamma0xh << 31) | (gamma0xl >>> 1)) ^
|
|
209
|
-
((gamma0xh << 24) | (gamma0xl >>> 8)) ^
|
|
210
|
-
((gamma0xh << 25) | (gamma0xl >>> 7));
|
|
211
|
-
|
|
212
|
-
const gamma1xh = w[(i - 2) * 2];
|
|
213
|
-
const gamma1xl = w[(i - 2) * 2 + 1];
|
|
214
|
-
const gamma1h =
|
|
215
|
-
((gamma1xl << 13) | (gamma1xh >>> 19)) ^
|
|
216
|
-
((gamma1xh << 3) | (gamma1xl >>> 29)) ^
|
|
217
|
-
(gamma1xh >>> 6);
|
|
218
|
-
const gamma1l =
|
|
219
|
-
((gamma1xh << 13) | (gamma1xl >>> 19)) ^
|
|
220
|
-
((gamma1xl << 3) | (gamma1xh >>> 29)) ^
|
|
221
|
-
((gamma1xh << 26) | (gamma1xl >>> 6));
|
|
222
|
-
|
|
223
|
-
const wr7h = w[(i - 7) * 2];
|
|
224
|
-
const wr7l = w[(i - 7) * 2 + 1];
|
|
225
|
-
const wr16h = w[(i - 16) * 2];
|
|
226
|
-
const wr16l = w[(i - 16) * 2 + 1];
|
|
227
|
-
|
|
228
|
-
wrl = gamma0l + wr7l;
|
|
229
|
-
wrh = gamma0h + wr7h + ((wrl >>> 0) < (gamma0l >>> 0) ? 1 : 0);
|
|
230
|
-
wrl += gamma1l;
|
|
231
|
-
wrh += gamma1h + ((wrl >>> 0) < (gamma1l >>> 0) ? 1 : 0);
|
|
232
|
-
wrl += wr16l;
|
|
233
|
-
wrh += wr16h + ((wrl >>> 0) < (wr16l >>> 0) ? 1 : 0);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
w[i * 2] = wrh |= 0;
|
|
237
|
-
w[i * 2 + 1] = wrl |= 0;
|
|
238
|
-
|
|
239
240
|
const chh = (eh & fh) ^ (~eh & gh);
|
|
240
241
|
const chl = (el & fl) ^ (~el & gl);
|
|
241
|
-
|
|
242
242
|
const majh = (ah & bh) ^ (ah & ch) ^ (bh & ch);
|
|
243
243
|
const majl = (al & bl) ^ (al & cl) ^ (bl & cl);
|
|
244
|
-
|
|
245
|
-
const
|
|
246
|
-
const
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
t1l =
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
const
|
|
264
|
-
const t2h = sigma0h + majh + ((t2l >>> 0) < (sigma0l >>> 0) ? 1 : 0);
|
|
244
|
+
const s0h = ((al << 4) | (ah >>> 28)) ^ ((ah << 30) | (al >>> 2)) ^ ((ah << 25) | (al >>> 7));
|
|
245
|
+
const s0l = ((ah << 4) | (al >>> 28)) ^ ((al << 30) | (ah >>> 2)) ^ ((al << 25) | (ah >>> 7));
|
|
246
|
+
const s1h = ((el << 18) | (eh >>> 14)) ^ ((el << 14) | (eh >>> 18)) ^ ((eh << 23) | (el >>> 9));
|
|
247
|
+
const s1l = ((eh << 18) | (el >>> 14)) ^ ((eh << 14) | (el >>> 18)) ^ ((el << 23) | (eh >>> 9));
|
|
248
|
+
|
|
249
|
+
// t1 = h + s1 + ch + k[i] + w[i]
|
|
250
|
+
let tl = (hl + s1l) | 0;
|
|
251
|
+
let th = (hh + s1h + (((hl & s1l) | ((hl | s1l) & ~tl)) >>> 31)) | 0;
|
|
252
|
+
let nl = (tl + chl) | 0;
|
|
253
|
+
th = (th + chh + (((tl & chl) | ((tl | chl) & ~nl)) >>> 31)) | 0;
|
|
254
|
+
const kl = k[i * 2 + 1];
|
|
255
|
+
tl = (nl + kl) | 0;
|
|
256
|
+
th = (th + k[i * 2] + (((nl & kl) | ((nl | kl) & ~tl)) >>> 31)) | 0;
|
|
257
|
+
const wl = w[i * 2 + 1];
|
|
258
|
+
nl = (tl + wl) | 0;
|
|
259
|
+
th = (th + w[i * 2] + (((tl & wl) | ((tl | wl) & ~nl)) >>> 31)) | 0;
|
|
260
|
+
const t1l = nl, t1h = th;
|
|
261
|
+
// t2 = s0 + maj
|
|
262
|
+
const t2l = (s0l + majl) | 0;
|
|
263
|
+
const t2h = (s0h + majh + (((s0l & majl) | ((s0l | majl) & ~t2l)) >>> 31)) | 0;
|
|
265
264
|
|
|
266
265
|
hh = gh; hl = gl;
|
|
267
266
|
gh = fh; gl = fl;
|
|
268
267
|
fh = eh; fl = el;
|
|
269
268
|
el = (dl + t1l) | 0;
|
|
270
|
-
eh = (dh + t1h + ((
|
|
269
|
+
eh = (dh + t1h + (((dl & t1l) | ((dl | t1l) & ~el)) >>> 31)) | 0;
|
|
271
270
|
dh = ch; dl = cl;
|
|
272
271
|
ch = bh; cl = bl;
|
|
273
272
|
bh = ah; bl = al;
|
|
274
273
|
al = (t1l + t2l) | 0;
|
|
275
|
-
ah = (t1h + t2h + ((
|
|
274
|
+
ah = (t1h + t2h + (((t1l & t2l) | ((t1l | t2l) & ~al)) >>> 31)) | 0;
|
|
276
275
|
}
|
|
277
276
|
|
|
278
|
-
|
|
279
|
-
h[0] = (
|
|
280
|
-
|
|
281
|
-
h[2] = (
|
|
282
|
-
|
|
283
|
-
h[4] = (
|
|
284
|
-
|
|
285
|
-
h[6] = (
|
|
286
|
-
|
|
287
|
-
h[8] = (
|
|
288
|
-
|
|
289
|
-
h[10] = (
|
|
290
|
-
|
|
291
|
-
h[12] = (
|
|
292
|
-
|
|
293
|
-
h[14] = (
|
|
277
|
+
let x = h[1] | 0, y = (x + al) | 0;
|
|
278
|
+
h[0] = ((h[0] | 0) + ah + (((x & al) | ((x | al) & ~y)) >>> 31)) | 0; h[1] = y;
|
|
279
|
+
x = h[3] | 0; y = (x + bl) | 0;
|
|
280
|
+
h[2] = ((h[2] | 0) + bh + (((x & bl) | ((x | bl) & ~y)) >>> 31)) | 0; h[3] = y;
|
|
281
|
+
x = h[5] | 0; y = (x + cl) | 0;
|
|
282
|
+
h[4] = ((h[4] | 0) + ch + (((x & cl) | ((x | cl) & ~y)) >>> 31)) | 0; h[5] = y;
|
|
283
|
+
x = h[7] | 0; y = (x + dl) | 0;
|
|
284
|
+
h[6] = ((h[6] | 0) + dh + (((x & dl) | ((x | dl) & ~y)) >>> 31)) | 0; h[7] = y;
|
|
285
|
+
x = h[9] | 0; y = (x + el) | 0;
|
|
286
|
+
h[8] = ((h[8] | 0) + eh + (((x & el) | ((x | el) & ~y)) >>> 31)) | 0; h[9] = y;
|
|
287
|
+
x = h[11] | 0; y = (x + fl) | 0;
|
|
288
|
+
h[10] = ((h[10] | 0) + fh + (((x & fl) | ((x | fl) & ~y)) >>> 31)) | 0; h[11] = y;
|
|
289
|
+
x = h[13] | 0; y = (x + gl) | 0;
|
|
290
|
+
h[12] = ((h[12] | 0) + gh + (((x & gl) | ((x | gl) & ~y)) >>> 31)) | 0; h[13] = y;
|
|
291
|
+
x = h[15] | 0; y = (x + hl) | 0;
|
|
292
|
+
h[14] = ((h[14] | 0) + hh + (((x & hl) | ((x | hl) & ~y)) >>> 31)) | 0; h[15] = y;
|
|
294
293
|
}
|
|
295
294
|
};
|
|
296
295
|
|
|
@@ -300,15 +299,15 @@ export const sha512 = {
|
|
|
300
299
|
// Default = SHA-512 (FIPS 180-4 §5.3.5, full 512-bit digest = 16 words).
|
|
301
300
|
const _sha512 = _makeSha(_INIT, 16);
|
|
302
301
|
|
|
303
|
-
return /** @type {Sha512API} */ (/** @type {any} */ ({
|
|
302
|
+
return /** @type {Sha512API} */ (/** @type {any} */ (Object.defineProperty({
|
|
304
303
|
// Public API (unchanged)
|
|
305
304
|
fn: _sha512.fn,
|
|
306
|
-
hash: _sha512.hash
|
|
307
|
-
|
|
305
|
+
hash: _sha512.hash
|
|
306
|
+
}, Symbol.for('@awacloud/fw/internal'), {
|
|
308
307
|
// Internal escape hatch - used by sha512_224.js and sha512_256.js
|
|
309
308
|
// (FIPS 180-4 §5.3.6) to share the SHA-512 compression function with
|
|
310
309
|
// a custom IV and truncated output.
|
|
311
|
-
|
|
312
|
-
}));
|
|
310
|
+
value: { makeSha: _makeSha }
|
|
311
|
+
})));
|
|
313
312
|
}
|
|
314
313
|
};
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
## Implemented algorithm
|
|
15
15
|
|
|
16
16
|
`sha512_224.factory(sha512)` — minimal wrapper around
|
|
17
|
-
`sha512.
|
|
18
|
-
compression function (see `sha512.acvp.md` —
|
|
17
|
+
`internalOf(sha512).makeSha(IV_512_224, 7)`. Fully reuses the SHA-512
|
|
18
|
+
compression function (see `sha512.acvp.md` — the
|
|
19
19
|
parameterizable builder). Block size = **1024 bits** (identical to
|
|
20
20
|
SHA-512, required for HMAC-SHA-512/224).
|
|
21
21
|
|
|
@@ -26,7 +26,7 @@ Public API (HMAC-compatible contract):
|
|
|
26
26
|
|
|
27
27
|
The IV (`_INIT_512_224`) is computed per FIPS 180-4 §5.3.6:
|
|
28
28
|
`H = SHA-512_with_IV_xor_0xa5a5..(ASCII("SHA-512/224"))`. Value derived
|
|
29
|
-
**by independent computation and verified**
|
|
29
|
+
**by independent computation and verified** (see tests).
|
|
30
30
|
|
|
31
31
|
## Test coverage
|
|
32
32
|
|
|
@@ -56,9 +56,9 @@ The IV (`_INIT_512_224`) is computed per FIPS 180-4 §5.3.6:
|
|
|
56
56
|
- [ ] **Bit-level AFT (non-byte-aligned)** — 880/1024 vectors filtered
|
|
57
57
|
out because our implementation only absorbs full bytes (limitation
|
|
58
58
|
inherited from sha512.js, see sha512.acvp.md). **P3** — rarely used.
|
|
59
|
-
- [x] **LDT (Large Data Test)** — **
|
|
59
|
+
- [x] **LDT (Large Data Test)** — **added by an audit**: tcId=1028
|
|
60
60
|
(1 GiB of repeated `0800e8a621b041c2`) integrated behind `CRYPTO_FULL=1`
|
|
61
|
-
(mirrors the
|
|
61
|
+
(mirrors the pattern from sha224/256/384/512, previously overlooked
|
|
62
62
|
for the truncated variant). Validates the 64-bit `_length` counter
|
|
63
63
|
per FIPS 180-4 §5.1.1 over ≥ 2³³ bits.
|
|
64
64
|
|
|
@@ -84,7 +84,7 @@ The IV (`_INIT_512_224`) is computed per FIPS 180-4 §5.3.6:
|
|
|
84
84
|
|
|
85
85
|
- Module: [`hash/sha512_224.js`](./sha512_224.js)
|
|
86
86
|
- Tests: [`hash/sha512_224.test.js`](https://github.com/awacloud/awa/blob/main/packages/front/fw/src/crypto/hash/sha512_224.test.js) — **82 tests** (81 pass + 1 skip LDT — `CRYPTO_FULL=1` to enable; 73 AFT + 1 MCT + 5 module + 2 additional + 1 LDT)
|
|
87
|
-
- Underlying SHA-512 module: [`./sha512.js`](./sha512.js) — see [sha512.acvp.md](./sha512.acvp.md) (
|
|
87
|
+
- Underlying SHA-512 module: [`./sha512.js`](./sha512.js) — see [sha512.acvp.md](./sha512.acvp.md) (it exposes `internalOf(sha512_224).makeSha`)
|
|
88
88
|
- Sibling SHA-512/256 module: [`./sha512_256.js`](./sha512_256.js) — see [sha512_256.acvp.md](./sha512_256.acvp.md)
|
|
89
89
|
- Vectors: `references/NIST/ACVP-Server-1.1.0.42/gen-val/json-files/SHA2-512-224-1.0/`
|
|
90
90
|
- Overall conformance: [`../NIST_CONFORMANCE.md`](../NIST_CONFORMANCE.md)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// Copyright (c) 2026 AwaCloud SAS
|
|
2
2
|
// Author: Matthieu Bouilloux
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
|
|
@@ -56,7 +56,7 @@ export const sha512_224 = {
|
|
|
56
56
|
];
|
|
57
57
|
|
|
58
58
|
// outWords = 7 → 7 × 32-bit = 224 bits.
|
|
59
|
-
const inner = sha512.
|
|
59
|
+
const inner = sha512[Symbol.for('@awacloud/fw/internal')].makeSha(_INIT_512_224, 7);
|
|
60
60
|
|
|
61
61
|
return {
|
|
62
62
|
fn: inner.fn,
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
## Implemented algorithm
|
|
14
14
|
|
|
15
15
|
`sha512_256.factory(sha512)` — minimal wrapper around
|
|
16
|
-
`sha512.
|
|
17
|
-
compression function (see
|
|
16
|
+
`internalOf(sha512).makeSha(IV_512_256, 8)`. Fully reuses the SHA-512
|
|
17
|
+
compression function (see `sha512.acvp.md`). Block size = **1024
|
|
18
18
|
bits** (identical to SHA-512, required for HMAC-SHA-512/256).
|
|
19
19
|
|
|
20
20
|
Public API (HMAC-compatible contract):
|
|
@@ -26,7 +26,7 @@ The IV (`_INIT_512_256`) is computed per FIPS 180-4 §5.3.6:
|
|
|
26
26
|
`H = SHA-512_with_IV_xor_0xa5a5..(ASCII("SHA-512/256"))`. **Historical
|
|
27
27
|
note**: several sources publish an erroneous value for `H_1` (low half
|
|
28
28
|
`c84d6b74` vs the correct value `c84c64c2`). Our IV was **derived by
|
|
29
|
-
independent computation
|
|
29
|
+
independent computation**, then cross-verified
|
|
30
30
|
against the OpenSSL `crypto/sha/sha512.c sha512_256_init` constants.
|
|
31
31
|
|
|
32
32
|
## Test coverage
|
|
@@ -58,9 +58,9 @@ against the OpenSSL `crypto/sha/sha512.c sha512_256_init` constants.
|
|
|
58
58
|
(3984 bits = 498 bytes); verifies each checkpoint byte-exact.
|
|
59
59
|
- [ ] **Exhaustive AFT** — 971/1024 vectors not covered (sub-sampling
|
|
60
60
|
stride ~20). **P3** — already excellent representative coverage.
|
|
61
|
-
- [x] **LDT (Large Data Test)** — **
|
|
61
|
+
- [x] **LDT (Large Data Test)** — **added by an audit**: tcId=1026
|
|
62
62
|
(1 GiB of repeated `dda456ef797c268f`) integrated behind `CRYPTO_FULL=1`
|
|
63
|
-
(mirrors the
|
|
63
|
+
(mirrors the pattern from sha224/256/384/512, previously overlooked
|
|
64
64
|
for the truncated variant). Validates the 64-bit `_length` counter
|
|
65
65
|
per FIPS 180-4 §5.1.1 over ≥ 2³³ bits.
|
|
66
66
|
|
|
@@ -90,7 +90,7 @@ against the OpenSSL `crypto/sha/sha512.c sha512_256_init` constants.
|
|
|
90
90
|
|
|
91
91
|
- Module: [`hash/sha512_256.js`](./sha512_256.js)
|
|
92
92
|
- Tests: [`hash/sha512_256.test.js`](https://github.com/awacloud/awa/blob/main/packages/front/fw/src/crypto/hash/sha512_256.test.js) — **61 tests** (60 pass + 1 skip LDT — `CRYPTO_FULL=1` to enable; 53 AFT + 1 MCT + 6 module + 1 LDT)
|
|
93
|
-
- Underlying SHA-512 module: [`./sha512.js`](./sha512.js) — see [sha512.acvp.md](./sha512.acvp.md) (
|
|
93
|
+
- Underlying SHA-512 module: [`./sha512.js`](./sha512.js) — see [sha512.acvp.md](./sha512.acvp.md) (it exposes `internalOf(sha512_256).makeSha`)
|
|
94
94
|
- Sibling SHA-512/224 module: [`./sha512_224.js`](./sha512_224.js) — see [sha512_224.acvp.md](./sha512_224.acvp.md)
|
|
95
95
|
- Vectors: `references/NIST/ACVP-Server-1.1.0.42/gen-val/json-files/SHA2-512-256-1.0/`
|
|
96
96
|
- Overall conformance: [`../NIST_CONFORMANCE.md`](../NIST_CONFORMANCE.md)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// Copyright (c) 2026 AwaCloud SAS
|
|
2
2
|
// Author: Matthieu Bouilloux
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
|
|
@@ -65,7 +65,7 @@ export const sha512_256 = {
|
|
|
65
65
|
];
|
|
66
66
|
|
|
67
67
|
// outWords = 8 → 8 × 32-bit = 256 bits.
|
|
68
|
-
const inner = sha512.
|
|
68
|
+
const inner = sha512[Symbol.for('@awacloud/fw/internal')].makeSha(_INIT_512_256, 8);
|
|
69
69
|
|
|
70
70
|
return {
|
|
71
71
|
fn: inner.fn,
|
|
@@ -76,7 +76,7 @@ direction × 3 keyLen) and 6 MCT. AFT strategy:
|
|
|
76
76
|
|
|
77
77
|
## Known limitations
|
|
78
78
|
|
|
79
|
-
- ~~**MCT not integrated**~~ ✅
|
|
79
|
+
- ~~**MCT not integrated**~~ ✅ implemented.
|
|
80
80
|
6 MCT testGroups from ACVP-AES-CBC-1.0 (37-42, encrypt + decrypt × AES-128/192/256)
|
|
81
81
|
integrated. Each MCT runs 100 outer × 1000 inner AES-CBC ops with:
|
|
82
82
|
1. Per-iter key transition (`Key[j+1] = Key[j] XOR last(keyLen, CT[998]||CT[999])`).
|
|
@@ -99,7 +99,7 @@ direction × 3 keyLen) and 6 MCT. AFT strategy:
|
|
|
99
99
|
## Cross-references
|
|
100
100
|
|
|
101
101
|
- Module: [`mode/cbc.js`](./cbc.js)
|
|
102
|
-
- Tests: [`mode/cbc.test.js`](https://github.com/awacloud/awa/blob/main/packages/front/fw/src/crypto/mode/cbc.test.js) — 163 tests (157 baseline + 6 MCT
|
|
102
|
+
- Tests: [`mode/cbc.test.js`](https://github.com/awacloud/awa/blob/main/packages/front/fw/src/crypto/mode/cbc.test.js) — 163 tests (157 baseline + 6 MCT: 3 encrypt + 3 decrypt × AES-128/192/256, byte-exact iter0 + iter99)
|
|
103
103
|
- ACVP draft: `references/NIST/ACVP/src/draft-celi-acvp-symmetric.adoc`
|
|
104
104
|
- Vectors: `references/NIST/ACVP-Server-1.1.0.42/gen-val/json-files/ACVP-AES-CBC-1.0/`
|
|
105
105
|
- Overall conformance: [`NIST_CONFORMANCE.md`](../NIST_CONFORMANCE.md)
|
package/src/crypto/mode/cbc.js
CHANGED
|
@@ -25,7 +25,7 @@ API (`Uint8Array`):
|
|
|
25
25
|
- `encrypt(key, nonce, plaintext, aad?)` → `{ ct, tag }` (16-byte
|
|
26
26
|
tag), or `false` if key/nonce has the wrong size.
|
|
27
27
|
- `decrypt(key, nonce, ciphertext, tag, aad?)` → `Uint8Array` (plaintext)
|
|
28
|
-
or `false` if tag verification fails (`console.
|
|
28
|
+
or `false` if tag verification fails (`console.warn CORRUPT`).
|
|
29
29
|
|
|
30
30
|
Internal construction (RFC 8439 §2.8.1):
|
|
31
31
|
1. `polyKey = ChaCha20(key, nonce, 0×64)[0..31]` — counter=0 block.
|
|
@@ -72,7 +72,7 @@ Internal construction (RFC 8439 §2.8.1):
|
|
|
72
72
|
(see poly1305.acvp.md; accumulated XOR).
|
|
73
73
|
- [x] **key/nonce/tag length validation** — early return false;
|
|
74
74
|
negative tests.
|
|
75
|
-
- [x] **No `throw`** — `console.
|
|
75
|
+
- [x] **No `throw`** — `console.warn CORRUPT` + `return false`
|
|
76
76
|
on tag mismatch (reviewed lines 80-85).
|
|
77
77
|
- [ ] **XChaCha20-Poly1305 (192-bit nonce)** — not implemented
|
|
78
78
|
(draft-irtf-cfrg-xchacha). **P3**.
|
|
@@ -80,7 +80,7 @@ Internal construction (RFC 8439 §2.8.1):
|
|
|
80
80
|
~2⁶⁴ ChaCha20 blocks per (key, nonce) pair. No runtime guard;
|
|
81
81
|
caller's responsibility. **P3** — could be added as a
|
|
82
82
|
counter.
|
|
83
|
-
- [x] **Nonce-reuse detection** —
|
|
83
|
+
- [x] **Nonce-reuse detection** — `nonceTracker(key)`
|
|
84
84
|
exposed (symmetric pattern to `mode/gcm.js:258`). Wraps `encrypt` /
|
|
85
85
|
`decrypt` with a `Set` of seen nonces, reuse → `console.error('[crypto]
|
|
86
86
|
CORRUPT: chacha20poly1305: nonce reuse rejected by tracker')` + `false`.
|
|
@@ -97,18 +97,18 @@ Internal construction (RFC 8439 §2.8.1):
|
|
|
97
97
|
| Length-encoding binding | ✅ | ct length tampering rejected |
|
|
98
98
|
| Constant-time tag verify | ✅ | delegated to poly1305.verify |
|
|
99
99
|
| No `throw` | ✅ | `console.error` + return false |
|
|
100
|
-
| Nonce-reuse protection | ✅ (opt-in) |
|
|
100
|
+
| Nonce-reuse protection | ✅ (opt-in) | `nonceTracker(key)` wraps encrypt/decrypt with a Set of nonces, reuse → `false` + `CORRUPT` warn |
|
|
101
101
|
|
|
102
102
|
## Known limitations
|
|
103
103
|
|
|
104
104
|
- **Outside NIST scope** — no ACVP vector. Validation = RFC 8439.
|
|
105
105
|
- **No XChaCha20-Poly1305**: see P3 above.
|
|
106
|
-
- ~~**No nonce-reuse tracker**~~ — resolved
|
|
106
|
+
- ~~**No nonce-reuse tracker**~~ — resolved (see above).
|
|
107
107
|
|
|
108
108
|
## Cross-references
|
|
109
109
|
|
|
110
110
|
- Module: [`mode/chacha20poly1305.js`](./chacha20poly1305.js)
|
|
111
|
-
- Tests: [`mode/chacha20poly1305.test.js`](https://github.com/awacloud/awa/blob/main/packages/front/fw/src/crypto/mode/chacha20poly1305.test.js) — **23 tests** (including
|
|
111
|
+
- Tests: [`mode/chacha20poly1305.test.js`](https://github.com/awacloud/awa/blob/main/packages/front/fw/src/crypto/mode/chacha20poly1305.test.js) — **23 tests** (including 5 for `nonceTracker` opt-in — first-encrypt / reuse rejected / distinct nonces / decrypt does not increment the set / per-wrapper scope; was 6 before the upgrade)
|
|
112
112
|
- RFC 8439: [`https://datatracker.ietf.org/doc/html/rfc8439`](https://datatracker.ietf.org/doc/html/rfc8439)
|
|
113
113
|
- Stream cipher: [`../cipher/chacha20.js`](../cipher/chacha20.js) — see [chacha20.acvp.md](../cipher/chacha20.acvp.md)
|
|
114
114
|
- MAC: [`../hash/poly1305.js`](../hash/poly1305.js) — see [poly1305.acvp.md](../hash/poly1305.acvp.md)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// Copyright (c) 2026 AwaCloud SAS
|
|
2
2
|
// Author: Matthieu Bouilloux
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
|
|
@@ -113,13 +113,13 @@ export const chacha20poly1305 = {
|
|
|
113
113
|
const polyKey = _polyKey(key, nonce);
|
|
114
114
|
if (polyKey === false) return false;
|
|
115
115
|
if (!poly1305.verify(polyKey, _macInput(aad, ciphertext), tag)) {
|
|
116
|
-
console.
|
|
116
|
+
console.warn('[crypto] CORRUPT: chacha20poly1305: authentication tag mismatch');
|
|
117
117
|
return false;
|
|
118
118
|
}
|
|
119
119
|
return chacha20.xor(key, nonce, ciphertext, 1);
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
// ──
|
|
122
|
+
// ── Nonce-uniqueness tracker (opt-in) ─────────────
|
|
123
123
|
//
|
|
124
124
|
// ChaCha20-Poly1305 (RFC 8439) requires the (key, nonce) pair to be
|
|
125
125
|
// unique : reuse leaks the Poly1305 key (forgery + plaintext recovery
|
|
@@ -49,7 +49,7 @@ ACVP CMAC-AES-1.0 exposes **54 testGroups / 756 tests** organized as:
|
|
|
49
49
|
|
|
50
50
|
- [x] **`K1`, `K2` subkey derivation** — RFC 4493 §4 vector + all
|
|
51
51
|
189 ACVP (each tag depends on the correct subkeys).
|
|
52
|
-
- [x] **GF(2^128) doubling** — `_dbl` exposed (`
|
|
52
|
+
- [x] **GF(2^128) doubling** — `_dbl` exposed (`internalOf(cmac).dbl`) and validated
|
|
53
53
|
against the RFC 4493 values (`L`, `K1`, `K2`).
|
|
54
54
|
- [x] **Full block vs padded branch** — covered by msgLen ∈ {0
|
|
55
55
|
(padded), 4256 (= 532 bytes, non-aligned mod 16 → padded K2), 65536 (= 8192
|
|
@@ -76,7 +76,7 @@ ACVP CMAC-AES-1.0 exposes **54 testGroups / 756 tests** organized as:
|
|
|
76
76
|
## Known limitations
|
|
77
77
|
|
|
78
78
|
- **CMAC-TDES not covered**: `CMAC-TDES-1.0` present in `references/NIST/`
|
|
79
|
-
but out of scope.
|
|
79
|
+
but out of scope. `_checkBlockSize`
|
|
80
80
|
rejects any PRF with `blockSize !== 16` (TDES = 8 bytes) with a typed
|
|
81
81
|
`DEPRECATED` warning. Prevents any silent use by a consumer that would
|
|
82
82
|
mistakenly pass a TDES PRF.
|
|
@@ -84,8 +84,8 @@ ACVP CMAC-AES-1.0 exposes **54 testGroups / 756 tests** organized as:
|
|
|
84
84
|
the same code paths. The anchors cover `[first, middle, last]`
|
|
85
85
|
per group and each `(keyLen, msgLen, macLen)` combination has at least
|
|
86
86
|
3 gen + 4 ver integrated.
|
|
87
|
-
- ~~**No explicit guard against invalid macLen**~~ ✅
|
|
88
|
-
|
|
87
|
+
- ~~**No explicit guard against invalid macLen**~~ ✅
|
|
88
|
+
`truncatedMac(prf, message, tagLen)` and
|
|
89
89
|
`truncatedVerify(prf, message, tag, tagLen)` which enforce
|
|
90
90
|
`tagLen ∈ [32, 128]` (SP 800-38B §6.4). The legacy `mac()` API remains
|
|
91
91
|
unchanged (returns 128 bits) for back-compat; the new functions are
|
|
@@ -100,7 +100,7 @@ ACVP CMAC-AES-1.0 exposes **54 testGroups / 756 tests** organized as:
|
|
|
100
100
|
## Cross-references
|
|
101
101
|
|
|
102
102
|
- Module: [`mode/cmac.js`](./cmac.js)
|
|
103
|
-
- Tests: [`mode/cmac.test.js`](https://github.com/awacloud/awa/blob/main/packages/front/fw/src/crypto/mode/cmac.test.js) — 210 tests (197 baseline + 13
|
|
103
|
+
- Tests: [`mode/cmac.test.js`](https://github.com/awacloud/awa/blob/main/packages/front/fw/src/crypto/mode/cmac.test.js) — 210 tests (197 baseline + 13 more: TDES guard + truncatedMac SP 800-38B §6.4 enforcement)
|
|
104
104
|
- ACVP draft: `references/NIST/ACVP/src/cmac/`
|
|
105
105
|
- Vectors: `references/NIST/ACVP-Server-1.1.0.42/gen-val/json-files/CMAC-AES-1.0/`
|
|
106
106
|
- Overall conformance: [`NIST_CONFORMANCE.md`](../NIST_CONFORMANCE.md)
|
package/src/crypto/mode/cmac.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// Copyright (c) 2026 AwaCloud SAS
|
|
2
2
|
// Author: Matthieu Bouilloux
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
|
|
@@ -27,7 +27,6 @@ import { bitArray } from '../utils/bitArray.js';
|
|
|
27
27
|
* @property {(prf: {encrypt: Function}, message: number[], tag: number[]) => boolean} verify Constant-time tag verification.
|
|
28
28
|
* @property {(prf: {encrypt: Function}, message: number[], tagLen: number) => (number[]|false)} truncatedMac Truncated MAC (tagLen 32..128 bits).
|
|
29
29
|
* @property {(prf: {encrypt: Function}, message: number[], tag: number[], tagLen: number) => boolean} truncatedVerify Constant-time truncated verification.
|
|
30
|
-
* @property {{ dbl: (b: number[]) => number[] }} _internal Internal primitive (KAT tests only).
|
|
31
30
|
*/
|
|
32
31
|
|
|
33
32
|
export const cmac = {
|
|
@@ -42,7 +41,7 @@ export const cmac = {
|
|
|
42
41
|
|
|
43
42
|
const _RB = 0x87;
|
|
44
43
|
|
|
45
|
-
//
|
|
44
|
+
// TDES rejection.
|
|
46
45
|
// SP 800-131A §2.4 marks Triple-DES as deprecated since 2024 and
|
|
47
46
|
// disallowed for cryptographic protection beyond 2023. SP 800-38B §5.1
|
|
48
47
|
// explicitly requires AES (16-byte block). We reject any PRF that
|
|
@@ -130,7 +129,7 @@ export const cmac = {
|
|
|
130
129
|
return bitArray.equal(expected, tag);
|
|
131
130
|
}
|
|
132
131
|
|
|
133
|
-
//
|
|
132
|
+
// Truncated MAC.
|
|
134
133
|
// SP 800-38B §6.4 (Length of MAC) recommends `Tlen ≥ 32 bits` for
|
|
135
134
|
// applications where forgery probability of `2^-Tlen` is acceptable
|
|
136
135
|
// (smaller Tlen requires a per-application risk analysis). The
|
|
@@ -160,13 +159,14 @@ export const cmac = {
|
|
|
160
159
|
return bitArray.equal(expected, tag);
|
|
161
160
|
}
|
|
162
161
|
|
|
163
|
-
return {
|
|
162
|
+
return Object.defineProperty({
|
|
164
163
|
mac,
|
|
165
164
|
verify,
|
|
166
165
|
truncatedMac,
|
|
167
|
-
truncatedVerify
|
|
166
|
+
truncatedVerify
|
|
167
|
+
}, Symbol.for('@awacloud/fw/internal'), {
|
|
168
168
|
// Internal primitive - exposed for KAT tests only.
|
|
169
|
-
|
|
170
|
-
};
|
|
169
|
+
value: { dbl: _dbl }
|
|
170
|
+
});
|
|
171
171
|
}
|
|
172
172
|
};
|
|
@@ -86,8 +86,8 @@ many) and verify the CT byte-exact against the same source. The
|
|
|
86
86
|
- **MCT not specified for CTR by the ACVP**: the official suite is
|
|
87
87
|
limited to AFT (unlike AES-CBC/ECB). Not a coverage gap —
|
|
88
88
|
confirmed by inspecting `ACVP-AES-CTR-1.0/prompt.json` (6 testGroups,
|
|
89
|
-
all `testType=AFT`, no `MCT`)
|
|
90
|
-
|
|
89
|
+
all `testType=AFT`, no `MCT`): CBC has its 6 MCTs, CTR stays AFT-only
|
|
90
|
+
by construction.
|
|
91
91
|
- **No F.5.2/F.5.3/F.5.4 vector (AES-192/256-CTR)** integrated
|
|
92
92
|
manually — covered indirectly by the ACVP encrypt/decrypt × 192/256.
|
|
93
93
|
- **No anti-IV-reuse guard**: if the same (K, IV) pair is
|