CONFIGURE_FILE(packaging/lib${PROJECT_NAME}-test.manifest.in lib${PROJECT_NAME}-test.manifest @ONLY)
################# common configurations for srcs and test ######################
-SET(DEPENDENTS "openssl dlog key-manager libtzplatform-config")
+SET(DEPENDENTS "openssl1.1 dlog key-manager libtzplatform-config")
PKG_CHECK_MODULES(WEB_APP_ENC_DEPS
REQUIRED
${DEPENDENTS}
crypto_element_s *dek_kek = NULL;
-static bool __initialized = false;
-
-void _initialize()
-{
- if (!__initialized) {
- ERR_load_crypto_strings();
- OpenSSL_add_all_algorithms();
- __initialized = true;
- }
-}
-
int _generate_dek_kek()
{
int ret = WAE_ERROR_NONE;
raw_buffer_s *encrypted_data = NULL;
int ret = WAE_ERROR_NONE;
- _initialize();
-
WAE_SLOGI("Encryption Started. size=%zu", data->size);
/* check input paramter */
raw_buffer_s *data = NULL;
int ret = WAE_ERROR_NONE;
- _initialize();
-
WAE_SLOGI("Decryption Started. size=%zu", encrypted_data->size);
/* check input paramter */
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;
}
*pdecrypted = decrypted;
error:
- EVP_CIPHER_CTX_cleanup(&ctx);
+ EVP_CIPHER_CTX_free(ctx);
if (ret != WAE_ERROR_NONE)
buffer_destroy(decrypted);