Replace YACA_ERROR_TOO_BIG_ARGUMENT with YACA_ERROR_INVALID_ARGUMENT 25/71925/3
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Fri, 27 May 2016 13:47:45 +0000 (15:47 +0200)
committerDariusz Michaluk <d.michaluk@samsung.com>
Fri, 27 May 2016 14:42:44 +0000 (16:42 +0200)
Change-Id: Iadf4d6a6044e6bc68389897f369064ec61ca309f

src/encrypt.c
src/key.c
src/seal.c
src/simple.c

index 0edeb3e..385bec7 100644 (file)
@@ -89,7 +89,7 @@ static int get_encrypt_output_length(const yaca_ctx_h ctx, size_t input_len, siz
 
        if (input_len > 0) {
                if ((size_t)block_size > SIZE_MAX - input_len + 1)
-                       return YACA_ERROR_TOO_BIG_ARGUMENT;
+                       return YACA_ERROR_INVALID_ARGUMENT;
 
                *output_len = block_size + input_len - 1;
        } else {
index a0e771a..3de2ba4 100755 (executable)
--- a/src/key.c
+++ b/src/key.c
@@ -93,7 +93,7 @@ int base64_decode(const char *data, size_t data_len, BIO **output)
 
        /* This is because of BIO_new_mem_buf() having its length param typed int */
        if (data_len > INT_MAX)
-               return YACA_ERROR_TOO_BIG_ARGUMENT;
+               return YACA_ERROR_INVALID_ARGUMENT;
 
        /* First phase of correctness checking, calculate expected output length */
        ret = base64_decode_length(data, data_len, &b64_len);
@@ -204,7 +204,7 @@ int import_simple(yaca_key_h *key,
        }
 
        if (key_data_len > SIZE_MAX - sizeof(struct yaca_key_simple_s)) {
-               ret = YACA_ERROR_TOO_BIG_ARGUMENT;
+               ret = YACA_ERROR_INVALID_ARGUMENT;
                goto out;
        }
 
@@ -278,7 +278,7 @@ int import_evp(yaca_key_h *key,
 
        /* This is because of BIO_new_mem_buf() having its length param typed int */
        if (data_len > INT_MAX)
-               return YACA_ERROR_TOO_BIG_ARGUMENT;
+               return YACA_ERROR_INVALID_ARGUMENT;
 
        src = BIO_new_mem_buf(data, data_len);
        if (src == NULL) {
@@ -616,7 +616,7 @@ int gen_simple(struct yaca_key_simple_s **out, size_t key_bits)
        size_t key_byte_len = key_bits / 8;
 
        if (key_byte_len > SIZE_MAX - sizeof(struct yaca_key_simple_s))
-               return YACA_ERROR_TOO_BIG_ARGUMENT;
+               return YACA_ERROR_INVALID_ARGUMENT;
 
        nk = yaca_zalloc(sizeof(struct yaca_key_simple_s) + key_byte_len);
        if (nk == NULL)
@@ -646,7 +646,7 @@ int gen_simple_des(struct yaca_key_simple_s **out, size_t key_bits)
        size_t key_byte_len = key_bits / 8;
 
        if (key_byte_len > SIZE_MAX - sizeof(struct yaca_key_simple_s))
-               return YACA_ERROR_TOO_BIG_ARGUMENT;
+               return YACA_ERROR_INVALID_ARGUMENT;
 
        nk = yaca_zalloc(sizeof(struct yaca_key_simple_s) + key_byte_len);
        if (nk == NULL)
@@ -1175,7 +1175,7 @@ API int yaca_key_derive_pbkdf2(const char *password,
                return YACA_ERROR_INVALID_ARGUMENT;
 
        if (key_byte_len > SIZE_MAX - sizeof(struct yaca_key_simple_s))
-               return YACA_ERROR_TOO_BIG_ARGUMENT;
+               return YACA_ERROR_INVALID_ARGUMENT;
 
        ret = digest_get_algorithm(algo, &md);
        if (ret != YACA_ERROR_NONE)
index c17cc5d..5c1ecb1 100644 (file)
@@ -88,7 +88,7 @@ static int get_seal_output_length(const yaca_ctx_h ctx, size_t input_len, size_t
 
        if (input_len > 0) {
                if ((size_t)block_size > SIZE_MAX - input_len + 1)
-                       return YACA_ERROR_TOO_BIG_ARGUMENT;
+                       return YACA_ERROR_INVALID_ARGUMENT;
 
                *output_len = block_size + input_len - 1;
        } else {
index 3ba93f8..df4839a 100644 (file)
@@ -112,7 +112,7 @@ API int yaca_encrypt(yaca_enc_algo_e algo,
                goto err;
 
        if (out_len > SIZE_MAX - lcipher_len) {
-               ret = YACA_ERROR_TOO_BIG_ARGUMENT;
+               ret = YACA_ERROR_INVALID_ARGUMENT;
                goto err;
        }
 
@@ -189,7 +189,7 @@ API int yaca_decrypt(yaca_enc_algo_e algo,
                goto err;
 
        if (out_len > SIZE_MAX - lplain_len) {
-               ret = YACA_ERROR_TOO_BIG_ARGUMENT;
+               ret = YACA_ERROR_INVALID_ARGUMENT;
                goto err;
        }