Giter Site home page Giter Site logo

junkurihara / jscu Goto Github PK

View Code? Open in Web Editor NEW
148.0 7.0 16.0 5.6 MB

JavaScript cryptographic utilities for crypto-suite compatibility including PEM/X509/JWK converter.

Home Page: https://junkurihara.github.io/jscu-webpage/

License: MIT License

JavaScript 13.86% Shell 0.35% TypeScript 85.79%

jscu's Introduction

jscu: A Universal Cryptographic Library for JavaScript

--

Unit Test codecov Maintainability License: MIT

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.

NOTE: This repository is a monorepo of a universal cryptographic library for JavaScript called js-crypto-utils (jscu), which is designed to work in most modern browsers and Node.js. A detailed explanation would be given in each package repository. The root package is given here (in develop branch).

Terminated to support MS IE11 and released v1.0 (Sep. 30, 2020).

Introduction and overview of this monorepo

This project called jscu is being developed to provide unified cryptographic APIs for browsers and Node.js. There currently exist various sophisticated cryptographic suites for JavaScript that are implemented as native functions, e.g., WebCrypto API and crypto in Node.js. However, they have different interfaces and are NOT supported on all platforms. For instance, FireFox cannot be fed PKCS8-formatted private key in WebCrypto API but Chrome does. On the other hand, such suites have not been designed to keep compatibility with existing non-Web cryptographic suites like OpenSSL. This can be seen from the fact that WebCrypto API does not support PEM-formatted keys. Hence we (actually I!) need to write ugly codes to enable apps to work in various environments. From this observation, we aim that this library provides support functions to fill such gaps among JS cryptographic suites and that between JavaScript and other popular crypto suites.

In particular, this library provides unified APIs of the following cryptographic functions that work in most modern browsers and Node.js.

  • ECDSA signing, verification, key generation (P-256/P-384/P-521/P-256K)
  • RSA-PSS/RSASSA-PKCS1-v1_5 signing, verification, key generation.
  • Encryption using ECDH and HKDF.
  • Encryption using RSA-OAEP.
  • Public/private key format conversion between JWK and PEM/DER (SPKI for public/PKCS8 for private)
  • Generation of JWK Thumbprint
  • Generation of X.509 public key certificate from JWK and extraction of JWK public key from X.509 public key certificate.

Additionally, this library provides random, hash, AES, HMAC, HKDF, and PBKDF functions. This implies the jscu is composed of several subpackages and can be seen as a cryptographic suite like openpgpjs. The root package, js-crypto-utils, of the suite and its subpackages are listed as follows.

  • crypto-utils: Root cryptographic package providing unified APIs.
  • x509-utils: Subpackage handling X509 certificates.
  • key-utils: Subpackage handling various key formats like PEM, DER, and JWK.
  • ec: Subpackage providing naive encryption and signing of elliptic curve cryptography.
  • rsa: Subpackage providing naive encryption and signing of RSA cryptography.
  • aes: Subpackage for AES encryption.
  • random: Subpackage for the cryptographic random generator.
  • hash: Subpackage providing hash functions including SHA-2 and SHA-3.
  • hkdf: Subpackage providing hash-based key derivation function.
  • pbkdf: Subpackage providing password-based key derivation function 1 and 2.
  • hmac: Subpackage providing hash-based message authentication code.

The structure of the package is described in the README.md of the root package, and hence we should start from there. But we can use various cryptographic functions not only via the root package, js-crypto-utils, but also by directly importing subpackages of intended functions. We should refer to README.md of each subpackage for its detailed usage.

For developers and contributors

Using npm package is the simplest way to fully leverage jscu functions. Considering you fork, develop, and update jscu packages themselves, i.e., as developers and contributors, usage of this monorepo and procedures for NPM deployment are summarized as follows.

  • This monorepo is managed via Yarn Workspace and Lerna. After cloning this Git repo, just do yarn install at the root of the cloned folder. Then the setup is all done.
  • Versioning pattern of each package is completely independent, but the version of this Git repository specified in the root package.json is tied with the root package, i.e., packages/js-crypto-utils. The name of root package is also given in the root package.json.
  • Deployment of packages to NPM must be done through CircleCI, and the deployment operation is only triggered by tags associated with Git repo version. Any commits to any branch and any tags of individual package versions won't kick the deployment mechanism. The versioning and tagging would be done through the following combination of GitFlow and Lerna procedures.
    1. First execute yarn flow:version and bump a version of each package that has been modified on develop branch. Here we note that for each updated package, the updated tag would be committed (not pushed), and hence we should almost finalize the release operation at least for each package. This simultaneously update the repo version specified in the root package.json without committing.
    2. Add final changes for release at the level of GitHub repo. Then, commit changes and then execute yarn release:start to start the release process on a release branch. Here we note the release version will be the updated Git repo version.
    3. To finalize the release operation, execute yarn release:finish to merge the release branch to master, and then merge master to develop. It will also tag the master branch with the updated Git repo version, i.e., the root package (packages/js-crypto-utils) version.
    4. Execute yarn release:push and push all branches and the generated tag of Git repo version to GitHub.

Contributing

jscu is free, open-source software licensed under MIT License.

You can open issues for bugs you've found or features you think are missing. You can also submit pull requests to this repository.

Contributors are more than welcome!

Documentation

The jscu documentation is a dynamically generated site from this monorepo via esdoc. You can submit pull requests to 'docs' of this monorepo for document updates.

jscu's People

Contributors

acdcjunior avatar junkurihara avatar quvox avatar renovate-bot avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

jscu's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/ci-test.yml
  • actions/checkout v4
  • actions/setup-node v4
  • actions/cache v4
  • codecov/codecov-action v4
  • actions/checkout v4
  • actions/setup-node v4
  • actions/checkout v4
  • actions/setup-node v4
npm
package.json
  • @types/elliptic 6.4.18
  • @types/jest 29.5.12
  • @types/node 20.14.2
  • @typescript-eslint/eslint-plugin 7.12.0
  • @typescript-eslint/parser 7.12.0
  • can-npm-publish 1.3.6
  • cross-env 7.0.3
  • esdoc 1.1.0
  • esdoc-standard-plugin 1.0.0
  • eslint 9.4.0
  • jasmine-core 5.1.2
  • jest 29.7.0
  • karma 6.4.3
  • karma-chrome-launcher 3.2.0
  • karma-cli 2.0.0
  • karma-jasmine 5.1.0
  • karma-typescript 5.5.4
  • lerna 8.1.3
  • ts-jest 29.1.4
  • ts-loader 9.5.1
  • typescript 5.2.2
  • webpack 5.91.0
  • webpack-cli 5.1.4
packages/js-crypto-aes/package.json
  • js-encoding-utils 0.7.3
packages/js-crypto-ec/package.json
  • asn1.js ~5.4.1
  • buffer ~6.0.0
  • elliptic ~6.5.0
  • js-encoding-utils 0.7.3
  • @types/elliptic 6.4.18
packages/js-crypto-env/package.json
packages/js-crypto-hash/package.json
  • buffer ~6.0.0
  • hash.js ~1.1.7
  • md5 ~2.3.0
  • sha3 ~2.1.0
  • js-encoding-utils 0.7.3
packages/js-crypto-hkdf/package.json
  • js-encoding-utils 0.7.3
packages/js-crypto-hmac/package.json
  • js-encoding-utils 0.7.3
packages/js-crypto-key-utils/package.json
  • asn1.js ~5.4.1
  • buffer ~6.0.0
  • des.js ~1.1.0
  • elliptic ~6.5.0
  • js-encoding-utils 0.7.3
  • lodash.clonedeep ~4.5.0
packages/js-crypto-pbkdf/package.json
  • js-encoding-utils 0.7.3
packages/js-crypto-random/package.json
packages/js-crypto-rsa/package.json
  • bn.js ~5.2.0
  • buffer ~6.0.0
  • js-encoding-utils 0.7.3
packages/js-crypto-utils/package.json
  • js-encoding-utils 0.7.3
  • lodash.clonedeep ~4.5.0
packages/js-x509-utils/package.json
  • asn1.js ~5.4.1
  • asn1.js-rfc5280 ~3.0.0
  • bn.js ~5.2.0
  • buffer ~6.0.0
  • js-encoding-utils 0.7.3

  • Check this box to trigger a request for Renovate to run again on this repository

Uint8Array key to JWK Object

Can js-crypto-key-utils be used to set a Uint8Array with the structure of a jwk object

Something like this

Uint8Array(32)ย [217, 75, 191, 175, 56, 204, 195, 184, 100, 8, 111, 246, 165, 76, 251, 227, 86, 250, 37, 57, 35, 62, 191, 131, 221, 73, 44, 115, 107, 105, 153, 240]

to

KCVXrFs8oJBheco-JxbHkPL9bxyN5\WZ68hyfVgrBuJg

Verification of x509 certificate is failed

The cert I have created with code:

const name = {
    countryName: 'US',
    stateOrProvinceName: 'D',
    organizationName: 'D',
    organizationalUnitName: 'D',
    commonName: 'D'
}

jscu.x509.fromJwk(
    keyPair.publicKey._jwk, // Client public key (derived from private)
    privateCAKeyJwk, // CA private key (for signature)
    'pem',
    {
        signature: 'ecdsa-with-sha256', // signature algorithm
        days: 365, // expired in days
        issuer: name,
        subject: name
    }
).then( async (cert) => {
    console.log(cert)
}

has failed verication. You can see that something strange with Issuer and Subject fields (separators changed)

openssl verify -CAfile ./rootCA.pem ./Output/brwr-00000002/device.crt 
C = US + ST = D + O = D + OU = D + CN = D
error 18 at 0 depth lookup: self signed certificate
error ./Output/brwr-00000002/device.crt: verification failed

openssl x509 -in ./Output/brwr-00000002/device.crt -text
Certificate:
    Data:
        Version: 1 (0x0)
        Serial Number:
            27:5d:44:9a:fe:dc:0b:0e:a1:39:1b:b7:03:76:81:a9:93:a9:a8:01
        Signature Algorithm: ecdsa-with-SHA256
        Issuer: C = US + ST = D + O = D + OU = D + CN = D
        Validity
            Not Before: Jan 13 22:08:14 2020 GMT
            Not After : Jan 12 22:08:14 2021 GMT
        Subject: C = US + ST = D + O = D + OU = D + CN = D
        Subject Public Key Info:
            Public Key Algorithm: id-ecPublicKey
                Public-Key: (256 bit)
                pub:
                    04:5d:34:d7:5e:05:53:49:81:b6:4a:31:85:4f:d0:
                    f1:b1:85:1f:f9:c2:89:03:b2:de:a8:0f:d8:b6:eb:
                    b4:48:6a:fc:0f:a9:f1:96:5b:19:24:63:84:06:7f:
                    3b:d9:5f:db:03:52:13:19:18:a4:77:6a:11:64:46:
                    c8:0e:85:f5:6b
                ASN1 OID: prime256v1
                NIST CURVE: P-256
    Signature Algorithm: ecdsa-with-SHA256
         30:45:02:21:00:ad:30:47:2d:72:52:bb:2d:87:e3:08:2c:00:
         d8:cf:f5:f4:26:1d:4b:d7:dd:55:8f:86:4d:aa:3f:89:29:a3:
         fc:02:20:3d:50:da:ec:e7:73:87:b5:49:e0:34:ba:f6:cd:9e:
         e2:30:09:a8:83:93:64:26:e0:a6:ca:96:c1:29:ff:ca:2d
-----BEGIN CERTIFICATE-----
MIIBaTCCAQ0CFCddRJr+3AsOoTkbtwN2gamTqagBMAwGCCqGSM49BAMCBQAwNTEz
MAkGA1UEBgwCVVMwCAYDVQQIDAFEMAgGA1UECgwBRDAIBgNVBAsMAUQwCAYDVQQD
DAFEMB4XDTIwMDExMzIyMDgxNFoXDTIxMDExMjIyMDgxNFowNTEzMAkGA1UEBgwC
VVMwCAYDVQQIDAFEMAgGA1UECgwBRDAIBgNVBAsMAUQwCAYDVQQDDAFEMFkwEwYH
KoZIzj0CAQYIKoZIzj0DAQcDQgAEXTTXXgVTSYG2SjGFT9DxsYUf+cKJA7LeqA/Y
tuu0SGr8D6nxllsZJGOEBn872V/bA1ITGRikd2oRZEbIDoX1azAMBggqhkjOPQQD
AgUAA0gAMEUCIQCtMEctclK7LYfjCCwA2M/19CYdS9fdVY+GTao/iSmj/AIgPVDa
7Odzh7VJ4DS69s2e4jAJqIOTZCbgpsqWwSn/yi0=
-----END CERTIFICATE-----

But if I use openssl to create x509 with previously created (in jscu) private key - this certificate seems to be correct:

openssl verify -CAfile ./rootCA.pem ./Output/brwr-00000002/device.crt 
./Output/brwr-00000002/device.crt: OK

deno support?

hello, this project is interesting to me, because the thing holding me back from switching from node to deno, has been deno's current lack of complete crypto implementation, which my production apps require

are there plans for this project to support deno?

cheers! ๐Ÿป

allow usage of (window.)crypto.subtle in service worker

when i use this library in a service worker, it will try to use node's crypto library as defined in https://github.com/junkurihara/jscu/blob/develop/packages/js-crypto-env/src/index.ts
however the problem with this is, that in a service worker window is not defined and it needs crypto.subtle instead of window.crypto.subtle
i thought about a way to fix this and came up with either checking for only crypto (or crypto.subtle) instead of the window and window.crypto in js-crypto-env so it doesn't mistake the service worker for a nodejs environment, or you could simply allow the crypto interface to be also user-defined, since the decrypt/encrypt functions in webapi actually pass it as a variable

export const decrypt = async (
data: Uint8Array,
key: Uint8Array,
{name='AES-GCM', iv, additionalData=new Uint8Array([]), tagLength}: cipherOptions
): Promise<Uint8Array> => {
// assertion and sanitizing
assertAlgorithms({name, iv, tagLength});
if(params.ciphers[name].tagLength && !tagLength) tagLength = params.ciphers[name].tagLength;
const env = util.getCrypto();
if (env.name === 'webCrypto') {// for web API
if (typeof env.crypto.importKey !== 'function' || typeof env.crypto.decrypt !== 'function') throw new Error('UnsupportedWebCrypto');
return webapi.decrypt(data, key, {name, iv, additionalData, tagLength}, env.crypto);
}
else if (env.name === 'nodeCrypto') { // for node
return nodeapi.decrypt(data, key, {name, iv, additionalData, tagLength}, env.crypto);
} else throw new Error('UnsupportedEnvironment');
};

export const decrypt = async (
data: Uint8Array,
key: Uint8Array,
{name, iv, additionalData, tagLength}: cipherOptions,
webCrypto: any
): Promise<Uint8Array> => {
const decryptionConfig = setCipherParams({name, iv, additionalData, tagLength});
try {
const sessionKeyObj = await webCrypto.importKey('raw', key, decryptionConfig, false, ['encrypt', 'decrypt']);
const msg = await webCrypto.decrypt(decryptionConfig, sessionKeyObj, data);
return new Uint8Array(msg);
} catch (e: unknown) {
if (e instanceof Error) {
throw new Error(`WebCrypto_DecryptionFailure: ${e.message}`);
}
else {
throw new Error('WebCrypto_DecryptionFailure');
}
}
};

New monorepo management tool

Currently, jscu uses Lerna (+ Yarn workspace) to manage this monorepo structure. However, as you may know, Lerna is not being actively maintained and almost outdated. So I think we should consider to switch our monorepo management tool from Lerna to another one before we faces an issue due to the outdated tool.

So if you have any idea of alternatives to Lerna suitable for this monorepo, please please let us know!

How to generate the sha3-256 hash?

I want use it to generate sha3-256 hash, what should i do?below is realization of the package futoin-hkdf

const hkdf = new Hkdf.Hkdf('sha3-256');
const masterPrk =hkdf.extract('aaa', 'bbb');
const secretKey =hkdf.expand(masterPrk, 'ccc', 32);

cannot encrypt more than 190 bytes

const rsa = require('js-crypto-rsa')

const msg = Uint8Array.from([
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
])

rsa.generateKey(2048).then(key => {
const publicKey = key.publicKey
const privateKey = key.privateKey

rsa.encrypt(msg, publicKey, 'SHA-256', {name: 'RSA-PSS'})
.then(encrypted => {
console.log(encrypted)
return rsa.decrypt(encrypted, privateKey, 'SHA-256', {name: 'RSA-PSS'})
})
.then(decrypted => {
console.log(decrypted)
})
})

=>

(node:12827) UnhandledPromiseRejectionWarning: Error: MessageTooLong

React 17 - Webpack fallback error

Hello!
I have installed your library per npm. I import it with 'import rsa from "js-crypto-rsa"' (in my case i have only installed the rsa part). If i start my react app with npm start the follow error appear:
If you want to include a polyfill, you need to: - add a fallback 'resolve.fallback: { "crypto": require.resolve("crypto-browserify") }' - install 'crypto-browserify' If you don't want to include a polyfill, you can use an empty module like this: resolve.fallback: { "crypto": false }
Can you help?

Greatings, Flo

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: Cannot find preset's package (github>whitesource/merge-confidence:beta)

How to display contents of a certificate

Is it possible to output the contents of a certificate, similar like the output from openssl:

openssl x509 -in server.pem -noout -text
Certificate:
Data:
Version: 3 (0x2)
Serial Number: 4096 (0x1000)
Signature Algorithm: sha256WithRSAEncryption
Issuer: C = GB, ST = England, O = Alice Ltd, OU = Alice Ltd Certificate Authority, CN = Alice Ltd Intermediate CA
Validity
Not Before: Apr 30 22:32:26 2020 GMT
Not After : May 10 22:32:26 2021 GMT
Subject: C = US, ST = Califonia, L = Mountain View, O = Alice Ltd, OU = Alice Ltd Web Services, CN = localhost
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
RSA Public-Key: (2048 bit)
...

How to extract data from TBS Certificate?

I have the following code. I need to extract subject field from CA certificate to use it as issuer in newly created certificate. I understand it is stored in tbsCertificate with asn1 encoding.
Is it possible to get this data without using some other external module (i.e. asn1.js and so on)?

const CA_crt_pem= fs.readFileSync(CaPath + '/rootCA.pem').toString()
const CA_crt_jwk= jscu.x509.parse(CA_crt_pem, 'pem')
console.log(CA_crt_jwk)

Output:

{
  tbsCertificate: Uint8Array [
     48, 130,   1, 139, 160,   3,   2,   1,   2,   2,  20,  27,
     46, 168, 145, 223, 170,  96,  29, 156,  82, 142, 209, 121,
     82, 142,  81, 196, 237, 109, 144,  48,  10,   6,   8,  42,
    134,  72, 206,  61,   4,   3,   2,  48,  72,  49,  11,  48,
      9,   6,   3,  85,   4,   6,  19,   2,  82,  85,  49,  20,
     48,  18,   6,   3,  85,   4,   8,  12,  11,  75,  97, 108,
    105, 110, 105, 110, 103, 114,  97, 100,  49,  22,  48,  20,
      6,   3,  85,   4,  10,  12,  13,  66, 101, 101, 114, 119,
     97, 114, 101,  32,
    ... 299 more items
  ],
  signatureValue: Uint8Array [
     48,  70,   2,  33,   0, 236, 115, 244, 225,  39,  79, 168,
    212,  18, 172, 215, 214, 194, 102, 125, 187, 123, 242,  88,
     43, 174,  16,  39,  14, 177,  61, 177,  88, 104,  33, 156,
    118,   2,  33,   0, 192, 101,  44, 129, 246, 236, 235, 219,
     87, 142, 248, 242,  92,   8, 227,  79, 216,   6, 197, 247,
     89,  60, 125, 108, 247, 131,  66, 242,  62,  62,  59, 230
  ],
  signatureAlgorithm: { algorithm: 'ecdsa-with-sha256', parameters: { hash: 'SHA-256' } }
}

Terminating to support IE11

Hey guys,

Now I think to remove ugly branches that have been implemented in order to support legacy IE 11. I would like to hear your opinions about this change.

I know that most jscu users and developers use Chromium/Safari/Firefox based browsers and there's just few IE users. Further, in order to support IE11, I had added tons of extra ugly codes. So I would like to discontinue the support of IE11, and this yields smaller bundled-js size and simpler codes. When I suspend IE codes, I would also like to bump the jscu version to 1.0.0.

Cheers!

Unsupported environment error

Hi @junkurihara , while running the code locally it works fine.
But while using in aws with centos os getting below error,

core.mjs:6469 ERROR Error: Uncaught (in promise): Error: UnsupportedEnvironment
Error: UnsupportedEnvironment
    at eval (aes.js:159:23)
    at step (aes.js:55:23)
    at Object.eval [as next] (aes.js:36:53)
    at eval (aes.js:30:71)
    at new ZoneAwarePromise (zone.js:1340:1)
    at __awaiter (aes.js:26:12)
    at Object.decrypt (aes.js:142:12)
    at _callee2$ (rum.js:99:77)
    at tryCatch (runtime.js:63:40)
    at Generator.invoke [as _invoke] (runtime.js:293:22)
    at resolvePromise (zone.js:1255:1)
    at zone.js:1162:1
    at asyncGeneratorStep (asyncToGenerator.js:10:5)
    at _throw (asyncToGenerator.js:33:9)
    at ZoneDelegate.invoke (zone.js:400:1)
    at Object.onInvoke (core.mjs:25450:1)
    at ZoneDelegate.invoke (zone.js:399:1)
    at Zone.run (zone.js:160:1)
    at zone.js:1318:1

Thanks!

Need help for migrating Webpack 5.x

Hello guys,

I actually got stacked up to migrate jscu to brand-new Webpack 5.x. It has incredibly lots of breaking changes... Actually it works with Webpack 4.x flawlessly, however, it should be migrated to 5.x for future compatibility and support. Anyone can help it? Please!

Jun

Problem during installation

โžœ js-crypto-rsa yarn build
yarn run v1.22.5
$ rm -rf ./dist && yarn babel && yarn webpack:prod
$ cross-env NODE_ENV=production tsc --build ./tsconfig.json
src/oaep.ts:5:21 - error TS2307: Cannot find module 'js-crypto-hash' or its corresponding type declarations.

5 import jschash from 'js-crypto-hash';
~~~~~~~~~~~~~~~~

src/oaep.ts:6:20 - error TS2307: Cannot find module 'js-crypto-random' or its corresponding type declarations.

6 import random from 'js-crypto-random';
~~~~~~~~~~~~~~~~~~

src/oaep.ts:119:33 - error TS7006: Parameter 'elem' implicitly has an 'any' type.

119 const maskedSeed = seed.map( (elem, idx) => 0xFF & (elem ^ seedMask[idx]));
~~~~

src/oaep.ts:119:39 - error TS7006: Parameter 'idx' implicitly has an 'any' type.

119 const maskedSeed = seed.map( (elem, idx) => 0xFF & (elem ^ seedMask[idx]));
~~~

src/nodeapi.ts:6:19 - error TS2307: Cannot find module 'js-crypto-key-utils' or its corresponding type declarations.

6 import {Key} from 'js-crypto-key-utils';
~~~~~~~~~~~~~~~~~~~~~

src/rsa.ts:5:23 - error TS2307: Cannot find module 'js-crypto-env' or its corresponding type declarations.

5 import * as util from 'js-crypto-env';
~~~~~~~~~~~~~~~

Found 6 errors.

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Supporting react-native

Hi @junkurihara,

In relation to #548, can you elaborate? Trying to import js-crypto-key-utils results in a failure about missing crypto, which is obviously not present on react-native.

Please add 'emailAddress' attribute

Please add 'emailAddress' attribute and OID to
attributeTypeOIDMap (./node_modules/js-x509-utils/dist/x509.js:240)

var attributeTypeOIDMap = {
    // X509name DirectoryName
    name: [2, 5, 4, 41],
    surname: [2, 5, 4, 4],
    givenName: [2, 5, 4, 42],
    initials: [2, 5, 4, 43],
    generationQualifier: [2, 5, 4, 44],
    commonName: [2, 5, 4, 3],
    localityName: [2, 5, 4, 7],
    stateOrProvinceName: [2, 5, 4, 8],
    organizationName: [2, 5, 4, 10],
    organizationalUnitName: [2, 5, 4, 11],
    title: [2, 5, 4, 12],
    dnQualifier: [2, 5, 4, 46],
    countryName: [2, 5, 4, 6],
    serialNumber: [2, 5, 4, 5],
    pseudonym: [2, 5, 4, 65],
    domainComponent: [0, 9, 2342, 19200300, 100, 1, 25],
    emailAddress: [1, 2, 840, 113549, 1, 9, 1],
};

clarify readme.md

https://github.com/junkurihara/jscu/blob/develop/packages/js-crypto-hkdf/README.md#derive-key-from-a-master-secret-without-salt-salt-is-randomly-generated-inside-the-function

The headings are misplaced. First set of code corresponds to one without salt and second corresponds to one with salt.

also isn't it hkdf.compute..... instead of hmac.compute...

hmac.compute(masterSecret, hash, length, info, salt).then( (derivedKey) => {
  // now you get a key derived from the masterSecret
});

Error converting DER to JWK

I am getting an error when converting an elliptic curve DER to JWK. I have been able to convert this same key in swift and java.

Error: FailedToDecodeKey

The code

const publicKeyObject = new jscu.Key('der', new Uint8Array(Buffer.from(key, 'base64')));
const key = await publicKeyObject.export('jwk');

The DER

MIICnDCCAkKgAwIBAgIIJr8oA/3jYAQwCgYIKoZIzj0EAwIwUDEkMCIGA1UEAwwbUG9sYW5kIERHQyBSb290Q1NDQSAxIEFDQyBTMRswGQYDVQQKDBJNaW5pc3RyeSBvZiBIZWFsdGgxCzAJBgNVBAYTAlBMMB4XDTIxMDUyNDExMTgxNloXDTIzMDUyNDExMTgxNlowcjEtMCsGA1UEAwwkUG9sYW5kIFZhY2NpbmF0aW9uIERHQyBTZXJ2aWNlIDMgQUNDMRcwFQYDVQQLDA5lSGVhbHRoIENlbnRlcjEbMBkGA1UECgwSTWluaXN0cnkgb2YgSGVhbHRoMQswCQYDVQQGEwJQTDBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABBb5V0Rbo5Qc1yAVxRyXaLt/QjmI4WG3qsXf81WoH6L2Uf4oj5iGnAuem1TSotax+FUgvn+GbcUg7BTrL+ePAQSjgeMwgeAwHwYDVR0jBBgwFoAUqc15HwkAJgfQl/0DpjHxRVJ9E28wFgYDVR0lBA8wDQYLKwYBBAGON49lAQIwTAYDVR0fBEUwQzBBoD+gPYY7aHR0cDovL2FjYy1wMS5lemRyb3dpZS5nb3YucGwvY2NwMS9jcmwvREdDUm9vdENTQ0ExQUNDUy5jcmwwHQYDVR0OBBYEFAenLsHAhybxn8MjzWYLq+xrD8iYMCsGA1UdEAQkMCKADzIwMjEwNTI0MTExODE2WoEPMjAyMjA1MjQxMTE4MTZaMAsGA1UdDwQEAwIHgDAKBggqhkjOPQQDAgNIADBFAiEAw17oXs3K8q+VorcGq014/zCZAnxqRIQ6fCkHGCENJWQCIB3hvpk+NdLphX7aokerbhsF6xuJ7hT6DnD67SFgLI/9

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.