@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
|
@@ -19,40 +19,49 @@ Strict DER serialisation for key formats (PKCS#8, SPKI, SEC1, JWK Key OPS) and s
|
|
|
19
19
|
|
|
20
20
|
```js
|
|
21
21
|
const asn1 = runtime.resolve('asn1');
|
|
22
|
-
// Returns: {
|
|
22
|
+
// Returns: { TAG, encodeInteger, encodeOctetString, encodeBitString, encodeNull, encodeOid,
|
|
23
|
+
// encodeSequence, encodeSet, encodeExplicit, encodeImplicit,
|
|
24
|
+
// parseOne, parseChildren, readInteger, readOid, readBitString }
|
|
23
25
|
```
|
|
24
26
|
|
|
25
|
-
## API
|
|
27
|
+
## API
|
|
26
28
|
|
|
27
29
|
| Method | Signature | Returns |
|
|
28
30
|
|--------|-----------|---------|
|
|
29
|
-
| `
|
|
30
|
-
| `
|
|
31
|
-
| `
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
| `TAG` | `{INTEGER, BIT_STRING, OCTET_STRING, NULL, OID, SEQUENCE, SET}` | Tag-byte constants |
|
|
32
|
+
| `encodeInteger(value)` | `(Uint8Array \| number[] \| number) => Uint8Array \| false` | An INTEGER TLV (minimal two's-complement) |
|
|
33
|
+
| `encodeOctetString(bytes)` | `(Uint8Array \| number[]) => Uint8Array \| false` | An OCTET STRING TLV |
|
|
34
|
+
| `encodeBitString(bytes, unusedBits)` | `(Uint8Array \| number[], number) => Uint8Array \| false` | A BIT STRING TLV |
|
|
35
|
+
| `encodeNull()` | `() => Uint8Array` | `05 00` |
|
|
36
|
+
| `encodeOid(dotted)` | `(string) => Uint8Array \| false` | An OBJECT IDENTIFIER TLV |
|
|
37
|
+
| `encodeSequence(items)` / `encodeSet(items)` | `(Uint8Array[]) => Uint8Array \| false` | A SEQUENCE / SET of encoded TLVs |
|
|
38
|
+
| `encodeExplicit(n, body)` | `(number, Uint8Array) => Uint8Array \| false` | `body` wrapped in context-specific `[n]` EXPLICIT |
|
|
39
|
+
| `encodeImplicit(n, tlv, constructed?)` | `(number, Uint8Array, boolean?) => Uint8Array` | `tlv` re-tagged as context-specific `[n]` IMPLICIT |
|
|
40
|
+
| `parseOne(buf, off)` | `(Uint8Array, number) => node \| false` | One TLV: `{tag, length, value, valueOff, next}` (`value` is a view into `buf`) |
|
|
41
|
+
| `parseChildren(value)` | `(Uint8Array) => node[] \| false` | The TLVs of a constructed value |
|
|
42
|
+
| `readInteger(node)` | `(node) => Uint8Array \| false` | The INTEGER's two's-complement bytes |
|
|
43
|
+
| `readOid(node)` | `(node) => string \| false` | The OID, dotted |
|
|
44
|
+
| `readBitString(node)` | `(node) => {unusedBits, bytes} \| false` | The BIT STRING's content |
|
|
34
45
|
|
|
35
46
|
## Examples
|
|
36
47
|
|
|
37
48
|
```js
|
|
38
49
|
const { asn1, hex } = fw.runtime.resolveAll(['asn1', 'hex']);
|
|
39
50
|
|
|
40
|
-
// ECDSA signature
|
|
41
|
-
const der = asn1.
|
|
42
|
-
type: 'SEQUENCE',
|
|
43
|
-
value: [
|
|
44
|
-
{ type: 'INTEGER', value: rBytes },
|
|
45
|
-
{ type: 'INTEGER', value: sBytes }
|
|
46
|
-
]
|
|
47
|
-
});
|
|
51
|
+
// ECDSA signature: SEQUENCE { INTEGER r, INTEGER s }
|
|
52
|
+
const der = asn1.encodeSequence([asn1.encodeInteger(rBytes), asn1.encodeInteger(sBytes)]);
|
|
48
53
|
hex.fromBytes(der);
|
|
54
|
+
|
|
55
|
+
// and back
|
|
56
|
+
const seq = asn1.parseOne(der, 0);
|
|
57
|
+
const [r, s] = asn1.parseChildren(seq.value).map(asn1.readInteger);
|
|
49
58
|
```
|
|
50
59
|
|
|
51
60
|
## Worker Usage
|
|
52
61
|
|
|
53
62
|
```js
|
|
54
63
|
const worker = fw.createWorker(
|
|
55
|
-
function ({ libs, args }) { self.postMessage(libs.asn1.
|
|
64
|
+
function ({ libs, args }) { self.postMessage(libs.asn1.parseOne(args[0], 0).tag); },
|
|
56
65
|
{ dependencies: ['asn1'], args: [derBytes] }
|
|
57
66
|
);
|
|
58
67
|
```
|
|
@@ -27,15 +27,15 @@ const jws = runtime.resolve('jws');
|
|
|
27
27
|
| Method | Signature | Returns |
|
|
28
28
|
|--------|-----------|---------|
|
|
29
29
|
| `sign(payload, alg, key, extraHeader?)` | `(Uint8Array, 'HS256'\|'HS512'\|'EdDSA', Uint8Array, Object?) => string \| false` | Compact JWS token |
|
|
30
|
-
| `verify(token, key, opts
|
|
30
|
+
| `verify(token, key, opts)` | `(string, Uint8Array, {expectedAlg, expectedTyp?}) => {header, payload} \| false` | Verified result or `false`; throws `TypeError` without `expectedAlg` |
|
|
31
31
|
| `signJwt(claims, alg, key)` | `(Object, string, Uint8Array) => string \| false` | Sign shortcut with `typ:'JWT'` |
|
|
32
|
-
| `verifyJwt(token, key, opts
|
|
32
|
+
| `verifyJwt(token, key, opts)` | `(string, Uint8Array, {expectedAlg, expectedTyp?}) => {header, payload, claims} \| false` | Verify + parse JSON claims; throws `TypeError` without `expectedAlg` |
|
|
33
33
|
|
|
34
34
|
### `verify` / `verifyJwt` — options
|
|
35
35
|
|
|
36
36
|
| Option | Type | Description |
|
|
37
37
|
|--------|------|-------------|
|
|
38
|
-
| `expectedAlg` | `string \| string[]` | Algorithm allowlist (anti-alg-confusion / downgrade) |
|
|
38
|
+
| `expectedAlg` | `string \| string[]` | **Required.** Algorithm allowlist (anti-alg-confusion / downgrade); a token whose header `alg` is not in it is refused (`false`) |
|
|
39
39
|
| `expectedTyp` | `string` | Expected value of the `typ` field (anti-cross-protocol confusion) |
|
|
40
40
|
|
|
41
41
|
## Examples
|
|
@@ -82,7 +82,9 @@ const worker = fw.createWorker(
|
|
|
82
82
|
|
|
83
83
|
## Notes
|
|
84
84
|
|
|
85
|
-
- **`verify`
|
|
85
|
+
- **`verify` requires `expectedAlg`** (RFC 8725 §3.1): the header must not choose the algorithm — an attacker could flip HS512→HS256, or sign an `HS256` token with an Ed25519 **public** key as the HMAC key, which verifies against that key when the header decides. Without `expectedAlg` (or with an empty one), `verify` and `verifyJwt` throw a `TypeError` before reading the token.
|
|
86
|
+
- **Canonical base64url only**: each part must be unpadded base64url (RFC 4648 §5) in its canonical form — a length of 1 mod 4, or non-zero unused bits in the last character, is refused (`false` + one `INVALID` warning per call). A token therefore has one spelling, and two tokens with the same bytes compare equal as strings.
|
|
87
|
+
- **Log levels**: a malformed token or a mismatched `alg`/`typ` warns `INVALID`; a signature that does not verify warns `CORRUPT` — an expected outcome, reported at warn level, never as `console.error`.
|
|
86
88
|
- **`expectedTyp`**: use to prevent cross-protocol token reuse (e.g. a generic JWS token accepted as a JWT).
|
|
87
89
|
- **HS384 not supported** — no `sha384` dependency declared in the factory; warns if attempted.
|
|
88
90
|
- **alg='none'** not accepted (RFC 8725 §3.1) — returns `false` + `console.warn('INVALID')`.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
module: keyformat
|
|
3
3
|
category: crypto/utils
|
|
4
|
-
dependencies: [asn1
|
|
4
|
+
dependencies: [asn1]
|
|
5
5
|
returns: object
|
|
6
6
|
worker-safe: true
|
|
7
7
|
status: complete
|
|
@@ -9,11 +9,11 @@ status: complete
|
|
|
9
9
|
|
|
10
10
|
# keyformat
|
|
11
11
|
|
|
12
|
-
> EC / Ed25519 / X25519 key serialisation — PKCS#8
|
|
12
|
+
> RSA / EC / Ed25519 / X25519 key serialisation — PKCS#8, SPKI, SEC1, PKCS#1 (RFC 5915 / 8410 / 8017).
|
|
13
13
|
|
|
14
|
-
**Module** `keyformat` | **Source** `packages/front/fw/src/crypto/utils/keyformat.js` | **Deps** `asn1
|
|
14
|
+
**Module** `keyformat` | **Source** `packages/front/fw/src/crypto/utils/keyformat.js` | **Deps** `asn1` | **Worker-safe** yes
|
|
15
15
|
|
|
16
|
-
Round-trip for ECDSA (P-256/384/521), Ed25519
|
|
16
|
+
Round-trip for RSA, ECDSA (P-256/384/521), Ed25519 and X25519 keys. Pivot format for interop with OpenSSL / WebCrypto / Node. RSA keys use the shapes [`rsaKeygen`](./rsaKeygen.md) returns and [`rsa`](../pkc/rsa.md) takes: `{ n, e }` and `{ n, e, d, p, q, dp, dq, qInv }`, unsigned big-endian `Uint8Array`s.
|
|
17
17
|
|
|
18
18
|
## Resolve
|
|
19
19
|
|
|
@@ -38,20 +38,29 @@ const keyformat = runtime.resolve('keyformat');
|
|
|
38
38
|
| `encodeSec1` / `decodeSec1` | EC (P-256/384/521) — raw `ECPrivateKey` | RFC 5915 |
|
|
39
39
|
| `encodePkcs8Ec` / `decodePkcs8Ec` | EC — PKCS#8 private key (wraps SEC1) | RFC 5208 + RFC 5915 |
|
|
40
40
|
| `encodeSpkiEc` / `decodeSpkiEc` | EC — SPKI public key | RFC 5480 |
|
|
41
|
+
| `encodeRsaPublicKey` / `decodeRsaPublicKey` | RSA — PKCS#1 `RSAPublicKey` (`{ n, e }`) | RFC 8017 A.1.1 |
|
|
42
|
+
| `encodeRsaPrivateKey` / `decodeRsaPrivateKey` | RSA — PKCS#1 `RSAPrivateKey`, two-prime (version 0) | RFC 8017 A.1.2 |
|
|
43
|
+
| `encodeSpkiRsa` / `decodeSpkiRsa` | RSA — SPKI public key (rsaEncryption, NULL parameters) | RFC 3279 §2.3.1 |
|
|
44
|
+
| `encodePkcs8Rsa` / `decodePkcs8Rsa` | RSA — PKCS#8 private key (wraps PKCS#1) | RFC 5208 + RFC 8017 |
|
|
41
45
|
| `OID` | OID constants (curves, algos) | — |
|
|
42
46
|
|
|
43
47
|
## Examples
|
|
44
48
|
|
|
45
49
|
```js
|
|
46
|
-
const { keyformat, pem } = fw.runtime.resolveAll(['keyformat', 'pem']);
|
|
50
|
+
const { keyformat, pem, rsaKeygen } = fw.runtime.resolveAll(['keyformat', 'pem', 'rsaKeygen']);
|
|
47
51
|
|
|
48
|
-
// Ed25519 → DER PKCS#8 → PEM
|
|
49
|
-
const
|
|
50
|
-
const skPem = pem.encode(skBytes, 'PRIVATE KEY');
|
|
52
|
+
// Ed25519: 32-byte seed → DER PKCS#8 → PEM
|
|
53
|
+
const skPem = pem.encode(keyformat.encodePkcs8Edwards(keyformat.OID.ED25519, seed), 'PRIVATE KEY');
|
|
51
54
|
|
|
52
|
-
// PEM → Ed25519
|
|
53
|
-
const back = keyformat.decodePkcs8Edwards(pem.decode(skPem));
|
|
54
|
-
// → { oid, seed
|
|
55
|
+
// PEM → Ed25519
|
|
56
|
+
const back = keyformat.decodePkcs8Edwards(pem.decode(skPem, 'PRIVATE KEY').bytes);
|
|
57
|
+
// → { oid: '1.3.101.112', seed }
|
|
58
|
+
|
|
59
|
+
// RSA: key pair → SPKI / PKCS#8 PEM, which OpenSSL and node read as is
|
|
60
|
+
const { publicKey, privateKey } = rsaKeygen.generate({ bits: 2048 });
|
|
61
|
+
const pubPem = pem.encode(keyformat.encodeSpkiRsa(publicKey), 'PUBLIC KEY');
|
|
62
|
+
const privPem = pem.encode(keyformat.encodePkcs8Rsa(privateKey), 'PRIVATE KEY');
|
|
63
|
+
const pub = keyformat.decodeSpkiRsa(pem.decode(pubPem, 'PUBLIC KEY').bytes); // { n, e }
|
|
55
64
|
```
|
|
56
65
|
|
|
57
66
|
## Worker Usage
|
|
@@ -59,18 +68,18 @@ const back = keyformat.decodePkcs8Edwards(pem.decode(skPem));
|
|
|
59
68
|
```js
|
|
60
69
|
const worker = fw.createWorker(
|
|
61
70
|
function ({ libs, args }) {
|
|
62
|
-
self.postMessage(libs.keyformat.encodeSec1(args[0]));
|
|
71
|
+
self.postMessage(libs.keyformat.encodeSec1(args[0], args[1], args[2]));
|
|
63
72
|
},
|
|
64
|
-
{ dependencies: ['keyformat'], args: [
|
|
73
|
+
{ dependencies: ['keyformat'], args: [d, publicKey, curveOid] } // encodeSec1(d, pub?, curveOid?)
|
|
65
74
|
);
|
|
66
75
|
```
|
|
67
76
|
|
|
68
77
|
## Notes
|
|
69
78
|
|
|
70
79
|
- **Round-trip only**: no cryptographic key validation (e.g. point-on-curve check). Use `ecc.deserialize` after decode for subgroup check.
|
|
71
|
-
- **OpenSSL compatibility** verified for Edwards (Ed25519/X25519) and EC.
|
|
80
|
+
- **OpenSSL compatibility** verified for Edwards (Ed25519/X25519) and EC; the RSA encodings are byte-identical to node's (`node:crypto` DER export, 2048 and 3072 bits).
|
|
72
81
|
- **JWK** not supported (use an external converter if required).
|
|
73
|
-
- **RSA**:
|
|
82
|
+
- **RSA decoding is strict**: rsaEncryption with NULL parameters only, a two-prime private key only (a multi-prime version-1 key is refused), no trailing bytes; integers come back unsigned (the DER sign byte dropped). Encoding a private key needs all eight integers.
|
|
74
83
|
|
|
75
84
|
## See also
|
|
76
85
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
module: pem
|
|
3
3
|
category: crypto/utils
|
|
4
|
-
dependencies: []
|
|
4
|
+
dependencies: [b64]
|
|
5
5
|
returns: object
|
|
6
6
|
worker-safe: true
|
|
7
7
|
status: complete
|
|
@@ -11,7 +11,7 @@ status: complete
|
|
|
11
11
|
|
|
12
12
|
> PEM (RFC 7468) — encode/decode between `Uint8Array` and `-----BEGIN/END LABEL-----` Base64.
|
|
13
13
|
|
|
14
|
-
**Module** `pem` | **Source** `packages/front/fw/src/crypto/utils/pem.js` | **Deps**
|
|
14
|
+
**Module** `pem` | **Source** `packages/front/fw/src/crypto/utils/pem.js` | **Deps** `b64` | **Worker-safe** yes
|
|
15
15
|
|
|
16
16
|
## Resolve
|
|
17
17
|
|
|
@@ -25,7 +25,7 @@ const pem = runtime.resolve('pem');
|
|
|
25
25
|
| Method | Signature | Returns |
|
|
26
26
|
|--------|-----------|---------|
|
|
27
27
|
| `encode(bytes, label)` | `(Uint8Array, string) => string` | PEM with BEGIN/END headers |
|
|
28
|
-
| `decode(text, label?)` | `(string, string?) =>
|
|
28
|
+
| `decode(text, label?)` | `(string, string?) => {label, bytes} \| false` | The first block's label and bytes, or `false` if invalid / label mismatch |
|
|
29
29
|
|
|
30
30
|
## Examples
|
|
31
31
|
|
|
@@ -19,8 +19,8 @@ The framework's sole randomness source. `Math.random` and `crypto.randomUUID` ar
|
|
|
19
19
|
|
|
20
20
|
```js
|
|
21
21
|
const random = runtime.resolve('random');
|
|
22
|
-
// Returns: { fill, float, int, bytes, words, bits,
|
|
23
|
-
// health, isReady, selfTest
|
|
22
|
+
// Returns: { fill, float, int, bytes, words, bits, drbg,
|
|
23
|
+
// health, isReady, selfTest }
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
## API
|
|
@@ -32,13 +32,12 @@ const random = runtime.resolve('random');
|
|
|
32
32
|
| `bits(n)` | `(number) => bitArray \| false` | n random bits (SJCL bitArray) |
|
|
33
33
|
| `int(min, max)` | `(number, number) => number` | Integer in [min, max] (rejection sampling, no modulo bias) |
|
|
34
34
|
| `float()` | `() => number` | Float in [0, 1) |
|
|
35
|
-
| `range(min, max)` | `(number, number) => number` | Float in [min, max) |
|
|
36
35
|
| `fill(typedArray)` | `(TypedArray) => TypedArray` | In-place fill |
|
|
37
36
|
| `drbg(options?)` | `({personalisation?, aesKeyBits?, df?}) => DrbgInstance \| false` | Dedicated CTR_DRBG instance |
|
|
38
37
|
| `health` | `{feed, reset, isDead}` | Continuous health-tests SP 800-90B |
|
|
39
38
|
| `isReady()` | `() => boolean` | `true` if `crypto.getRandomValues` is available |
|
|
40
39
|
| `selfTest()` | `() => boolean` | Re-run the CTR_DRBG POST KAT |
|
|
41
|
-
| `
|
|
40
|
+
| `internalOf(random).makeDrbg(opts?)` | — | Parametric builder (test-only) |
|
|
42
41
|
|
|
43
42
|
### `drbg(options)`
|
|
44
43
|
|
|
@@ -21,7 +21,7 @@ All outputs are big-endian `Uint8Array`, compatible with the [`rsa`](../pkc/rsa.
|
|
|
21
21
|
|
|
22
22
|
```js
|
|
23
23
|
const rsaKeygen = runtime.resolve('rsaKeygen');
|
|
24
|
-
// Returns: { generate, generateProbablePrime
|
|
24
|
+
// Returns: { generate, generateProbablePrime }
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
## API
|
|
@@ -30,7 +30,7 @@ const rsaKeygen = runtime.resolve('rsaKeygen');
|
|
|
30
30
|
|--------|-----------|---------|
|
|
31
31
|
| `generate(options?)` | `({bits?, e?, drbg?}) => {publicKey, privateKey} \| false` | RSA pair or `false` on error |
|
|
32
32
|
| `generateProbablePrime(nbits, eBn, drbg)` | `(number, BN, DrbgInstance) => BN \| false` | Probable `nbits`-bit prime, coprime with `e` |
|
|
33
|
-
| `
|
|
33
|
+
| `internalOf(rsaKeygen).{...}` | — | `millerRabin`, `smallPrimes`, `divmod`, `lcm`, `inverseModAny` (test/KAT only) |
|
|
34
34
|
|
|
35
35
|
### `generate` options
|
|
36
36
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
module: totp
|
|
3
3
|
category: crypto/utils
|
|
4
|
-
dependencies: [hmac, random, base32]
|
|
4
|
+
dependencies: [hmac, random, base32, bitArray, sha256, sha512]
|
|
5
5
|
returns: object
|
|
6
6
|
worker-safe: true
|
|
7
7
|
status: complete
|
|
@@ -11,7 +11,7 @@ status: complete
|
|
|
11
11
|
|
|
12
12
|
> TOTP RFC 6238 — time-based OTP generation, verification, and enrollment.
|
|
13
13
|
|
|
14
|
-
**Module** `totp` | **Source** `packages/front/fw/src/crypto/utils/totp.js` | **Deps** `hmac`, `random`, `base32` | **Worker-safe** yes
|
|
14
|
+
**Module** `totp` | **Source** `packages/front/fw/src/crypto/utils/totp.js` | **Deps** `hmac`, `random`, `base32`, `bitArray`, `sha256`, `sha512` | **Worker-safe** yes
|
|
15
15
|
|
|
16
16
|
Strict TOTP (RFC 6238) implementation built on HOTP (RFC 4226). Algorithm: HMAC-SHA-1/256/512 of the time counter T (8 bytes big-endian), dynamic truncation, modulo 10^digits. Includes enrollment helpers (random secret generation, `otpauth://` URI) compatible with standard authenticators (Google Authenticator, Authy, etc.).
|
|
17
17
|
|
|
@@ -41,8 +41,8 @@ const uuid = runtime.resolve('uuid');
|
|
|
41
41
|
|
|
42
42
|
| Value | Output | Example |
|
|
43
43
|
|-------|--------|---------|
|
|
44
|
-
| `'
|
|
45
|
-
| `'
|
|
44
|
+
| `'rfc4122'` (`v4`'s default) | 36-char canonical RFC 4122 §3 | `91c274f2-9a0d-4ce6-9d5d-b2c3d4e5f607` |
|
|
45
|
+
| `'compact'` (`v1`'s default) | 32 hex without dashes | `91c274f29a0d4ce69d5db2c3d4e5f607` |
|
|
46
46
|
|
|
47
47
|
## Examples
|
|
48
48
|
|
|
@@ -59,8 +59,8 @@ uuid.v4(true); // Uint8Array(16)
|
|
|
59
59
|
### v1 time-based
|
|
60
60
|
|
|
61
61
|
```js
|
|
62
|
-
uuid.v1(); //
|
|
63
|
-
uuid.v1(false, false, '
|
|
62
|
+
uuid.v1(); // canonical with dashes
|
|
63
|
+
uuid.v1(false, false, 'compact'); // 32 hex, no dashes
|
|
64
64
|
```
|
|
65
65
|
|
|
66
66
|
### Validation with valid
|
|
@@ -86,7 +86,7 @@ const worker = fw.createWorker(
|
|
|
86
86
|
|
|
87
87
|
- **Randomness source**: `crypto.getRandomValues` (Web Crypto `RandomSource`). Custom `prng` with automatic fallback to `crypto.getRandomValues` if the callback does not modify the buffer.
|
|
88
88
|
- **v1 uses a random MAC** (multicast bit forced per RFC 4122 §4.5) — no hardware MAC accessible in the browser.
|
|
89
|
-
- **
|
|
89
|
+
- **Formats**: `v1()` and `v4()` return the canonical 8-4-4-4-12 string; `format = 'compact'` (the third argument) gives the 32 hex without dashes.
|
|
90
90
|
- **v3 / v5 / v6 / v7 / v8 not implemented** — RFC 9562 §5.6-5.8; v7 (timestamp-sortable) would be useful for DB IDs.
|
|
91
91
|
- Requires `globalThis.crypto.getRandomValues` — available in browsers, Node ≥ 19, Bun, Deno. Throws if absent.
|
|
92
92
|
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
---
|
|
2
|
+
module: x509
|
|
3
|
+
category: crypto/utils
|
|
4
|
+
dependencies: [asn1, keyformat, pem, ed25519, ecc, sha256, bitArray]
|
|
5
|
+
returns: object
|
|
6
|
+
worker-safe: true
|
|
7
|
+
status: complete
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# x509
|
|
11
|
+
|
|
12
|
+
> X.509 v3 certificates (RFC 5280) for Ed25519 and ECDSA P-256 keys — create, parse, verify, PEM.
|
|
13
|
+
|
|
14
|
+
**Module** `x509` | **Source** `packages/front/fw/src/crypto/utils/x509.js` | **Deps** `asn1`, `keyformat`, `pem`, `ed25519`, `ecc`, `sha256`, `bitArray` | **Worker-safe** yes
|
|
15
|
+
|
|
16
|
+
Builds and reads certificates whose key and signature are Ed25519 (RFC 8410: pure
|
|
17
|
+
Ed25519 over the TBS bytes) or ECDSA P-256 with SHA-256 (RFC 5758:
|
|
18
|
+
`ecdsa-with-SHA256`, DER `r, s`, RFC 6979 deterministic `k`). It checks one
|
|
19
|
+
signature; it does not validate a certification path.
|
|
20
|
+
|
|
21
|
+
## Resolve
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
const x509 = runtime.resolve('x509');
|
|
25
|
+
// Returns: { create, parse, verify, toPem, fromPem }
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## API
|
|
29
|
+
|
|
30
|
+
| Method | Signature | Returns |
|
|
31
|
+
|--------|-----------|---------|
|
|
32
|
+
| `create(spec, signer)` | `(X509Spec, X509Signer) => Uint8Array \| false` | The DER certificate; `false` on any malformed input |
|
|
33
|
+
| `parse(der)` | `(Uint8Array) => X509Parsed \| false` | The TBS fields |
|
|
34
|
+
| `verify(der, issuerPublicKey)` | `(Uint8Array, {alg, key}) => boolean` | `true` when that key signed the certificate |
|
|
35
|
+
| `toPem(der)` | `(Uint8Array) => string` | A `CERTIFICATE` PEM block |
|
|
36
|
+
| `fromPem(text)` | `(string) => Uint8Array \| false` | The DER of the first `CERTIFICATE` block |
|
|
37
|
+
|
|
38
|
+
### `X509Spec`
|
|
39
|
+
|
|
40
|
+
| Field | Type | Notes |
|
|
41
|
+
|---|---|---|
|
|
42
|
+
| `subject` | `{ CN?, O?, OU?, L?, ST?, C? }` | At least one attribute, 1..64 characters each (UTF8String); `C` is two upper-case letters (PrintableString). Encoded in key order |
|
|
43
|
+
| `issuer` | same | Defaults to `subject`: a self-signed certificate |
|
|
44
|
+
| `serial` | `Uint8Array` | Unsigned big-endian, positive, at most 20 encoded octets (RFC 5280 § 4.1.2.2) |
|
|
45
|
+
| `notBefore`, `notAfter` | `Date` | `notBefore < notAfter`; UTCTime before 2050, GeneralizedTime from 2050; milliseconds dropped |
|
|
46
|
+
| `publicKey` | `{ alg: 'Ed25519', key }` \| `{ alg: 'ECDSA-P256', key }` | 32 bytes, or the 65-byte SEC1 uncompressed point (checked on the curve) |
|
|
47
|
+
| `extensions` | object, optional | See below |
|
|
48
|
+
|
|
49
|
+
### `X509Signer`
|
|
50
|
+
|
|
51
|
+
| Field | Type | Notes |
|
|
52
|
+
|---|---|---|
|
|
53
|
+
| `alg` | `'Ed25519'` \| `'ECDSA-P256'` | The signature algorithm follows the signer's key |
|
|
54
|
+
| `privateKey` | `Uint8Array` | Ed25519: 64 bytes (seed ‖ public key, as `ed25519.keyPair` returns it). ECDSA P-256: the 32-byte scalar |
|
|
55
|
+
| `publicKey` | `Uint8Array`, optional | The issuer's public key; needed for `authorityKeyIdentifier` unless self-signed |
|
|
56
|
+
|
|
57
|
+
### Extensions
|
|
58
|
+
|
|
59
|
+
| Key | Value | Critical |
|
|
60
|
+
|---|---|---|
|
|
61
|
+
| `basicConstraints` | `{ ca: boolean, pathLen?: number }` (`pathLen` only with `ca`) | yes |
|
|
62
|
+
| `keyUsage` | names: `digitalSignature`, `nonRepudiation`, `keyEncipherment`, `dataEncipherment`, `keyAgreement`, `keyCertSign`, `cRLSign`, `encipherOnly`, `decipherOnly` | yes |
|
|
63
|
+
| `extKeyUsage` | dotted OIDs, e.g. `1.3.6.1.5.5.7.3.1` (serverAuth), `1.3.6.1.5.5.7.3.4` (emailProtection) | no |
|
|
64
|
+
| `subjectAltName` | `{ dns?: string[], email?: string[] }` (ASCII) | no |
|
|
65
|
+
| `subjectKeyIdentifier` | `true` | no |
|
|
66
|
+
| `authorityKeyIdentifier` | `true` | no |
|
|
67
|
+
|
|
68
|
+
Key identifiers are the leftmost 160 bits of SHA-256 of the subjectPublicKey bits
|
|
69
|
+
(RFC 7093 § 2, method 1): fw has no SHA-1.
|
|
70
|
+
|
|
71
|
+
### `X509Parsed`
|
|
72
|
+
|
|
73
|
+
`{ version, serial, signatureAlgorithm, issuer, subject, notBefore, notAfter, publicKey, extensions, tbs, signature }`.
|
|
74
|
+
`signatureAlgorithm` is `'Ed25519'`, `'ECDSA-SHA256'` or the dotted OID; a name
|
|
75
|
+
attribute fw does not name appears under its dotted OID, a repeated one as an
|
|
76
|
+
array; `publicKey` is `{ alg, key }` for the two supported keys and
|
|
77
|
+
`{ alg: <oid>, key: null, spki }` otherwise; `extensions` holds the six keys of the
|
|
78
|
+
table above (each with `critical`) and `other: [{ oid, critical, value }]`.
|
|
79
|
+
|
|
80
|
+
## Examples
|
|
81
|
+
|
|
82
|
+
```js
|
|
83
|
+
const { x509, ed25519, ecc } = fw.runtime.resolveAll(['x509', 'ed25519', 'ecc']);
|
|
84
|
+
|
|
85
|
+
// A self-signed Ed25519 certificate
|
|
86
|
+
const kp = ed25519.keyPair(seed); // seed: 32 random bytes
|
|
87
|
+
const der = x509.create({
|
|
88
|
+
subject: { CN: 'signer.example', O: 'Example', C: 'FR' },
|
|
89
|
+
serial: Uint8Array.of(0x01),
|
|
90
|
+
notBefore: new Date(), notAfter: new Date(Date.now() + 365 * 86400e3),
|
|
91
|
+
publicKey: { alg: 'Ed25519', key: kp.publicKey },
|
|
92
|
+
extensions: { basicConstraints: { ca: false }, keyUsage: ['digitalSignature', 'nonRepudiation'] },
|
|
93
|
+
}, { alg: 'Ed25519', privateKey: kp.privateKey });
|
|
94
|
+
|
|
95
|
+
x509.verify(der, { alg: 'Ed25519', key: kp.publicKey }); // true
|
|
96
|
+
const cert = x509.parse(der); // cert.subject.CN === 'signer.example'
|
|
97
|
+
const pemText = x509.toPem(der); // -----BEGIN CERTIFICATE----- …
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
A CA issues a certificate by passing its own name as `issuer` and its own key as
|
|
101
|
+
`signer` (with `signer.publicKey` for `authorityKeyIdentifier`).
|
|
102
|
+
|
|
103
|
+
## Worker Usage
|
|
104
|
+
|
|
105
|
+
```js
|
|
106
|
+
const worker = fw.createWorker(
|
|
107
|
+
function ({ libs, args }) {
|
|
108
|
+
self.postMessage(libs.x509.parse(new Uint8Array(args[0])).subject);
|
|
109
|
+
},
|
|
110
|
+
{ dependencies: ['x509'], args: [Array.from(der)] } // args are JSON: pass bytes as an array
|
|
111
|
+
);
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Notes
|
|
115
|
+
|
|
116
|
+
- **Interop measured**: certificates fw creates are read by `node:crypto`'s `X509Certificate` (fields, `ca`, `verify`, issuance) and `openssl x509 -text`; `openssl verify` accepts a fw CA and the leaf it issues; fw parses and verifies certificates `openssl req -x509` creates (Ed25519 and P-256).
|
|
117
|
+
- **Not claimed**: path validation (chains, revocation, name constraints, validity against a clock), RSA keys, CSRs.
|
|
118
|
+
- **No-throw**: malformed input returns `false` and logs `[crypto] INVALID: x509: …`.
|
|
119
|
+
|
|
120
|
+
## See also
|
|
121
|
+
|
|
122
|
+
- [keyformat](./keyformat.md) — the SPKI encodings the certificate embeds
|
|
123
|
+
- [ed25519](../pkc/ed25519.md), [ecc](../pkc/ecc.md) — the signing primitives
|
|
124
|
+
- [pem](./pem.md) — the PEM armour
|
|
@@ -59,7 +59,7 @@ All methods resolve `false` (never throw) when a parameter is invalid (`[crypto]
|
|
|
59
59
|
|
|
60
60
|
### CTR counter / nonce note
|
|
61
61
|
|
|
62
|
-
The frozen `aes_ctr` ABI consumes a **12-byte nonce**: the 16-byte counter block is `nonce(12) ‖ be32(0)` with the 32-bit block counter starting at `0` (J0-style). This matches the package KAT, which cross-checks against WebCrypto AES-CTR configured with `counter = nonce ‖ be32(0)`, `length: 32`. (
|
|
62
|
+
The frozen `aes_ctr` ABI consumes a **12-byte nonce**: the 16-byte counter block is `nonce(12) ‖ be32(0)` with the 32-bit block counter starting at `0` (J0-style). This matches the package KAT, which cross-checks against WebCrypto AES-CTR configured with `counter = nonce ‖ be32(0)`, `length: 32`. (An earlier ABI draft named a 16-byte full-width counter; the delivered binary — `targets.json` + `shims/aes.c` — is authoritative.)
|
|
63
63
|
|
|
64
64
|
## Examples
|
|
65
65
|
|
|
@@ -37,7 +37,7 @@ const wasmArgon2 = runtime.resolve('wasmArgon2');
|
|
|
37
37
|
| Field | Type | Meaning |
|
|
38
38
|
|-------|------|---------|
|
|
39
39
|
| `timeCost` | `number` | Passes `t` (≥ 1) |
|
|
40
|
-
| `memoryKiB` | `number` | Memory cost `m` in KiB (≥ 8·`parallelism`) |
|
|
40
|
+
| `memoryKiB` | `number` | Memory cost `m` in KiB (≥ 8·`parallelism`, ≤ `1048576` — the 1 GiB ceiling) |
|
|
41
41
|
| `parallelism` | `number` | Lanes `p` (≥ 1) |
|
|
42
42
|
| `hashLen` | `number` | Output tag length in bytes (`4` .. `2^32-1`) |
|
|
43
43
|
| `secret` | `Uint8Array` *(optional)* | Key `K` |
|
|
@@ -45,9 +45,9 @@ const wasmArgon2 = runtime.resolve('wasmArgon2');
|
|
|
45
45
|
|
|
46
46
|
`hash`/`verify` resolve `false` (never throw) when:
|
|
47
47
|
|
|
48
|
-
- a parameter is invalid (`[crypto] INVALID: …` logged): `timeCost < 1`, `parallelism < 1`, `memoryKiB < 8·parallelism`, `hashLen ∉ [4, 2^32-1]`, or `password`/`salt`/`secret`/`ad` not a `Uint8Array`;
|
|
48
|
+
- a parameter is invalid (`[crypto] INVALID: …` logged): `timeCost < 1`, `parallelism < 1`, `memoryKiB < 8·parallelism`, `memoryKiB > 1048576` (`[crypto] INVALID: wasmArgon2: memoryKiB above the ceiling of 1048576 KiB (1 GiB)`), `hashLen ∉ [4, 2^32-1]`, or `password`/`salt`/`secret`/`ad` not a `Uint8Array`;
|
|
49
49
|
- the binary cannot load — `WebAssembly` unavailable, fetch/compile failure, or ABI mismatch (`[crypto] FAIL: …` logged by `wasmRuntime.load`);
|
|
50
|
-
- the WASM call returns a non-zero status (`[crypto] FAIL: wasmArgon2.hash: argon2id_hash status <n>`).
|
|
50
|
+
- the WASM call returns a non-zero status (`[crypto] FAIL: wasmArgon2.hash: argon2id_hash status <n>`) — `-2` when the engine refuses to grow linear memory for the matrix (the page is out of memory below the ceiling).
|
|
51
51
|
|
|
52
52
|
`verify` additionally returns `false` when `expected` is not a `Uint8Array`, when its length differs from the produced tag, or when the bytes differ.
|
|
53
53
|
|
|
@@ -96,7 +96,9 @@ const tag = await wasmArgon2.hash(
|
|
|
96
96
|
|
|
97
97
|
## Notes
|
|
98
98
|
|
|
99
|
-
- **Memory-hard ⇒ the prime reason to reach for WASM here.** Choose `memoryKiB` as large as your environment allows (RFC 9106 §4 suggests `m = 2^
|
|
99
|
+
- **Memory-hard ⇒ the prime reason to reach for WASM here.** Choose `memoryKiB` as large as your environment allows (RFC 9106 §4 suggests `m = 2^16` KiB / 64 MiB when constrained; the OWASP Password Storage Cheat Sheet's floor is `m = 19456` KiB (19 MiB) with `t = 2`, `p = 1`, or `m = 47104` KiB (47 MiB) with `t = 1`, `p = 1` — both run here and match the pure-JS module byte for byte).
|
|
100
|
+
- **Accepted range and ceiling.** `8·parallelism ≤ memoryKiB ≤ 1048576` (1 GiB). The ceiling sits under the 4 GiB wasm32 limit and the browsers' practical per-page limit; RFC 9106's 2 GiB server profile is therefore out of reach of this binary (use a native implementation server-side). Above the ceiling `hash` refuses up front with the named `INVALID` error above, before touching the binary.
|
|
101
|
+
- **Linear memory grows and is not returned.** The block matrix (`m'` KiB) is not taken from the binary's 16 MiB scratch arena: the first call that needs it grows the module's linear memory, and a later, larger call extends it. WebAssembly memory never shrinks, so that memory stays allocated for the life of the loaded module (a later, smaller call reuses it); the matrix is zeroed after every call. A page that never hashes pays nothing.
|
|
100
102
|
- **Not in WebCrypto.** `crypto.subtle` has no Argon2; this WASM tier (or the pure-JS [`argon2`](../hash/argon2.md)) is the only path.
|
|
101
103
|
- **Scalar-only binary.** `wasmArgon2` forces `{ variant: 'scalar' }` when loading because the `argon2` target ships no SIMD build. Other `crypto/wasm/*` modules with a SIMD variant load it automatically via `wasmRuntime`.
|
|
102
104
|
- **Output is copied OUT** of WASM linear memory into a fresh `Uint8Array` (never a view that could alias reused memory).
|
|
@@ -29,7 +29,7 @@ const wasmPbkdf2 = runtime.resolve('wasmPbkdf2');
|
|
|
29
29
|
| Method | Signature | Returns |
|
|
30
30
|
|--------|-----------|---------|
|
|
31
31
|
| `isAvailable` | `() => boolean` | `true` when `WebAssembly` is present (mirrors `wasmRuntime`) |
|
|
32
|
-
| `deriveBits` | `(password: Uint8Array, salt: Uint8Array,
|
|
32
|
+
| `deriveBits` | `(password: Uint8Array, salt: Uint8Array, lengthBits: number, iterations?: number, hash?: 256\|384\|512) => Promise<Uint8Array\|false>` | `lengthBits / 8`-byte derived key, or `false` on any failure |
|
|
33
33
|
|
|
34
34
|
### Parameter constraints
|
|
35
35
|
|
|
@@ -37,13 +37,13 @@ const wasmPbkdf2 = runtime.resolve('wasmPbkdf2');
|
|
|
37
37
|
|-----------|---------|-----------|
|
|
38
38
|
| `password` | — | `Uint8Array`; any byte length including `0` (empty password is valid per RFC 8018) |
|
|
39
39
|
| `salt` | — | `Uint8Array`; any byte length (≥ 16 bytes recommended by SP 800-132) |
|
|
40
|
-
| `
|
|
40
|
+
| `lengthBits` | — | A positive multiple of 8 (**bits**, as the pure and WebCrypto tiers) |
|
|
41
41
|
| `iterations` | `600000` | Integer ≥ 1 (OWASP 2023 default for PBKDF2-HMAC-SHA-256) |
|
|
42
42
|
| `hash` | `256` | One of `256` / `384` / `512` (selects HMAC-SHA-2 PRF) |
|
|
43
43
|
|
|
44
44
|
`deriveBits` resolves `false` (never rejects) when:
|
|
45
45
|
|
|
46
|
-
- a parameter is invalid: `password` or `salt` not a `Uint8Array`; `iterations < 1` or non-integer; `
|
|
46
|
+
- a parameter is invalid: `password` or `salt` not a `Uint8Array`; `iterations < 1` or non-integer; `lengthBits` not a positive multiple of 8; `hash ∉ {256, 384, 512}` — logged as `[crypto] INVALID: …`;
|
|
47
47
|
- the binary cannot load — `WebAssembly` unavailable, fetch/compile failure, or ABI mismatch — logged as `[crypto] FAIL: …` by `wasmRuntime.load`;
|
|
48
48
|
- the WASM call returns a non-zero status (`WC_EBADPARAM = -1`).
|
|
49
49
|
|
|
@@ -56,7 +56,7 @@ const wasmPbkdf2 = runtime.resolve('wasmPbkdf2');
|
|
|
56
56
|
|
|
57
57
|
const password = new TextEncoder().encode('my-passphrase');
|
|
58
58
|
const salt = crypto.getRandomValues(new Uint8Array(16));
|
|
59
|
-
const dk = await wasmPbkdf2.deriveBits(password, salt,
|
|
59
|
+
const dk = await wasmPbkdf2.deriveBits(password, salt, 256); // 256 bits = 32 bytes
|
|
60
60
|
// dk is a 32-byte Uint8Array, or false on failure.
|
|
61
61
|
if (dk === false) {
|
|
62
62
|
// WASM unavailable — fall back to webcrypto/pbkdf2 or hash/pbkdf2.
|
|
@@ -67,7 +67,7 @@ if (dk === false) {
|
|
|
67
67
|
|
|
68
68
|
```js
|
|
69
69
|
// 100 000 iterations, HMAC-SHA-512, 64-byte output.
|
|
70
|
-
const dk = await wasmPbkdf2.deriveBits(password, salt,
|
|
70
|
+
const dk = await wasmPbkdf2.deriveBits(password, salt, 512, 100_000, 512);
|
|
71
71
|
```
|
|
72
72
|
|
|
73
73
|
### RFC 7914 §11 published vector (c=1, SHA-256)
|
|
@@ -75,7 +75,7 @@ const dk = await wasmPbkdf2.deriveBits(password, salt, 64, 100_000, 512);
|
|
|
75
75
|
```js
|
|
76
76
|
const pw = new TextEncoder().encode('password');
|
|
77
77
|
const salt = new TextEncoder().encode('salt');
|
|
78
|
-
const dk = await wasmPbkdf2.deriveBits(pw, salt,
|
|
78
|
+
const dk = await wasmPbkdf2.deriveBits(pw, salt, 256, 1, 256);
|
|
79
79
|
// hex(dk) === '120fb6cffcf8b32c43e7225256c4f837a86548c92ccc35480805987cb70be17b'
|
|
80
80
|
```
|
|
81
81
|
|
|
@@ -87,8 +87,8 @@ const dk = await wasmPbkdf2.deriveBits(pw, salt, 32, 1, 256);
|
|
|
87
87
|
const worker = fw.createWorker(() => {
|
|
88
88
|
const wasmPbkdf2 = runtime.resolve('wasmPbkdf2');
|
|
89
89
|
self.onmessage = async ({ data }) => {
|
|
90
|
-
const { password, salt,
|
|
91
|
-
const dk = await wasmPbkdf2.deriveBits(password, salt,
|
|
90
|
+
const { password, salt, lengthBits } = data;
|
|
91
|
+
const dk = await wasmPbkdf2.deriveBits(password, salt, lengthBits);
|
|
92
92
|
self.postMessage(dk);
|
|
93
93
|
};
|
|
94
94
|
});
|
|
@@ -102,7 +102,7 @@ await wasmRsa.verify(kp.publicKey, bad, msg, 'PSS', 256); // → false
|
|
|
102
102
|
- **NIST-anchored.** The test suite verifies a genuine NIST RSA-SigGen-FIPS186-5 PKCS#1-v1.5 signature byte-for-byte against the delivered binary, plus OAEP/PSS/PKCS1 round-trips on a fixed NIST DecryptionPrimitive key.
|
|
103
103
|
- **Scalar only.** The `rsa` target ships `rsa.scalar.wasm` (no SIMD build); the wrapper passes `{ variant: 'scalar' }` to `wasmRuntime.load`.
|
|
104
104
|
- **Output is copied OUT** of WASM linear memory into fresh `Uint8Array`s (never a view that could alias reused memory).
|
|
105
|
-
- **No-throw contract.** Every failure path resolves to `false
|
|
105
|
+
- **No-throw contract.** Every failure path resolves to `false`; nothing rejects. An OAEP decryption failure (a wrong key, a tampered ciphertext) logs `CORRUPT` at warn level, every other failure logs at `console.error`.
|
|
106
106
|
|
|
107
107
|
## See also
|
|
108
108
|
|