Those functions can be static now 07/231707/5
authorLukasz Pawelczyk <l.pawelczyk@samsung.com>
Thu, 23 Apr 2020 14:12:21 +0000 (16:12 +0200)
committerLukasz Pawelczyk <l.pawelczyk@samsung.com>
Fri, 26 Jun 2020 15:36:20 +0000 (17:36 +0200)
I suppose they were used in seal previously. They're only used
directly from encrypt.c now.

Also move some structs to encrypt.c that are not used anywhere else as
well.

Change-Id: I64fbac4c7f011fedde6fdf5b3263f253ab863802

src/encrypt.c
src/internal.h

index c413ea0..e3b6fe4 100644 (file)
 
 #include "internal.h"
 
+static int set_encrypt_property(yaca_context_h ctx, yaca_property_e property,
+                                                               const void *value, size_t value_len);
+
+static int get_encrypt_property(const yaca_context_h ctx, yaca_property_e property,
+                                                               void **value, size_t *value_len);
+
 static const size_t DEFAULT_GCM_TAG_LEN = 16;
 static const size_t DEFAULT_CCM_TAG_LEN = 12;
 
+enum encrypt_context_state_e {
+       ENC_CTX_INITIALIZED = 0,
+       ENC_CTX_MSG_LENGTH_UPDATED,
+       ENC_CTX_AAD_UPDATED,
+       ENC_CTX_MSG_UPDATED,
+       ENC_CTX_TAG_SET,
+       ENC_CTX_TAG_LENGTH_SET,
+       ENC_CTX_FINALIZED,
+
+       ENC_CTX_COUNT,
+};
+
+struct yaca_encrypt_context_s {
+       struct yaca_context_s ctx;
+       struct yaca_backup_context_s *backup_ctx;
+
+       EVP_CIPHER_CTX *cipher_ctx;
+       enum encrypt_op_type_e op_type; /* Operation context was created for */
+       size_t tag_len;
+       enum encrypt_context_state_e state;
+};
+
+struct yaca_backup_context_s {
+       const EVP_CIPHER *cipher;
+       yaca_key_h sym_key;
+       yaca_key_h iv;
+       yaca_padding_e padding;
+};
+
 static const struct {
        yaca_encrypt_algorithm_e algo;
        yaca_block_cipher_mode_e bcm;
@@ -229,7 +264,7 @@ static bool is_valid_tag_len(int mode, size_t tag_len)
        }
 }
 
-struct yaca_encrypt_context_s *get_encrypt_context(const yaca_context_h ctx)
+static struct yaca_encrypt_context_s *get_encrypt_context(const yaca_context_h ctx)
 {
        if (ctx == YACA_CONTEXT_NULL)
                return NULL;
@@ -242,7 +277,7 @@ struct yaca_encrypt_context_s *get_encrypt_context(const yaca_context_h ctx)
        }
 }
 
-void destroy_encrypt_context(const yaca_context_h ctx)
+static void destroy_encrypt_context(const yaca_context_h ctx)
 {
        struct yaca_encrypt_context_s *c = get_encrypt_context(ctx);
 
@@ -260,7 +295,7 @@ void destroy_encrypt_context(const yaca_context_h ctx)
        c->cipher_ctx = NULL;
 }
 
-int get_encrypt_output_length(const yaca_context_h ctx, size_t input_len, size_t *output_len)
+static int get_encrypt_output_length(const yaca_context_h ctx, size_t input_len, size_t *output_len)
 {
        assert(output_len != NULL);
 
@@ -291,7 +326,7 @@ int get_encrypt_output_length(const yaca_context_h ctx, size_t input_len, size_t
        return YACA_ERROR_NONE;
 }
 
-int get_wrap_output_length(const yaca_context_h ctx, size_t input_len, size_t *output_len)
+static int get_wrap_output_length(const yaca_context_h ctx, size_t input_len, size_t *output_len)
 {
        assert(output_len != NULL);
 
@@ -647,10 +682,10 @@ static int encrypt_ctx_set_rc2_effective_key_bits(struct yaca_encrypt_context_s
        return ret;
 }
 
-int set_encrypt_property(yaca_context_h ctx,
-                                                yaca_property_e property,
-                                                const void *value,
-                                                size_t value_len)
+static int set_encrypt_property(yaca_context_h ctx,
+                                                               yaca_property_e property,
+                                                               const void *value,
+                                                               size_t value_len)
 {
        struct yaca_encrypt_context_s *c = get_encrypt_context(ctx);
        int len;
@@ -764,8 +799,8 @@ int set_encrypt_property(yaca_context_h ctx,
        return ret;
 }
 
-int get_encrypt_property(const yaca_context_h ctx, yaca_property_e property,
-                                                void **value, size_t *value_len)
+static int get_encrypt_property(const yaca_context_h ctx, yaca_property_e property,
+                                                               void **value, size_t *value_len)
 {
        int ret;
        void *tag = NULL;
index ac8062b..c6b933c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *  Copyright (c) 2016-2020 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *  Contact: Krzysztof Jackiewicz <k.jackiewicz@samsung.com>
  *
@@ -90,25 +90,6 @@ struct yaca_context_s {
                                                void **value, size_t *value_len);
 };
 
-struct yaca_backup_context_s {
-       const EVP_CIPHER *cipher;
-       yaca_key_h sym_key;
-       yaca_key_h iv;
-       yaca_padding_e padding;
-};
-
-enum encrypt_context_state_e {
-       ENC_CTX_INITIALIZED = 0,
-       ENC_CTX_MSG_LENGTH_UPDATED,
-       ENC_CTX_AAD_UPDATED,
-       ENC_CTX_MSG_UPDATED,
-       ENC_CTX_TAG_SET,
-       ENC_CTX_TAG_LENGTH_SET,
-       ENC_CTX_FINALIZED,
-
-       ENC_CTX_COUNT,
-};
-
 enum context_state_e {
        CTX_INITIALIZED = 0,
        CTX_MSG_UPDATED,
@@ -117,16 +98,6 @@ enum context_state_e {
        CTX_COUNT,
 };
 
-struct yaca_encrypt_context_s {
-       struct yaca_context_s ctx;
-       struct yaca_backup_context_s *backup_ctx;
-
-       EVP_CIPHER_CTX *cipher_ctx;
-       enum encrypt_op_type_e op_type; /* Operation context was created for */
-       size_t tag_len;
-       enum encrypt_context_state_e state;
-};
-
 /* Base structure for crypto keys - to be inherited */
 struct yaca_key_s {
        yaca_key_type_e type;
@@ -165,18 +136,6 @@ struct yaca_key_evp_s {
 
 int digest_get_algorithm(yaca_digest_algorithm_e algo, const EVP_MD **md);
 
-struct yaca_encrypt_context_s *get_encrypt_context(const yaca_context_h ctx);
-
-void destroy_encrypt_context(const yaca_context_h ctx);
-
-int get_encrypt_output_length(const yaca_context_h ctx, size_t input_len, size_t *output_len);
-
-int set_encrypt_property(yaca_context_h ctx, yaca_property_e property,
-                                                const void *value, size_t value_len);
-
-int get_encrypt_property(const yaca_context_h ctx, yaca_property_e property,
-                                                void **value, size_t *value_len);
-
 int encrypt_get_algorithm(yaca_encrypt_algorithm_e algo,
                                                  yaca_block_cipher_mode_e bcm,
                                                  size_t key_bit_len,