How microsoft/msr-javascript-crypto works
msrCrypto is a JavaScript Web Cryptography API polyfill. The main workflow is an application calling msrCrypto.subtle, which validates and prepares an operation, dispatches it to a worker or synchronous fallback, and returns the cryptographic result. The algorithm layer covers encryption, signatures, hashing, key derivation, and key wrapping; key management and arithmetic support these operations. The README documents the broader algorithm set; sampled excerpts confirm the API, worker dispatch, key storage, and core math mechanisms, but not every algorithm’s internal wiring.
Main entry points: worker.js Worker Runner · workerManager.js Worker Manager · subtleInterface.js SubtleCrypto API · global.js Public API
Components 20
WebCrypto API
- Public API
src/global.js - SubtleCrypto API
src/subtle/subtleInterface.js - Key Manager
src/subtle/keyManager.js
Execution Dispatch
- Operation Registry
src/operations.js - Worker Manager
src/subtle/workerManager.js - Sync Worker
src/subtle/syncWorker.js - Worker Runner
src/worker.js
Crypto Algorithms
- AES
src/aes.js - RSA
src/rsa.js - Hash Functions
src/sha.js - HMAC
src/hmac.js - Elliptic Curves
src/cryptoECC.js - ECDSA
src/ecdsa.js - ECDH
src/ecdh.js - Key Derivation
src/pbkdf2.js - Concat KDF
src/concat.js
Crypto Primitives
- Random Generator
src/random.js - Big-Number Math
src/cryptoMath.js - Byte Utilities
src/utilities.js
Other components
- Application
Connections 21
- Application → Public API: uses polyfill
- Public API → SubtleCrypto API: exposes API
- SubtleCrypto API → Worker Manager: dispatches jobs
- SubtleCrypto API → Key Manager: manages keys
- Worker Manager → Worker Runner: posts jobs
- Worker Manager → Sync Worker: falls back to
- Sync Worker → Worker Runner: runs handler
- Worker Runner → Operation Registry: looks up handler
- Worker Runner → AES: invokes handler
- Worker Runner → RSA: invokes handler
- Worker Runner → Hash Functions: invokes handler
- Worker Runner → HMAC: invokes handler
- Worker Runner → ECDSA: invokes handler
- Worker Runner → ECDH: invokes handler
- Worker Runner → Key Derivation: invokes handler
- Worker Runner → Concat KDF: invokes handler
- Worker Runner → Random Generator: seeds from
- Elliptic Curves → Big-Number Math: uses arithmetic
- RSA → Big-Number Math: uses arithmetic
- AES → Byte Utilities: uses byte helpers
- Worker Manager → Random Generator: seeds workers