Replace YACA_ERROR_OPENSSL_FAILURE with YACA_ERROR_INTERNAL 29/67829/3
authorDariusz Michaluk <d.michaluk@samsung.com>
Thu, 28 Apr 2016 12:01:30 +0000 (14:01 +0200)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Wed, 4 May 2016 12:28:43 +0000 (05:28 -0700)
Change-Id: Ibb6ffca3dc778479556ba7412b46b3f9c542c424

api/yaca/error.h
src/crypto.c
src/digest.c
src/encrypt.c
src/key.c
src/seal.c
src/sign.c

index d82c3fc..eaca621 100644 (file)
@@ -40,7 +40,7 @@ extern "C" {
 enum __yaca_error_code {
        YACA_ERROR_INVALID_ARGUMENT   = -1,
        YACA_ERROR_NOT_IMPLEMENTED    = -2,
-       YACA_ERROR_OPENSSL_FAILURE    = -3,
+       YACA_ERROR_INTERNAL           = -3,
        YACA_ERROR_NOT_SUPPORTED      = -4,
        YACA_ERROR_TOO_BIG_ARGUMENT   = -5,
        YACA_ERROR_OUT_OF_MEMORY      = -6,
index bfcb358..734dba5 100644 (file)
@@ -90,7 +90,7 @@ API int yaca_rand_bytes(char *data, size_t data_len)
        if (ret == -1)
                ret = YACA_ERROR_NOT_SUPPORTED;
        else
-               ret = YACA_ERROR_OPENSSL_FAILURE;
+               ret = YACA_ERROR_INTERNAL;
 
        ERROR_DUMP(ret);
        return ret;
index e23f7b5..b9f4ce4 100644 (file)
@@ -108,7 +108,7 @@ int digest_get_algorithm(yaca_digest_algo_e algo, const EVP_MD **md)
        }
 
        if (ret == 0 && *md == NULL) {
-               ret = YACA_ERROR_OPENSSL_FAILURE;
+               ret = YACA_ERROR_INTERNAL;
                ERROR_DUMP(ret);
        }
 
@@ -138,14 +138,14 @@ API int yaca_digest_init(yaca_ctx_h *ctx, yaca_digest_algo_e algo)
 
        nc->mdctx = EVP_MD_CTX_create();
        if (nc->mdctx == NULL) {
-               ret = YACA_ERROR_OPENSSL_FAILURE;
+               ret = YACA_ERROR_INTERNAL;
                ERROR_DUMP(ret);
                goto free;
        }
 
        ret = EVP_DigestInit(nc->mdctx, md);
        if (ret != 1) {
-               ret = YACA_ERROR_OPENSSL_FAILURE;
+               ret = YACA_ERROR_INTERNAL;
                ERROR_DUMP(ret);
                goto ctx;
        }
@@ -171,7 +171,7 @@ API int yaca_digest_update(yaca_ctx_h ctx, const char *data, size_t data_len)
 
        ret = EVP_DigestUpdate(c->mdctx, data, data_len);
        if (ret != 1) {
-               ret = YACA_ERROR_OPENSSL_FAILURE;
+               ret = YACA_ERROR_INTERNAL;
                ERROR_DUMP(ret);
                return ret;
        }
@@ -193,7 +193,7 @@ API int yaca_digest_final(yaca_ctx_h ctx, char *digest, size_t *digest_len)
 
        ret = EVP_DigestFinal_ex(c->mdctx, (unsigned char*)digest, &len);
        if (ret != 1) {
-               ret = YACA_ERROR_OPENSSL_FAILURE;
+               ret = YACA_ERROR_INTERNAL;
                ERROR_DUMP(ret);
                return ret;
        }
index 3fee076..40aa2ee 100644 (file)
@@ -78,8 +78,8 @@ static int get_encrypt_output_length(const yaca_ctx_h ctx, size_t input_len)
 
        block_size = EVP_CIPHER_CTX_block_size(nc->cipher_ctx);
        if (block_size == 0) {
-               ERROR_DUMP(YACA_ERROR_OPENSSL_FAILURE);
-               return YACA_ERROR_OPENSSL_FAILURE;
+               ERROR_DUMP(YACA_ERROR_INTERNAL);
+               return YACA_ERROR_INTERNAL;
        }
 
        if (input_len > 0)
@@ -158,7 +158,7 @@ int encrypt_get_algorithm(yaca_enc_algo_e algo,
 
        lcipher = EVP_get_cipherbyname(cipher_name);
        if (lcipher == NULL) {
-               ret = YACA_ERROR_OPENSSL_FAILURE;
+               ret = YACA_ERROR_INTERNAL;
                ERROR_DUMP(ret);
                return ret;
        }
@@ -210,7 +210,7 @@ static int encrypt_init(yaca_ctx_h *ctx,
 
        ret = EVP_CIPHER_iv_length(cipher);
        if (ret < 0) {
-               ret = YACA_ERROR_OPENSSL_FAILURE;
+               ret = YACA_ERROR_INTERNAL;
                ERROR_DUMP(ret);
                goto err_free;
        }
@@ -235,7 +235,7 @@ static int encrypt_init(yaca_ctx_h *ctx,
 
        nc->cipher_ctx = EVP_CIPHER_CTX_new();
        if (nc->cipher_ctx == NULL) {
-               ret =  YACA_ERROR_OPENSSL_FAILURE;
+               ret =  YACA_ERROR_INTERNAL;
                ERROR_DUMP(ret);
                goto err_free;
        }
@@ -257,7 +257,7 @@ static int encrypt_init(yaca_ctx_h *ctx,
        }
 
        if (ret != 1) {
-               ret = YACA_ERROR_OPENSSL_FAILURE;
+               ret = YACA_ERROR_INTERNAL;
                ERROR_DUMP(ret);
                goto err_ctx;
        }
@@ -303,7 +303,7 @@ static int encrypt_update(yaca_ctx_h ctx,
        }
 
        if (ret != 1) {
-               ret = YACA_ERROR_OPENSSL_FAILURE;
+               ret = YACA_ERROR_INTERNAL;
                ERROR_DUMP(ret);
                return ret;
        }
@@ -339,7 +339,7 @@ static int encrypt_final(yaca_ctx_h ctx,
        }
 
        if (ret != 1) {
-               ret = YACA_ERROR_OPENSSL_FAILURE;
+               ret = YACA_ERROR_INTERNAL;
                ERROR_DUMP(ret);
                return ret;
        }
index 4365e3c..477fb18 100644 (file)
--- a/src/key.c
+++ b/src/key.c
@@ -111,7 +111,7 @@ API int yaca_key_get_bits(const yaca_key_h key)
                // TODO: handle ECC keys when they're implemented
                ret = EVP_PKEY_bits(evp_key->evp);
                if (ret <= 0) {
-                       ret = YACA_ERROR_OPENSSL_FAILURE;
+                       ret = YACA_ERROR_INTERNAL;
                        ERROR_DUMP(ret);
                        return ret;
                }
@@ -297,7 +297,7 @@ API int yaca_key_gen_pair(yaca_key_h *prv_key,
 
        ret = BN_set_word(bne, RSA_F4);
        if (ret != 1) {
-               ret = YACA_ERROR_OPENSSL_FAILURE;
+               ret = YACA_ERROR_INTERNAL;
                ERROR_DUMP(ret);
                goto free_bne;
        }
@@ -311,7 +311,7 @@ API int yaca_key_gen_pair(yaca_key_h *prv_key,
 
        ret = RSA_generate_key_ex(rsa, key_bits, bne, NULL);
        if (ret != 1) {
-               ret = YACA_ERROR_OPENSSL_FAILURE;
+               ret = YACA_ERROR_INTERNAL;
                ERROR_DUMP(ret);
                goto free_rsa;
        }
@@ -332,14 +332,14 @@ API int yaca_key_gen_pair(yaca_key_h *prv_key,
 
        ret = EVP_PKEY_assign_RSA(nk_prv->evp, RSAPrivateKey_dup(rsa));
        if (ret != 1) {
-               ret = YACA_ERROR_OPENSSL_FAILURE;
+               ret = YACA_ERROR_INTERNAL;
                ERROR_DUMP(ret);
                goto free_evp_pub;
        }
 
        ret = EVP_PKEY_assign_RSA(nk_pub->evp, RSAPublicKey_dup(rsa));
        if (ret != 1) {
-               ret = YACA_ERROR_OPENSSL_FAILURE;
+               ret = YACA_ERROR_INTERNAL;
                ERROR_DUMP(ret);
                goto free_evp_pub;
        }
@@ -439,7 +439,7 @@ API int yaca_key_derive_pbkdf2(const char *password,
                                salt_len, iter, md, key_byte_len,
                                (unsigned char*)nk->d);
        if (ret != 1) {
-               ret = YACA_ERROR_OPENSSL_FAILURE;
+               ret = YACA_ERROR_INTERNAL;
                ERROR_DUMP(ret);
                goto err;
        }
index c39b8be..a5fb2ae 100644 (file)
@@ -79,8 +79,8 @@ static int get_seal_output_length(const yaca_ctx_h ctx, size_t input_len)
 
        block_size = EVP_CIPHER_CTX_block_size(nc->cipher_ctx);
        if (block_size <= 0) {
-               ERROR_DUMP(YACA_ERROR_OPENSSL_FAILURE);
-               return YACA_ERROR_OPENSSL_FAILURE;
+               ERROR_DUMP(YACA_ERROR_INTERNAL);
+               return YACA_ERROR_INTERNAL;
        }
 
        if (input_len > 0)
@@ -124,14 +124,14 @@ static int seal_init(yaca_ctx_h *ctx,
 
        nc->cipher_ctx = EVP_CIPHER_CTX_new();
        if (nc->cipher_ctx == NULL) {
-               ret =  YACA_ERROR_OPENSSL_FAILURE;
+               ret =  YACA_ERROR_INTERNAL;
                ERROR_DUMP(ret);
                goto err_free;
        }
 
        ret = EVP_PKEY_size(lpub->evp);
        if (ret <= 0) {
-               ret = YACA_ERROR_OPENSSL_FAILURE;
+               ret = YACA_ERROR_INTERNAL;
                ERROR_DUMP(ret);
                goto err_ctx;
        }
@@ -149,7 +149,7 @@ static int seal_init(yaca_ctx_h *ctx,
 
        ret = EVP_CIPHER_iv_length(cipher);
        if (ret < 0) {
-               ret = YACA_ERROR_OPENSSL_FAILURE;
+               ret = YACA_ERROR_INTERNAL;
                ERROR_DUMP(ret);
                goto err_key;
        }
@@ -173,7 +173,7 @@ static int seal_init(yaca_ctx_h *ctx,
                           1);
 
        if (ret != 1) {
-               ret = YACA_ERROR_OPENSSL_FAILURE;
+               ret = YACA_ERROR_INTERNAL;
                ERROR_DUMP(ret);
                goto err_iv;
        }
@@ -244,7 +244,7 @@ static int open_init(yaca_ctx_h *ctx,
 
        ret = EVP_CIPHER_iv_length(cipher);
        if (ret < 0) {
-               ret = YACA_ERROR_OPENSSL_FAILURE;
+               ret = YACA_ERROR_INTERNAL;
                ERROR_DUMP(ret);
                goto err_free;
        }
@@ -270,7 +270,7 @@ static int open_init(yaca_ctx_h *ctx,
 
        nc->cipher_ctx = EVP_CIPHER_CTX_new();
        if (nc->cipher_ctx == NULL) {
-               ret =  YACA_ERROR_OPENSSL_FAILURE;
+               ret =  YACA_ERROR_INTERNAL;
                ERROR_DUMP(ret);
                goto err_free;
        }
@@ -281,7 +281,7 @@ static int open_init(yaca_ctx_h *ctx,
                           (unsigned char*)liv->d,
                           lprv->evp);
        if (ret != 1) {
-               ret = YACA_ERROR_OPENSSL_FAILURE;
+               ret = YACA_ERROR_INTERNAL;
                ERROR_DUMP(ret);
                goto err_ctx;
        }
@@ -322,7 +322,7 @@ static int seal_update(yaca_ctx_h ctx,
        }
 
        if (ret != 1) {
-               ret = YACA_ERROR_OPENSSL_FAILURE;
+               ret = YACA_ERROR_INTERNAL;
                ERROR_DUMP(ret);
                return ret;
        }
@@ -353,7 +353,7 @@ static int seal_final(yaca_ctx_h ctx,
        }
 
        if (ret != 1) {
-               ret = YACA_ERROR_OPENSSL_FAILURE;
+               ret = YACA_ERROR_INTERNAL;
                ERROR_DUMP(ret);
                return ret;
        }
index a77b403..0c789bc 100644 (file)
@@ -104,8 +104,8 @@ static int create_sign_pkey(const yaca_key_h key, EVP_PKEY **pkey)
                                             (unsigned char *)simple_key->d,
                                             simple_key->bits / 8);
                if (*pkey == NULL) {
-                       ERROR_DUMP(YACA_ERROR_OPENSSL_FAILURE);
-                       return YACA_ERROR_OPENSSL_FAILURE;
+                       ERROR_DUMP(YACA_ERROR_INTERNAL);
+                       return YACA_ERROR_INTERNAL;
                }
 
                return 0;
@@ -174,7 +174,7 @@ API int yaca_sign_init(yaca_ctx_h *ctx,
 
        nc->mdctx = EVP_MD_CTX_create();
        if (nc->mdctx == NULL) {
-               ret = YACA_ERROR_OPENSSL_FAILURE;
+               ret = YACA_ERROR_INTERNAL;
                ERROR_DUMP(ret);
                goto free_ctx;
        }
@@ -186,7 +186,7 @@ API int yaca_sign_init(yaca_ctx_h *ctx,
                goto ctx;
        }
        if (ret != 1) {
-               ret = YACA_ERROR_OPENSSL_FAILURE;
+               ret = YACA_ERROR_INTERNAL;
                ERROR_DUMP(ret);
                goto ctx;
        }
@@ -225,7 +225,7 @@ API int yaca_sign_update(yaca_ctx_h ctx,
        if (ret == -2)
                ret = YACA_ERROR_NOT_SUPPORTED;
        else
-               ret = YACA_ERROR_OPENSSL_FAILURE;
+               ret = YACA_ERROR_INTERNAL;
 
        ERROR_DUMP(ret);
        return ret;
@@ -249,7 +249,7 @@ API int yaca_sign_final(yaca_ctx_h ctx,
        if (ret == -2)
                ret = YACA_ERROR_NOT_SUPPORTED;
        else
-               ret = YACA_ERROR_OPENSSL_FAILURE;
+               ret = YACA_ERROR_INTERNAL;
 
        ERROR_DUMP(ret);
        return ret;
@@ -305,7 +305,7 @@ API int yaca_verify_init(yaca_ctx_h *ctx,
 
        nc->mdctx = EVP_MD_CTX_create();
        if (nc->mdctx == NULL) {
-               ret = YACA_ERROR_OPENSSL_FAILURE;
+               ret = YACA_ERROR_INTERNAL;
                ERROR_DUMP(ret);
                goto free_ctx;
        }
@@ -329,7 +329,7 @@ API int yaca_verify_init(yaca_ctx_h *ctx,
                goto ctx;
        }
        if (ret != 1) {
-               ret = YACA_ERROR_OPENSSL_FAILURE;
+               ret = YACA_ERROR_INTERNAL;
                ERROR_DUMP(ret);
                goto ctx;
        }
@@ -378,7 +378,7 @@ API int yaca_verify_update(yaca_ctx_h ctx,
        if (ret == -2)
                ret = YACA_ERROR_NOT_SUPPORTED;
        else
-               ret = YACA_ERROR_OPENSSL_FAILURE;
+               ret = YACA_ERROR_INTERNAL;
 
        ERROR_DUMP(ret);
        return ret;
@@ -411,7 +411,7 @@ API int yaca_verify_final(yaca_ctx_h ctx,
                if (ret == -2)
                        ret = YACA_ERROR_NOT_SUPPORTED;
                else
-                       ret = YACA_ERROR_OPENSSL_FAILURE;
+                       ret = YACA_ERROR_INTERNAL;
 
                ERROR_DUMP(ret);
                return ret;
@@ -427,7 +427,7 @@ API int yaca_verify_final(yaca_ctx_h ctx,
                else if (ret == -2)
                        ret = YACA_ERROR_NOT_SUPPORTED;
                else
-                       ret = YACA_ERROR_OPENSSL_FAILURE;
+                       ret = YACA_ERROR_INTERNAL;
 
                ERROR_DUMP(ret);
                return ret;