Cascade - An encryption and signing library for x-brid encryption via several crypto suites
npm install crypto-cascadeCascade - Encryption and signing library for x-brid encryption via several cryptographic suites.
--




!Unit Test
> WARNING: At this time this solution should be considered suitable for research and experimentation, further code and security review is needed before utilization in a production application.
Considering existing cryptographic libraries and native APIs for JavaScript, as far as we know, fundamental implementations of primitives have been developed separately in multiple environments such as Node.js and various browsers. In order to fill gaps among those different environments, there exist several nice universal cryptographic suites that flawlessly work in most of modern JavaScript environments. Here we have defined 'suites' as ones providing encryption, singing and other supplemental functions like OpenPGP library.
However, they are still too primitive to realize a bit more modern cryptographic services in JavaScript. In other words, we see that simple encryption and signing provided by those primitives are insufficient to directly satisfy more complex demands, e.g., revocation of decryption rights after encryption of data. Considering such situation, the aim of this project called Cascade is to provide a flexible cryptographic application library in JavaScript that realizes the x-brid encryption and signing by utilizing multiple cryptographic suites. This enables us to, for instance, realize complex structures of access rights to encrypted data, e.g., revocation after encryption as mentioned above.
Here we shall explain the detailed mechanism of x-brid encryption by illustrating the simplest example instance of hybrid encryption, i.e., x = 2, which is a well-known cryptosystem in the current security technology. The following is a schematic block diagram of the hybrid encryption.
!Schematic Diagram of Hybrid Encryption
As we see, this hybrid procedure consists of two steps where the step 1 encrypts the given plaintext message under (one-time) session key in a certain symmetric key encryption, and the step 2 encrypts the previously-used session key under a given public key(s) as a plaintext in a public key encryption. Although this looks somewhat redundant and waste of computing resource, it has a great advantage in terms of storage usage in the case where we have multiple receivers, i.e., multiple public keys. Namely, the encrypted message body that is likely big would be common and recycled to all the receivers, and only encrypted session key that should be small is 'personalized' to each receivers.
Moreover, this cryptosystem could yield another merit, which is the revocation after encryption of data. Assume that we first provide receivers the encrypted message body, and recall that at this point, no one can decrypt it. This implies that you can provide 'personalized' encrypted session keys to only authorized person later and freely discard the encrypted session keys, i.e., granting and revoking decryption rights and access rights to the data. We may know that this is a very basic and fundamental concept of encryption-based access control that is likely to be a part of well-known digital rights management (DRM).
Cascade project can instantiate the above mentioned hybrid encryption by its nature, and it also generalizes this basic 2-step cryptosystem to x-step one (x > 0), namely, x-brid encryption.
We briefly explained our concept of x-brid encryption by providing a fairly simple hybrid instance as above. As a natural consequence of the generalization by Cascade, we can simply increase the value x and compose, say, tri-brid (x = 3) or tetra-brid (x = 4) encryption by cascading symmetric encryption steps. (We are honestly unsure this technically sounds at this point, but such structures may fit a certain type of application like the relationship of hybrid encryption and DRM.)
On the other hand, there is another room to generalize the cryptosystem from the viewpoint of encryption function at each step of x-brid encryption. The current implementation of Cascade can utilize encryption functions of a couple of cryptographic suites, and they supports only basic public key encryption (RSA and elliptic curve cryptosystems) and symmetric key encryption (AES). We mean that as additions to the public/private key pair based cryptosystem, we should plan to supports other types of modern cryptography as suites. In fact, the concept and current implementation can accept more interesting and modern cryptographic primitive functions as a step of x-brid encryption. For instance:
- Broadcast encryption
- Attribute-based encryption
- Secret sharing (e.g., split our session key at the final step!)
We can see that by employing those functions at some steps, new types of cryptographic application could be realized.
We also mention that a classical broadcast encryption based on tree can be possibly instantiated in the context of x-brid encryption. This is from the following observation. First consider to attach public key encryption to all steps, and assume that the plaintext message at each step is the private key used in the previous step. This composes a tree of multiple layers of private key encapsulation that is the core of tree-based broadcast encryption.
This library currently supports one cryptographic suite, js-crypto-utils. js-crypto-utils is a simple crypto suite for plain implementations of cryptographic functions unlike fully-specified suites like OpenPGP. We should note that js-crypto-utils can be viewed as a integrated wrapper or interfaces of RFC standardized functions that are mostly built-in ones of browsers and Node.js. At the initial implementation, although we had adopted openpgpjs as a suite, it has been disruptively changing its (internal) APIs to follow the OpenPGP RFC standards and hence we purged the OpenPGP support from cascade due to the toughness of tracking its changes.
* Encryption and decryption:
* js-crypto-utils
* Public key encryption (ECDH, HKDF and AES256-GCM combination)
* Public key encryption (RSA-OAEP)
* Session key encryption (AES-GCM)
* Signing and verification:
* js-crypto-utils
* RSA-PSS signature (May not work in IE11 and Edge.)
* RSASSA-PKCS1-v1_5 signature
* ECDSA signature
* Key generation:
* js-crypto-utils
* Public and private key pair generation w/ and w/o passphrase in PEM armored format (ECC and RSA)
* Session key generation
At your project directory, first do either one of the following.
``shell`
$ npm install --save crypto-cascade # from npm
$ yarn add crypto-cascade # from yarn
Then import the Cascade library as follows.
`javascript`
import cascade from 'crypto-cascade'
Of cource, you can also directly import the source code by cloning this Github repo.
The Cascade library doesn't internally import cryptographic suites, i.e., js-crypto-utils in a static manner, but it loads them in a dynamic manner. In particular, it calls those suites via require for Node.js and as window objects for browsers. This means that for browsers, js-crypto-utils (jscu.bundle.js) must be pre-loaded by