Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
Update readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
alokmenghrajani committed Sep 15, 2016
1 parent 3ea8123 commit a69db8b
Showing 1 changed file with 34 additions and 18 deletions.
52 changes: 34 additions & 18 deletions README.md
Expand Up @@ -6,11 +6,13 @@ Javascript library for Jose JWE and JWS
Overview
--------
JavaScript library to sign/verify and encrypt/decrypt data in JSON Web
Signatures and Web Encryption (JWE) formats. It can do RSA-based public/private
crypto as well as shared key encryption.
Encryption (JWE) and JSON Web Signatures (JWS) formats.

The library can be used to implement RSA-based public/private cryptography as
well as shared key encryption.

Both JWE and JWS are encapsulation formats which makes it easy to share
signatures and ciphertext between different platforms: data signed or encrypted
ciphertext and signatures between different platforms: data encrypred or signed
in a browser can be verified or decrypted in Go, Java, etc.

The library uses compact representation. There is therefore no support for
Expand All @@ -20,18 +22,19 @@ The library partially supports extra headers.

The library uses the Web Crypto API, which is available in (recent browsers)
[http://caniuse.com/#feat=cryptography]. As of March 2016, it seems +80%
of users have some form of Web Crypto support. It works fine on Node but requires [polyfill for WebCrypto](https://github.com/PeculiarVentures/node-webcrypto-ossl) to be used.
of users have some form of Web Crypto support. You can use the library on Node
using a [polyfill for WebCrypto](https://github.com/PeculiarVentures/node-webcrypto-ossl).

This code has been tested in Chrome 38 and is compatible with the [Golang
implementation](https://github.com/square/go-jose).

JSON web encryption is currently a set of drafts. This code is based on the
following drafts:

* https://tools.ietf.org/html/draft-ietf-jose-json-web-encryption-40
* https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40
* https://tools.ietf.org/html/draft-ietf-jose-json-web-key-41
* https://tools.ietf.org/html/draft-ietf-jose-json-web-signature-41
JWE and JWS have been standardized under:
* https://tools.ietf.org/html/rfc7516 JSON Web Encryption (JWE)
* https://tools.ietf.org/html/rfc7515 JSON Web Signature (JWS)
* https://tools.ietf.org/html/rfc7518 JSON Web Algorithms (JWA)
* https://tools.ietf.org/html/rfc7517 JSON Web Key (JKW)
* https://tools.ietf.org/html/rfc7519 JSON Web Token (JWT)
* https://tools.ietf.org/html/rfc7520 Examples of Protecting Content Using JSON Object Signing and Encryption (JOSE)

**Disclaimer**: This library contains encryption software that is subject to the
U.S. Export Administration Regulations. You may not export, re-export, transfer
Expand All @@ -45,16 +48,19 @@ Example encryption
------------------

<script src="jose.min.js"></script>
var joseJWE = new JoseJWE();
<script>
var cryptographer = new Jose.WebCryptographer();
var rsa_key = Jose.Utils.importRsaPublicKey({
"n": "c2:4b:af:0f:2d:2b:ad:36:72:a7:91:0f:ee:30:a0:95:d5:3a:46:82:86:96:7e:42:c6:fe:8f:20:97:af:49:f6:48:a3:91:53:ac:2e:e6:ec:9a:9a:e0:0a:fb:1c:db:44:40:5b:8c:fc:d5:1c:cb:b6:9b:60:c0:a8:ac:06:f1:6b:29:5e:2f:7b:09:d9:93:32:da:3f:db:53:9c:2e:ea:3b:41:7f:6b:c9:7b:88:9f:2e:c5:dd:42:1e:7f:8f:04:f6:60:3c:fe:43:6d:32:10:ce:8d:99:cb:76:f7:10:97:05:af:28:1e:39:0f:78:35:50:7b:8e:28:22:a4:7d:11:51:22:d1:0e:ab:6b:6f:96:cb:cf:7d:eb:c6:aa:a2:6a:2e:97:2a:93:af:a5:89:e6:c8:bc:9f:fd:85:2b:0f:b4:c0:e4:ca:b5:a7:9a:01:05:81:93:6b:f5:8d:1c:f7:f3:77:0e:6e:53:34:92:0f:48:21:34:33:44:14:5e:4a:00:41:3a:7d:cb:38:82:c1:65:e0:79:ea:a1:05:84:b2:6e:40:19:77:1a:0e:38:4b:28:1f:34:b5:cb:ac:c5:2f:58:51:d7:ec:a8:08:0e:7c:c0:20:c1:5e:a1:4d:b1:30:17:63:0e:e7:58:8e:7f:6e:9f:a4:77:8b:1e:a2:d2:2e:1b:e9",
"n": "c2:4b:af:0f:2d:2b:ad:36:72:a7:91:0f:ee:30:a0:95:d5:3a:46:82:86:96:7e:42:c6:fe:8f:20:97:af:49:f6:48:a3:91:53:ac:2e:e6:ec:9a:9a:e0:0a:fb:1c:db:44:40:5b:8c:fc:d5:1c:cb:b6:9b:60:c0:a8:ac:06:f1:6b:29:5e:2f:7b:09:d9:93:32:da:3f:db:53:9c:2e:ea:3b:41:7f:6b:c9:7b:88:9f:2e:c5:dd:42:1e:7f:8f:04:f6:60:3c:fe:43:6d:32:10:ce:8d:99:cb:76:f7:10:97:05:af:28:1e:39:0f:78:35:50:7b:8e:28:22:a4:7d:11:51:22:d1:0e:ab:6b:6f:96:cb:cf:7d:eb:c6:aa:a2:6a:2e:97:2a:93:af:a5:89:e6:c8:bc:9f:fd:85:2b:0f:b4:c0:e4:ca:b5:a7:9a:01:05:81:93:6b:f5:8d:1c:f7:f3:77:0e:6e:53:34:92:0f:48:21:34:33:44:14:5e:4a:00:41:3a:7d:cb:38:82:c1:65:e0:79:ea:a1:05:84:b2:6e:40:19:77:1a:0e:38:4b:28:1f:34:b5:cb:ac:c5:2f:58:51:d7:ec:a8:08:0e:7c:c0 :20:c1:5e:a1:4d:b1:30:17:63:0e:e7:58:8e:7f:6e:9f:a4:77:8b:1e:a2:d2:2e:1b:e9",
"e": 65537
});
joseJWE.encrypt(rsa_key, "hello world").then(function(result) {
console.log(result);
}, "RSA-OAEP");
var encrypter = new JoseJWE.Encrypter(cryptographer, rsa_key);
encrypter.encrypt("hello world").then(function(result) {
console.log(result);
}).catch(function(err){
console.error(err);
console.error(err);
});
</script>

Example signature
-----------------
Expand Down Expand Up @@ -92,7 +98,6 @@ Example signature
var signer = new JoseJWS.Signer(cryptographer);
signer.addSigner(rsa_key).then(function() {
signer.sign(plaintext.textContent, null, {}).then(function(message) {

console.log(message);
var verifier = new JoseJWS.Verifier(cryptographer, message);
verifier.addRecipient(rsa_key).then(function() {
Expand Down Expand Up @@ -177,6 +182,17 @@ implemented against an earlier version of the ietf draft). We will either
need to implement a thin abstraction layer or [wait for Microsoft to update
things](https://status.modern.ie/webcryptoapi?term=crypto).

Authors and contributors
------------------------
(in no particular order)
* Cedric Staub
* Davis Gallinghouse
* Leonid Lance
* Robert Coie
* Ryan Hurst
* Sam Quigley
* Alok Menghrajani

Random other interesting resources
----------------------------------
* Web Crypto API polyfill for Node: https://github.com/PeculiarVentures/node-webcrypto-ossl
Expand Down

0 comments on commit a69db8b

Please sign in to comment.