Unify argument naming and description 22/84622/4
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Mon, 29 Aug 2016 14:19:44 +0000 (16:19 +0200)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Mon, 29 Aug 2016 14:19:44 +0000 (16:19 +0200)
In digest, sign & simple API:
- data -> message,
- data_len -> message_len,
- data to be verified -> message,
- data to be signed -> message to be signed,
- signature -> message signature to be verified (verify only)
- NULL input allowed

Change-Id: Ib8283fe13e44f1be261b90327f3034a626587d39

api/yaca/yaca_digest.h
api/yaca/yaca_sign.h
api/yaca/yaca_simple.h
src/digest.c
src/sign.c

index b5dfaf22ccfe0edee0f9d22f1d062a53f215d1d0..d9d25cbce8a44c5fe485f7f141507fd3e514e745 100755 (executable)
@@ -61,13 +61,13 @@ extern "C" {
 int yaca_digest_initialize(yaca_context_h *ctx, yaca_digest_algorithm_e algo);
 
 /**
- * @brief  Feeds the data into the message digest algorithm.
+ * @brief  Feeds the message into the message digest algorithm.
  *
  * @since_tizen 3.0
  *
- * @param[in,out] ctx       Context created by yaca_digest_initialize()
- * @param[in]     data      Data from which the digest is to be calculated
- * @param[in]     data_len  Length of the data
+ * @param[in,out] ctx          Context created by yaca_digest_initialize()
+ * @param[in]     message      Message from which the digest is to be calculated
+ * @param[in]     message_len  Length of the message
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
@@ -78,7 +78,7 @@ int yaca_digest_initialize(yaca_context_h *ctx, yaca_digest_algorithm_e algo);
  * @see yaca_digest_initialize()
  * @see yaca_digest_finalize()
  */
-int yaca_digest_update(yaca_context_h ctx, const char *data, size_t data_len);
+int yaca_digest_update(yaca_context_h ctx, const char *message, size_t message_len);
 
 /**
  * @brief  Calculates the final digest.
index 8db0e1e54926a69b0bbb045b0aacc5ea6f98d168..84aae2c11965be1116cc61e9365d97377285ab4c 100755 (executable)
@@ -143,14 +143,14 @@ int yaca_sign_initialize_cmac(yaca_context_h *ctx,
                               const yaca_key_h sym_key);
 
 /**
- * @brief  Feeds the data into the digital signature or MAC algorithm.
+ * @brief  Feeds the message into the digital signature or MAC algorithm.
  *
  * @since_tizen 3.0
  *
- * @param[in,out] ctx       Context created by yaca_sign_initialize(),
- *                          yaca_sign_initialize_hmac() or yaca_sign_initialize_cmac()
- * @param[in]     data      Data to be signed
- * @param[in]     data_len  Length of the data
+ * @param[in,out] ctx          Context created by yaca_sign_initialize(),
+ *                             yaca_sign_initialize_hmac() or yaca_sign_initialize_cmac()
+ * @param[in]     message      Message to be signed
+ * @param[in]     message_len  Length of the message
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
@@ -164,8 +164,8 @@ int yaca_sign_initialize_cmac(yaca_context_h *ctx,
  * @see yaca_sign_initialize_cmac()
  */
 int yaca_sign_update(yaca_context_h ctx,
-                     const char *data,
-                     size_t data_len);
+                     const char *message,
+                     size_t message_len);
 
 /**
  * @brief  Calculates the final signature or MAC.
@@ -176,7 +176,7 @@ int yaca_sign_update(yaca_context_h ctx,
  *           signature or MAC of an empty message.
  *
  * @param[in,out] ctx              A valid sign context
- * @param[out]    signature        Buffer for the MAC or the signature
+ * @param[out]    signature        Buffer for the MAC or the message signature
  *                                 (must be allocated by client, see yaca_context_get_output_length())
  * @param[out]    signature_len    Length of the MAC or the signature,
  *                                 actual number of bytes written will be returned here
@@ -230,13 +230,13 @@ int yaca_verify_initialize(yaca_context_h *ctx,
                            const yaca_key_h pub_key);
 
 /**
- * @brief  Feeds the data into the digital signature verification algorithm.
+ * @brief  Feeds the message into the digital signature verification algorithm.
  *
  * @since_tizen 3.0
  *
- * @param[in,out] ctx       Context created by yaca_verify_initialize()
- * @param[in]     data      Data to be verified
- * @param[in]     data_len  Length of the data
+ * @param[in,out] ctx          Context created by yaca_verify_initialize()
+ * @param[in]     message      Message
+ * @param[in]     message_len  Length of the message
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
@@ -248,8 +248,8 @@ int yaca_verify_initialize(yaca_context_h *ctx,
  * @see yaca_verify_finalize()
  */
 int yaca_verify_update(yaca_context_h ctx,
-                       const char *data,
-                       size_t data_len);
+                       const char *message,
+                       size_t message_len);
 
 /**
  * @brief  Performs the verification.
@@ -260,8 +260,8 @@ int yaca_verify_update(yaca_context_h ctx,
  *           the signature of an empty message.
  *
  * @param[in,out] ctx            A valid verify context
- * @param[in]     signature      Input signature (returned by yaca_sign_finalize())
- * @param[in]     signature_len  Size of the signature
+ * @param[in]     signature      Message signature to be verified
+ * @param[in]     signature_len  Length of the signature
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
index adb44564b34cc69e30c468893492fcfd3acfe1b2..a6d00ce7c6c1ccc3b73eccddb399cc5031428243 100755 (executable)
@@ -55,6 +55,8 @@ extern "C" {
  *
  * @remarks  The @a ciphertext should be freed using yaca_free()
  *
+ * @remarks  The @a plaintext can be NULL but then @a plaintext_len must be 0
+ *
  * @param[in]  algo            Encryption algorithm (select #YACA_ENCRYPT_AES if unsure)
  * @param[in]  bcm             Chaining mode (select #YACA_BCM_CBC if unsure)
  * @param[in]  sym_key         Symmetric encryption key (see yaca_key.h for key generation functions)
@@ -94,6 +96,8 @@ int yaca_simple_encrypt(yaca_encrypt_algorithm_e algo,
  *
  * @remarks  The @a plaintext should be freed using yaca_free()
  *
+ * @remarks  The @a ciphertext can be NULL but then @a ciphertext_len must be 0
+ *
  * @param[in]  algo            Decryption algorithm that was used to encrypt the data
  * @param[in]  bcm             Chaining mode that was used to encrypt the data
  * @param[in]  sym_key         Symmetric encryption key that was used to encrypt the data
@@ -125,17 +129,19 @@ int yaca_simple_decrypt(yaca_encrypt_algorithm_e algo,
                         size_t *plaintext_len);
 
 /**
- * @brief  Calculates a digest of a buffer.
+ * @brief  Calculates a digest of a message.
  *
  * @since_tizen 3.0
  *
  * @remarks  The @a digest should be freed using yaca_free()
  *
- * @param[in]  algo        Digest algorithm (select #YACA_DIGEST_SHA256 if unsure)
- * @param[in]  data        Data from which the digest is to be calculated
- * @param[in]  data_len    Length of the data. Can be 0.
- * @param[out] digest      Message digest, will be allocated by the library
- * @param[out] digest_len  Length of message digest (depends on algorithm)
+ * @remarks  The @a message can be NULL but then @a message_len must be 0
+ *
+ * @param[in]  algo         Digest algorithm (select #YACA_DIGEST_SHA256 if unsure)
+ * @param[in]  message      Message from which the digest is to be calculated
+ * @param[in]  message_len  Length of the message
+ * @param[out] digest       Message digest, will be allocated by the library
+ * @param[out] digest_len   Length of message digest (depends on algorithm)
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
@@ -148,8 +154,8 @@ int yaca_simple_decrypt(yaca_encrypt_algorithm_e algo,
  * @see yaca_free()
  */
 int yaca_simple_calculate_digest(yaca_digest_algorithm_e algo,
-                                 const char *data,
-                                 size_t data_len,
+                                 const char *message,
+                                 size_t message_len,
                                  char **digest,
                                  size_t *digest_len);
 
@@ -160,14 +166,16 @@ int yaca_simple_calculate_digest(yaca_digest_algorithm_e algo,
  *
  * @remarks  The @a signature should be freed using yaca_free()
  *
+ * @remarks  The @a message can be NULL but then @a message_len must be 0
+ *
  * @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
- * @param[in]  data           Data to be signed
- * @param[in]  data_len       Length of the data
+ * @param[in]  message        Message to be signed
+ * @param[in]  message_len    Length of the message
  * @param[out] signature      Message signature, will be allocated by the library
  * @param[out] signature_len  Length of the signature
  *
@@ -185,8 +193,8 @@ int yaca_simple_calculate_digest(yaca_digest_algorithm_e algo,
  */
 int yaca_simple_calculate_signature(yaca_digest_algorithm_e algo,
                                     const yaca_key_h prv_key,
-                                    const char *data,
-                                    size_t data_len,
+                                    const char *message,
+                                    size_t message_len,
                                     char **signature,
                                     size_t *signature_len);
 
@@ -195,15 +203,17 @@ int yaca_simple_calculate_signature(yaca_digest_algorithm_e algo,
  *
  * @since_tizen 3.0
  *
+ * @remarks  The @a message can be NULL but then @a message_len must be 0
+ *
  * @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
- * @param[in]  data           Signed data
- * @param[in]  data_len       Length of the data
- * @param[in]  signature      Message signature
+ * @param[in]  message        Message
+ * @param[in]  message_len    Length of the message
+ * @param[in]  signature      Message signature to be verified
  * @param[in]  signature_len  Length of the signature
  *
  * @return #YACA_ERROR_NONE on success, negative on error
@@ -220,8 +230,8 @@ int yaca_simple_calculate_signature(yaca_digest_algorithm_e algo,
  */
 int yaca_simple_verify_signature(yaca_digest_algorithm_e algo,
                                  const yaca_key_h pub_key,
-                                 const char *data,
-                                 size_t data_len,
+                                 const char *message,
+                                 size_t message_len,
                                  const char *signature,
                                  size_t signature_len);
 
@@ -235,14 +245,16 @@ 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]  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
- * @param[in]  data_len  Length of the data
- * @param[out] mac       MAC, will be allocated by the library
- * @param[out] mac_len   Length of the MAC
+ * @remarks  The @a message can be NULL but then @a message_len must be 0
+ *
+ * @param[in]  algo         Digest algorithm that will be used
+ * @param[in]  sym_key      Key that will be used, supported key types:
+ *                          - #YACA_KEY_TYPE_SYMMETRIC,
+ *                          - #YACA_KEY_TYPE_DES
+ * @param[in]  message      Message to calculate HMAC from
+ * @param[in]  message_len  Length of the message
+ * @param[out] mac          MAC, will be allocated by the library
+ * @param[out] mac_len      Length of the MAC
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
@@ -258,8 +270,8 @@ int yaca_simple_verify_signature(yaca_digest_algorithm_e algo,
  */
 int yaca_simple_calculate_hmac(yaca_digest_algorithm_e algo,
                                const yaca_key_h sym_key,
-                               const char *data,
-                               size_t data_len,
+                               const char *message,
+                               size_t message_len,
                                char **mac,
                                size_t *mac_len);
 
@@ -273,14 +285,16 @@ 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]  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
- * @param[in]  data_len  Length of the data
- * @param[out] mac       MAC, will be allocated by the library
- * @param[out] mac_len   Length of the MAC
+ * @remarks  The @a message can be NULL but then @a message_len must be 0
+ *
+ * @param[in]  algo         Encryption algorithm that will be used
+ * @param[in]  sym_key      Key that will be used, supported key types:
+ *                          - #YACA_KEY_TYPE_SYMMETRIC,
+ *                          - #YACA_KEY_TYPE_DES
+ * @param[in]  message      Message to calculate CMAC from
+ * @param[in]  message_len  Length of the message
+ * @param[out] mac          MAC, will be allocated by the library
+ * @param[out] mac_len      Length of the MAC
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
@@ -296,8 +310,8 @@ int yaca_simple_calculate_hmac(yaca_digest_algorithm_e algo,
  */
 int yaca_simple_calculate_cmac(yaca_encrypt_algorithm_e algo,
                                const yaca_key_h sym_key,
-                               const char *data,
-                               size_t data_len,
+                               const char *message,
+                               size_t message_len,
                                char **mac,
                                size_t *mac_len);
 
index 0d7b42695be62051fad151b4ffeb7736a10024a6..361b9f8b0e93cc35ebbd654ad97d3a5723972fcb 100644 (file)
@@ -165,15 +165,15 @@ exit:
        return ret;
 }
 
-API int yaca_digest_update(yaca_context_h ctx, const char *data, size_t data_len)
+API int yaca_digest_update(yaca_context_h ctx, const char *message, size_t message_len)
 {
        struct yaca_digest_context_s *c = get_digest_context(ctx);
        int ret;
 
-       if (c == NULL || data == NULL || data_len == 0)
+       if (c == NULL || message == NULL || message_len == 0)
                return YACA_ERROR_INVALID_PARAMETER;
 
-       ret = EVP_DigestUpdate(c->md_ctx, data, data_len);
+       ret = EVP_DigestUpdate(c->md_ctx, message, message_len);
        if (ret != 1) {
                ret = YACA_ERROR_INTERNAL;
                ERROR_DUMP(ret);
index f79e2278cf6d9e2c43fc9f5a420c85f190741ead..aaa5863290f40967ebff894499b0c64a41ec782e 100644 (file)
@@ -442,17 +442,17 @@ exit:
 }
 
 API int yaca_sign_update(yaca_context_h ctx,
-                         const char *data,
-                         size_t data_len)
+                         const char *message,
+                         size_t message_len)
 {
        struct yaca_sign_context_s *c = get_sign_context(ctx);
        int ret;
 
        if (c == NULL || c->op_type != OP_SIGN ||
-           data == NULL || data_len == 0)
+           message == NULL || message_len == 0)
                return YACA_ERROR_INVALID_PARAMETER;
 
-       ret = EVP_DigestSignUpdate(c->md_ctx, data, data_len);
+       ret = EVP_DigestSignUpdate(c->md_ctx, message, message_len);
        if (ret != 1) {
                ret = YACA_ERROR_INTERNAL;
                ERROR_DUMP(ret);
@@ -544,16 +544,16 @@ exit:
 }
 
 API int yaca_verify_update(yaca_context_h ctx,
-                           const char *data,
-                           size_t data_len)
+                           const char *message,
+                           size_t message_len)
 {
        struct yaca_sign_context_s *c = get_sign_context(ctx);
        int ret;
 
-       if (c == NULL || data == NULL || data_len == 0 || c->op_type != OP_VERIFY)
+       if (c == NULL || message == NULL || message_len == 0 || c->op_type != OP_VERIFY)
                return YACA_ERROR_INVALID_PARAMETER;
 
-       ret = EVP_DigestVerifyUpdate(c->md_ctx, data, data_len);
+       ret = EVP_DigestVerifyUpdate(c->md_ctx, message, message_len);
        if (ret != 1) {
                ret = YACA_ERROR_INTERNAL;
                ERROR_DUMP(ret);