All Projects → PeculiarVentures → Webcrypto Liner

PeculiarVentures / Webcrypto Liner

Licence: mit
webcrypto-liner is a polyfill that let's down-level User Agents (like IE/Edge) use libraries that depend on WebCrypto. (Keywords: Javascript, WebCrypto, Shim, Polyfill)

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Webcrypto Liner

Encrypt
🔒 A set of high-level APIs over PointyCastle for two-way cryptography.
Stars: ✭ 199 (+103.06%)
Mutual labels:  cryptography, rsa
Open Crypto
🔑 Hashing (BCrypt, SHA2, HMAC), encryption (AES), public-key (RSA), and random data generation.
Stars: ✭ 115 (+17.35%)
Mutual labels:  cryptography, rsa
Mirage Crypto
Cryptographic primitives for MirageOS
Stars: ✭ 39 (-60.2%)
Mutual labels:  cryptography, rsa
Rsactftool
RSA attack tool (mainly for ctf) - retreive private key from weak public key and/or uncipher data
Stars: ✭ 3,163 (+3127.55%)
Mutual labels:  cryptography, rsa
Oscrypto
Compiler-free Python crypto library backed by the OS, supporting CPython and PyPy
Stars: ✭ 257 (+162.24%)
Mutual labels:  cryptography, rsa
Rsa And Lll Attacks
attacking RSA via lattice reductions (LLL)
Stars: ✭ 482 (+391.84%)
Mutual labels:  cryptography, rsa
Low Latency Android Ios Linux Windows Tvos Macos Interactive Audio Platform
🇸Superpowered Audio, Networking and Cryptographics SDKs. High performance and cross platform on Android, iOS, macOS, tvOS, Linux, Windows and modern web browsers.
Stars: ✭ 1,121 (+1043.88%)
Mutual labels:  cryptography, rsa
Paramikojs
port of the paramiko library from python->javascript
Stars: ✭ 89 (-9.18%)
Mutual labels:  cryptography
Computer Science Resources
A list of resources in different fields of Computer Science (multiple languages)
Stars: ✭ 1,316 (+1242.86%)
Mutual labels:  cryptography
Zcash Mini
A minimal portable Zcash z-address generator for offline / paper wallets
Stars: ✭ 87 (-11.22%)
Mutual labels:  cryptography
Pentesting toolkit
🏴‍☠️ Tools for pentesting, CTFs & wargames. 🏴‍☠️
Stars: ✭ 1,268 (+1193.88%)
Mutual labels:  cryptography
Py Seccure
SECCURE compatible Elliptic Curve cryptography in Python
Stars: ✭ 90 (-8.16%)
Mutual labels:  cryptography
Polyfill Php54
This component provides functions unavailable in releases prior to PHP 5.4.
Stars: ✭ 93 (-5.1%)
Mutual labels:  polyfill
Tokenscript
TokenScript schema, specs and paper
Stars: ✭ 89 (-9.18%)
Mutual labels:  cryptography
Proposal Array Unique
ECMAScript proposal for Deduplicating method of Array
Stars: ✭ 96 (-2.04%)
Mutual labels:  polyfill
Hybrid Crypto Js
RSA+AES hybrid encryption implementation for JavaScript. Works with Node.js, React Native and modern browsers.
Stars: ✭ 87 (-11.22%)
Mutual labels:  rsa
Webvr Polyfill
Use WebVR today, without requiring a special browser build.
Stars: ✭ 1,343 (+1270.41%)
Mutual labels:  polyfill
Match Media
Universal polyfill for match media API using Expo APIs on mobile
Stars: ✭ 95 (-3.06%)
Mutual labels:  polyfill
Encryptor4j
Strong encryption for Java simplified
Stars: ✭ 92 (-6.12%)
Mutual labels:  rsa
Cryptopals Python3
Solutions to Matasano crypto challenges in Python 3.
Stars: ✭ 91 (-7.14%)
Mutual labels:  cryptography

webcrypto-liner

license npm version Build Status

NPM

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.

Browsers support

IE / Edge Edge FirefoxFirefox ChromeChrome SafariSafari
last 2 versions last 2 versions last 2 versions last 2 versions

Information

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.

Using

<head>
  <!-- Crypto providers are optional -->
  <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.7.0/polyfill.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/asmCrypto/2.3.2/asmcrypto.all.es5.min.js"></script>
  <script src="https://cdn.rawgit.com/indutny/elliptic/master/dist/elliptic.min.js"></script>
  <!-- Crypto -->
  <script src="webcrypto-liner.shim.js"></script>
</head>
<body>
  <script> 
    crypto.subtle.generateKey({name: "AES-GCM", length: 192}, true, ["encrypt", "decrypt"])
      .then(function(key){
        return crypto.subtle.encrypt({
            name: "AES-GCM", 
            iv: new Uint8Array([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]),
            tagLength: 128
          }, key, new Uint8Array([1,2,3,4,5]))
      })
      .then(function(enc){
        console.log(new Uint8Array(enc));
      })
      .catch(function(err){
        console.log(err.message); // Chrome throws: 192-bit AES keys are not supported
      })
  </script>
</body>

Dependencies

typescript

npm install typescript --global

Installation

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

FAQ

  • Do I need to use a promise library? - No, not if your browser supports promises.
  • Do I need to include asmcrypto.js? No, not unless you want to use the algorithms it exposes.
  • Do I need to include elliptic.js? No, not unless you want to use the algorithms it exposes.
  • How are random numbers generated? We use two libraries for crypto operations in Javascript, asymcrypto and ellipticjs both rely on window.crypto.getRandomValues where available. asymcrypto also has a fallback mechanism where it generates its own random numbers if not present.
  • How big is the total package? Right now, if you include all optional dependencies (minfied) the package is ~300 KB, if you include only ECC or only RSA support that is lowered to about 180 KB. Additionally you will see GZIP compression provide about 30% savings above and beyond that. If you use 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.
  • Will it work in Node? No. It is compiles to pure Javascript but uses the 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.

Related

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].