Unify simple key param names, EC for sign/verify 41/84841/3
authorLukasz Pawelczyk <l.pawelczyk@samsung.com>
Mon, 22 Aug 2016 14:12:16 +0000 (16:12 +0200)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Mon, 29 Aug 2016 11:33:46 +0000 (04:33 -0700)
Change-Id: If812d71791c18e7bc798c71a5335f0c498c35ea1

api/yaca/yaca_sign.h
api/yaca/yaca_simple.h
src/sign.c
src/simple.c

index 8daf68209a68b43c2687c85d9e7daf22e0014b9f..8db0e1e54926a69b0bbb045b0aacc5ea6f98d168 100755 (executable)
@@ -46,13 +46,13 @@ extern "C" {
  *
  * @remarks  The @a ctx should be released using yaca_context_destroy()
  *
- * @param[out] ctx   Newly created context
- * @param[in]  algo  Digest algorithm that will be used
- * @param[in]  key   Private key that will be used, algorithm is deduced based
- *                   on key type, supported key types:
- *                   - #YACA_KEY_TYPE_RSA_PRIV,
- *                   - #YACA_KEY_TYPE_DSA_PRIV,
- *                   - #YACA_KEY_TYPE_EC_PRIV
+ * @param[out] ctx      Newly created context
+ * @param[in]  algo     Digest algorithm that will be used
+ * @param[in]  prv_key  Private key that will be used, algorithm is deduced based
+ *                      on key type, supported key types:
+ *                      - #YACA_KEY_TYPE_RSA_PRIV,
+ *                      - #YACA_KEY_TYPE_DSA_PRIV,
+ *                      - #YACA_KEY_TYPE_EC_PRIV
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
@@ -72,7 +72,7 @@ extern "C" {
  */
 int yaca_sign_initialize(yaca_context_h *ctx,
                          yaca_digest_algorithm_e algo,
-                         const yaca_key_h key);
+                         const yaca_key_h prv_key);
 
 /**
  * @brief  Initializes a signature context for HMAC.
@@ -84,11 +84,11 @@ int yaca_sign_initialize(yaca_context_h *ctx,
  *
  * @remarks  The @a ctx should be released using yaca_context_destroy()
  *
- * @param[out] ctx   Newly created context
- * @param[in]  algo  Digest algorithm that will be used
- * @param[in]  key   Symmetric key that will be used, supported key types:
- *                   - #YACA_KEY_TYPE_SYMMETRIC,
- *                   - #YACA_KEY_TYPE_DES
+ * @param[out] ctx      Newly created context
+ * @param[in]  algo     Digest algorithm that will be used
+ * @param[in]  sym_key  Symmetric key that will be used, supported key types:
+ *                      - #YACA_KEY_TYPE_SYMMETRIC,
+ *                      - #YACA_KEY_TYPE_DES
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
@@ -106,7 +106,7 @@ int yaca_sign_initialize(yaca_context_h *ctx,
  */
 int yaca_sign_initialize_hmac(yaca_context_h *ctx,
                               yaca_digest_algorithm_e algo,
-                              const yaca_key_h key);
+                              const yaca_key_h sym_key);
 
 /**
  * @brief  Initializes a signature context for CMAC.
@@ -118,11 +118,11 @@ int yaca_sign_initialize_hmac(yaca_context_h *ctx,
  *
  * @remarks  The @a ctx should be released using yaca_context_destroy()
  *
- * @param[out] ctx   Newly created context
- * @param[in]  algo  Encryption algorithm that will be used
- * @param[in]  key   Symmetric key that will be used, supported key types:
- *                   - #YACA_KEY_TYPE_SYMMETRIC,
- *                   - #YACA_KEY_TYPE_DES
+ * @param[out] ctx      Newly created context
+ * @param[in]  algo     Encryption algorithm that will be used
+ * @param[in]  sym_key  Symmetric key that will be used, supported key types:
+ *                      - #YACA_KEY_TYPE_SYMMETRIC,
+ *                      - #YACA_KEY_TYPE_DES
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
@@ -140,7 +140,7 @@ int yaca_sign_initialize_hmac(yaca_context_h *ctx,
  */
 int yaca_sign_initialize_cmac(yaca_context_h *ctx,
                               yaca_encrypt_algorithm_e algo,
-                              const yaca_key_h key);
+                              const yaca_key_h sym_key);
 
 /**
  * @brief  Feeds the data into the digital signature or MAC algorithm.
@@ -204,13 +204,13 @@ int yaca_sign_finalize(yaca_context_h ctx,
  *
  * @remarks  The @a ctx should be released using yaca_context_destroy()
  *
- * @param[out] ctx   Newly created context
- * @param[in]  algo  Digest algorithm that will be used
- * @param[in]  key   Public key that will be used, algorithm is deduced based on
- *                   key type, supported key types:
- *                   - #YACA_KEY_TYPE_RSA_PUB,
- *                   - #YACA_KEY_TYPE_DSA_PUB,
- *                   - #YACA_KEY_TYPE_EC_PUB
+ * @param[out] ctx      Newly created context
+ * @param[in]  algo     Digest algorithm that will be used
+ * @param[in]  pub_key  Public key that will be used, algorithm is deduced based on
+ *                      key type, supported key types:
+ *                      - #YACA_KEY_TYPE_RSA_PUB,
+ *                      - #YACA_KEY_TYPE_DSA_PUB,
+ *                      - #YACA_KEY_TYPE_EC_PUB
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
@@ -227,7 +227,7 @@ int yaca_sign_finalize(yaca_context_h ctx,
  */
 int yaca_verify_initialize(yaca_context_h *ctx,
                            yaca_digest_algorithm_e algo,
-                           const yaca_key_h key);
+                           const yaca_key_h pub_key);
 
 /**
  * @brief  Feeds the data into the digital signature verification algorithm.
index 8f37875d49dc6a4aaf030cd39d03af43f1da83e4..e1260746d711fa34570d93ce268f000f0dd81673 100755 (executable)
@@ -160,10 +160,11 @@ int yaca_simple_calculate_digest(yaca_digest_algorithm_e algo,
  * @remarks  The @a signature should be freed using yaca_free()
  *
  * @param[in]  algo           Digest algorithm that will be used
- * @param[in]  key            Private key that will be used, algorithm is
+ * @param[in]  prv_key        Private key that will be used, algorithm is
  *                            deduced based on key type, supported key types:
  *                            - #YACA_KEY_TYPE_RSA_PRIV,
  *                            - #YACA_KEY_TYPE_DSA_PRIV,
+ *                            - #YACA_KEY_TYPE_EC_PRIV
  * @param[in]  data           Data to be signed
  * @param[in]  data_len       Length of the data
  * @param[out] signature      Message signature, will be allocated by the library
@@ -182,7 +183,7 @@ int yaca_simple_calculate_digest(yaca_digest_algorithm_e algo,
  * @see yaca_free()
  */
 int yaca_simple_calculate_signature(yaca_digest_algorithm_e algo,
-                                    const yaca_key_h key,
+                                    const yaca_key_h prv_key,
                                     const char *data,
                                     size_t data_len,
                                     char **signature,
@@ -194,10 +195,11 @@ int yaca_simple_calculate_signature(yaca_digest_algorithm_e algo,
  * @since_tizen 3.0
  *
  * @param[in]  algo           Digest algorithm that will be used
- * @param[in]  key            Public key that will be used, algorithm is
+ * @param[in]  pub_key        Public key that will be used, algorithm is
  *                            deduced based on key type, supported key types:
  *                            - #YACA_KEY_TYPE_RSA_PUB,
  *                            - #YACA_KEY_TYPE_DSA_PUB,
+ *                            - #YACA_KEY_TYPE_EC_PUB
  * @param[in]  data           Signed data
  * @param[in]  data_len       Length of the data
  * @param[in]  signature      Message signature
@@ -216,7 +218,7 @@ int yaca_simple_calculate_signature(yaca_digest_algorithm_e algo,
  * @see yaca_simple_calculate_signature()
  */
 int yaca_simple_verify_signature(yaca_digest_algorithm_e algo,
-                                 const yaca_key_h key,
+                                 const yaca_key_h pub_key,
                                  const char *data,
                                  size_t data_len,
                                  const char *signature,
@@ -233,7 +235,7 @@ int yaca_simple_verify_signature(yaca_digest_algorithm_e algo,
  * @remarks  The @a mac should be freed using yaca_free()
  *
  * @param[in]  algo      Digest algorithm that will be used
- * @param[in]  key       Key that will be used, supported key types:
+ * @param[in]  sym_key   Key that will be used, supported key types:
  *                       - #YACA_KEY_TYPE_SYMMETRIC,
  *                       - #YACA_KEY_TYPE_DES
  * @param[in]  data      Data to calculate HMAC from
@@ -254,7 +256,7 @@ int yaca_simple_verify_signature(yaca_digest_algorithm_e algo,
  * @see yaca_free()
  */
 int yaca_simple_calculate_hmac(yaca_digest_algorithm_e algo,
-                               const yaca_key_h key,
+                               const yaca_key_h sym_key,
                                const char *data,
                                size_t data_len,
                                char **mac,
@@ -271,7 +273,7 @@ int yaca_simple_calculate_hmac(yaca_digest_algorithm_e algo,
  * @remarks  The @a mac should be freed using yaca_free()
  *
  * @param[in]  algo      Encryption algorithm that will be used
- * @param[in]  key       Key that will be used, supported key types:
+ * @param[in]  sym_key   Key that will be used, supported key types:
  *                       - #YACA_KEY_TYPE_SYMMETRIC,
  *                       - #YACA_KEY_TYPE_DES
  * @param[in]  data      Data to calculate CMAC from
@@ -292,7 +294,7 @@ int yaca_simple_calculate_hmac(yaca_digest_algorithm_e algo,
  * @see yaca_free()
  */
 int yaca_simple_calculate_cmac(yaca_encrypt_algorithm_e algo,
-                               const yaca_key_h key,
+                               const yaca_key_h sym_key,
                                const char *data,
                                size_t data_len,
                                char **mac,
index 4233c98f17f59351f2d7304077b890eb8386548b..644349d1cd4892251e8bef5829ff38ee714ba631 100644 (file)
@@ -236,17 +236,17 @@ int get_sign_property(const yaca_context_h ctx,
 
 API int yaca_sign_initialize(yaca_context_h *ctx,
                              yaca_digest_algorithm_e algo,
-                             const yaca_key_h key)
+                             const yaca_key_h prv_key)
 {
        struct yaca_sign_context_s *nc = NULL;
        const EVP_MD *md = NULL;
        int ret;
-       const struct yaca_key_evp_s *evp_key = key_get_evp(key);
+       const struct yaca_key_evp_s *evp_key = key_get_evp(prv_key);
 
        if (ctx == NULL || evp_key == NULL)
                return YACA_ERROR_INVALID_PARAMETER;
 
-       switch (key->type) {
+       switch (prv_key->type) {
        case YACA_KEY_TYPE_RSA_PRIV:
        case YACA_KEY_TYPE_DSA_PRIV:
        case YACA_KEY_TYPE_EC_PRIV:
@@ -296,16 +296,16 @@ exit:
 
 API int yaca_sign_initialize_hmac(yaca_context_h *ctx,
                                   yaca_digest_algorithm_e algo,
-                                  const yaca_key_h key)
+                                  const yaca_key_h sym_key)
 {
        struct yaca_sign_context_s *nc = NULL;
        EVP_PKEY *pkey = NULL;
        const EVP_MD *md;
        int ret;
-       const struct yaca_key_simple_s *simple_key = key_get_simple(key);
+       const struct yaca_key_simple_s *simple_key = key_get_simple(sym_key);
 
        if (ctx == NULL || simple_key == NULL ||
-           (key->type != YACA_KEY_TYPE_SYMMETRIC && key->type != YACA_KEY_TYPE_DES))
+           (sym_key->type != YACA_KEY_TYPE_SYMMETRIC && sym_key->type != YACA_KEY_TYPE_DES))
                return YACA_ERROR_INVALID_PARAMETER;
 
        ret = yaca_zalloc(sizeof(struct yaca_sign_context_s), (void**)&nc);
@@ -360,17 +360,17 @@ exit:
 
 API int yaca_sign_initialize_cmac(yaca_context_h *ctx,
                                   yaca_encrypt_algorithm_e algo,
-                                  const yaca_key_h key)
+                                  const yaca_key_h sym_key)
 {
        struct yaca_sign_context_s *nc = NULL;
        CMAC_CTX* cmac_ctx = NULL;
        const EVP_CIPHER* cipher = NULL;
        EVP_PKEY *pkey = NULL;
        int ret;
-       const struct yaca_key_simple_s *simple_key = key_get_simple(key);
+       const struct yaca_key_simple_s *simple_key = key_get_simple(sym_key);
 
        if (ctx == NULL || simple_key == NULL ||
-           (key->type != YACA_KEY_TYPE_SYMMETRIC && key->type != YACA_KEY_TYPE_DES))
+           (sym_key->type != YACA_KEY_TYPE_SYMMETRIC && sym_key->type != YACA_KEY_TYPE_DES))
                return YACA_ERROR_INVALID_PARAMETER;
 
        ret = yaca_zalloc(sizeof(struct yaca_sign_context_s), (void**)&nc);
@@ -487,17 +487,17 @@ API int yaca_sign_finalize(yaca_context_h ctx,
 
 API int yaca_verify_initialize(yaca_context_h *ctx,
                                yaca_digest_algorithm_e algo,
-                               const yaca_key_h key)
+                               const yaca_key_h pub_key)
 {
        struct yaca_sign_context_s *nc = NULL;
        const EVP_MD *md = NULL;
        int ret;
-       const struct yaca_key_evp_s *evp_key = key_get_evp(key);
+       const struct yaca_key_evp_s *evp_key = key_get_evp(pub_key);
 
        if (ctx == NULL || evp_key == NULL)
                return YACA_ERROR_INVALID_PARAMETER;
 
-       switch (key->type) {
+       switch (pub_key->type) {
        case YACA_KEY_TYPE_RSA_PUB:
        case YACA_KEY_TYPE_DSA_PUB:
        case YACA_KEY_TYPE_EC_PUB:
index 322c1235ef3813464cb6fa2ba82cc240395c6867..5fabcc8a8758cd4f299f5048f78c2e7ff2b6d3f5 100644 (file)
@@ -265,7 +265,7 @@ static int sign(const yaca_context_h ctx, const char *data, size_t data_len,
 }
 
 API int yaca_simple_calculate_signature(yaca_digest_algorithm_e algo,
-                                        const yaca_key_h key,
+                                        const yaca_key_h prv_key,
                                         const char *data,
                                         size_t data_len,
                                         char **signature,
@@ -278,7 +278,7 @@ API int yaca_simple_calculate_signature(yaca_digest_algorithm_e algo,
            signature == NULL || signature_len == NULL)
                return YACA_ERROR_INVALID_PARAMETER;
 
-       ret = yaca_sign_initialize(&ctx, algo, key);
+       ret = yaca_sign_initialize(&ctx, algo, prv_key);
        if (ret != YACA_ERROR_NONE)
                return ret;
 
@@ -290,7 +290,7 @@ API int yaca_simple_calculate_signature(yaca_digest_algorithm_e algo,
 }
 
 API int yaca_simple_verify_signature(yaca_digest_algorithm_e algo,
-                                     const yaca_key_h key,
+                                     const yaca_key_h pub_key,
                                      const char *data,
                                      size_t data_len,
                                      const char *signature,
@@ -303,7 +303,7 @@ API int yaca_simple_verify_signature(yaca_digest_algorithm_e algo,
            signature == NULL || signature_len == 0)
                return YACA_ERROR_INVALID_PARAMETER;
 
-       ret = yaca_verify_initialize(&ctx, algo, key);
+       ret = yaca_verify_initialize(&ctx, algo, pub_key);
        if (ret != YACA_ERROR_NONE)
                return ret;
 
@@ -322,7 +322,7 @@ exit:
 }
 
 API int yaca_simple_calculate_hmac(yaca_digest_algorithm_e algo,
-                                   const yaca_key_h key,
+                                   const yaca_key_h sym_key,
                                    const char *data,
                                    size_t data_len,
                                    char **mac,
@@ -335,7 +335,7 @@ API int yaca_simple_calculate_hmac(yaca_digest_algorithm_e algo,
            mac == NULL || mac_len == NULL)
                return YACA_ERROR_INVALID_PARAMETER;
 
-       ret = yaca_sign_initialize_hmac(&ctx, algo, key);
+       ret = yaca_sign_initialize_hmac(&ctx, algo, sym_key);
        if (ret != YACA_ERROR_NONE)
                return ret;
 
@@ -347,7 +347,7 @@ API int yaca_simple_calculate_hmac(yaca_digest_algorithm_e algo,
 }
 
 API int yaca_simple_calculate_cmac(yaca_encrypt_algorithm_e algo,
-                                   const yaca_key_h key,
+                                   const yaca_key_h sym_key,
                                    const char *data,
                                    size_t data_len,
                                    char **mac,
@@ -360,7 +360,7 @@ API int yaca_simple_calculate_cmac(yaca_encrypt_algorithm_e algo,
            mac == NULL || mac_len == NULL)
                return YACA_ERROR_INVALID_PARAMETER;
 
-       ret = yaca_sign_initialize_cmac(&ctx, algo, key);
+       ret = yaca_sign_initialize_cmac(&ctx, algo, sym_key);
        if (ret != YACA_ERROR_NONE)
                return ret;