Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions ext/openssl/openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -4865,6 +4865,7 @@ PHP_FUNCTION(openssl_seal)

if (!EVP_EncryptInit(&ctx,cipher,NULL,NULL)) {
RETVAL_FALSE;
EVP_CIPHER_CTX_cleanup(&ctx);
goto clean_exit;
}

Expand All @@ -4875,10 +4876,12 @@ PHP_FUNCTION(openssl_seal)
#endif
/* allocate one byte extra to make room for \0 */
buf = emalloc(data_len + EVP_CIPHER_CTX_block_size(&ctx));
EVP_CIPHER_CTX_cleanup(&ctx);

if (!EVP_SealInit(&ctx, cipher, eks, eksl, NULL, pkeys, nkeys) || !EVP_SealUpdate(&ctx, buf, &len1, (unsigned char *)data, data_len)) {
RETVAL_FALSE;
efree(buf);
EVP_CIPHER_CTX_cleanup(&ctx);
goto clean_exit;
}

Expand Down Expand Up @@ -4911,6 +4914,7 @@ PHP_FUNCTION(openssl_seal)
efree(buf);
}
RETVAL_LONG(len1 + len2);
EVP_CIPHER_CTX_cleanup(&ctx);

clean_exit:
for (i=0; i<nkeys; i++) {
Expand Down Expand Up @@ -4969,25 +4973,21 @@ PHP_FUNCTION(openssl_open)
if (EVP_OpenInit(&ctx, cipher, (unsigned char *)ekey, ekey_len, NULL, pkey) && EVP_OpenUpdate(&ctx, buf, &len1, (unsigned char *)data, data_len)) {
if (!EVP_OpenFinal(&ctx, buf + len1, &len2) || (len1 + len2 == 0)) {
efree(buf);
if (keyresource == -1) {
EVP_PKEY_free(pkey);
}
RETURN_FALSE;
RETVAL_FALSE;
} else {
zval_dtor(opendata);
buf[len1 + len2] = '\0';
ZVAL_STRINGL(opendata, erealloc(buf, len1 + len2 + 1), len1 + len2, 0);
RETVAL_TRUE;
}
} else {
efree(buf);
if (keyresource == -1) {
EVP_PKEY_free(pkey);
}
RETURN_FALSE;
RETVAL_FALSE;
}
if (keyresource == -1) {
EVP_PKEY_free(pkey);
}
zval_dtor(opendata);
buf[len1 + len2] = '\0';
ZVAL_STRINGL(opendata, erealloc(buf, len1 + len2 + 1), len1 + len2, 0);
RETURN_TRUE;
EVP_CIPHER_CTX_cleanup(&ctx);
}
/* }}} */

Expand Down