Questions tagged [subtlecrypto]

63 questions
5
votes
1 answer

Crypto Subtle Decrypt Parameter Not Type "CryptoKey"

I'm trying to decrypt a string using SubtleCrypto that was pre-generated. Instead of getting decrypted text I'm getting the error: Failed to execute 'decrypt' on 'SubtleCrypto': parameter 2 is not of type…
GFL
  • 1,278
  • 2
  • 15
  • 24
3
votes
1 answer

Unable to decrypt RSA-OAEP message encrypted with PyCryptodome using SubtleCrypto Web Crypto API

On the server side I am using PyCryptodome to encrypt a message with RSA-OAEP (with SHA-256). I'm trying to decrypt the message using SubtleCrypto Web Crypto API on the client side, but it give me a DOMException error without no further details. On…
2
votes
1 answer

Why would web crypto SHA-256 encrypt message while SHA-512 fail sometimes?

I encountered this issue when trying to encrypt some message using RSA-OAEP. To my surprise (as a beginner in crypto) that in some condition SHA-256 works while SHA-512 doesn't. I couldn't find any helpful info from…
Toyiff
  • 23
  • 2
2
votes
0 answers

Why can some PKCS#8 private keys be imported and some can not?

I have been trying to import my PKCS#8 private key from Apple (used for signing JWTs for their Web services/APIs), for use with the browser's Subtle Crypto API (https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#pkcs_8_import).…
2
votes
2 answers

Obtaining the auth tag of a AES-GCM cipher in Web Crypto API

The Node.js crypto module provides a cipher.getAuthTag() implementation that returns a Buffer which contains the authentication tag after the data has been successfully encrypted. The SubtleCrypto.encrypt() Web Crypto API method supports the AES-GCM…
2
votes
1 answer

Crypto.subtle in Dart?

Is there any package or utilities related to crypto.subtle present in Dart? I found this but I believe that's read-only, not accessible and for browsers only. I am looking for something similar for this piece of code in dart static async…
2
votes
1 answer

How to generate private key from modulus and exponent?

Having this code: const { subtle } = require("crypto"); const getPem = require("rsa-pem-from-mod-exp"); const Token = require("jsonwebtoken"); async function createKeys() { const keyPair = await subtle.generateKey({ name:…
milanHrabos
  • 2,010
  • 3
  • 11
  • 45
2
votes
1 answer

Using RSA to encrypt a message in JS and decrypt in Python

I want to encrypt a message using RSA with a provided PEM public key in Javascript, using SubtleCrypto window.crypto.subtle and then decode it with Python (PyCryptodome) in the back-end. However, I get a ValueError: Incorrect decryption.. I'm not…
musava_ribica
  • 476
  • 1
  • 5
  • 18
2
votes
2 answers

JS SubtleCrypto RSA Encrypt and Decrypt

So I am trying to implement some methods to encrypt then decrypt some data. I don't have any experience with this, and I've tried to follow along with some posts online on how to go about this. When i pass the encrypted 'hello' into the decrypt…
Red
  • 65
  • 8
2
votes
1 answer

How do you destroy keys with Subtle's cryptography API?

In the WebCrypto/Subtle crypto API, you can generate keys and whatnot. However there appears to be a distinct lack of .destroyKey() or something of the sort. Are keys cleaned up upon their reference count reaching zero or something of the sort? Is…
Qix - MONICA WAS MISTREATED
  • 14,451
  • 16
  • 82
  • 145
2
votes
0 answers

Web Crypto API: how to import RSA private key

I have 2 different web software. At one of them I want to encrypt user's data in browser using public key from the server and store encrypted user's data at database. After that I want to have possibility to decrypt those data on server side or…
Senid
  • 563
  • 5
  • 13
1
vote
1 answer

How does JWK EC public key co-ordinate encoding work?

I'm attempting to re-create a P-521 JWK from just the private key. According to the spec (section 4.2.1): "The x member contains the x coordinate for the elliptic curve point. It is represented as the base64url encoding of the coordinate's…
knaccc
  • 232
  • 2
  • 11
1
vote
1 answer

JavaScript SubtleCrypto - Is there a way to convert the ECDSA keys into a bit more "portable" format and preferably shorter?

I am using the browser built in SubtleCrypto library in javascript to generate public and private keys as such: let keyPair = await crypto.subtle.generateKey( { name: "ECDSA", namedCurve: "P-521", }, true, ['sign',…
1
vote
1 answer

PHP openssl_encrypt and Javascript crypto.subtle.encrypt have different output (AES-256-GCM)

I'm trying to encrypt in PHP with openssl and decrypt in Javascript with crypto.subtle. The problem is the encrypted string in PHP is 16 bytes shorter than the same encrypted string in Javascript and I can't figure out what the problem is. (For the…
Michel
  • 4,076
  • 4
  • 34
  • 52
1
vote
1 answer

How to decrypt NodeJS crypto on the client side with a known encryption key?

I am trying to have AES encryption on the server side, and decryption on the client side. I have followed an example where CryptoJS is used on the client side for encryption and SubtleCrypto on the client side as well for decryption, but in my case…
xfscrypt
  • 16
  • 5
  • 28
  • 59
1
2 3 4 5