diff options
author | Konrad Lipinski <k.lipinski2@partner.samsung.com> | 2019-05-29 15:47:48 +0200 |
---|---|---|
committer | Dariusz Michaluk <d.michaluk@samsung.com> | 2019-07-08 13:46:09 +0200 |
commit | 34adffffdb13b88c5117c27f6785c0184f9179a1 (patch) | |
tree | 4c5d2485d31cec0751cadb83631a5a436159e118 /srcs/decrypt_migrated_wgt.c | |
parent | fd2d39061c3fde9b2faba0a4146eb79114c29660 (diff) | |
download | libwebappenc-34adffffdb13b88c5117c27f6785c0184f9179a1.tar.gz libwebappenc-34adffffdb13b88c5117c27f6785c0184f9179a1.tar.bz2 libwebappenc-34adffffdb13b88c5117c27f6785c0184f9179a1.zip |
Migrate to openssl 1.1submit/tizen/20190708.161352submit/tizen/20190708.115723accepted/tizen/unified/20190709.113113
Change-Id: I43ac640debc91648e0d314e90f4c9b42ef0bf5a3
Diffstat (limited to 'srcs/decrypt_migrated_wgt.c')
-rw-r--r-- | srcs/decrypt_migrated_wgt.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/srcs/decrypt_migrated_wgt.c b/srcs/decrypt_migrated_wgt.c index 6dbc627..8d4bc29 100644 --- a/srcs/decrypt_migrated_wgt.c +++ b/srcs/decrypt_migrated_wgt.c @@ -113,34 +113,36 @@ static int _decrypt(const crypto_element_s *ce, const raw_buffer_s *data, int in_len = data->size; int out_len = 0; int final_len = 0; + int ret = WAE_ERROR_NONE; raw_buffer_s *decrypted = buffer_create( - (in_len / algo->block_size + 1) * algo->block_size); + (in_len / EVP_CIPHER_block_size(algo) + 1) * EVP_CIPHER_block_size(algo)); if (decrypted == NULL) return WAE_ERROR_MEMORY; - EVP_CIPHER_CTX ctx; - EVP_CIPHER_CTX_init(&ctx); - - int ret = WAE_ERROR_NONE; + EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new(); + if (!ctx) { + ret = WAE_ERROR_MEMORY; + goto error; + } - if (EVP_CipherInit(&ctx, algo, ce->dek->buf, ce->iv->buf, 0) != 1) { + if (EVP_CipherInit(ctx, algo, ce->dek->buf, ce->iv->buf, 0) != 1) { ret = WAE_ERROR_CRYPTO; goto error; } - if (EVP_CIPHER_CTX_set_padding(&ctx, 1) != 1) { + if (EVP_CIPHER_CTX_set_padding(ctx, 1) != 1) { ret = WAE_ERROR_CRYPTO; goto error; } - if (EVP_CipherUpdate(&ctx, decrypted->buf, &out_len, data->buf, in_len) != 1) { + if (EVP_CipherUpdate(ctx, decrypted->buf, &out_len, data->buf, in_len) != 1) { ret = WAE_ERROR_CRYPTO; goto error; } - if (EVP_CipherFinal(&ctx, decrypted->buf + out_len, &final_len) != 1) { + if (EVP_CipherFinal(ctx, decrypted->buf + out_len, &final_len) != 1) { ret = WAE_ERROR_CRYPTO; goto error; } @@ -150,7 +152,7 @@ static int _decrypt(const crypto_element_s *ce, const raw_buffer_s *data, *pdecrypted = decrypted; error: - EVP_CIPHER_CTX_cleanup(&ctx); + EVP_CIPHER_CTX_free(ctx); if (ret != WAE_ERROR_NONE) buffer_destroy(decrypted); |