Gathering detailed insights and metrics for webcrypto-liner
Gathering detailed insights and metrics for webcrypto-liner
Gathering detailed insights and metrics for webcrypto-liner
Gathering detailed insights and metrics for webcrypto-liner
npm install webcrypto-liner
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
149 Stars
373 Commits
26 Forks
10 Watching
9 Branches
9 Contributors
Updated on 01 Nov 2024
Minified
Minified + Gzipped
TypeScript (96.12%)
JavaScript (3.88%)
Cumulative downloads
Total Downloads
Last day
-25.2%
744
Compared to previous day
Last week
-6.4%
4,937
Compared to previous week
Last month
-19.9%
22,794
Compared to previous month
Last year
-10.8%
396,816
Compared to previous year
11
19
A polyfill for WebCrypto that "smooths out" the rough-edges in existing User Agent implementations.
Though WebCrypto is well supported across browsers, several browsers still have prefixed and buggy implementations. Additionally, they do not always support the same algorithms, for example, Edge does not support SHA1 or ECC while both Firefox and Chrome do.
NOTE: If you are not familiar with how to use the various capabilities of WebCrypto see this great example page.
Edge | Firefox | Chrome | Safari |
---|---|---|---|
last 2 versions | last 2 versions | last 2 versions | last 2 versions |
webcrypto-liner
is a wrapper for WebCrypto designed to address these issues, at the same time it was designed to be modular so that it can also be used for testing the addition of new algorithms to WebCrypto in the future.
Intentionally webcrypto-liner
does not implement any cryptography though it does consume libraries that do. We strongly recommend you read "What’s wrong with in-browser cryptography?" before using this library.
The libraries webcrypto-liner
relies on include:
Package | Description | Size | Optional |
---|---|---|---|
asmcrypto.js | A performant JavaScript implementation of popular cryptographic utilities with performance in mind. | 131Â KB | Yes |
elliptic | Fast Elliptic Curve Cryptography in plain javascript | 130Â KB | Yes |
webcrypto-core | A input validation layer for WebCrypto polyfills 1 | 25Â KB | No |
1 This library is compiled into webcrypto-liner.
webcrypto-liner
will always try to use a native implementation of webcrypto, or a prefixed version of webcrypto, before it falls back to a Javascript implementation of a given algorithm. We have no control over the corresponding implementation and what it does, for example, it may not use window.crypto.getRandomValues
even if it is available and the mechanism it uses to gather randomness may be both insecure and weak.
We have done no security review or take a position on the security of these third-party libraries. YOU HAVE BEEN WARNED.
To keep webcrypto-liner
as small as possible (right now it is ~11kb without dependencies) it was designed to be modular, so if you do not need ECC support, do not include elliptic
as a dependency and it will not be loaded.
If you do not load any of the dependencies that provide cryptographic implementations webcrypto-liner
will work as an interoperability layer, very similar to webcrypto-shim.
webcrypto-liner
supports the following algorithms and key lengths:
Capability | Details |
---|---|
Encryption/Decryption | RSA-OAEP, DES-CBC1, DES-EDE3-CBC1, AES-ECB 1, AES-CBC, AES-ECB and AES-GCM |
Sign/Verify | RSA-PSS, RSASSA_PKCS1-v1_5 and ECDSA |
Hash | SHA-1, and SHA-256, SHA-512 |
Derive Key/Bits | ECDH, PBKDF2 |
Keywrap | AES-GCM, AES-CBC, AES-ECB 1, DES-CBC1, DES-EDE3-CBC1 |
ECC Curves | P-256, P-384, P-521, and K-2562 (secp256k1) |
RSA Key Lengths | 1024, 2048, 3072, and 4096 |
AES Key Lengths | 128, 192 and 256 |
1 Mechanism is not defined by the WebCrypto specifications. Use of mechanism in a safe way is hard, it was added for the purpose of enabling interoperability with an existing system. We recommend against its use unless needed for interoperability.
2 K-256 (secp256k1) curve is not defined by the WebCrypto specifications.
You can see the webcrypto-liner
in use in the pv-webcrypto-tests
page.
1<head> 2 <!-- Crypto providers are optional --> 3 <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.7.0/polyfill.min.js"></script> 4 <script src="https://cdnjs.cloudflare.com/ajax/libs/asmCrypto/2.3.2/asmcrypto.all.es5.min.js"></script> 5 <script src="https://cdn.rawgit.com/indutny/elliptic/master/dist/elliptic.min.js"></script> 6 <!-- Crypto --> 7 <script src="webcrypto-liner.shim.js"></script> 8</head> 9<body> 10 <script> 11 crypto.subtle.generateKey({name: "AES-GCM", length: 192}, true, ["encrypt", "decrypt"]) 12 .then(function(key){ 13 return crypto.subtle.encrypt({ 14 name: "AES-GCM", 15 iv: new Uint8Array([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]), 16 tagLength: 128 17 }, key, new Uint8Array([1,2,3,4,5])) 18 }) 19 .then(function(enc){ 20 console.log(new Uint8Array(enc)); 21 }) 22 .catch(function(err){ 23 console.log(err.message); // Chrome throws: 192-bit AES keys are not supported 24 }) 25 </script> 26</body>
typescript
npm install typescript --global
The module has been designed to be useful in ES6 and ES5 projects. The default is ES5 with commonjs, to install and build you would run:
npm install
npm run build
asymcrypto
also has a fallback mechanism where it generates its own random numbers if not present.webcrypto-liner
as just an interopability shim and do not use any of the optional third-party libraries it will be under 44 KB in size.window
object so it wont work in Node at this time. With some minor changes it should also be able to work in Node also but you really should be using node-webcrypto-ossl on Node instead.No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 2/25 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
11 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More