diff options
| author | Jakub Zelenka <bukka@php.net> | 2015-12-13 19:05:19 +0000 |
|---|---|---|
| committer | Jakub Zelenka <bukka@php.net> | 2015-12-13 19:05:19 +0000 |
| commit | fc3575aaf14983b9c7337e027ad73aec753997ef (patch) | |
| tree | 2d4f95a407758f6e3bee677ada1bd7f0b65b64e1 | |
| parent | c54174255d8b5149821c94bd29eb90267197d763 (diff) | |
| download | php-git-fc3575aaf14983b9c7337e027ad73aec753997ef.tar.gz | |
Retrieve tag in AEAD cipher mode encryption
| -rw-r--r-- | ext/openssl/openssl.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index 63bc66854a..56c7e05aa3 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -5431,6 +5431,19 @@ PHP_FUNCTION(openssl_encrypt) zend_string_release(outbuf); RETVAL_STR(base64_str); } + if (mode.is_aead) { + zend_string *tag_str = zend_string_alloc(tag_len, 0); + + if (EVP_CIPHER_CTX_ctrl(cipher_ctx, mode.aead_get_tag_flag, tag_len, ZSTR_VAL(tag_str)) == 1) { + zval_dtor(tag); + ZSTR_VAL(tag_str)[tag_len] = '\0'; + ZSTR_LEN(tag_str) = tag_len; + ZVAL_NEW_STR(tag, tag_str); + } else { + zend_string_release(tag_str); + php_error_docref(NULL, E_WARNING, "Retrieving verification tag failed"); + } + } } else { zend_string_release(outbuf); RETVAL_FALSE; |
