webcrypto | A WebCrypto Polyfill for NodeJS | Cryptography library

 by   PeculiarVentures TypeScript Version: v1.4.3 License: MIT

kandi X-RAY | webcrypto Summary

kandi X-RAY | webcrypto Summary

webcrypto is a TypeScript library typically used in Security, Cryptography applications. webcrypto has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. You can download it from GitHub.

We wanted to be able to write Javascript that used crypto on both the client and the server but we did not want to rely on Javascript implementations of crypto. The only native cryptography available in browser is Web Crypto, this resulted in us creating a @peculiar/webcrypto.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              webcrypto has a low active ecosystem.
              It has 147 star(s) with 16 fork(s). There are 10 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 13 open issues and 25 have been closed. On average issues are closed in 30 days. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of webcrypto is v1.4.3

            kandi-Quality Quality

              webcrypto has 0 bugs and 0 code smells.

            kandi-Security Security

              webcrypto has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              webcrypto code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              webcrypto is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              webcrypto releases are not available. You will need to build from source code and install.
              Installation instructions are not available. Examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of webcrypto
            Get all kandi verified functions for this library.

            webcrypto Key Features

            No Key Features are available at this moment for webcrypto.

            webcrypto Examples and Code Snippets

            No Code Snippets are available at this moment for webcrypto.

            Community Discussions

            QUESTION

            Decrypt encrypted RSA Private Key on the Browser side
            Asked 2022-Feb-06 at 13:38

            I have an encrypted private RSA key:

            ...

            ANSWER

            Answered 2022-Feb-06 at 13:38

            So for anyone who will in the future maybe face the same issue like I did:

            PKI.js is providing an examples folder in their repo: OpenSSLPrivateKeyEncryption

            In there you will find a method called decrypt. With the code I were able to decrypt my AES-CBC Private key.

            Source https://stackoverflow.com/questions/70927417

            QUESTION

            How to verify RSA signatures in ReactJS?
            Asked 2022-Jan-07 at 06:42

            I have a ReactJS application that should be able to verify signatures with a given RSA public key like the Web Crypto API it does with subtle and import_key etc. Does any one knows if there exist such a library or how to use the Web Crypto API in react directly? I searched a lot, but I wasn't able to find a working example for me. Maybe I missed something.

            I tried before the @trust/webcrypto library and installed it with npm.

            This is the code that I tried before:

            ...

            ANSWER

            Answered 2022-Jan-07 at 06:42

            @Topaco mentioned to use a public key I has to use the spki format. That solves the issue with the import of the public key. This code solves my problem.

            Source https://stackoverflow.com/questions/70610498

            QUESTION

            Decrypting OAEP RSA In JavaScript (Like PHP's openssl_private_decrypt)
            Asked 2021-Dec-23 at 04:35

            I'm currently encrypting data in PHP as follows:

            ...

            ANSWER

            Answered 2021-Dec-23 at 04:35

            PKCS#1 Versus PKCS#8

            Note that while private keys generated without pass phrases in PHP are PKCS#1, the private key generated from PHP with a pass phrase is actually PKCS#8 (see this link for how to determine which standard applies to a private key).

            Third Party Library Required

            In order to work with PEM-format keys, a custom JavaScript library (or other custom code) is required. There are various libraries at this link which you can look at. Many are not maintained anymore.

            This example uses the Forge JavaScript library, but you could also use a different library.

            Installing/Importing Forge

            While there are various ways to build the Forge environment, the easiest is to add the following HTML code prior to where you need to do encryption/decryption:

            Source https://stackoverflow.com/questions/70408813

            QUESTION

            nodejs webcrypto imporKey rsa error "error:0D07207B:asn1 encoding routines:ASN1_get_object:header too long"
            Asked 2021-Oct-08 at 07:22

            Ok, so I was building an application and using RSA to decrypt data encrypted from the browser's webcrypto and I was getting a strange error before the web side even started.. I tried searching the error but I didn't find anything helpful.. I'm using nodejs(v16.10.0)

            ...

            ANSWER

            Answered 2021-Oct-06 at 14:21

            This is due to your atob() and btoa() methods defined for NodeJS.

            Buffer.from() and Buffer#toString() apply UTF-8 by default if no other encoding is specified. However, UTF-8 generally corrupts arbitrary binary data. Instead of UTF-8 use binary as encoding:

            Source https://stackoverflow.com/questions/69467004

            QUESTION

            node-webcrypto-ossl, GLIBC_2.32 not found, Manjaro OS
            Asked 2021-Oct-04 at 23:09

            When I try to run an application that uses node-webcrypto-ossl node module I get the error:

            ...

            ANSWER

            Answered 2021-Oct-04 at 23:09

            Obviously node-webcrypto-ossl requires an older version of glibc.

            No. GLIBC is backwards compatible: applications built against older version continue to run fine on newer GLIBC versions.

            Your problem is the opposite: you have an application linked against GLIBC_2.32 trying to run against an older version of GLIBC.

            The version of glibc installed on my machine is 2.33-5

            The application is not using that version; it's using some other GLIBC.

            The problem was that I was trying to run my app in docker ...

            That's one way running against older than expected GLIBC could happen.

            Source https://stackoverflow.com/questions/69434597

            QUESTION

            How can I create a signed JWT using npm Jose and then verify this token?
            Asked 2021-Sep-11 at 13:58

            I am struggling to understand how to use the npm jose module (https://www.npmjs.com/package/jose) to create and verify signed JWT tokens in my Node application. My scenario is this: I want to sign an authenticated request to access a resource. I can successfully create a JWT claim for this request grant token that respects the properties of “its” and “aud”, “exp”, etc. but I want to sign it (to wit, using the SignJWT object and the ‘sign’ method) so that when it gets passed back to my server as a request I can validate it and grant or reject access. The “sign” method doesn’t seem to like anything I pass it for the ‘key’ parameter (I am not passing any options — maybe I should be, but what?). I am attempting to use RSA key pairs. I want to sign with the private key and verify with the public key. For my immediate need, I suppose I could use a symmetric key instead, but I am thinking of some other future scenarios where I will want this classic PKCS relationship of certificate keys. And at any rate, I don’t think this choice has anything to do with the current roadblock to my progress. I first tried to use jose/util/generate_key_pair to create my public/private pair. But when I went to use the key, the error informed me this was not supported by my implementation. So I switched to trying to create a ‘pem’ cert outside of my app and applying that (as text), but that also failed. The ‘sign’ method reports that the key must be a ‘KeyLike’, ‘CryptoKey’, or ‘Uint8Array’ type. Well, the UInt8Array (node buffer) is not enough type information: it doesn’t speak to what is in that buffer, and “KeyLike” is such a vague definition that it’s ignorable. After beseeching the oracles of the search engines, I found I could create a key pair in CryptoKey format using the following from Node APIs:

            ...

            ANSWER

            Answered 2021-Sep-11 at 05:13

            I have also struggled with signing and verifying JWT using jose but was finally able to succeed with HS256 symmetric key encryption. I produced it by following steps (I am using jose-node-cjs-runtime for Node.js only use case. Feel free to replace with desired package. Also please note that I have found that these codes are working for Node.js version 16.7.0, 16.9.0 so please ensure that any of them is installed. If you want to deploy these changes to production environment, then also you have to ensure the deploy environment has the same Node.js version. One way this can be achieved is by mentioning Node.js version in engines key in package.json):

            Add Required imports

            Source https://stackoverflow.com/questions/69126222

            QUESTION

            How to use getRandomValues() in nodejs?
            Asked 2021-Sep-07 at 15:25

            I am using a Javascript to generate wireguard keypairs but it's browser faced so i removed the window objects and have one more issue that prevents creation of private key.

            the issue is this line of code that i cannot run in nodejs:

            ...

            ANSWER

            Answered 2021-Sep-07 at 15:25

            You need to understand getRandomValues is on window.crypto that means it works on browser. To make it work on Node.js you need to install get-random-values

            Source https://stackoverflow.com/questions/69088396

            QUESTION

            Cloudflare worker - verify presigned url
            Asked 2021-Aug-28 at 13:55

            I am playing around with presigned urls. Server generates a presigned url using node, works great with object storage. Now I am trying to verify the presigned url with a Cloudflare worker, but I don't get it.

            Any solutions on the worker side for this server code?

            ...

            ANSWER

            Answered 2021-Aug-28 at 13:55

            The JavaScript runtime of Cloudflare Workers is not based on Node. So there won't be a pre-bundled module called crypto that you can require or import.

            If you start from these template projects with Webpack configured, required/imported modules are typically those which you have installed manually (e.g. via npm install/yarn add foobar and later being listed as dependencies in package.json). In other words, it is somewhat alike to writing front-end JS.

            The Workers provides a built-in WebCrypto-compliant cryptography library implementation as documented here: https://developers.cloudflare.com/workers/runtime-apis/web-crypto. According to the doc, crypto is just a global object that can be accessed directly with importing.

            Even though I do not have a try, I suppose the link to the example you given is a completed Worker script with no more modifications needed to test. That is, just copy&paste into the online editor of Workers and test.

            Source https://stackoverflow.com/questions/68855856

            QUESTION

            Failing to verify ECDSA signature using WebCrypto
            Asked 2021-Aug-16 at 10:32

            I am trying to verify an ECDSA signature via WebCrypto and failing. The signature is created using Java (Bouncy Castle). The curve used is secp256r1 and SHA256 hash is used at signature creation. Then I tried creating signature using RSA (SHA256) in Java and tried verified in WebCrypto and succeeded. This seems like an ECDSA specific issue. In java I exported the public key in SPKI and then imported successfully in WebCrypto. What could be causing WebCrypto to fail verifying ECDSA based keys.

            ...

            ANSWER

            Answered 2021-Aug-13 at 10:57

            EC signatures can be specified in two formats: r|s (IEEE P1363) or ASN.1/DER. Both formats are explained here.

            WebCrypto uses the r|s format, while MEUCI... has the ASN.1 format. Your signature in r|s format is Base64 encoded:

            Source https://stackoverflow.com/questions/68770259

            QUESTION

            This is a Python code to get a md5 digest of a signature, Need help to implement this thing in JavaScript
            Asked 2021-Jun-26 at 15:37

            Python Code that works fine and I checked this Python code for message "a" it gives me the result "52F17E7031982DE1744A57F6EE9BD3A3"

            ...

            ANSWER

            Answered 2021-Jun-26 at 15:37

            WebCrypto implicitly generates the hash of the data during signing using the digest SHA-256 specified in the key, so explicit hashing with SHA-256 is not necessary.
            Also, the generated signature is directly hashed with MD5, i.e. without prior Base64 encoding.

            With these changes, the JavaScript code is (using a test key):

            Source https://stackoverflow.com/questions/68142165

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install webcrypto

            You can download it from GitHub.

            Support

            1 Mechanism supports extended list of named curves P-256, P-384, P-521, K-256, brainpoolP160r1, brainpoolP160t1, brainpoolP192r1, brainpoolP192t1, brainpoolP224r1, brainpoolP224t1, brainpoolP256r1, brainpoolP256t1, brainpoolP320r1, brainpoolP320t1, brainpoolP384r1, brainpoolP384t1, brainpoolP512r1, and brainpoolP512t1. 2 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. 3 Mechanism supports extended list of named curves Ed25519, and Ed448. 4 Mechanism supports extended list of named curves X25519, and X448.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/PeculiarVentures/webcrypto.git

          • CLI

            gh repo clone PeculiarVentures/webcrypto

          • sshUrl

            git@github.com:PeculiarVentures/webcrypto.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular Cryptography Libraries

            dogecoin

            by dogecoin

            tink

            by google

            crypto-js

            by brix

            Ciphey

            by Ciphey

            libsodium

            by jedisct1

            Try Top Libraries by PeculiarVentures

            PKI.js

            by PeculiarVenturesTypeScript

            ASN1.js

            by PeculiarVenturesTypeScript

            GammaCV

            by PeculiarVenturesJavaScript

            xadesjs

            by PeculiarVenturesTypeScript

            graphene

            by PeculiarVenturesTypeScript