Open panva opened 1 year ago
I think line 96 is returning an error:
From openssl/cipher.h
:
// EVP_EncryptFinal_ex writes at most a block of ciphertext to |out| and sets
// |*out_len| to the number of bytes written. If padding is enabled (the
// default) then standard padding is applied to create the final block. If
// padding is disabled (with |EVP_CIPHER_CTX_set_padding|) then any partial
// block remaining will cause an error. The function returns one on success and
// zero otherwise.
OPENSSL_EXPORT int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, uint8_t *out,
int *out_len);
So I'm guessing that "any partial block remaining" is the problem.
@robobun
test repro bot
const name = "AES-GCM";
const key = await crypto.subtle.generateKey({ name, length: 128 }, false, [
"encrypt",
"decrypt",
]);
const data = new Uint8Array();
const iv = crypto.getRandomValues(new Uint8Array(16));
const algorithm = { name, iv, tagLength: 128 };
const ciphertext = await crypto.subtle.encrypt(algorithm, key, data);
console.log(await crypto.subtle.decrypt(algorithm, key, ciphertext));
@robobun
test #2
const name = "AES-GCM";
const key = await crypto.subtle.generateKey({ name, length: 128 }, false, [
"encrypt",
"decrypt",
]);
const data = new Uint8Array();
const iv = crypto.getRandomValues(new Uint8Array(16));
const algorithm = { name, iv, tagLength: 128 };
const ciphertext = await crypto.subtle.encrypt(algorithm, key, data);
console.log(await crypto.subtle.decrypt(algorithm, key, ciphertext));
@Jarred-Sumner here you go!
OperationError: The operation failed for an operation-specific reason
Ran using the latest build of Bun, an all-in-one JavaScript runtime.
I meet the same issue in my project.
Confirmed this still reproduces in Bun v1.1.15
What version of Bun is running?
No response
What platform is your computer?
No response
What steps can reproduce the bug?
How often does it reproduce? Is there a required condition?
No response
What is the expected behavior?
No response
What do you see instead?
OperationError: The operation failed for an operation-specific reason
Additional information
No response