-bool cipher_decrypt(cipher_t *cipher, const void *indata, size_t inlen, void *outdata, size_t *outlen, bool oneshot) {
- if(oneshot) {
- int len, pad;
-
- if(EVP_DecryptInit_ex(cipher->ctx, NULL, NULL, NULL, NULL)
- && EVP_DecryptUpdate(cipher->ctx, (unsigned char *)outdata, &len, indata, (int)inlen)
- && EVP_DecryptFinal_ex(cipher->ctx, (unsigned char *)outdata + len, &pad)) {
- if(outlen) {
- *outlen = len + pad;
- }
-
- return true;
- }
- } else {
- int len;
-
- if(EVP_DecryptUpdate(cipher->ctx, outdata, &len, indata, (int)inlen)) {
- if(outlen) {
- *outlen = len;
- }
-
- return true;
- }
- }
+bool cipher_encrypt(cipher_t *cipher, const void *indata, size_t inlen, void *outdata, size_t *outlen, bool oneshot) {
+ return cipher_encrypt_decrypt(cipher, indata, inlen, outdata, outlen, oneshot,
+ EVP_EncryptInit_ex, EVP_EncryptUpdate, EVP_EncryptFinal_ex);
+}