320 questions
2
votes
1
answer
107
views
The operation failed for an operation-specific reason: Cipher job failed
I have the following code that should encrypt a string with a password in nodeJS. You can find an example here: https://jsfiddle.net/ujr4gev3/1/
I have also tried the approach here: https://gist....
0
votes
2
answers
194
views
Generating Key & Nonce Pairs from Web Crypto API vs from Word List. Is entropy the same?
I want to find out if the 2 methods shown below achieve the same level of entropy.
For this first secure method, a 32 byte / 256 bit key and a 12 byte / 96 bit nonce are generated using the JavaScript ...
1
vote
1
answer
197
views
WebCrypto JS problem decrypting an encrypted file download chunked stream
I have a sample client-side HTML webpage that allows a user to upload a file to a NodeJS file storage server. When a user uploads a file from the webpage, the client's browser encrypts the file with a ...
0
votes
1
answer
111
views
How to specify desired HKDF output length with `crypto.subtle.deriveKey`
The web crypto API defines two different KDF utilities, namely deriveBits and deriveKey. While the former allows you to specify the desired output length (RFC 5869 calls this parameter L), the latter ...
0
votes
1
answer
334
views
How to decrypt MSAL auth artifact, encrypted with AES-GCM and a HKDF-derived the key?
I use @azure/msal-browser in my project.
Account information are stored in the local storage and they were exploitable until recently.
But it changed in their v4 release:
if you are using the ...
0
votes
0
answers
82
views
How to generate a p12 with javascript generated key pair and server side internal CA
I'm working on a client-certificate based authentication of users for a website.
The server configuration part is OK
(Apache server, keywords: SSLCACertificateFile / SSLVerifyDepth / SSLVerifyClient ...
0
votes
1
answer
55
views
WebCrypto:DataError when attempting to unwrapKey
I want to use one public key to wrap another public key. Almost everything works right up until the unwrapKey step. It throws an opaque DataError with no further information about what is wrong. ...
0
votes
1
answer
132
views
Use wrapKey to encrypt one public key with another public key: OperationError
My application calls for encrypting one public key with another public key. I can generate both keys, but calling wrapKey throws an OperationError with no details regarding why it is failing.
const {...
1
vote
1
answer
343
views
"Unable to export a raw Ed25519 private key" when using exporting a key using "raw" format
I am using node.js 22.
The secure curves in webcrypto spec (scroll down to 'Export Key') says raw is a supported export format for Ed25519:
import { webcrypto } from "node:crypto";
const ...
0
votes
1
answer
336
views
How can I make a webcrypto CryptoKeyPair from a Uint8Array?
I'm using the webcrypto API and have a valid Ed25519 private key stored as a UInt8Array.
I would like to use the private key in KeyPair. Here's my attempt so far:
import { webcrypto } from "node:...
0
votes
1
answer
230
views
usage of pbkdf2 with browser's webcrypto api
how to use the pbkdf2 derivation function in the (firefox) browser's webcrypto api to obtain the same result as the sjcl.misc.pbkdf2 function (stanford javascript crypto library) or the “derive pbkdf2 ...
0
votes
1
answer
99
views
OperationError Issue with window.crypto.subtle.decrypt
I am developing a session encryption scheme, but when I try to decrypt the session key using the private key, I receive an OperationError.
// This method generates the keys
static async ...
0
votes
1
answer
97
views
Web Crypto API ECDSA and OpenSSL
I created ECDSA key pair using openssl
openssl ecparam -name prime256v1 -genkey -noout -out ecdsa_private_key.pem
openssl ec -in ecdsa_private_key.pem -pubout -out ecdsa_public_key.pem
and using ...
0
votes
1
answer
144
views
@peculiar/webcrypto - can not access to crypto.subtle
I am using @peculiar/webcrypto 1.5.0.(node v18.18.2)
To test my logic, I need crypto.subtle.
Below is simple test code in my jest.setup.js.
const { Crypto } = require('@peculiar/webcrypto');
global....
0
votes
1
answer
469
views
Decrypting JavaScript Web Crypto API (RSA-OAEP) in Java
I am trying to encrypt a string using RSA-OAEP-SHA-512 in the WebCrypto API (client side) and then I want to decrypt the string again using Java (server side). However, the server side decryption ...
0
votes
1
answer
119
views
NotSupportedError - WebCrypto generateKey in k6
I'm using the k6 JavaScript API to run tests, k6 is very limited when it comes to using libraries, so to do EC cryptography I'm using k6/experimental/webcrypto:
import { crypto } from "k6/...
0
votes
1
answer
1k
views
Error: OperationError (in promise) when trying to decrypt content
I have been playing with WebCrypto, building a little Astro site with an encoded block that is decoded using it (I know this wouldn't be particularly secure, it's not going to be used for anything ...
0
votes
1
answer
1k
views
Implementing encryption/decryption in Typescript using Web Crypto API
I'm having a security requirement not to send data as plain-text to the server and the credentials shouldn't be visible in the network tab of the browser. I could have used hashing but the catch is we ...
0
votes
1
answer
175
views
Why does crypto throw 'ERR_CRYPTO_UNKNOWN_CIPHER' when using AES-KW as encryption algorithm in Electron main process?
I've been developing an app with TIDAL's auth web sdk. In it, they call SubtleCrypto's wrapKey function using parameters nearly identical to those in the example in the MDN docs.
const wrapCryptoKey = ...
0
votes
1
answer
212
views
Unable to verify EDSCSA SHA-256 signature
I am trying to verify a ECDSA, SHA-256 key. But i am unable to do so with the web crypto API.
My code looks like this-
export async function verifySignature(
requestData: string,
...
0
votes
1
answer
178
views
Signing a CloudKit web services request using the Web Crypto API
I am trying to authenticate a CloudKit web services request using the Web Crypto API.
I already have authentication using the node crypto API, and have verified this works:
import Crypto from 'crypto'
...
0
votes
1
answer
314
views
Verify with PHP ECDSA signature generated with Web Crypto API
I have the following task.
I have to generate ECDSA key pair. Sign data with the private key and verify the signature in PHP. For some unknown for me reason i am unable to verify the data successfuly.
...
0
votes
1
answer
356
views
Using python to decrypt AES-GCM encrypted in JavaScript
I have some code in JavaScript running inside the browser using WebCrypto. It uses AES-GCM to encrypt some data.
I generate a key and then export it to hex, then generate an initialization vector, and ...
0
votes
0
answers
207
views
Encrypt AES-GCM in PHP, decrypt in Javascript
I have a message encrypted in PHP like this:
function encode(string $input): string
{
return base64EncodeSafe(encodeOpenSsl($input));
}
function encodeOpenSsl(string $string): string
{
if (!...
0
votes
1
answer
387
views
How to implement k6 webcrypto encryption same way as PHP openssl_encrypt function
I have some code to encrypt text in PHP, it looks like this:
$key = '1234aaaff80b56233525ac2355ac3456'; // something like this
$utf16Content = \mb_convert_encoding('Some text', 'UTF-16LE');
$cipher = '...
0
votes
1
answer
992
views
using web crypto to decrypt AES-CBC: Uncaught (in promise) Error
Here's my code:
var key = 'aaaaaaaaaaaaaaaa'
var iv = 'bbbbbbbbbbbbbbbb';
var ciphertext = '10f42fd95857ed2775cfbc4b471bc213';
// from https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/...
0
votes
0
answers
240
views
Web Crypto : AES-GCM Decryption Failure in Ionic Application Background Mode?
I’m currently facing a challenge with the Web Crypto API. While attempting to perform decryption, I’ve noticed that it functions as expected when the ionic application is in the foreground. However, ...
1
vote
1
answer
499
views
Web Crypto API decryption failing with RSA-OAEP
I have generated a private key as follows:
openssl genpkey -algorithm RSA -out private_key.pem -pkeyopt rsa_keygen_bits:2048
openssl rsa -pubout -in private_key.pem -out public_key.pem
openssl pkcs8 ...
2
votes
1
answer
365
views
How Verify Public Key With Web Crypto API
I can perform verification in Node Crypto without problem and it outputs true, but when i tried with Web Crypto it outputs false without any errors but both using same variables. I can't use Node ...
3
votes
1
answer
7k
views
crypto.subtle is undefined even though I'm using http://localhost:3000
I'm trying to use crypto.subtle.digest() as part of a checksum function for a file upload project I'm working on but for some reason I keep getting the following error:
upload-form.tsx:129 Uncaught ...
0
votes
0
answers
663
views
Firefox trigger a "DOMException: The operation failed for an operation-specific reason" when using 'window.crypto.subtle.decrypt'
Here is the minimum code needed to replicate the issue, the error I'm getting is generic and not descriptive at all DOMException: The operation failed for an operation-specific reason in short it ...
2
votes
2
answers
521
views
How to sign data in Javascript and verify the signature in PHP?
I have a simple string of text that needs to be signed inside a Javascript and verified on the server (PHP). To start my test I first created a key pair:
// Function to generate a new RSA key pair
...
0
votes
1
answer
96
views
Problem while sign > serialize > deserialize > verify using web crypto
As a part of my JS code, using web crypto, I wanted to sign a string, serialize it and later deserialize it and verify it.
For this I created these custom functions createHexTokenFromStrClaim and ...
0
votes
1
answer
120
views
crypto.subtle.importKey throws unspecified Error
I'm trying to sign a text using WEB Crypto API. I'm depending on a 3rd party to extract the certificate from a smart card, which returns a Base64 string representation of it. As far as I understand, ...
0
votes
1
answer
2k
views
how can I decrypt the content in frontend which was encrypted in backend
It might be a little problem but I'm neither getting any specific error nor getting any solution.
I am building a full stack project. In here I need a condition where I have to encrypt a content in ...
0
votes
1
answer
251
views
Issue in SubtleCrypto: decrypt() method in production build. Works fine on localhost
I'm using the Web Crypto API in an Angular (v15) application to decrypt a hex-encoded string encrypted with AES/CBC/PKCS7Padding.
The implementation works as expected when served in the development ...
1
vote
1
answer
308
views
Decrypting NTAG424 encrypted data fails sporadically with WebCrypto
This is a follow-up question to a previous one, trying to get a working decryption of NDEF URLs from an NXP NTAG424 tag according to this documentation from NXP (4.4.2.1).
I've put together an initial ...
1
vote
1
answer
243
views
How to Resolve DOMException When Decrypting Files with Web Crypto API in a Streaming Manner?
I m trying to encrypt file in browser uisng webcrypto api. I m using chunking mechanism too so that i can encrypt and decrypt large files without crashing browser.
My provided code is working if i m ...
0
votes
1
answer
194
views
Cross platform end to end encryption (Swift & Node)
I've generated 2 sets of private/public keys and exported to pem, now I'm trying to import them into both Swift & a JS script but they seem to be generating different shared keys so swift can't ...
0
votes
0
answers
165
views
WebCrypto API can't unwrap the same key multiple times
I'm developing an E2EE web chat app to learn more about encryption. I'm using WebCrypto API and hash-wasm for encryption, and Firebase to store data such as encrypted keypairs and messages.
When a ...
-1
votes
1
answer
709
views
Blazor Webassemby Rsa Decryption using Web Crypto API
I've been trying to run this system where I can encrypt in blazor webassembly (server side) and decrypt it in client side using JSInterop, but I can't figure out the error "OperationError" ...
1
vote
1
answer
196
views
AEC/CBC/PKCS7 java and Web Cryptography API encryption produces two different results
I need to achieve what is done here using java:
import javax.crypto.*;
import java.security.*;
import java.util.*;
....
// Generate a random salt
byte[] salt = Base64.getDecoder().decode(&...
1
vote
1
answer
117
views
Public exponent not the same as calculated based on JWK (d, p, q) from exportKey('jwk')
I'm trying to use SubtleCrypto (interface of the Web Crypto API) to generate an RSA private key.
But in the validation step, the manually calculated public exponent differs from JWK.e in 50% of cases. ...
1
vote
0
answers
272
views
DOMException Invalid key type from webcrypto importKey on RSA-PSS public key in spki DER
Problem
I getting a strange errors when export a RSA-PSS public key from node with SPKI DER and import them with importKey of webcrypto.subtle to simulate the in-broweser context inside tests.
Key ...
1
vote
1
answer
633
views
What is a reliable way to generate bitcoin private key in browser?
Is there a way to generate truly random bitcoin private key without relying on 3rd party libraries like ECPair nor tiny-secp256k1?
As a recommended approach to generate secure random key is to use ...
0
votes
1
answer
170
views
Assert type of global using TypeScript assertion function?
Is it possible to create a TypeScript assertion function that asserts the type of something other than the arguments passed to it – a global, for instance:
// Pseudo-code
function ...
1
vote
0
answers
470
views
Export private key in pkcs8 format and public key in spki format in .net framework c#
I am creating PublicKey and PrivateKey to sign and verify data in in .net core with below code.
ECDsa ecDsaVerify = ECDsa.Create(ECCurve.NamedCurves.nistP384);
byte[] publicKey = ecDsaVerify....
2
votes
0
answers
154
views
Where is SubtleCrypto's CryptoKey Stored?
I am currently utilizing the WebCrypto API, specifically SubtleCrypto. I store CryptoKey in IndexedDB and call it as needed. As far as I know, IndexedDB is a serialized database. If I can access ...
3
votes
1
answer
445
views
JavaScript WebCryptoApi: Why does this not satisfy operation specific requirements?
Setup:
I generate a key-encryption-key (kek, AES-GCM, 256)
I generate a RSA-OAEP keypair
I wrap the generated private key with the kek using AES-GCM-256 and a random iv, exported as pkcs8
I try to ...
1
vote
1
answer
1k
views
When using Crypto Subtle in Javascript to sign a message, do we need to sign the hash of the encoded message or the encoded message itself?
When using the browser built in Crypto Subtle in Javascript to sign a message, do we need to sign the hash of the encoded message or the encoded message itself?
The reason I ask is because as per the ...