Questions tagged [subtlecrypto]

63 questions
1
vote
2 answers

Window Crypto Subtle : How we can use encrypt / decrypt method if we generate public private key with "RSASSA-PKCS1-v1_5" algo?

I want to use the same public-private key to do some encryption/decryption at the code level and want to send encrypted data to the backend along with my public key which I am appending inside of my JWT AUTH Token. So pls help me to encrypt /…
nks
  • 623
  • 1
  • 8
  • 19
1
vote
1 answer

crypto.subtle decrypting compact jwe with ECDH-ES+A128KW - The operation failed for an operation-specific reason

I am trying to decrypt a compact JWE formatted response message with the crypto.subtle libraries. I am sending to the Server my public key in JWK format with curve algo ECDH-ES+A128KW, encryption A256GCM, curve name P-256. The server sends me back a…
keriati
  • 55
  • 1
  • 7
1
vote
1 answer

asp.net core blazor webassembly subtlecrypto - how to use a custom secret key

We are trying to integrate Subtlecrypto into our blazor webassembly app. It seems this is the only cryptography package that blazor wasm supports. According to the official example, there is not a way to change/custom the secret key. If the secret…
Cal
  • 747
  • 1
  • 13
  • 30
1
vote
1 answer

Sending RSA encoded message from JavaScript React to Python. Ciphertext length must be equal to key size. issue

I receive the error "Ciphertext length must be equal to key size." when trying to send an encoded message from javascript to python. I have encoded the bytesarray to base64 in javascript and decoded the base64 back to a bytes array in Python. Yet,…
ChrisD
  • 109
  • 10
1
vote
1 answer

Encrypt with 'window.crypto.subtle', decrypt in c#

I want to encrypt with window.crypto.subtle and decrypt in C#. The crypt / decrypt in js are working. In C#, The computed authentification tag don't match the input. I don't know if I can put any 12 bytes as salt nor if I need to derive the…
Vincent
  • 510
  • 1
  • 5
  • 23
1
vote
0 answers

Decrypting SubtleCrypto AES-GCM encoded string with Go

I'm trying to decrypt a string that was encrypted with SubtleCrypto AES-GCM in the browser (https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/encrypt). Using the following code in Javascript: async function aesGcmEncrypt(plaintext,…
elw
  • 13
  • 3
1
vote
1 answer

Javascript Web Crypto - Unable to import ECDH P-256 Public Key

I'm trying to exchange public keys between Browser and Server, and generate secret to be used for encryption of data. I'm trying to utilize ECDH (Elliptic Curve Diffie-Hellman). On the Server side I'm generating ECDH with prime256v1 algorithm. On…
1
vote
1 answer

Is phpseclib AES-GCM encryption compatible with javascript WebCrypto?

I'm trying to encrypt/decrypt symmetrically from php/phpseclib to js/WebCrypto(SubtleCrypto). The algorithm is AES-GCM with PBKDF2 derivation and also with plain key. I had no success. The error received from the window.crypto.subtle.decrypt()…
stk
  • 55
  • 6
1
vote
1 answer

How to verify an ES256 (ECDSA using P-256 and SHA-256) signature with window.crypto.subtle?

I'm having trouble figuring out the right parameters to verify a SHA-256 signature that was created with an ECDSA P-256 public key in web crypto. Below script outputs: Node verify result: true Web verify result: false What are the parameters to…
Otto
  • 1,787
  • 1
  • 17
  • 25
1
vote
1 answer

Subtle Crypto Importing PCKS RSA Key leads to ERR_OSSL_ASN1_WRONG_TAG

I'm trying out the subtle crypto methods in Node.js 18. I want to import a private RSA Key. I copied the example straight from the MDN docs (https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#pkcs_8_import) and rewrote it to be…
ffritz
  • 2,180
  • 1
  • 28
  • 64
1
vote
1 answer

Decrypt AES-256-CBC using openssl_decrypt in PHP from Subtle Crypto Javascript Payload

I'm trying to encrypt something in JS using webcrypto/window.crypto to AES-256-CBC and trying to decrypt it using PHP's openssl_decrypt function. My problem is that the decyrption function simply returns false and thus does not seem to work. const…
ffritz
  • 2,180
  • 1
  • 28
  • 64
1
vote
1 answer

How to know the text encoding scheme so that I can decode the bytes to a string

I'm using Chrome Browser's crypto.SubCrypto API. I generate a PSA-PSS key in it and want to export the key: let key = await window.crypto.subtle.generateKey( { name: "RSA-PSS", modulusLength: 2048, publicExponent: new Uint8Array([0x01,…
Shiqi
  • 837
  • 1
  • 10
  • 18
1
vote
1 answer

SubtleCrypto: "InvalidAccessError: The key is not of the expected type" when trying to export CryptoKeyPair.publicKey

I'm trying to create a web application to generate RSA public/private key pairs and I'm testing my code. (async function() { const subtle = crypto.subtle; const keyConfig = { name: "RSA-OAEP", modulusLength: 2048, …
rfl890
  • 82
  • 2
  • 5
1
vote
0 answers

Encrypt large data

Following code works fine when I encrypt 190 bytes or less. But if I try 191 or more, an exception is thrown. What is the right way of encrypting larger pieces of data? async function go(size) { var { publicKey, privateKey } = await…
Qwertiy
  • 19,681
  • 15
  • 61
  • 128
1
vote
0 answers

How do I encrypt for multiple recipients using RSA in window.crypto.subtle?

I need to use window.crypto.subtle.encrypt() to encrypt for multiple recipient public keys. This is my code right now: const encryptedMessage = await window.crypto.subtle.encrypt( rsaOptions, participantKeys[0], …