-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, inlen)
- && EVP_DecryptFinal(cipher->ctx, (unsigned char *)outdata + len, &pad)) {
- if(outlen) *outlen = len + pad;
- return true;
- }
- } else {
- int len;
- if(EVP_EncryptUpdate(cipher->ctx, outdata, &len, indata, 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);
+}