add? update

This commit is contained in:
Zheyuan Wu
2026-02-11 17:31:34 -06:00
parent a03f90a4ba
commit 6cc8ce61b3
5 changed files with 22 additions and 6 deletions

View File

@@ -45,13 +45,19 @@ int stream_decrypt(unsigned char *ciphertext, int ciphertext_len, unsigned char
ctx = EVP_CIPHER_CTX_new();
/* Initialise the decryption operation. */
EVP_DecryptInit_ex(ctx, EVP_aes_256_ctr(), NULL, key, iv);
if (EVP_DecryptInit_ex(ctx, EVP_aes_256_ctr(), NULL, key, iv) != 1){
ERR_print_errors_fp(stderr);
}
/* Provide the message to be decrypted, and obtain the plaintext output. EVP_DecryptUpdate can be called multiple times if necessary */
EVP_DecryptUpdate(ctx, plaintext, &len, ciphertext, ciphertext_len);
if (EVP_DecryptUpdate(ctx, plaintext, &len, ciphertext, ciphertext_len) != 1) {
ERR_print_errors_fp(stderr);
}
/* Finalize the decryption. Further plaintext bytes may be written at this stage. */
EVP_DecryptFinal_ex(ctx, plaintext + len, &plaintext_len);
if (EVP_DecryptFinal_ex(ctx, plaintext + len, &plaintext_len) != 1) {
ERR_print_errors_fp(stderr);
}
/* Clean up */
EVP_CIPHER_CTX_free(ctx);