diff options
author | Krzysztof Jackiewicz <k.jackiewicz@samsung.com> | 2016-08-29 16:19:44 +0200 |
---|---|---|
committer | Krzysztof Jackiewicz <k.jackiewicz@samsung.com> | 2016-08-29 16:19:44 +0200 |
commit | 5375f24f02a95cc049aebe78da395f77e5051062 (patch) | |
tree | 5f8e101c0d1334f33ec6e1c4bb4001d06cd45e68 | |
parent | 21379829e551a05db75f42a8daecf80279c9f73b (diff) | |
download | yaca-5375f24f02a95cc049aebe78da395f77e5051062.tar.gz yaca-5375f24f02a95cc049aebe78da395f77e5051062.tar.bz2 yaca-5375f24f02a95cc049aebe78da395f77e5051062.zip |
Unify argument naming and description
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
-rwxr-xr-x | api/yaca/yaca_digest.h | 10 | ||||
-rwxr-xr-x | api/yaca/yaca_sign.h | 32 | ||||
-rwxr-xr-x | api/yaca/yaca_simple.h | 88 | ||||
-rw-r--r-- | src/digest.c | 6 | ||||
-rw-r--r-- | src/sign.c | 16 |
5 files changed, 83 insertions, 69 deletions
diff --git a/api/yaca/yaca_digest.h b/api/yaca/yaca_digest.h index b5dfaf2..d9d25cb 100755 --- a/api/yaca/yaca_digest.h +++ b/api/yaca/yaca_digest.h @@ -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. diff --git a/api/yaca/yaca_sign.h b/api/yaca/yaca_sign.h index 8db0e1e..84aae2c 100755 --- a/api/yaca/yaca_sign.h +++ b/api/yaca/yaca_sign.h @@ -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 diff --git a/api/yaca/yaca_simple.h b/api/yaca/yaca_simple.h index adb4456..a6d00ce 100755 --- a/api/yaca/yaca_simple.h +++ b/api/yaca/yaca_simple.h @@ -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); diff --git a/src/digest.c b/src/digest.c index 0d7b426..361b9f8 100644 --- a/src/digest.c +++ b/src/digest.c @@ -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); @@ -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); |