ACR: fixes for function and enumeration names/values 18/73118/6
authorLukasz Pawelczyk <l.pawelczyk@samsung.com>
Mon, 6 Jun 2016 14:11:16 +0000 (16:11 +0200)
committerLukasz Pawelczyk <l.pawelczyk@samsung.com>
Tue, 7 Jun 2016 15:38:35 +0000 (17:38 +0200)
This commit extends the names of functions, enumeration and enumeration
values to be longer, more descriptive and not use abbreviation.

Function parameters will be covered in a separate commit.

Change-Id: I4d08291fb667a5740320a23dbe0c24f656405a2c

26 files changed:
api/yaca/yaca_crypto.h
api/yaca/yaca_digest.h
api/yaca/yaca_encrypt.h
api/yaca/yaca_error.h
api/yaca/yaca_key.h
api/yaca/yaca_seal.h
api/yaca/yaca_sign.h
api/yaca/yaca_simple.h
api/yaca/yaca_types.h
examples/digest.c
examples/encrypt.c
examples/encrypt_aes_gcm_ccm.c
examples/key_exchange.c
examples/key_import_export.c
examples/key_password.c
examples/seal.c
examples/sign.c
src/crypto.c
src/debug.c
src/digest.c
src/encrypt.c
src/internal.h
src/key.c
src/seal.c
src/sign.c
src/simple.c

index b342ec0..3964d7e 100644 (file)
@@ -44,7 +44,7 @@ extern "C" {
  *
  * @since_tizen 3.0
  */
-#define YACA_CTX_NULL ((yaca_ctx_h) NULL)
+#define YACA_CONTEXT_NULL ((yaca_context_h) NULL)
 
 /**
  * @brief  Initializes the library. Must be called before any other crypto function.
@@ -56,21 +56,21 @@ extern "C" {
  * @retval #YACA_ERROR_OUT_OF_MEMORY Out of memory error
  * @retval #YACA_ERROR_INTERNAL Internal error
  *
- * @see yaca_exit()
+ * @see yaca_cleanup()
  */
-int yaca_init(void);
+int yaca_initialize(void);
 
 /**
  * @brief  Closes the library. Must be called before exiting the application.
  *
  * @since_tizen 3.0
  *
- * @see yaca_init()
- *
  * @return #YACA_ERROR_NONE on success
  * @retval #YACA_ERROR_NONE Successful
+ *
+ * @see yaca_initialize()
  */
-int yaca_exit(void);
+int yaca_cleanup(void);
 
 /**
  * @brief  Allocates the memory.
@@ -82,7 +82,7 @@ int yaca_exit(void);
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL, 0)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL, 0)
  * @retval #YACA_ERROR_OUT_OF_MEMORY Out of memory error
  *
  * @see yaca_zalloc()
@@ -101,7 +101,7 @@ int yaca_malloc(size_t size, void **memory);
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL, 0)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL, 0)
  * @retval #YACA_ERROR_OUT_OF_MEMORY Out of memory error
  *
  * @see yaca_malloc()
@@ -126,7 +126,7 @@ int yaca_zalloc(size_t size, void **memory);
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL, 0)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL, 0)
  * @retval #YACA_ERROR_OUT_OF_MEMORY Out of memory error
  *
  * @see yaca_malloc()
@@ -153,6 +153,21 @@ int yaca_realloc(size_t size, void **memory);
 int yaca_free(void *ptr);
 
 /**
+ * @brief  Safely compares first @b len bytes of two buffers.
+ *
+ * @since_tizen 3.0
+ *
+ * @param[in]  first  Pointer to the first buffer
+ * @param[in]  second Pointer to the second buffer
+ * @param[in]  len    Length to compare
+ *
+ * @return #YACA_ERROR_NONE when buffers are equal otherwise #YACA_ERROR_DATA_MISMATCH
+ * @retval #YACA_ERROR_NONE Successful
+ * @retval #YACA_ERROR_DATA_MISMATCH Buffers are different
+ */
+int yaca_memcmp(const void *first, const void *second, size_t len);
+
+/**
  * @brief  Generates random data.
  *
  * @since_tizen 3.0
@@ -162,66 +177,66 @@ int yaca_free(void *ptr);
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL, 0)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL, 0)
  * @retval #YACA_ERROR_INTERNAL Internal error
  */
-int yaca_rand_bytes(char *data, size_t data_len);
+int yaca_randomize_bytes(char *data, size_t data_len);
 
 /**
- * @brief  Sets the extended context parameters. Can only be called on an
+ * @brief  Sets the non-standard context properties. Can only be called on an
  *         initialized context.
  *
  * @since_tizen 3.0
  *
  * @param[in,out] ctx        Previously initialized crypto context
- * @param[in]     param      Parameter to be set
- * @param[in]     value      Parameter value
- * @param[in]     value_len  Length of the parameter value
+ * @param[in]     param      Property to be set
+ * @param[in]     value      Property value
+ * @param[in]     value_len  Length of the property value
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL, 0,
- *                                      invalid context or param)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL, 0,
+ *                                       invalid ctx or param)
  * @retval #YACA_ERROR_INTERNAL Internal error
  *
- * @see #yaca_ex_param_e
- * @see yaca_ctx_get_param()
+ * @see #yaca_property_e
+ * @see yaca_context_get_property()
  */
-int yaca_ctx_set_param(yaca_ctx_h ctx,
-                       yaca_ex_param_e param,
-                       const void *value,
-                       size_t value_len);
+int yaca_context_set_property(yaca_context_h ctx,
+                              yaca_property_e param,
+                              const void *value,
+                              size_t value_len);
 
 /**
- * @brief  Returns the extended context parameters. Can only be called on an
+ * @brief  Returns the non-standard context properties. Can only be called on an
  *         initialized context.
  *
  * @since_tizen 3.0
  *
  * @param[in]  ctx        Previously initialized crypto context
- * @param[in]  param      Parameter to be read
- * @param[out] value      Copy of the parameter value (must be freed with yaca_free())
- * @param[out] value_len  Length of the parameter value will be returned here
+ * @param[in]  param      Property to be read
+ * @param[out] value      Copy of the property value (must be freed with yaca_free())
+ * @param[out] value_len  Length of the property value will be returned here
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL,
- *                                      invalid context or param)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL,
+ *                                       invalid ctx or param)
  * @retval #YACA_ERROR_OUT_OF_MEMORY Out of memory error
  * @retval #YACA_ERROR_INTERNAL Internal error
  *
- * @see #yaca_ex_param_e
- * @see yaca_ctx_set_param()
+ * @see #yaca_property_e
+ * @see yaca_context_set_property()
  * @see yaca_free()
  */
-int yaca_ctx_get_param(const yaca_ctx_h ctx,
-                       yaca_ex_param_e param,
-                       void **value,
-                       size_t *value_len);
+int yaca_context_get_property(const yaca_context_h ctx,
+                              yaca_property_e param,
+                              void **value,
+                              size_t *value_len);
 
 /**
  * @brief  Destroys the crypto context. Must be called on all contexts that are
- *         no longer used. Passing #YACA_CTX_NULL is allowed.
+ *         no longer used. Passing #YACA_CONTEXT_NULL is allowed.
  *
  * @since_tizen 3.0
  *
@@ -230,10 +245,10 @@ int yaca_ctx_get_param(const yaca_ctx_h ctx,
  * @return #YACA_ERROR_NONE on success
  * @retval #YACA_ERROR_NONE Successful
  *
- * @see #yaca_ctx_h
+ * @see #yaca_context_h
  *
  */
-int yaca_ctx_free(yaca_ctx_h ctx);
+int yaca_context_destroy(yaca_context_h ctx);
 
 /**
  * @brief  Returns the output length for a given algorithm. Can only be called
@@ -247,11 +262,11 @@ int yaca_ctx_free(yaca_ctx_h ctx);
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL,
- *                                      invalid context or input_len)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL,
+ *                                       invalid context or input_len)
  * @retval #YACA_ERROR_INTERNAL Internal error
  */
-int yaca_get_output_length(const yaca_ctx_h ctx, size_t input_len, size_t *output_len);
+int yaca_get_output_length(const yaca_context_h ctx, size_t input_len, size_t *output_len);
 
 /**
  * @brief  Wrapper - returns the length of the digest (for a given context).
@@ -274,21 +289,6 @@ int yaca_get_output_length(const yaca_ctx_h ctx, size_t input_len, size_t *outpu
  */
 #define yaca_get_block_length(ctxa, output_len) yaca_get_output_length((ctxa), 0, (output_len))
 
-/**
- * @brief  Safely compares first @b len bytes of two buffers.
- *
- * @since_tizen 3.0
- *
- * @param[in]  first  Pointer to the first buffer
- * @param[in]  second Pointer to the second buffer
- * @param[in]  len    Length to compare
- *
- * @return #YACA_ERROR_NONE when buffers are equal otherwise #YACA_ERROR_DATA_MISMATCH
- * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_DATA_MISMATCH Buffers are different
- */
-int yaca_memcmp(const void *first, const void *second, size_t len);
-
 /**@}*/
 
 #ifdef __cplusplus
index b599fe1..8ad20d8 100644 (file)
@@ -44,42 +44,42 @@ extern "C" {
  *
  * @since_tizen 3.0
  *
- * @param[out] ctx   Newly created context (must be freed with yaca_ctx_free())
+ * @param[out] ctx   Newly created context (must be freed with yaca_context_destroy())
  * @param[in]  algo  Digest algorithm that will be used
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL,
- *                                      invalid algo)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL,
+ *                                       invalid algo)
  * @retval #YACA_ERROR_OUT_OF_MEMORY Out of memory error
  * @retval #YACA_ERROR_INTERNAL Internal error
  *
- * @see #yaca_digest_algo_e
+ * @see #yaca_digest_algorithm_e
  * @see yaca_digest_update()
- * @see yaca_digest_final()
- * @see yaca_ctx_free()
+ * @see yaca_digest_finalize()
+ * @see yaca_context_destroy()
  */
-int yaca_digest_init(yaca_ctx_h *ctx, yaca_digest_algo_e algo);
+int yaca_digest_initialize(yaca_context_h *ctx, yaca_digest_algorithm_e algo);
 
 /**
  * @brief  Feeds the data into the message digest algorithm.
  *
  * @since_tizen 3.0
  *
- * @param[in,out] ctx       Context created by yaca_digest_init()
+ * @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
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL, 0,
- *                                      invalid context)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL, 0,
+ *                                       invalid context)
  * @retval #YACA_ERROR_INTERNAL Internal error
  *
- * @see yaca_digest_init()
- * @see yaca_digest_final()
+ * @see yaca_digest_initialize()
+ * @see yaca_digest_finalize()
  */
-int yaca_digest_update(yaca_ctx_h ctx, const char *data, size_t data_len);
+int yaca_digest_update(yaca_context_h ctx, const char *data, size_t data_len);
 
 /**
  * @brief  Calculates the final digest.
@@ -94,15 +94,15 @@ int yaca_digest_update(yaca_ctx_h ctx, const char *data, size_t data_len);
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL,
- *                                      invalid context)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL,
+ *                                       invalid context)
  * @retval #YACA_ERROR_INTERNAL Internal error
  *
- * @see yaca_digest_init()
+ * @see yaca_digest_initialize()
  * @see yaca_digest_update()
  * @see yaca_get_digest_length()
  */
-int yaca_digest_final(yaca_ctx_h ctx, char *digest, size_t *digest_len);
+int yaca_digest_finalize(yaca_context_h ctx, char *digest, size_t *digest_len);
 
 /**@}*/
 
index d7a38f2..062caa7 100644 (file)
@@ -44,7 +44,7 @@ extern "C" {
  *
  * @since_tizen 3.0
  *
- * @param[out] ctx      Newly created context (must be freed with yaca_ctx_free())
+ * @param[out] ctx      Newly created context (must be freed with yaca_context_destroy())
  * @param[in]  algo     Encryption algorithm that will be used
  * @param[in]  bcm      Chaining mode that will be used
  * @param[in]  sym_key  Symmetric key that will be used
@@ -52,29 +52,29 @@ extern "C" {
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL,
- *                                      invalid algo, bcm, sym_key or iv)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL,
+ *                                       invalid algo, bcm, sym_key or iv)
  * @retval #YACA_ERROR_OUT_OF_MEMORY Out of memory error
  * @retval #YACA_ERROR_INTERNAL Internal error
  *
- * @see #yaca_enc_algo_e
+ * @see #yaca_encrypt_algorithm_e
  * @see #yaca_block_cipher_mode_e
  * @see yaca_encrypt_update()
- * @see yaca_encrypt_final()
- * @see yaca_ctx_free()
+ * @see yaca_encrypt_finalize()
+ * @see yaca_context_destroy()
  */
-int yaca_encrypt_init(yaca_ctx_h *ctx,
-                      yaca_enc_algo_e algo,
-                      yaca_block_cipher_mode_e bcm,
-                      const yaca_key_h sym_key,
-                      const yaca_key_h iv);
+int yaca_encrypt_initialize(yaca_context_h *ctx,
+                            yaca_encrypt_algorithm_e algo,
+                            yaca_block_cipher_mode_e bcm,
+                            const yaca_key_h sym_key,
+                            const yaca_key_h iv);
 
 /**
  * @brief  Encrypts chunk of the data.
  *
  * @since_tizen 3.0
  *
- * @param[in,out] ctx         Context created by yaca_encrypt_init()
+ * @param[in,out] ctx         Context created by yaca_encrypt_initialize()
  * @param[in]     plain       Plain text to be encrypted
  * @param[in]     plain_len   Length of the plain text
  * @param[out]    cipher      Buffer for the encrypted data
@@ -84,15 +84,15 @@ int yaca_encrypt_init(yaca_ctx_h *ctx,
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL, 0,
- *                                      invalid context)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL, 0,
+ *                                       invalid context)
  * @retval #YACA_ERROR_INTERNAL Internal error
  *
- * @see yaca_encrypt_init()
- * @see yaca_encrypt_final()
+ * @see yaca_encrypt_initialize()
+ * @see yaca_encrypt_finalize()
  * @see yaca_get_output_length()
  */
-int yaca_encrypt_update(yaca_ctx_h ctx,
+int yaca_encrypt_update(yaca_context_h ctx,
                         const char *plain,
                         size_t plain_len,
                         char *cipher,
@@ -111,24 +111,24 @@ int yaca_encrypt_update(yaca_ctx_h ctx,
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL,
- *                                      invalid context)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL,
+ *                                       invalid context)
  * @retval #YACA_ERROR_INTERNAL Internal error
  *
- * @see yaca_encrypt_init()
+ * @see yaca_encrypt_initialize()
  * @see yaca_encrypt_update()
  * @see yaca_get_output_length()
  */
-int yaca_encrypt_final(yaca_ctx_h ctx,
-                       char *cipher,
-                       size_t *cipher_len);
+int yaca_encrypt_finalize(yaca_context_h ctx,
+                          char *cipher,
+                          size_t *cipher_len);
 
 /**
  * @brief  Initializes an decryption context.
  *
  * @since_tizen 3.0
  *
- * @param[out] ctx      Newly created context (must be freed with yaca_ctx_free())
+ * @param[out] ctx      Newly created context (must be freed with yaca_context_destroy())
  * @param[in]  algo     Encryption 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 key that was used to encrypt the data
@@ -136,29 +136,29 @@ int yaca_encrypt_final(yaca_ctx_h ctx,
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL,
- *                                      invalid algo, bcm, sym_key or iv)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL,
+ *                                       invalid algo, bcm, sym_key or iv)
  * @retval #YACA_ERROR_OUT_OF_MEMORY Out of memory error
  * @retval #YACA_ERROR_INTERNAL Internal error
  *
- * @see #yaca_enc_algo_e
+ * @see #yaca_encrypt_algorithm_e
  * @see #yaca_block_cipher_mode_e
  * @see yaca_decrypt_update()
- * @see yaca_decrypt_final()
- * @see yaca_ctx_free()
+ * @see yaca_decrypt_finalize()
+ * @see yaca_context_destroy()
  */
-int yaca_decrypt_init(yaca_ctx_h *ctx,
-                      yaca_enc_algo_e algo,
-                      yaca_block_cipher_mode_e bcm,
-                      const yaca_key_h sym_key,
-                      const yaca_key_h iv);
+int yaca_decrypt_initialize(yaca_context_h *ctx,
+                            yaca_encrypt_algorithm_e algo,
+                            yaca_block_cipher_mode_e bcm,
+                            const yaca_key_h sym_key,
+                            const yaca_key_h iv);
 
 /**
  * @brief  Decrypts chunk of the data.
  *
  * @since_tizen 3.0
  *
- * @param[in,out] ctx         Context created by yaca_decrypt_init()
+ * @param[in,out] ctx         Context created by yaca_decrypt_initialize()
  * @param[in]     cipher      Cipher text to be decrypted
  * @param[in]     cipher_len  Length of the cipher text
  * @param[out]    plain       Buffer for the decrypted data
@@ -168,15 +168,15 @@ int yaca_decrypt_init(yaca_ctx_h *ctx,
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL, 0,
- *                                      invalid context)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL, 0,
+ *                                       invalid context)
  * @retval #YACA_ERROR_INTERNAL Internal error
  *
- * @see yaca_decrypt_init()
- * @see yaca_decrypt_final()
+ * @see yaca_decrypt_initialize()
+ * @see yaca_decrypt_finalize()
  * @see yaca_get_output_length()
  */
-int yaca_decrypt_update(yaca_ctx_h ctx,
+int yaca_decrypt_update(yaca_context_h ctx,
                         const char *cipher,
                         size_t cipher_len,
                         char *plain,
@@ -195,17 +195,17 @@ int yaca_decrypt_update(yaca_ctx_h ctx,
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL,
- *                                      invalid context)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL,
+ *                                       invalid context)
  * @retval #YACA_ERROR_INTERNAL Internal error
  *
- * @see yaca_decrypt_init()
+ * @see yaca_decrypt_initialize()
  * @see yaca_decrypt_update()
  * @see yaca_get_block_length()
  */
-int yaca_decrypt_final(yaca_ctx_h ctx,
-                       char *plain,
-                       size_t *plain_len);
+int yaca_decrypt_finalize(yaca_context_h ctx,
+                          char *plain,
+                          size_t *plain_len);
 
 /**
  * @brief  Returns the recommended/default length of the IV for a given encryption configuration.
@@ -222,15 +222,15 @@ int yaca_decrypt_final(yaca_ctx_h ctx,
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL,
- *                                      invalid algo, bcm or key_bits)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL,
+ *                                       invalid algo, bcm or key_bits)
  * @retval #YACA_ERROR_INTERNAL Internal error
  *
  */
-int yaca_get_iv_bits(yaca_enc_algo_e algo,
-                     yaca_block_cipher_mode_e bcm,
-                     size_t key_bits,
-                     size_t *iv_bits);
+int yaca_encrypt_get_iv_bit_length(yaca_encrypt_algorithm_e algo,
+                                   yaca_block_cipher_mode_e bcm,
+                                   size_t key_bits,
+                                   size_t *iv_bits);
 
 /**@}*/
 
index 263f3d7..3b76814 100644 (file)
@@ -48,7 +48,7 @@ typedef enum {
        /** Successful */
        YACA_ERROR_NONE               = TIZEN_ERROR_NONE,
        /** Invalid function parameter */
-       YACA_ERROR_INVALID_ARGUMENT   = TIZEN_ERROR_INVALID_PARAMETER,
+       YACA_ERROR_INVALID_PARAMETER  = TIZEN_ERROR_INVALID_PARAMETER,
        /** Out of memory */
        YACA_ERROR_OUT_OF_MEMORY      = TIZEN_ERROR_OUT_OF_MEMORY,
 
@@ -57,7 +57,7 @@ typedef enum {
        /** Data mismatch */
        YACA_ERROR_DATA_MISMATCH      = TIZEN_ERROR_YACA | 0x02,
        /** Invalid password */
-       YACA_ERROR_PASSWORD_INVALID   = TIZEN_ERROR_YACA | 0x03
+       YACA_ERROR_INVALID_PASSWORD   = TIZEN_ERROR_YACA | 0x03
 } yaca_error_e;
 
 /**@}*/
index 32fd671..ee5167e 100644 (file)
@@ -56,7 +56,7 @@ extern "C" {
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Either of the params is NULL
+ * @retval #YACA_ERROR_INVALID_PARAMETER Either of the params is NULL
  */
 int yaca_key_get_type(const yaca_key_h key, yaca_key_type_e *key_type);
 
@@ -70,10 +70,10 @@ int yaca_key_get_type(const yaca_key_h key, yaca_key_type_e *key_type);
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Either of the params is NULL
+ * @retval #YACA_ERROR_INVALID_PARAMETER Either of the params is NULL
  * @retval #YACA_ERROR_INTERNAL Internal error
  */
-int yaca_key_get_bits(const yaca_key_h key, size_t *key_bits);
+int yaca_key_get_bit_length(const yaca_key_h key, size_t *key_bits);
 
 /**
  * @brief  Imports a key.
@@ -94,26 +94,26 @@ int yaca_key_get_bits(const yaca_key_h key, size_t *key_bits);
  *
  * @remarks If the key is encrypted the algorithm will be autodetected and password
  *          used. If it's not known if the key is encrypted one should pass NULL as
- *          password and check for the #YACA_ERROR_PASSWORD_INVALID return code.
+ *          password and check for the #YACA_ERROR_INVALID_PASSWORD return code.
  *
  * @param[in]  key_type  Type of the key
  * @param[in]  password  null terminated password for the key (can be NULL)
  * @param[in]  data      Blob containing the key
  * @param[in]  data_len  Size of the blob
- * @param[out] key       Returned key (must be freed with yaca_key_free())
+ * @param[out] key       Returned key (must be freed with yaca_key_destroy())
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL, 0,
- *                                      invalid key_type or data_len too big)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL, 0,
+ *                                       invalid key_type or data_len too big)
  * @retval #YACA_ERROR_OUT_OF_MEMORY Out of memory error
  * @retval #YACA_ERROR_INTERNAL Internal error
- * @retval #YACA_ERROR_PASSWORD_INVALID Invalid password given or password was required
+ * @retval #YACA_ERROR_INVALID_PASSWORD Invalid password given or password was required
  *                                      and none was given
  *
  * @see #yaca_key_type_e
  * @see yaca_key_export()
- * @see yaca_key_free()
+ * @see yaca_key_destroy()
  */
 int yaca_key_import(yaca_key_type_e key_type,
                     const char *password,
@@ -156,19 +156,19 @@ int yaca_key_import(yaca_key_type_e key_type,
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL, 0,
- *                                      invalid key/file format or data_len too big)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL, 0,
+ *                                       invalid key/file format or data_len too big)
  * @retval #YACA_ERROR_OUT_OF_MEMORY Out of memory error
  * @retval #YACA_ERROR_INTERNAL Internal error
  *
- * @see #yaca_key_fmt_e
- * @see #yaca_key_file_fmt_e
+ * @see #yaca_key_format_e
+ * @see #yaca_key_file_format_e
  * @see yaca_key_import()
- * @see yaca_key_free()
+ * @see yaca_key_destroy()
  */
 int yaca_key_export(const yaca_key_h key,
-                    yaca_key_fmt_e key_fmt,
-                    yaca_key_file_fmt_e key_file_fmt,
+                    yaca_key_format_e key_fmt,
+                    yaca_key_file_format_e key_file_fmt,
                     const char *password,
                     char **data,
                     size_t *data_len);
@@ -186,22 +186,22 @@ int yaca_key_export(const yaca_key_h key,
  *
  * @param[in]  key_type  Type of the key to be generated
  * @param[in]  key_bits  Length of the key (in bits) to be generated
- * @param[out] key       Newly generated key (must be freed with yaca_key_free())
+ * @param[out] key       Newly generated key (must be freed with yaca_key_destroy())
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT key is NULL, incorrect key_type or
- *                                      key_bits is not dividable by 8
+ * @retval #YACA_ERROR_INVALID_PARAMETER key is NULL, incorrect key_type or
+ *                                       key_bits is not dividable by 8
  * @retval #YACA_ERROR_OUT_OF_MEMORY Out of memory error
  * @retval #YACA_ERROR_INTERNAL Internal error
  *
  * @see #yaca_key_type_e
- * @see #yaca_key_bits_e
- * @see yaca_key_free()
+ * @see #yaca_key_bit_length_e
+ * @see yaca_key_destroy()
  */
-int yaca_key_gen(yaca_key_type_e key_type,
-                 size_t key_bits,
-                 yaca_key_h *key);
+int yaca_key_generate(yaca_key_type_e key_type,
+                      size_t key_bits,
+                      yaca_key_h *key);
 
 /**
  * @brief  Extracts public key from a private one.
@@ -209,17 +209,17 @@ int yaca_key_gen(yaca_key_type_e key_type,
  * @since_tizen 3.0
  *
  * @param[in]  prv_key   Private key to extract the public one from
- * @param[out] pub_key   Extracted public key (must be freed with yaca_key_free())
+ * @param[out] pub_key   Extracted public key (must be freed with yaca_key_destroy())
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT prv_key is of invalid type or pub_key is NULL
+ * @retval #YACA_ERROR_INVALID_PARAMETER prv_key is of invalid type or pub_key is NULL
  * @retval #YACA_ERROR_OUT_OF_MEMORY Out of memory error
  * @retval #YACA_ERROR_INTERNAL Internal error
  *
- * @see yaca_key_gen()
+ * @see yaca_key_generate()
  * @see yaca_key_import()
- * @see yaca_key_free()
+ * @see yaca_key_destroy()
  */
 int yaca_key_extract_public(const yaca_key_h prv_key, yaca_key_h *pub_key);
 
@@ -235,9 +235,9 @@ int yaca_key_extract_public(const yaca_key_h prv_key, yaca_key_h *pub_key);
  *
  * @see yaca_key_import()
  * @see yaca_key_export()
- * @see yaca_key_gen()
+ * @see yaca_key_generate()
  */
-int yaca_key_free(yaca_key_h key);
+int yaca_key_destroy(yaca_key_h key);
 
 /**@}*/
 
@@ -260,23 +260,23 @@ int yaca_key_free(yaca_key_h key);
  * @param[in]  iter      Number of iterations
  * @param[in]  algo      Digest algorithm that should be used in key generation
  * @param[in]  key_bits  Length of a key (in bits) to be generated
- * @param[out] key       Newly generated key (must be freed with yaca_key_free())
+ * @param[out] key       Newly generated key (must be freed with yaca_key_destroy())
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL, 0,
- *                                      invalid algo or key_bits not dividable by 8)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL, 0,
+ *                                       invalid algo or key_bits not dividable by 8)
  * @retval #YACA_ERROR_OUT_OF_MEMORY Out of memory error
  * @retval #YACA_ERROR_INTERNAL Internal error
  *
- * @see #yaca_digest_algo_e
- * @see yaca_key_free()
+ * @see #yaca_digest_algorithm_e
+ * @see yaca_key_destroy()
  */
 int yaca_key_derive_pbkdf2(const char *password,
                            const char *salt,
                            size_t salt_len,
                            int iter,
-                           yaca_digest_algo_e algo,
+                           yaca_digest_algorithm_e algo,
                            size_t key_bits,
                            yaca_key_h *key);
 
index 5bf3f2e..58b4102 100644 (file)
@@ -48,45 +48,45 @@ extern "C" {
  *
  * @since_tizen 3.0
  *
- * @param[out] ctx           Newly created context (must be freed with yaca_ctx_free())
+ * @param[out] ctx           Newly created context (must be freed with yaca_context_destroy())
  * @param[in]  pub_key       Public key of the peer that will receive the encrypted data
  * @param[in]  algo          Symmetric algorithm that will be used
  * @param[in]  bcm           Block chaining mode for the symmetric algorithm
  * @param[in]  sym_key_bits  Symmetric key length (in bits) that will be generated
  * @param[out] sym_key       Generated symmetric key that will be used,
  *                           it is encrypted with peer's public key
- *                           (must be freed with yaca_key_free())
+ *                           (must be freed with yaca_key_destroy())
  * @param[out] iv            Generated initialization vector that will be used
- *                           (must be freed with yaca_key_free())
+ *                           (must be freed with yaca_key_destroy())
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL,
- *                                      invalid algo, bcm, sym_key_bits or pub_key)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL,
+ *                                       invalid algo, bcm, sym_key_bits or pub_key)
  * @retval #YACA_ERROR_OUT_OF_MEMORY Out of memory error
  * @retval #YACA_ERROR_INTERNAL Internal error
  *
- * @see #yaca_enc_algo_e
+ * @see #yaca_encrypt_algorithm_e
  * @see #yaca_block_cipher_mode_e
  * @see yaca_seal_update()
- * @see yaca_seal_final()
- * @see yaca_key_free()
- * @see yaca_ctx_free()
+ * @see yaca_seal_finalize()
+ * @see yaca_key_destroy()
+ * @see yaca_context_destroy()
  */
-int yaca_seal_init(yaca_ctx_h *ctx,
-                   const yaca_key_h pub_key,
-                   yaca_enc_algo_e algo,
-                   yaca_block_cipher_mode_e bcm,
-                   yaca_key_bits_e sym_key_bits,
-                   yaca_key_h *sym_key,
-                   yaca_key_h *iv);
+int yaca_seal_initialize(yaca_context_h *ctx,
+                         const yaca_key_h pub_key,
+                         yaca_encrypt_algorithm_e algo,
+                         yaca_block_cipher_mode_e bcm,
+                         yaca_key_bit_length_e sym_key_bits,
+                         yaca_key_h *sym_key,
+                         yaca_key_h *iv);
 
 /**
  * @brief  Encrypts piece of the data.
  *
  * @since_tizen 3.0
  *
- * @param[in,out] ctx         Context created by yaca_seal_init()
+ * @param[in,out] ctx         Context created by yaca_seal_initialize()
  * @param[in]     plain       Plain text to be encrypted
  * @param[in]     plain_len   Length of the plain text
  * @param[out]    cipher      Buffer for the encrypted data
@@ -96,15 +96,15 @@ int yaca_seal_init(yaca_ctx_h *ctx,
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL, 0,
- *                                      invalid context)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL, 0,
+ *                                       invalid context)
  * @retval #YACA_ERROR_INTERNAL Internal error
  *
- * @see yaca_seal_init()
- * @see yaca_seal_final()
+ * @see yaca_seal_initialize()
+ * @see yaca_seal_finalize()
  * @see yaca_get_output_length()
  */
-int yaca_seal_update(yaca_ctx_h ctx,
+int yaca_seal_update(yaca_context_h ctx,
                      const char *plain,
                      size_t plain_len,
                      char *cipher,
@@ -123,24 +123,24 @@ int yaca_seal_update(yaca_ctx_h ctx,
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL,
- *                                      invalid context)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL,
+ *                                       invalid context)
  * @retval #YACA_ERROR_INTERNAL Internal error
  *
- * @see yaca_seal_init()
+ * @see yaca_seal_initialize()
  * @see yaca_seal_update()
  * @see yaca_get_block_length()
  */
-int yaca_seal_final(yaca_ctx_h ctx,
-                    char *cipher,
-                    size_t *cipher_len);
+int yaca_seal_finalize(yaca_context_h ctx,
+                       char *cipher,
+                       size_t *cipher_len);
 
 /**
  * @brief  Initializes an asymmetric decryption context.
  *
  * @since_tizen 3.0
  *
- * @param[out] ctx           Newly created context (must be freed by yaca_ctx_free())
+ * @param[out] ctx           Newly created context (must be freed by yaca_context_destroy())
  * @param[in]  prv_key       Private key, part of the pair that was used for the encryption
  * @param[in]  algo          Symmetric algorithm that was used for the encryption
  * @param[in]  bcm           Block chaining mode for the symmetric algorithm
@@ -151,31 +151,31 @@ int yaca_seal_final(yaca_ctx_h ctx,
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL,
- *                                      invalid algo, bcm, sym_key_bits, prv_key, sym_key or iv)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL,
+ *                                       invalid algo, bcm, sym_key_bits, prv_key, sym_key or iv)
  * @retval #YACA_ERROR_OUT_OF_MEMORY Out of memory error
  * @retval #YACA_ERROR_INTERNAL Internal error
  *
- * @see #yaca_enc_algo_e
+ * @see #yaca_encrypt_algorithm_e
  * @see #yaca_block_cipher_mode_e
  * @see yaca_open_update()
- * @see yaca_open_final()
- * @see yaca_ctx_free()
+ * @see yaca_open_finalize()
+ * @see yaca_context_destroy()
  */
-int yaca_open_init(yaca_ctx_h *ctx,
-                   const yaca_key_h prv_key,
-                   yaca_enc_algo_e algo,
-                   yaca_block_cipher_mode_e bcm,
-                   yaca_key_bits_e sym_key_bits,
-                   const yaca_key_h sym_key,
-                   const yaca_key_h iv);
+int yaca_open_initialize(yaca_context_h *ctx,
+                         const yaca_key_h prv_key,
+                         yaca_encrypt_algorithm_e algo,
+                         yaca_block_cipher_mode_e bcm,
+                         yaca_key_bit_length_e sym_key_bits,
+                         const yaca_key_h sym_key,
+                         const yaca_key_h iv);
 
 /**
  * @brief  Decrypts piece of the data.
  *
  * @since_tizen 3.0
  *
- * @param[in,out] ctx         Context created by yaca_open_init()
+ * @param[in,out] ctx         Context created by yaca_open_initialize()
  * @param[in]     cipher      Cipher text to be decrypted
  * @param[in]     cipher_len  Length of the cipher text
  * @param[out]    plain       Buffer for the decrypted data
@@ -185,15 +185,15 @@ int yaca_open_init(yaca_ctx_h *ctx,
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL, 0,
- *                                      invalid context)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL, 0,
+ *                                       invalid context)
  * @retval #YACA_ERROR_INTERNAL Internal error
  *
- * @see yaca_open_init()
- * @see yaca_open_final()
+ * @see yaca_open_initialize()
+ * @see yaca_open_finalize()
  * @see yaca_get_output_length()
  */
-int yaca_open_update(yaca_ctx_h ctx,
+int yaca_open_update(yaca_context_h ctx,
                      const char *cipher,
                      size_t cipher_len,
                      char *plain,
@@ -212,17 +212,17 @@ int yaca_open_update(yaca_ctx_h ctx,
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL,
- *                                      invalid context)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL,
+ *                                       invalid context)
  * @retval #YACA_ERROR_INTERNAL Internal error
  *
- * @see yaca_open_init()
+ * @see yaca_open_initialize()
  * @see yaca_open_update()
  * @see yaca_get_block_length()
  */
-int yaca_open_final(yaca_ctx_h ctx,
-                    char *plain,
-                    size_t *plain_len);
+int yaca_open_finalize(yaca_context_h ctx,
+                       char *plain,
+                       size_t *plain_len);
 
 /**@}*/
 
index 75ef56c..4b9ec91 100644 (file)
@@ -45,10 +45,10 @@ extern "C" {
  *
  * @since_tizen 3.0
  *
- * @remarks For verification use yaca_verify_init(), yaca_verify_update() and
- *          yaca_verify_final() functions with matching public key.
+ * @remarks For verification use yaca_verify_initialize(), yaca_verify_update() and
+ *          yaca_verify_finalize() functions with matching public key.
  *
- * @param[out] ctx   Newly created context (must be freed with yaca_ctx_free())
+ * @param[out] ctx   Newly created context (must be freed with yaca_context_destroy())
  * @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:
@@ -57,23 +57,23 @@ extern "C" {
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL,
- *                                      invalid algo or key)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL,
+ *                                       invalid algo or key)
  * @retval #YACA_ERROR_OUT_OF_MEMORY Out of memory error
  * @retval #YACA_ERROR_INTERNAL Internal error
  *
  * @see #yaca_key_type_e
- * @see #yaca_digest_algo_e
+ * @see #yaca_digest_algorithm_e
  * @see yaca_sign_update()
- * @see yaca_sign_final()
- * @see yaca_verify_init()
+ * @see yaca_sign_finalize()
+ * @see yaca_verify_initialize()
  * @see yaca_verify_update()
- * @see yaca_verify_final()
- * @see yaca_ctx_free()
+ * @see yaca_verify_finalize()
+ * @see yaca_context_destroy()
  */
-int yaca_sign_init(yaca_ctx_h *ctx,
-                   yaca_digest_algo_e algo,
-                   const yaca_key_h key);
+int yaca_sign_initialize(yaca_context_h *ctx,
+                         yaca_digest_algorithm_e algo,
+                         const yaca_key_h key);
 
 /**
  * @brief  Initializes a signature context for HMAC.
@@ -83,7 +83,7 @@ int yaca_sign_init(yaca_ctx_h *ctx,
  * @remarks For verification, calculate message HMAC and compare with received MAC using
  *          yaca_memcmp().
  *
- * @param[out] ctx   Newly created context (must be freed with yaca_ctx_free())
+ * @param[out] ctx   Newly created context (must be freed with yaca_context_destroy())
  * @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,
@@ -91,21 +91,21 @@ int yaca_sign_init(yaca_ctx_h *ctx,
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL,
- *                                      invalid algo or key)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL,
+ *                                       invalid algo or key)
  * @retval #YACA_ERROR_OUT_OF_MEMORY Out of memory error
  * @retval #YACA_ERROR_INTERNAL Internal error
  *
  * @see #yaca_key_type_e
- * @see #yaca_digest_algo_e
+ * @see #yaca_digest_algorithm_e
  * @see yaca_sign_update()
- * @see yaca_sign_final()
+ * @see yaca_sign_finalize()
  * @see yaca_memcmp()
- * @see yaca_ctx_free()
+ * @see yaca_context_destroy()
  */
-int yaca_sign_hmac_init(yaca_ctx_h *ctx,
-                        yaca_digest_algo_e algo,
-                        const yaca_key_h key);
+int yaca_sign_initialize_hmac(yaca_context_h *ctx,
+                              yaca_digest_algorithm_e algo,
+                              const yaca_key_h key);
 
 /**
  * @brief  Initializes a signature context for CMAC.
@@ -115,7 +115,7 @@ int yaca_sign_hmac_init(yaca_ctx_h *ctx,
  * @remarks For verification, calculate message CMAC and compare with received MAC using
  *          yaca_memcmp().
  *
- * @param[out] ctx   Newly created context (must be freed with yaca_ctx_free())
+ * @param[out] ctx   Newly created context (must be freed with yaca_context_destroy())
  * @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,
@@ -123,44 +123,44 @@ int yaca_sign_hmac_init(yaca_ctx_h *ctx,
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL,
- *                                      invalid algo or key)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL,
+ *                                       invalid algo or key)
  * @retval #YACA_ERROR_OUT_OF_MEMORY Out of memory error
  * @retval #YACA_ERROR_INTERNAL Internal error
  *
  * @see #yaca_key_type_e
- * @see #yaca_enc_algo_e
+ * @see #yaca_encrypt_algorithm_e
  * @see yaca_sign_update()
- * @see yaca_sign_final()
+ * @see yaca_sign_finalize()
  * @see yaca_memcmp()
- * @see yaca_ctx_free()
+ * @see yaca_context_destroy()
  */
-int yaca_sign_cmac_init(yaca_ctx_h *ctx,
-                        yaca_enc_algo_e algo,
-                        const yaca_key_h key);
+int yaca_sign_initialize_cmac(yaca_context_h *ctx,
+                              yaca_encrypt_algorithm_e algo,
+                              const yaca_key_h key);
 
 /**
  * @brief  Feeds the data into the digital signature or MAC algorithm.
  *
  * @since_tizen 3.0
  *
- * @param[in,out] ctx       Context created by yaca_sign_init(),
- *                          yaca_sign_hmac_init() or yaca_sign_cmac_init()
+ * @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
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL, 0,
- *                                      invalid context)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL, 0,
+ *                                       invalid context)
  * @retval #YACA_ERROR_INTERNAL Internal error
  *
- * @see yaca_sign_init()
- * @see yaca_sign_final()
- * @see yaca_sign_hmac_init()
- * @see yaca_sign_cmac_init()
+ * @see yaca_sign_initialize()
+ * @see yaca_sign_finalize()
+ * @see yaca_sign_initialize_hmac()
+ * @see yaca_sign_initialize_cmac()
  */
-int yaca_sign_update(yaca_ctx_h ctx,
+int yaca_sign_update(yaca_context_h ctx,
                      const char *data,
                      size_t data_len);
 
@@ -177,26 +177,26 @@ int yaca_sign_update(yaca_ctx_h ctx,
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL,
- *                                      invalid context)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL,
+ *                                       invalid context)
  * @retval #YACA_ERROR_INTERNAL Internal error
  *
- * @see yaca_sign_init()
+ * @see yaca_sign_initialize()
  * @see yaca_sign_update()
- * @see yaca_sign_hmac_init()
- * @see yaca_sign_cmac_init()
+ * @see yaca_sign_initialize_hmac()
+ * @see yaca_sign_initialize_cmac()
  * @see yaca_get_sign_length()
  */
-int yaca_sign_final(yaca_ctx_h ctx,
-                    char *signature,
-                    size_t *signature_len);
+int yaca_sign_finalize(yaca_context_h ctx,
+                       char *signature,
+                       size_t *signature_len);
 
 /**
  * @brief  Initializes a signature verification context for asymmetric signatures
  *
  * @since_tizen 3.0
  *
- * @param[out] ctx   Newly created context (must be freed with yaca_ctx_free())
+ * @param[out] ctx   Newly created context (must be freed with yaca_context_destroy())
  * @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:
@@ -205,40 +205,40 @@ int yaca_sign_final(yaca_ctx_h ctx,
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL,
- *                                      invalid algo or key)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL,
+ *                                       invalid algo or key)
  * @retval #YACA_ERROR_OUT_OF_MEMORY Out of memory error
  * @retval #YACA_ERROR_INTERNAL Internal error
  *
  * @see #yaca_key_type_e
- * @see #yaca_digest_algo_e
+ * @see #yaca_digest_algorithm_e
  * @see yaca_verify_update()
- * @see yaca_verify_final()
- * @see yaca_ctx_free()
+ * @see yaca_verify_finalize()
+ * @see yaca_context_destroy()
  */
-int yaca_verify_init(yaca_ctx_h *ctx,
-                     yaca_digest_algo_e algo,
-                     const yaca_key_h key);
+int yaca_verify_initialize(yaca_context_h *ctx,
+                           yaca_digest_algorithm_e algo,
+                           const yaca_key_h key);
 
 /**
  * @brief  Feeds the data into the digital signature verification algorithm.
  *
  * @since_tizen 3.0
  *
- * @param[in,out] ctx       Context created by yaca_verify_init()
+ * @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
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL, 0,
- *                                      invalid context)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL, 0,
+ *                                       invalid context)
  * @retval #YACA_ERROR_INTERNAL Internal error
  *
- * @see yaca_verify_init()
- * @see yaca_verify_final()
+ * @see yaca_verify_initialize()
+ * @see yaca_verify_finalize()
  */
-int yaca_verify_update(yaca_ctx_h ctx,
+int yaca_verify_update(yaca_context_h ctx,
                        const char *data,
                        size_t data_len);
 
@@ -248,23 +248,23 @@ int yaca_verify_update(yaca_ctx_h ctx,
  * @since_tizen 3.0
  *
  * @param[in,out] ctx            A valid verify context
- * @param[in]     signature      Input signature (returned by yaca_sign_final())
+ * @param[in]     signature      Input signature (returned by yaca_sign_finalize())
  * @param[in]     signature_len  Size of the signature
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL,
- *                                      invalid context)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL,
+ *                                       invalid context)
  * @retval #YACA_ERROR_INTERNAL Internal error
  * @retval #YACA_ERROR_DATA_MISMATCH The verification failed
  *
- * @see yaca_verify_init()
+ * @see yaca_verify_initialize()
  * @see yaca_verify_update()
- * @see yaca_sign_final()
+ * @see yaca_sign_finalize()
  */
-int yaca_verify_final(yaca_ctx_h ctx,
-                      const char *signature,
-                      size_t signature_len);
+int yaca_verify_finalize(yaca_context_h ctx,
+                         const char *signature,
+                         size_t signature_len);
 
 /**@}*/
 
index c72f2d6..ae6ae5d 100644 (file)
@@ -61,26 +61,26 @@ extern "C" {
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL, 0
- *                                      invalid algo)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL, 0
+ *                                       invalid algo)
  * @retval #YACA_ERROR_OUT_OF_MEMORY Out of memory error
  * @retval #YACA_ERROR_INTERNAL Internal error
  *
- * @see #yaca_digest_algo_e
+ * @see #yaca_digest_algorithm_e
  * @see yaca_free()
  */
-int yaca_digest_calc(yaca_digest_algo_e algo,
-                     const char *data,
-                     size_t data_len,
-                     char **digest,
-                     size_t *digest_len);
+int yaca_simple_calculate_digest(yaca_digest_algorithm_e algo,
+                                 const char *data,
+                                 size_t data_len,
+                                 char **digest,
+                                 size_t *digest_len);
 
 /**
  * @brief  Encrypt data using a symmetric cipher.
  *
  * @since_tizen 3.0
  *
- * @param[in]  algo        Encryption algorithm (select #YACA_ENC_AES if unsure)
+ * @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 key.h for key generation functions)
  * @param[in]  iv          Initialization vector
@@ -92,24 +92,24 @@ int yaca_digest_calc(yaca_digest_algo_e algo,
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL, 0
- *                                      invalid algo, bcm, sym_key or iv)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL, 0
+ *                                       invalid algo, bcm, sym_key or iv)
  * @retval #YACA_ERROR_OUT_OF_MEMORY Out of memory error
  * @retval #YACA_ERROR_INTERNAL Internal error
  *
- * @see #yaca_enc_algo_e
+ * @see #yaca_encrypt_algorithm_e
  * @see #yaca_block_cipher_mode_e
- * @see yaca_decrypt()
+ * @see yaca_simple_decrypt()
  * @see yaca_free()
  */
-int yaca_encrypt(yaca_enc_algo_e algo,
-                 yaca_block_cipher_mode_e bcm,
-                 const yaca_key_h sym_key,
-                 const yaca_key_h iv,
-                 const char *plain,
-                 size_t plain_len,
-                 char **cipher,
-                 size_t *cipher_len);
+int yaca_simple_encrypt(yaca_encrypt_algorithm_e algo,
+                        yaca_block_cipher_mode_e bcm,
+                        const yaca_key_h sym_key,
+                        const yaca_key_h iv,
+                        const char *plain,
+                        size_t plain_len,
+                        char **cipher,
+                        size_t *cipher_len);
 
 /**
  * @brief  Decrypt data using a symmetric cipher.
@@ -128,24 +128,24 @@ int yaca_encrypt(yaca_enc_algo_e algo,
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL, 0
- *                                      invalid algo, bcm, sym_key or iv)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL, 0
+ *                                       invalid algo, bcm, sym_key or iv)
  * @retval #YACA_ERROR_OUT_OF_MEMORY Out of memory error
  * @retval #YACA_ERROR_INTERNAL Internal error
  *
- * @see #yaca_enc_algo_e
+ * @see #yaca_encrypt_algorithm_e
  * @see #yaca_block_cipher_mode_e
- * @see yaca_encrypt()
+ * @see yaca_simple_encrypt()
  * @see yaca_free()
  */
-int yaca_decrypt(yaca_enc_algo_e algo,
-                 yaca_block_cipher_mode_e bcm,
-                 const yaca_key_h sym_key,
-                 const yaca_key_h iv,
-                 const char *cipher,
-                 size_t cipher_len,
-                 char **plain,
-                 size_t *plain_len);
+int yaca_simple_decrypt(yaca_encrypt_algorithm_e algo,
+                        yaca_block_cipher_mode_e bcm,
+                        const yaca_key_h sym_key,
+                        const yaca_key_h iv,
+                        const char *cipher,
+                        size_t cipher_len,
+                        char **plain,
+                        size_t *plain_len);
 
 /**
  * @brief  Create a signature using asymmetric private key.
@@ -165,22 +165,22 @@ int yaca_decrypt(yaca_enc_algo_e algo,
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL, 0
- *                                      invalid algo or key)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL, 0
+ *                                       invalid algo or key)
  * @retval #YACA_ERROR_OUT_OF_MEMORY Out of memory error
  * @retval #YACA_ERROR_INTERNAL Internal error
  *
  * @see #yaca_key_type_e
- * @see #yaca_digest_algo_e
- * @see yaca_verify()
+ * @see #yaca_digest_algorithm_e
+ * @see yaca_simple_verify_signature()
  * @see yaca_free()
  */
-int yaca_sign(yaca_digest_algo_e algo,
-              const yaca_key_h key,
-              const char *data,
-              size_t data_len,
-              char **signature,
-              size_t *signature_len);
+int yaca_simple_calculate_signature(yaca_digest_algorithm_e algo,
+                                    const yaca_key_h key,
+                                    const char *data,
+                                    size_t data_len,
+                                    char **signature,
+                                    size_t *signature_len);
 
 /**
  * @brief  Verify a signature using asymmetric public key.
@@ -199,22 +199,22 @@ int yaca_sign(yaca_digest_algo_e algo,
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL, 0
- *                                      invalid algo or key)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL, 0
+ *                                       invalid algo or key)
  * @retval #YACA_ERROR_OUT_OF_MEMORY Out of memory error
  * @retval #YACA_ERROR_INTERNAL Internal error
  * @retval #YACA_ERROR_DATA_MISMATCH The verification failed
  *
  * @see #yaca_key_type_e
- * @see #yaca_digest_algo_e
- * @see yaca_sign()
+ * @see #yaca_digest_algorithm_e
+ * @see yaca_simple_calculate_signature()
  */
-int yaca_verify(yaca_digest_algo_e algo,
-                const yaca_key_h key,
-                const char *data,
-                size_t data_len,
-                const char *signature,
-                size_t signature_len);
+int yaca_simple_verify_signature(yaca_digest_algorithm_e algo,
+                                 const yaca_key_h key,
+                                 const char *data,
+                                 size_t data_len,
+                                 const char *signature,
+                                 size_t signature_len);
 
 /**
  * @brief  Calculate a HMAC of given message using symmetric key.
@@ -236,22 +236,22 @@ int yaca_verify(yaca_digest_algo_e algo,
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL, 0
- *                                      invalid algo or key)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL, 0
+ *                                       invalid algo or key)
  * @retval #YACA_ERROR_OUT_OF_MEMORY Out of memory error
  * @retval #YACA_ERROR_INTERNAL Internal error
  *
  * @see #yaca_key_type_e
- * @see #yaca_digest_algo_e
+ * @see #yaca_digest_algorithm_e
  * @see yaca_memcmp()
  * @see yaca_free()
  */
-int yaca_hmac(yaca_digest_algo_e algo,
-              const yaca_key_h key,
-              const char *data,
-              size_t data_len,
-              char **mac,
-              size_t *mac_len);
+int yaca_simple_calculate_hmac(yaca_digest_algorithm_e algo,
+                               const yaca_key_h key,
+                               const char *data,
+                               size_t data_len,
+                               char **mac,
+                               size_t *mac_len);
 
 /**
  * @brief  Calculate a CMAC of given message using symmetric key.
@@ -273,22 +273,22 @@ int yaca_hmac(yaca_digest_algo_e algo,
  *
  * @return #YACA_ERROR_NONE on success, negative on error
  * @retval #YACA_ERROR_NONE Successful
- * @retval #YACA_ERROR_INVALID_ARGUMENT Required parameters have incorrect values (NULL, 0
- *                                      invalid algo or key)
+ * @retval #YACA_ERROR_INVALID_PARAMETER Required parameters have incorrect values (NULL, 0
+ *                                       invalid algo or key)
  * @retval #YACA_ERROR_OUT_OF_MEMORY Out of memory error
  * @retval #YACA_ERROR_INTERNAL Internal error
  *
  * @see #yaca_key_type_e
- * @see #yaca_enc_algo_e
+ * @see #yaca_encrypt_algorithm_e
  * @see yaca_memcmp()
  * @see yaca_free()
  */
-int yaca_cmac(yaca_enc_algo_e algo,
-              const yaca_key_h key,
-              const char *data,
-              size_t data_len,
-              char **mac,
-              size_t *mac_len);
+int yaca_simple_calculate_cmac(yaca_encrypt_algorithm_e algo,
+                               const yaca_key_h key,
+                               const char *data,
+                               size_t data_len,
+                               char **mac,
+                               size_t *mac_len);
 
 /**@}*/
 
index 15cfe12..f24bb01 100644 (file)
@@ -41,7 +41,7 @@ extern "C" {
  *
  * @since_tizen 3.0
  */
-typedef struct yaca_ctx_s *yaca_ctx_h;
+typedef struct yaca_context_s *yaca_context_h;
 
 /**
  * @brief Key.
@@ -60,7 +60,7 @@ typedef enum {
        YACA_KEY_FORMAT_DEFAULT,
        /** Key is in PKCS#8, can only be used for asymmetric private keys */
        YACA_KEY_FORMAT_PKCS8
-} yaca_key_fmt_e;
+} yaca_key_format_e;
 
 /**
  * @brief Enumeration of YACA key file formats.
@@ -76,7 +76,7 @@ typedef enum {
        YACA_KEY_FILE_FORMAT_PEM,
        /** Key file is in DER file format, used for asymmetric keys */
        YACA_KEY_FILE_FORMAT_DER
-} yaca_key_file_fmt_e;
+} yaca_key_file_format_e;
 
 /**
  * @brief Enumeration of YACA key types, IV is considered as key.
@@ -105,28 +105,28 @@ typedef enum {
 /**
  * @brief Enumeration of YACA key lengths.
  *        It is possible to use arbitrary integer instead,
- *        this enums are placed here to avoid magic numbers.
+ *        this enum values are placed here to avoid magic numbers.
  *
  * @since_tizen 3.0
  */
 typedef enum {
-       YACA_KEY_IV_UNSAFE_24BIT = 24,
-       YACA_KEY_IV_64BIT = 64,
-       YACA_KEY_IV_128BIT = 128,
-       YACA_KEY_IV_256BIT = 256,
-       YACA_KEY_UNSAFE_8BIT = 8,
-       YACA_KEY_UNSAFE_40BIT = 40,
-       YACA_KEY_UNSAFE_64BIT = 64,
-       YACA_KEY_UNSAFE_80BIT = 80,
-       YACA_KEY_UNSAFE_128BIT = 128,
-       YACA_KEY_192BIT = 192,
-       YACA_KEY_256BIT = 256,
-       YACA_KEY_512BIT = 512,
-       YACA_KEY_1024BIT = 1024,
-       YACA_KEY_2048BIT = 2048,
-       YACA_KEY_3072BIT = 3072,
-       YACA_KEY_4096BIT = 4096
-} yaca_key_bits_e;
+       YACA_KEY_LENGTH_IV_UNSAFE_24BIT = 24,
+       YACA_KEY_LENGTH_IV_64BIT = 64,
+       YACA_KEY_LENGTH_IV_128BIT = 128,
+       YACA_KEY_LENGTH_IV_256BIT = 256,
+       YACA_KEY_LENGTH_UNSAFE_8BIT = 8,
+       YACA_KEY_LENGTH_UNSAFE_40BIT = 40,
+       YACA_KEY_LENGTH_UNSAFE_64BIT = 64,
+       YACA_KEY_LENGTH_UNSAFE_80BIT = 80,
+       YACA_KEY_LENGTH_UNSAFE_128BIT = 128,
+       YACA_KEY_LENGTH_192BIT = 192,
+       YACA_KEY_LENGTH_256BIT = 256,
+       YACA_KEY_LENGTH_512BIT = 512,
+       YACA_KEY_LENGTH_1024BIT = 1024,
+       YACA_KEY_LENGTH_2048BIT = 2048,
+       YACA_KEY_LENGTH_3072BIT = 3072,
+       YACA_KEY_LENGTH_4096BIT = 4096
+} yaca_key_bit_length_e;
 
 /**
  * @brief Enumeration of YACA message digest algorithms.
@@ -146,7 +146,7 @@ typedef enum {
        YACA_DIGEST_SHA384,
        /** Message digest algorithm SHA2, 512bit */
        YACA_DIGEST_SHA512,
-} yaca_digest_algo_e;
+} yaca_digest_algorithm_e;
 
 /**
  * @brief Enumeration of YACA symmetric encryption algorithms.
@@ -169,7 +169,7 @@ typedef enum {
         * #YACA_BCM_CTR
         * - see #yaca_block_cipher_mode_e for details on additional parameters (mandatory).
         */
-       YACA_ENC_AES = 0,
+       YACA_ENCRYPT_AES = 0,
 
        /**
         * DES encryption.
@@ -183,7 +183,7 @@ typedef enum {
         * #YACA_BCM_ECB
         * - see #yaca_block_cipher_mode_e for details on additional parameters (mandatory).
         */
-       YACA_ENC_UNSAFE_DES,
+       YACA_ENCRYPT_UNSAFE_DES,
 
        /**
         * 3DES 2-key encryption.
@@ -197,7 +197,7 @@ typedef enum {
         * - Use double DES keys to perform corresponding 2-key 3DES encryption.
 
         */
-       YACA_ENC_UNSAFE_3DES_2TDEA,
+       YACA_ENCRYPT_UNSAFE_3DES_2TDEA,
 
        /**
         * 3DES 3-key encryption.
@@ -212,7 +212,7 @@ typedef enum {
         * - see #yaca_block_cipher_mode_e for details on additional parameters (mandatory).
         * - Use triple DES keys to perform corresponding 3-key 3DES encryption.
         */
-       YACA_ENC_3DES_3TDEA,
+       YACA_ENCRYPT_3DES_3TDEA,
 
        /**
         * RC2 encryption.
@@ -225,7 +225,7 @@ typedef enum {
         * #YACA_BCM_CFB,
         * #YACA_BCM_ECB
         */
-       YACA_ENC_UNSAFE_RC2,
+       YACA_ENCRYPT_UNSAFE_RC2,
 
        /**
         * RC4 encryption.
@@ -233,7 +233,7 @@ typedef enum {
         * - Supported key lengths: 40–2048 bits in steps of 8 bits.
         * This cipher doesn't support block cipher modes, use #YACA_BCM_NONE instead.
         */
-       YACA_ENC_UNSAFE_RC4,
+       YACA_ENCRYPT_UNSAFE_RC4,
 
        /**
         * CAST5 encryption.
@@ -246,8 +246,8 @@ typedef enum {
         * #YACA_BCM_ECB
         * - see #yaca_block_cipher_mode_e for details on additional parameters (mandatory).
         */
-       YACA_ENC_CAST5,
-} yaca_enc_algo_e;
+       YACA_ENCRYPT_CAST5,
+} yaca_encrypt_algorithm_e;
 
 /**
  * @brief Enumeration of YACA chaining modes for block ciphers.
@@ -283,20 +283,20 @@ typedef enum {
         * This is a variable IV length mode (recommended 96 bits IV).
         *
         * Supported parameters:
-        * - #YACA_PARAM_GCM_TAG_LEN = GCM tag length\n
+        * - #YACA_PROPERTY_GCM_TAG_LEN = GCM tag length\n
         *   Supported tag lengths: @c 32, @c 64, @c 96, @c 104, @c 112, @c 120, @c 128,
         *   (recommended 128 bits tag).\n
-        *   Set after yaca_encrypt_final() and before yaca_ctx_get_param(#YACA_PARAM_GCM_TAG)
+        *   Set after yaca_encrypt_finalize() and before yaca_context_get_property(#YACA_PROPERTY_GCM_TAG)
         *   in encryption operation.\n\n
         *
-        * - #YACA_PARAM_GCM_TAG = GCM tag\n
-        *   Get after yaca_encrypt_final() in encryption operation.\n
-        *   Set before yaca_decrypt_final() in decryption operation.\n\n
+        * - #YACA_PROPERTY_GCM_TAG = GCM tag\n
+        *   Get after yaca_encrypt_finalize() in encryption operation.\n
+        *   Set before yaca_decrypt_finalize() in decryption operation.\n\n
         *
-        * - #YACA_PARAM_GCM_AAD = additional authentication data (optional)\n
-        *   Set after yaca_encrypt_init() and before yaca_encrypt_update()
+        * - #YACA_PROPERTY_GCM_AAD = additional authentication data (optional)\n
+        *   Set after yaca_encrypt_initialize() and before yaca_encrypt_update()
         *   in encryption operation.\n
-        *   Set after yaca_decrypt_init() and before yaca_decrypt_update()
+        *   Set after yaca_decrypt_initialize() and before yaca_decrypt_update()
         *   in decryption operation.\n\n
         *
         *   @see examples/encrypt_aes_gcm_ccm.c
@@ -333,26 +333,26 @@ typedef enum {
         * Supported IV lengths: 56-104 bits in steps of 8 bits (recommended 56 bits IV).\n\n
         *
         * Supported parameters:
-        * - #YACA_PARAM_CCM_TAG_LEN = CCM tag length\n
+        * - #YACA_PROPERTY_CCM_TAG_LEN = CCM tag length\n
         *   Supported tag lengths: 32-128 bits in step of 16 bits (recommended 96 bits tag).\n
-        *   Set after yaca_encrypt_init() and before yaca_encrypt_update()
+        *   Set after yaca_encrypt_initialize() and before yaca_encrypt_update()
         *   in encryption operation.\n\n
         *
-        * - #YACA_PARAM_CCM_TAG = CCM tag\n
-        *   Get after yaca_encrypt_final() in encryption operation.\n
-        *   Set after yaca_decrypt_init() and before yaca_decrypt_update()
+        * - #YACA_PROPERTY_CCM_TAG = CCM tag\n
+        *   Get after yaca_encrypt_finalize() in encryption operation.\n
+        *   Set after yaca_decrypt_initialize() and before yaca_decrypt_update()
         *   in decryption operation.\n\n
         *
-        * - #YACA_PARAM_CCM_AAD = additional authentication data (optional)\n
+        * - #YACA_PROPERTY_CCM_AAD = additional authentication data (optional)\n
         *   The total plain text length must be passed to yaca_encrypt_update()
         *   if AAD is used.\n
-        *   Set after yaca_encrypt_init() and before yaca_encrypt_update()
+        *   Set after yaca_encrypt_initialize() and before yaca_encrypt_update()
         *   in encryption operation.\n
         *   You can only call yaca_encrypt_update() once for AAD and once for the plain text.\n\n
         *
         *   The total encrypted text length must be passed to yaca_decrypt_update()
         *   if AAD is used.\n
-        *   Set after yaca_decrypt_init() and before yaca_decrypt_update()
+        *   Set after yaca_decrypt_initialize() and before yaca_decrypt_update()
         *   in decryption operation.\n\n
         *
         *   @see examples/encrypt_aes_gcm_ccm.c
@@ -363,28 +363,28 @@ typedef enum {
 
 
 /**
- * @brief Enumeration of YACA non-standard parameters for algorithms.
+ * @brief Enumeration of YACA non-standard properties for algorithms.
  *
  * @since_tizen 3.0
  */
 typedef enum {
        /** Padding */
-       YACA_PARAM_PADDING,
+       YACA_PROPERTY_PADDING,
 
        /** GCM Additional Authentication Data */
-       YACA_PARAM_GCM_AAD,
+       YACA_PROPERTY_GCM_AAD,
        /** GCM Tag bits */
-       YACA_PARAM_GCM_TAG,
+       YACA_PROPERTY_GCM_TAG,
        /** GCM Tag length */
-       YACA_PARAM_GCM_TAG_LEN,
+       YACA_PROPERTY_GCM_TAG_LEN,
 
        /** CCM Additional Authentication Data */
-       YACA_PARAM_CCM_AAD,
+       YACA_PROPERTY_CCM_AAD,
        /** CCM Tag bits */
-       YACA_PARAM_CCM_TAG,
+       YACA_PROPERTY_CCM_TAG,
        /** CCM Tag length */
-       YACA_PARAM_CCM_TAG_LEN
-} yaca_ex_param_e;
+       YACA_PROPERTY_CCM_TAG_LEN
+} yaca_property_e;
 
 /**
  * @brief Enumeration of YACA paddings.
index 404e5e9..78ff483 100644 (file)
@@ -36,7 +36,7 @@ void digest_simple(void)
        char *digest;
        size_t digest_len;
 
-       ret = yaca_digest_calc(YACA_DIGEST_SHA256,
+       ret = yaca_simple_calculate_digest(YACA_DIGEST_SHA256,
                               lorem1024,
                               1024, &digest, &digest_len);
        if (ret != YACA_ERROR_NONE)
@@ -50,9 +50,9 @@ void digest_simple(void)
 void digest_advanced(void)
 {
        int ret = YACA_ERROR_NONE;
-       yaca_ctx_h ctx;
+       yaca_context_h ctx;
 
-       ret = yaca_digest_init(&ctx, YACA_DIGEST_SHA256);
+       ret = yaca_digest_initialize(&ctx, YACA_DIGEST_SHA256);
        if (ret != YACA_ERROR_NONE)
                return;
 
@@ -68,7 +68,7 @@ void digest_advanced(void)
        {
                char digest[digest_len];
 
-               ret = yaca_digest_final(ctx, digest, &digest_len);
+               ret = yaca_digest_finalize(ctx, digest, &digest_len);
                if (ret != YACA_ERROR_NONE)
                        goto exit;
 
@@ -76,14 +76,14 @@ void digest_advanced(void)
        }
 
 exit:
-       yaca_ctx_free(ctx);
+       yaca_context_destroy(ctx);
 }
 
 int main()
 {
        yaca_debug_set_error_cb(debug_func);
 
-       int ret = yaca_init();
+       int ret = yaca_initialize();
        if (ret != YACA_ERROR_NONE)
                return ret;
 
@@ -91,6 +91,6 @@ int main()
 
        digest_advanced();
 
-       yaca_exit();
+       yaca_cleanup();
        return ret;
 }
index f4a460a..ff986cc 100644 (file)
@@ -33,7 +33,7 @@
 #include "misc.h"
 #include "../src/debug.h"
 
-void encrypt_simple(const yaca_enc_algo_e algo,
+void encrypt_simple(const yaca_encrypt_algorithm_e algo,
                     const yaca_block_cipher_mode_e bcm,
                     const size_t key_bits)
 {
@@ -53,18 +53,18 @@ void encrypt_simple(const yaca_enc_algo_e algo,
                                   YACA_DIGEST_SHA256, key_bits, &key) != YACA_ERROR_NONE)
                return;
 
-       if (yaca_get_iv_bits(algo, bcm, key_bits, &iv_bits) != YACA_ERROR_NONE)
+       if (yaca_encrypt_get_iv_bit_length(algo, bcm, key_bits, &iv_bits) != YACA_ERROR_NONE)
                goto exit;
 
-       if (iv_bits > 0 && yaca_key_gen(YACA_KEY_TYPE_IV, iv_bits, &iv) != YACA_ERROR_NONE)
+       if (iv_bits > 0 && yaca_key_generate(YACA_KEY_TYPE_IV, iv_bits, &iv) != YACA_ERROR_NONE)
                goto exit;
 
-       if (yaca_encrypt(algo, bcm, key, iv, lorem4096, LOREM4096_SIZE, &enc, &enc_size) != YACA_ERROR_NONE)
+       if (yaca_simple_encrypt(algo, bcm, key, iv, lorem4096, LOREM4096_SIZE, &enc, &enc_size) != YACA_ERROR_NONE)
                goto exit;
 
        dump_hex(enc, 16, "Encrypted data (16 of %zu bytes): ", enc_size);
 
-       if (yaca_decrypt(algo, bcm, key, iv, enc, enc_size, &dec, &dec_size) != YACA_ERROR_NONE)
+       if (yaca_simple_decrypt(algo, bcm, key, iv, enc, enc_size, &dec, &dec_size) != YACA_ERROR_NONE)
                goto exit;
 
        printf("Decrypted data (16 of %zu bytes): %.16s\n\n", dec_size, dec);
@@ -72,16 +72,16 @@ void encrypt_simple(const yaca_enc_algo_e algo,
 exit:
        yaca_free(enc);
        yaca_free(dec);
-       yaca_key_free(iv);
-       yaca_key_free(key);
+       yaca_key_destroy(iv);
+       yaca_key_destroy(key);
 }
 
-void encrypt_advanced(const yaca_enc_algo_e algo,
+void encrypt_advanced(const yaca_encrypt_algorithm_e algo,
                       const yaca_block_cipher_mode_e bcm,
                       const yaca_key_type_e key_type,
                       const size_t key_bits)
 {
-       yaca_ctx_h ctx = YACA_CTX_NULL;
+       yaca_context_h ctx = YACA_CONTEXT_NULL;
        yaca_key_h key = YACA_KEY_NULL;
        yaca_key_h iv = YACA_KEY_NULL;
        size_t iv_bits;
@@ -99,18 +99,18 @@ void encrypt_advanced(const yaca_enc_algo_e algo,
        printf("Plain data (16 of %zu bytes): %.16s\n", LOREM4096_SIZE, lorem4096);
 
        /* Key generation */
-       if (yaca_key_gen(key_type, key_bits, &key) != YACA_ERROR_NONE)
+       if (yaca_key_generate(key_type, key_bits, &key) != YACA_ERROR_NONE)
                return;
 
-       if (yaca_get_iv_bits(algo, bcm, key_bits, &iv_bits) != YACA_ERROR_NONE)
+       if (yaca_encrypt_get_iv_bit_length(algo, bcm, key_bits, &iv_bits) != YACA_ERROR_NONE)
                goto exit;
 
-       if (iv_bits > 0 && yaca_key_gen(YACA_KEY_TYPE_IV, iv_bits, &iv) != YACA_ERROR_NONE)
+       if (iv_bits > 0 && yaca_key_generate(YACA_KEY_TYPE_IV, iv_bits, &iv) != YACA_ERROR_NONE)
                goto exit;
 
        /* Encryption */
        {
-               if (yaca_encrypt_init(&ctx, algo, bcm, key, iv) != YACA_ERROR_NONE)
+               if (yaca_encrypt_initialize(&ctx, algo, bcm, key, iv) != YACA_ERROR_NONE)
                        goto exit;
 
                if (yaca_get_block_length(ctx, &block_len) != YACA_ERROR_NONE)
@@ -129,20 +129,20 @@ void encrypt_advanced(const yaca_enc_algo_e algo,
                        goto exit;
 
                rem = enc_size - out_size;
-               if (yaca_encrypt_final(ctx, enc + out_size, &rem) != YACA_ERROR_NONE)
+               if (yaca_encrypt_finalize(ctx, enc + out_size, &rem) != YACA_ERROR_NONE)
                        goto exit;
 
                enc_size = rem + out_size;
 
                dump_hex(enc, 16, "Encrypted data (16 of %zu bytes): ", enc_size);
 
-               yaca_ctx_free(ctx);
-               ctx = YACA_CTX_NULL;
+               yaca_context_destroy(ctx);
+               ctx = YACA_CONTEXT_NULL;
        }
 
        /* Decryption */
        {
-               if (yaca_decrypt_init(&ctx, algo, bcm, key, iv) != YACA_ERROR_NONE)
+               if (yaca_decrypt_initialize(&ctx, algo, bcm, key, iv) != YACA_ERROR_NONE)
                        goto exit;
 
                if (yaca_get_block_length(ctx, &block_len) != YACA_ERROR_NONE)
@@ -161,7 +161,7 @@ void encrypt_advanced(const yaca_enc_algo_e algo,
                        goto exit;
 
                rem = dec_size - out_size;
-               if (yaca_decrypt_final(ctx, dec + out_size, &rem) != YACA_ERROR_NONE)
+               if (yaca_decrypt_finalize(ctx, dec + out_size, &rem) != YACA_ERROR_NONE)
                        goto exit;
 
                dec_size = rem + out_size;
@@ -172,59 +172,59 @@ void encrypt_advanced(const yaca_enc_algo_e algo,
 exit:
        yaca_free(dec);
        yaca_free(enc);
-       yaca_ctx_free(ctx);
-       yaca_key_free(iv);
-       yaca_key_free(key);
+       yaca_context_destroy(ctx);
+       yaca_key_destroy(iv);
+       yaca_key_destroy(key);
 }
 
 int main()
 {
        yaca_debug_set_error_cb(debug_func);
 
-       int ret = yaca_init();
+       int ret = yaca_initialize();
        if (ret != YACA_ERROR_NONE)
                return ret;
 
-       yaca_enc_algo_e algo = YACA_ENC_AES;
+       yaca_encrypt_algorithm_e algo = YACA_ENCRYPT_AES;
        yaca_block_cipher_mode_e bcm = YACA_BCM_ECB;
        yaca_key_type_e key_type = YACA_KEY_TYPE_SYMMETRIC;
-       size_t key_bits = YACA_KEY_256BIT;
+       size_t key_bits = YACA_KEY_LENGTH_256BIT;
 
        encrypt_simple(algo, bcm, key_bits);
        encrypt_advanced(algo, bcm, key_type, key_bits);
 
-       algo = YACA_ENC_3DES_3TDEA;
+       algo = YACA_ENCRYPT_3DES_3TDEA;
        bcm = YACA_BCM_OFB;
        key_type = YACA_KEY_TYPE_DES;
-       key_bits = YACA_KEY_192BIT;
+       key_bits = YACA_KEY_LENGTH_192BIT;
 
        encrypt_advanced(algo, bcm, key_type, key_bits);
 
-       algo = YACA_ENC_CAST5;
+       algo = YACA_ENCRYPT_CAST5;
        bcm = YACA_BCM_CFB;
        key_type = YACA_KEY_TYPE_SYMMETRIC;
-       key_bits = YACA_KEY_UNSAFE_40BIT;
+       key_bits = YACA_KEY_LENGTH_UNSAFE_40BIT;
 
        encrypt_simple(algo, bcm, key_bits);
        encrypt_advanced(algo, bcm, key_type, key_bits);
 
-       algo = YACA_ENC_UNSAFE_RC2;
+       algo = YACA_ENCRYPT_UNSAFE_RC2;
        bcm = YACA_BCM_CBC;
        key_type = YACA_KEY_TYPE_SYMMETRIC;
-       key_bits = YACA_KEY_UNSAFE_8BIT;
+       key_bits = YACA_KEY_LENGTH_UNSAFE_8BIT;
 
        encrypt_simple(algo, bcm, key_bits);
        encrypt_advanced(algo, bcm, key_type, key_bits);
 
-       algo = YACA_ENC_UNSAFE_RC4;
+       algo = YACA_ENCRYPT_UNSAFE_RC4;
        bcm = YACA_BCM_NONE;
        key_type = YACA_KEY_TYPE_SYMMETRIC;
-       key_bits = YACA_KEY_2048BIT;
+       key_bits = YACA_KEY_LENGTH_2048BIT;
 
        encrypt_simple(algo, bcm, key_bits);
        encrypt_advanced(algo, bcm, key_type, key_bits);
 
-       yaca_exit();
+       yaca_cleanup();
 
        return ret;
 }
index 11f58e5..b0029af 100644 (file)
 
 void encrypt_decrypt_aes_gcm(void)
 {
-       yaca_enc_algo_e algo = YACA_ENC_AES;
+       yaca_encrypt_algorithm_e algo = YACA_ENCRYPT_AES;
        yaca_block_cipher_mode_e bcm = YACA_BCM_GCM;
        yaca_key_type_e key_type = YACA_KEY_TYPE_SYMMETRIC;
-       size_t key_bits = YACA_KEY_256BIT;
-       size_t iv_bits = YACA_KEY_IV_128BIT;
+       size_t key_bits = YACA_KEY_LENGTH_256BIT;
+       size_t iv_bits = YACA_KEY_LENGTH_IV_128BIT;
 
-       yaca_ctx_h ctx = YACA_CTX_NULL;
+       yaca_context_h ctx = YACA_CONTEXT_NULL;
        yaca_key_h key = YACA_KEY_NULL;
        yaca_key_h iv = YACA_KEY_NULL;
 
@@ -63,17 +63,17 @@ void encrypt_decrypt_aes_gcm(void)
        printf("Plain data (16 of %zu bytes): %.16s\n", LOREM4096_SIZE, lorem4096);
 
        /* Key generation */
-       if (yaca_key_gen(key_type, key_bits, &key) != YACA_ERROR_NONE)
+       if (yaca_key_generate(key_type, key_bits, &key) != YACA_ERROR_NONE)
                return;
 
        /* IV generation */
-       if (yaca_key_gen(YACA_KEY_TYPE_IV, iv_bits, &iv) != YACA_ERROR_NONE)
+       if (yaca_key_generate(YACA_KEY_TYPE_IV, iv_bits, &iv) != YACA_ERROR_NONE)
                goto exit;
 
        if (yaca_zalloc(aad_size, (void**)&aad) != YACA_ERROR_NONE)
                goto exit;
 
-       if (yaca_rand_bytes(aad, aad_size) != YACA_ERROR_NONE)
+       if (yaca_randomize_bytes(aad, aad_size) != YACA_ERROR_NONE)
                goto exit;
 
        if (yaca_zalloc(tag_size, (void**)&tag) != YACA_ERROR_NONE)
@@ -81,11 +81,11 @@ void encrypt_decrypt_aes_gcm(void)
 
        /* Encryption */
        {
-               if (yaca_encrypt_init(&ctx, algo, bcm, key, iv) != YACA_ERROR_NONE)
+               if (yaca_encrypt_initialize(&ctx, algo, bcm, key, iv) != YACA_ERROR_NONE)
                        goto exit;
 
                /* Provide any AAD data */
-               if (yaca_ctx_set_param(ctx, YACA_PARAM_GCM_AAD, aad, aad_size) != YACA_ERROR_NONE)
+               if (yaca_context_set_property(ctx, YACA_PROPERTY_GCM_AAD, aad, aad_size) != YACA_ERROR_NONE)
                        goto exit;
 
                if (yaca_get_block_length(ctx, &block_len) != YACA_ERROR_NONE)
@@ -104,32 +104,32 @@ void encrypt_decrypt_aes_gcm(void)
                        goto exit;
 
                rem = enc_size - out_size;
-               if (yaca_encrypt_final(ctx, enc + out_size, &rem) != YACA_ERROR_NONE)
+               if (yaca_encrypt_finalize(ctx, enc + out_size, &rem) != YACA_ERROR_NONE)
                        goto exit;
 
                enc_size = rem + out_size;
 
                /* Set the tag length and get the tag after final encryption */
-               if (yaca_ctx_set_param(ctx, YACA_PARAM_GCM_TAG_LEN,
+               if (yaca_context_set_property(ctx, YACA_PROPERTY_GCM_TAG_LEN,
                                       (void*)&tag_size, sizeof(tag_size)) != YACA_ERROR_NONE)
                        goto exit;
 
-               if (yaca_ctx_get_param(ctx, YACA_PARAM_GCM_TAG, (void**)tag, &tag_size) != YACA_ERROR_NONE)
+               if (yaca_context_get_property(ctx, YACA_PROPERTY_GCM_TAG, (void**)tag, &tag_size) != YACA_ERROR_NONE)
                        goto exit;
 
                dump_hex(enc, 16, "Encrypted data (16 of %zu bytes): ", enc_size);
 
-               yaca_ctx_free(ctx);
-               ctx = YACA_CTX_NULL;
+               yaca_context_destroy(ctx);
+               ctx = YACA_CONTEXT_NULL;
        }
 
        /* Decryption */
        {
-               if (yaca_decrypt_init(&ctx, algo, bcm, key, iv) != YACA_ERROR_NONE)
+               if (yaca_decrypt_initialize(&ctx, algo, bcm, key, iv) != YACA_ERROR_NONE)
                        goto exit;
 
                /* Provide any AAD data */
-               if (yaca_ctx_set_param(ctx, YACA_PARAM_GCM_AAD, aad, aad_size) != YACA_ERROR_NONE)
+               if (yaca_context_set_property(ctx, YACA_PROPERTY_GCM_AAD, aad, aad_size) != YACA_ERROR_NONE)
                        goto exit;
 
                if (yaca_get_block_length(ctx, &block_len) != YACA_ERROR_NONE)
@@ -150,10 +150,10 @@ void encrypt_decrypt_aes_gcm(void)
                rem = dec_size - out_size;
 
                /* Set expected tag value before final decryption */
-               if (yaca_ctx_set_param(ctx, YACA_PARAM_GCM_TAG, tag, tag_size) != YACA_ERROR_NONE)
+               if (yaca_context_set_property(ctx, YACA_PROPERTY_GCM_TAG, tag, tag_size) != YACA_ERROR_NONE)
                        goto exit;
 
-               if (yaca_decrypt_final(ctx, dec + out_size, &rem) != YACA_ERROR_NONE)
+               if (yaca_decrypt_finalize(ctx, dec + out_size, &rem) != YACA_ERROR_NONE)
                        goto exit;
 
                dec_size = rem + out_size;
@@ -166,20 +166,20 @@ exit:
        yaca_free(dec);
        yaca_free(tag);
        yaca_free(aad);
-       yaca_ctx_free(ctx);
-       yaca_key_free(iv);
-       yaca_key_free(key);
+       yaca_context_destroy(ctx);
+       yaca_key_destroy(iv);
+       yaca_key_destroy(key);
 }
 
 void encrypt_decrypt_aes_ccm(void)
 {
-       yaca_enc_algo_e algo = YACA_ENC_AES;
+       yaca_encrypt_algorithm_e algo = YACA_ENCRYPT_AES;
        yaca_block_cipher_mode_e bcm = YACA_BCM_CCM;
        yaca_key_type_e key_type = YACA_KEY_TYPE_SYMMETRIC;
-       size_t key_bits = YACA_KEY_256BIT;
-       size_t iv_bits = YACA_KEY_IV_64BIT;
+       size_t key_bits = YACA_KEY_LENGTH_256BIT;
+       size_t iv_bits = YACA_KEY_LENGTH_IV_64BIT;
 
-       yaca_ctx_h ctx = YACA_CTX_NULL;
+       yaca_context_h ctx = YACA_CONTEXT_NULL;
        yaca_key_h key = YACA_KEY_NULL;
        yaca_key_h iv = YACA_KEY_NULL;
 
@@ -203,17 +203,17 @@ void encrypt_decrypt_aes_ccm(void)
        printf("Plain data (16 of %zu bytes): %.16s\n", LOREM4096_SIZE, lorem4096);
 
        /* Key generation */
-       if (yaca_key_gen(key_type, key_bits, &key) != YACA_ERROR_NONE)
+       if (yaca_key_generate(key_type, key_bits, &key) != YACA_ERROR_NONE)
                return;
 
        /* IV generation */
-       if (yaca_key_gen(YACA_KEY_TYPE_IV, iv_bits, &iv) != YACA_ERROR_NONE)
+       if (yaca_key_generate(YACA_KEY_TYPE_IV, iv_bits, &iv) != YACA_ERROR_NONE)
                goto exit;
 
        if (yaca_zalloc(aad_size, (void**)&aad) != YACA_ERROR_NONE)
                goto exit;
 
-       if (yaca_rand_bytes(aad, aad_size) != YACA_ERROR_NONE)
+       if (yaca_randomize_bytes(aad, aad_size) != YACA_ERROR_NONE)
                goto exit;
 
        if (yaca_zalloc(tag_size, (void**)&tag) != YACA_ERROR_NONE)
@@ -221,11 +221,11 @@ void encrypt_decrypt_aes_ccm(void)
 
        /* Encryption */
        {
-               if (yaca_encrypt_init(&ctx, algo, bcm, key, iv) != YACA_ERROR_NONE)
+               if (yaca_encrypt_initialize(&ctx, algo, bcm, key, iv) != YACA_ERROR_NONE)
                        goto exit;
 
                /* Set tag length (optionally) */
-               if (yaca_ctx_set_param(ctx, YACA_PARAM_CCM_TAG_LEN,
+               if (yaca_context_set_property(ctx, YACA_PROPERTY_CCM_TAG_LEN,
                                       (void*)&tag_size, sizeof(tag_size)) != YACA_ERROR_NONE)
                        goto exit;
 
@@ -233,7 +233,7 @@ void encrypt_decrypt_aes_ccm(void)
                if (yaca_encrypt_update(ctx, NULL, LOREM4096_SIZE , NULL, &len) != YACA_ERROR_NONE)
                        goto exit;
 
-               if (yaca_ctx_set_param(ctx, YACA_PARAM_CCM_AAD, aad, aad_size) != YACA_ERROR_NONE)
+               if (yaca_context_set_property(ctx, YACA_PROPERTY_CCM_AAD, aad, aad_size) != YACA_ERROR_NONE)
                        goto exit;
 
                if (yaca_get_block_length(ctx, &block_len) != YACA_ERROR_NONE)
@@ -252,35 +252,35 @@ void encrypt_decrypt_aes_ccm(void)
                        goto exit;
 
                rem = enc_size - out_size;
-               if (yaca_encrypt_final(ctx, enc + out_size, &rem) != YACA_ERROR_NONE)
+               if (yaca_encrypt_finalize(ctx, enc + out_size, &rem) != YACA_ERROR_NONE)
                        goto exit;
 
                enc_size = rem + out_size;
 
                /* Get the tag after final encryption */
-               if (yaca_ctx_get_param(ctx, YACA_PARAM_CCM_TAG, (void**)tag, &tag_size) != YACA_ERROR_NONE)
+               if (yaca_context_get_property(ctx, YACA_PROPERTY_CCM_TAG, (void**)tag, &tag_size) != YACA_ERROR_NONE)
                        goto exit;
 
                dump_hex(enc, 16, "Encrypted data (16 of %zu bytes): ", enc_size);
 
-               yaca_ctx_free(ctx);
-               ctx = YACA_CTX_NULL;
+               yaca_context_destroy(ctx);
+               ctx = YACA_CONTEXT_NULL;
        }
 
        /* Decryption */
        {
-               if (yaca_decrypt_init(&ctx, algo, bcm, key, iv) != YACA_ERROR_NONE)
+               if (yaca_decrypt_initialize(&ctx, algo, bcm, key, iv) != YACA_ERROR_NONE)
                        goto exit;
 
                /* Set expected tag value */
-               if (yaca_ctx_set_param(ctx, YACA_PARAM_CCM_TAG, tag, tag_size) != YACA_ERROR_NONE)
+               if (yaca_context_set_property(ctx, YACA_PROPERTY_CCM_TAG, tag, tag_size) != YACA_ERROR_NONE)
                        goto exit;
 
                /* The total encrypted text length must be passed (only needed if AAD is passed) */
                if (yaca_decrypt_update(ctx, NULL, enc_size , NULL, &len) != YACA_ERROR_NONE)
                        goto exit;
 
-               if (yaca_ctx_set_param(ctx, YACA_PARAM_CCM_AAD, aad, aad_size) != YACA_ERROR_NONE)
+               if (yaca_context_set_property(ctx, YACA_PROPERTY_CCM_AAD, aad, aad_size) != YACA_ERROR_NONE)
                        goto exit;
 
                if (yaca_get_block_length(ctx, &block_len) != YACA_ERROR_NONE)
@@ -296,7 +296,7 @@ void encrypt_decrypt_aes_ccm(void)
 
                out_size = dec_size;
                /* The tag verify is performed when you call the final yaca_decrypt_update(),
-                * there is no call to yaca_decrypt_final() */
+                * there is no call to yaca_decrypt_finalize() */
                if (yaca_decrypt_update(ctx, enc, enc_size, dec, &out_size) != YACA_ERROR_NONE)
                        goto exit;
 
@@ -310,22 +310,22 @@ exit:
        yaca_free(dec);
        yaca_free(tag);
        yaca_free(aad);
-       yaca_ctx_free(ctx);
-       yaca_key_free(iv);
-       yaca_key_free(key);
+       yaca_context_destroy(ctx);
+       yaca_key_destroy(iv);
+       yaca_key_destroy(key);
 }
 
 int main()
 {
        yaca_debug_set_error_cb(debug_func);
 
-       int ret = yaca_init();
+       int ret = yaca_initialize();
        if (ret != YACA_ERROR_NONE)
                return ret;
 
        encrypt_decrypt_aes_gcm();
        encrypt_decrypt_aes_ccm();
 
-       yaca_exit();
+       yaca_cleanup();
        return ret;
 }
index 7a3ee5c..4f93eff 100644 (file)
@@ -46,7 +46,7 @@ void key_exchange_dh(void)
        long size;
 
        // generate  private, public key
-       ret = yaca_key_gen(YACA_KEY_TYPE_DH_PRIV, YACA_KEY_2048BIT, &private_key);
+       ret = yaca_key_generate(YACA_KEY_TYPE_DH_PRIV, YACA_KEY_LENGTH_2048BIT, &private_key);
        if (ret != YACA_ERROR_NONE)
                goto exit;
 
@@ -82,10 +82,10 @@ void key_exchange_dh(void)
                goto exit;
 
 exit:
-       yaca_key_free(private_key);
-       yaca_key_free(public_key);
-       yaca_key_free(peer_key);
-       yaca_key_free(secret);
+       yaca_key_destroy(private_key);
+       yaca_key_destroy(public_key);
+       yaca_key_destroy(peer_key);
+       yaca_key_destroy(secret);
        if (fp != NULL)
                fclose(fp);
        yaca_free(buffer);
@@ -108,7 +108,7 @@ void key_exchange_ecdh(void)
        long size;
 
        // generate  private, public key
-       ret = yaca_key_gen(YACA_KEY_TYPE_EC_PRIV, YACA_KEY_CURVE_P256, &private_key);
+       ret = yaca_key_generate(YACA_KEY_TYPE_EC_PRIV, YACA_KEY_CURVE_P256, &private_key);
        if (ret != YACA_ERROR_NONE)
                goto exit;
 
@@ -143,10 +143,10 @@ void key_exchange_ecdh(void)
                goto exit;
 
 exit:
-       yaca_key_free(private_key);
-       yaca_key_free(public_key);
-       yaca_key_free(peer_key);
-       yaca_key_free(secret);
+       yaca_key_destroy(private_key);
+       yaca_key_destroy(public_key);
+       yaca_key_destroy(peer_key);
+       yaca_key_destroy(secret);
        if (fp != NULL)
                fclose(fp);
        yaca_free(buffer);
@@ -157,13 +157,13 @@ int main()
 {
        yaca_debug_set_error_cb(debug_func);
 
-       int ret = yaca_init();
+       int ret = yaca_initialize();
        if (ret != YACA_ERROR_NONE)
                return ret;
 
        key_exchange_dh();
        key_exchange_ecdh();
 
-       yaca_exit();
+       yaca_cleanup();
        return ret;
 }
index 077657c..9b29011 100644 (file)
@@ -83,8 +83,8 @@ int key_import_export_sym(yaca_key_h sym)
        dump_hex(raw, raw_len, "\t***** RAW imported key: *****");
 
 exit:
-       yaca_key_free(raw_imported);
-       yaca_key_free(b64_imported);
+       yaca_key_destroy(raw_imported);
+       yaca_key_destroy(b64_imported);
        yaca_free(raw);
        yaca_free(b64);
 
@@ -193,10 +193,10 @@ int key_import_export_asym(yaca_key_h priv, yaca_key_h pub,
        dump_hex(der_pub, der_pub_len, "\t***** %s DER imported public key: *****", algo);
 
 exit:
-       yaca_key_free(der_pub_imported);
-       yaca_key_free(pem_pub_imported);
-       yaca_key_free(der_prv_imported);
-       yaca_key_free(pem_prv_imported);
+       yaca_key_destroy(der_pub_imported);
+       yaca_key_destroy(pem_pub_imported);
+       yaca_key_destroy(der_prv_imported);
+       yaca_key_destroy(pem_prv_imported);
        yaca_free(der_pub);
        yaca_free(pem_pub);
        yaca_free(der_prv);
@@ -234,7 +234,7 @@ int key_import_x509(void)
        printf("\n\t***** RSA X509 imported public key: *****\n%.*s", (int)pub_len, pub);
 
 exit:
-       yaca_key_free(rsa_pub_from_cert);
+       yaca_key_destroy(rsa_pub_from_cert);
        yaca_free(pub);
 
        return ret;
@@ -249,17 +249,17 @@ int main()
        yaca_key_h dsa_pub = YACA_KEY_NULL;
        int ret;
 
-       ret = yaca_init();
+       ret = yaca_initialize();
        if (ret != YACA_ERROR_NONE)
                return ret;
 
        yaca_debug_set_error_cb(debug_func);
 
-       ret = yaca_key_gen(YACA_KEY_TYPE_SYMMETRIC, YACA_KEY_1024BIT, &sym);
+       ret = yaca_key_generate(YACA_KEY_TYPE_SYMMETRIC, YACA_KEY_LENGTH_1024BIT, &sym);
        if (ret != YACA_ERROR_NONE)
                goto exit;
 
-       ret = yaca_key_gen(YACA_KEY_TYPE_RSA_PRIV, YACA_KEY_1024BIT, &rsa_priv);
+       ret = yaca_key_generate(YACA_KEY_TYPE_RSA_PRIV, YACA_KEY_LENGTH_1024BIT, &rsa_priv);
        if (ret != YACA_ERROR_NONE)
                goto exit;
 
@@ -267,7 +267,7 @@ int main()
        if (ret != YACA_ERROR_NONE)
                goto exit;
 
-       ret = yaca_key_gen(YACA_KEY_TYPE_DSA_PRIV, YACA_KEY_1024BIT, &dsa_priv);
+       ret = yaca_key_generate(YACA_KEY_TYPE_DSA_PRIV, YACA_KEY_LENGTH_1024BIT, &dsa_priv);
        if (ret != YACA_ERROR_NONE)
                goto exit;
 
@@ -312,13 +312,13 @@ int main()
                printf("\n\t*********** X509 - failure ************\n\n");
 
 exit:
-       yaca_key_free(dsa_pub);
-       yaca_key_free(dsa_priv);
-       yaca_key_free(rsa_pub);
-       yaca_key_free(rsa_priv);
-       yaca_key_free(sym);
+       yaca_key_destroy(dsa_pub);
+       yaca_key_destroy(dsa_priv);
+       yaca_key_destroy(rsa_pub);
+       yaca_key_destroy(rsa_priv);
+       yaca_key_destroy(sym);
 
-       yaca_exit();
+       yaca_cleanup();
 
        return ret;
 }
index 133ee75..829797c 100644 (file)
@@ -25,7 +25,7 @@
 #include "misc.h"
 #include "../src/debug.h"
 
-void example_password(const yaca_key_h key, yaca_key_fmt_e key_fmt)
+void example_password(const yaca_key_h key, yaca_key_format_e key_fmt)
 {
        char *k = NULL;
        size_t kl;
@@ -45,13 +45,13 @@ void example_password(const yaca_key_h key, yaca_key_fmt_e key_fmt)
        password = NULL;
 
        ret = yaca_key_import(YACA_KEY_TYPE_RSA_PRIV, NULL, k, kl, &lkey);
-       if (ret == YACA_ERROR_PASSWORD_INVALID) {
+       if (ret == YACA_ERROR_INVALID_PASSWORD) {
                ret = read_stdin_line("decryption pass: ", &password);
                if (ret != YACA_ERROR_NONE)
                        goto exit;
 
                ret = yaca_key_import(YACA_KEY_TYPE_RSA_PRIV, password, k, kl, &lkey);
-               if (ret == YACA_ERROR_PASSWORD_INVALID)
+               if (ret == YACA_ERROR_INVALID_PASSWORD)
                        printf("invalid password\n");
 
                yaca_free(password);
@@ -73,7 +73,7 @@ void example_password(const yaca_key_h key, yaca_key_fmt_e key_fmt)
 exit:
        yaca_free(k);
        yaca_free(password);
-       yaca_key_free(lkey);
+       yaca_key_destroy(lkey);
 }
 
 int main(int argc, char *argv[])
@@ -83,11 +83,11 @@ int main(int argc, char *argv[])
 
        yaca_debug_set_error_cb(debug_func);
 
-       ret = yaca_init();
+       ret = yaca_initialize();
        if (ret != YACA_ERROR_NONE)
                goto exit;
 
-       ret = yaca_key_gen(YACA_KEY_TYPE_RSA_PRIV, YACA_KEY_1024BIT, &key);
+       ret = yaca_key_generate(YACA_KEY_TYPE_RSA_PRIV, YACA_KEY_LENGTH_1024BIT, &key);
        if (ret != YACA_ERROR_NONE)
                goto exit;
 
@@ -97,8 +97,8 @@ int main(int argc, char *argv[])
        example_password(key, YACA_KEY_FORMAT_PKCS8);
 
 exit:
-       yaca_key_free(key);
-       yaca_exit();
+       yaca_key_destroy(key);
+       yaca_cleanup();
 
        return 0;
 }
index db5ab36..c9570e2 100644 (file)
 
 void encrypt_seal(void)
 {
-       const yaca_enc_algo_e algo = YACA_ENC_AES;
+       const yaca_encrypt_algorithm_e algo = YACA_ENCRYPT_AES;
        const yaca_block_cipher_mode_e bcm = YACA_BCM_CBC;
-       const size_t key_bits = YACA_KEY_256BIT;
-       yaca_ctx_h ctx = YACA_CTX_NULL;
+       const size_t key_bits = YACA_KEY_LENGTH_256BIT;
+       yaca_context_h ctx = YACA_CONTEXT_NULL;
        yaca_key_h key_pub = YACA_KEY_NULL;
        yaca_key_h key_priv = YACA_KEY_NULL;
        yaca_key_h aes_key = YACA_KEY_NULL;
@@ -56,7 +56,7 @@ void encrypt_seal(void)
        printf("Plain data (16 of %zu bytes): %.16s\n", LOREM4096_SIZE, lorem4096);
 
        /* Generate key pair */
-       if (yaca_key_gen(YACA_KEY_TYPE_RSA_PRIV, YACA_KEY_4096BIT, &key_priv) != YACA_ERROR_NONE)
+       if (yaca_key_generate(YACA_KEY_TYPE_RSA_PRIV, YACA_KEY_LENGTH_4096BIT, &key_priv) != YACA_ERROR_NONE)
                return;
 
        if (yaca_key_extract_public(key_priv, &key_pub) != YACA_ERROR_NONE)
@@ -64,7 +64,7 @@ void encrypt_seal(void)
 
        /* Encrypt a.k.a. seal */
        {
-               if (yaca_seal_init(&ctx, key_pub, algo, bcm, key_bits, &aes_key, &iv) != YACA_ERROR_NONE)
+               if (yaca_seal_initialize(&ctx, key_pub, algo, bcm, key_bits, &aes_key, &iv) != YACA_ERROR_NONE)
                        goto exit;
 
                if (yaca_get_block_length(ctx, &block_len) != YACA_ERROR_NONE)
@@ -84,20 +84,20 @@ void encrypt_seal(void)
                        goto exit;
 
                rem = enc_size - out_size;
-               if (yaca_seal_final(ctx, enc + out_size, &rem) != YACA_ERROR_NONE)
+               if (yaca_seal_finalize(ctx, enc + out_size, &rem) != YACA_ERROR_NONE)
                        goto exit;
 
                enc_size = rem + out_size;
 
                dump_hex(enc, 16, "Encrypted data (16 of %zu bytes): ", enc_size);
 
-               yaca_ctx_free(ctx);
-               ctx = YACA_CTX_NULL;
+               yaca_context_destroy(ctx);
+               ctx = YACA_CONTEXT_NULL;
        }
 
        /* Decrypt a.k.a. open */
        {
-               if (yaca_open_init(&ctx, key_priv, algo, bcm, key_bits, aes_key, iv) != YACA_ERROR_NONE)
+               if (yaca_open_initialize(&ctx, key_priv, algo, bcm, key_bits, aes_key, iv) != YACA_ERROR_NONE)
                        goto exit;
 
                if (yaca_get_block_length(ctx, &block_len) != YACA_ERROR_NONE)
@@ -117,7 +117,7 @@ void encrypt_seal(void)
                        goto exit;
 
                rem = dec_size - out_size;
-               if (yaca_open_final(ctx, dec + out_size, &rem) != YACA_ERROR_NONE)
+               if (yaca_open_finalize(ctx, dec + out_size, &rem) != YACA_ERROR_NONE)
                        goto exit;
 
                dec_size = rem + out_size;
@@ -128,23 +128,23 @@ void encrypt_seal(void)
 exit:
        yaca_free(dec);
        yaca_free(enc);
-       yaca_ctx_free(ctx);
-       yaca_key_free(aes_key);
-       yaca_key_free(iv);
-       yaca_key_free(key_pub);
-       yaca_key_free(key_priv);
+       yaca_context_destroy(ctx);
+       yaca_key_destroy(aes_key);
+       yaca_key_destroy(iv);
+       yaca_key_destroy(key_pub);
+       yaca_key_destroy(key_priv);
 }
 
 int main()
 {
        yaca_debug_set_error_cb(debug_func);
 
-       int ret = yaca_init();
+       int ret = yaca_initialize();
        if (ret != YACA_ERROR_NONE)
                return ret;
 
        encrypt_seal();
 
-       yaca_exit();
+       yaca_cleanup();
        return ret;
 }
index e4c2a6f..fa5eac5 100644 (file)
@@ -43,14 +43,14 @@ void simple_sign_verify_asym(yaca_key_type_e type, const char *algo)
        yaca_key_h pub = YACA_KEY_NULL;
 
        // GENERATE
-       if (yaca_key_gen(type, YACA_KEY_1024BIT, &prv) != YACA_ERROR_NONE)
+       if (yaca_key_generate(type, YACA_KEY_LENGTH_1024BIT, &prv) != YACA_ERROR_NONE)
                return;
 
        if (yaca_key_extract_public(prv, &pub) != YACA_ERROR_NONE)
                goto exit;
 
        // SIGN
-       if (yaca_sign(YACA_DIGEST_SHA512,
+       if (yaca_simple_calculate_signature(YACA_DIGEST_SHA512,
                      prv,
                      lorem4096,
                      LOREM4096_SIZE,
@@ -61,7 +61,7 @@ void simple_sign_verify_asym(yaca_key_type_e type, const char *algo)
        dump_hex(signature, signature_len, "[Simple API] %s Signature of lorem4096:", algo);
 
        // VERIFY
-       if (yaca_verify(YACA_DIGEST_SHA512,
+       if (yaca_simple_verify_signature(YACA_DIGEST_SHA512,
                        pub,
                        lorem4096,
                        LOREM4096_SIZE,
@@ -73,8 +73,8 @@ void simple_sign_verify_asym(yaca_key_type_e type, const char *algo)
 
 exit:
        yaca_free(signature);
-       yaca_key_free(prv);
-       yaca_key_free(pub);
+       yaca_key_destroy(prv);
+       yaca_key_destroy(pub);
 }
 
 void simple_sign_verify_hmac(void)
@@ -86,11 +86,11 @@ void simple_sign_verify_hmac(void)
        yaca_key_h key = YACA_KEY_NULL;
 
        // GENERATE
-       if (yaca_key_gen(YACA_KEY_TYPE_SYMMETRIC, YACA_KEY_256BIT, &key) != YACA_ERROR_NONE)
+       if (yaca_key_generate(YACA_KEY_TYPE_SYMMETRIC, YACA_KEY_LENGTH_256BIT, &key) != YACA_ERROR_NONE)
                return;
 
        // SIGN
-       if (yaca_hmac(YACA_DIGEST_SHA512,
+       if (yaca_simple_calculate_hmac(YACA_DIGEST_SHA512,
                      key,
                      lorem4096,
                      LOREM4096_SIZE,
@@ -101,7 +101,7 @@ void simple_sign_verify_hmac(void)
        dump_hex(signature1, signature_len, "[Simple API] HMAC Signature of lorem4096:");
 
        // VERIFY
-       if (yaca_hmac(YACA_DIGEST_SHA512,
+       if (yaca_simple_calculate_hmac(YACA_DIGEST_SHA512,
                      key,
                      lorem4096,
                      LOREM4096_SIZE,
@@ -117,7 +117,7 @@ void simple_sign_verify_hmac(void)
 exit:
        yaca_free(signature1);
        yaca_free(signature2);
-       yaca_key_free(key);
+       yaca_key_destroy(key);
 }
 
 void simple_sign_verify_cmac(void)
@@ -129,11 +129,11 @@ void simple_sign_verify_cmac(void)
        yaca_key_h key = YACA_KEY_NULL;
 
        // GENERATE
-       if (yaca_key_gen(YACA_KEY_TYPE_SYMMETRIC, YACA_KEY_256BIT, &key))
+       if (yaca_key_generate(YACA_KEY_TYPE_SYMMETRIC, YACA_KEY_LENGTH_256BIT, &key))
                return;
 
        // SIGN
-       if (yaca_cmac(YACA_ENC_AES,
+       if (yaca_simple_calculate_cmac(YACA_ENCRYPT_AES,
                      key,
                      lorem4096,
                      LOREM4096_SIZE,
@@ -145,7 +145,7 @@ void simple_sign_verify_cmac(void)
 
 
        // VERIFY
-       if (yaca_cmac(YACA_ENC_AES,
+       if (yaca_simple_calculate_cmac(YACA_ENCRYPT_AES,
                      key,
                      lorem4096,
                      LOREM4096_SIZE,
@@ -161,7 +161,7 @@ void simple_sign_verify_cmac(void)
 exit:
        yaca_free(signature1);
        yaca_free(signature2);
-       yaca_key_free(key);
+       yaca_key_destroy(key);
 }
 
 // Signature creation and verification using advanced API
@@ -170,23 +170,23 @@ void sign_verify_asym(yaca_key_type_e type, const char *algo)
        char *signature = NULL;
        size_t signature_len;
 
-       yaca_ctx_h ctx = YACA_CTX_NULL;
+       yaca_context_h ctx = YACA_CONTEXT_NULL;
        yaca_key_h prv = YACA_KEY_NULL;
        yaca_key_h pub = YACA_KEY_NULL;
        yaca_padding_e padding = YACA_PADDING_PKCS1_PSS;
 
        // GENERATE
-       if (yaca_key_gen(type, YACA_KEY_1024BIT, &prv) != YACA_ERROR_NONE)
+       if (yaca_key_generate(type, YACA_KEY_LENGTH_1024BIT, &prv) != YACA_ERROR_NONE)
                return;
 
        if (yaca_key_extract_public(prv, &pub) != YACA_ERROR_NONE)
                goto exit;
 
        // SIGN
-       if (yaca_sign_init(&ctx, YACA_DIGEST_SHA512, prv) != YACA_ERROR_NONE)
+       if (yaca_sign_initialize(&ctx, YACA_DIGEST_SHA512, prv) != YACA_ERROR_NONE)
                goto exit;
 
-       if (yaca_ctx_set_param(ctx, YACA_PARAM_PADDING, (char*)(&padding), sizeof(padding)) != YACA_ERROR_NONE)
+       if (yaca_context_set_property(ctx, YACA_PROPERTY_PADDING, (char*)(&padding), sizeof(padding)) != YACA_ERROR_NONE)
                goto exit;
 
        if (yaca_sign_update(ctx, lorem4096, LOREM4096_SIZE) != YACA_ERROR_NONE)
@@ -198,35 +198,35 @@ void sign_verify_asym(yaca_key_type_e type, const char *algo)
        if (yaca_malloc(signature_len, (void**)&signature) != YACA_ERROR_NONE)
                goto exit;
 
-       if (yaca_sign_final(ctx, signature, &signature_len) != YACA_ERROR_NONE)
+       if (yaca_sign_finalize(ctx, signature, &signature_len) != YACA_ERROR_NONE)
                goto exit;
 
        dump_hex(signature, signature_len, "[Advanced API] %s Signature of lorem4096:", algo);
 
        // CLEANUP
-       yaca_ctx_free(ctx);
-       ctx = YACA_CTX_NULL;
+       yaca_context_destroy(ctx);
+       ctx = YACA_CONTEXT_NULL;
 
        // VERIFY
-       if (yaca_verify_init(&ctx, YACA_DIGEST_SHA512, pub) != YACA_ERROR_NONE)
+       if (yaca_verify_initialize(&ctx, YACA_DIGEST_SHA512, pub) != YACA_ERROR_NONE)
                goto exit;
 
-       if (yaca_ctx_set_param(ctx, YACA_PARAM_PADDING, (char*)(&padding), sizeof(padding)) != YACA_ERROR_NONE)
+       if (yaca_context_set_property(ctx, YACA_PROPERTY_PADDING, (char*)(&padding), sizeof(padding)) != YACA_ERROR_NONE)
                goto exit;
 
        if (yaca_verify_update(ctx, lorem4096, LOREM4096_SIZE) != YACA_ERROR_NONE)
                goto exit;
 
-       if (yaca_verify_final(ctx, signature, signature_len) != YACA_ERROR_NONE)
+       if (yaca_verify_finalize(ctx, signature, signature_len) != YACA_ERROR_NONE)
                printf("[Advanced API] %s verification failed\n", algo);
        else
                printf("[Advanced API] %s verification successful\n", algo);
 
 exit:
        yaca_free(signature);
-       yaca_key_free(prv);
-       yaca_key_free(pub);
-       yaca_ctx_free(ctx);
+       yaca_key_destroy(prv);
+       yaca_key_destroy(pub);
+       yaca_context_destroy(ctx);
 }
 
 void sign_verify_hmac(void)
@@ -235,15 +235,15 @@ void sign_verify_hmac(void)
        char *signature2 = NULL;
        size_t signature_len;
 
-       yaca_ctx_h ctx = YACA_CTX_NULL;
+       yaca_context_h ctx = YACA_CONTEXT_NULL;
        yaca_key_h key = YACA_KEY_NULL;
 
        // GENERATE
-       if (yaca_key_gen(YACA_KEY_TYPE_SYMMETRIC, YACA_KEY_256BIT, &key) != YACA_ERROR_NONE)
+       if (yaca_key_generate(YACA_KEY_TYPE_SYMMETRIC, YACA_KEY_LENGTH_256BIT, &key) != YACA_ERROR_NONE)
                return;
 
        // SIGN
-       if (yaca_sign_hmac_init(&ctx, YACA_DIGEST_SHA512, key) != YACA_ERROR_NONE)
+       if (yaca_sign_initialize_hmac(&ctx, YACA_DIGEST_SHA512, key) != YACA_ERROR_NONE)
                goto exit;
 
        if (yaca_sign_update(ctx, lorem4096, LOREM4096_SIZE) != YACA_ERROR_NONE)
@@ -255,17 +255,17 @@ void sign_verify_hmac(void)
        if (yaca_malloc(signature_len, (void**)&signature1) != YACA_ERROR_NONE)
                goto exit;
 
-       if (yaca_sign_final(ctx, signature1, &signature_len) != YACA_ERROR_NONE)
+       if (yaca_sign_finalize(ctx, signature1, &signature_len) != YACA_ERROR_NONE)
                goto exit;
 
        dump_hex(signature1, signature_len, "[Advanced API] HMAC Signature of lorem4096:");
 
        // CLEANUP
-       yaca_ctx_free(ctx);
-       ctx = YACA_CTX_NULL;
+       yaca_context_destroy(ctx);
+       ctx = YACA_CONTEXT_NULL;
 
        // VERIFY
-       if (yaca_sign_hmac_init(&ctx, YACA_DIGEST_SHA512, key) != YACA_ERROR_NONE)
+       if (yaca_sign_initialize_hmac(&ctx, YACA_DIGEST_SHA512, key) != YACA_ERROR_NONE)
                goto exit;
 
        if (yaca_sign_update(ctx, lorem4096, LOREM4096_SIZE) != YACA_ERROR_NONE)
@@ -277,7 +277,7 @@ void sign_verify_hmac(void)
        if (yaca_malloc(signature_len, (void**)&signature2) != YACA_ERROR_NONE)
                goto exit;
 
-       if (yaca_sign_final(ctx, signature2, &signature_len) != YACA_ERROR_NONE)
+       if (yaca_sign_finalize(ctx, signature2, &signature_len) != YACA_ERROR_NONE)
                goto exit;
 
        if (yaca_memcmp(signature1, signature2, signature_len) != YACA_ERROR_NONE)
@@ -288,8 +288,8 @@ void sign_verify_hmac(void)
 exit:
        yaca_free(signature1);
        yaca_free(signature2);
-       yaca_key_free(key);
-       yaca_ctx_free(ctx);
+       yaca_key_destroy(key);
+       yaca_context_destroy(ctx);
 }
 
 void sign_verify_cmac(void)
@@ -298,15 +298,15 @@ void sign_verify_cmac(void)
        char *signature2 = NULL;
        size_t signature_len;
 
-       yaca_ctx_h ctx = YACA_CTX_NULL;
+       yaca_context_h ctx = YACA_CONTEXT_NULL;
        yaca_key_h key = YACA_KEY_NULL;
 
        // GENERATE
-       if (yaca_key_gen(YACA_KEY_TYPE_SYMMETRIC, YACA_KEY_256BIT, &key))
+       if (yaca_key_generate(YACA_KEY_TYPE_SYMMETRIC, YACA_KEY_LENGTH_256BIT, &key))
                return;
 
        // SIGN
-       if (yaca_sign_cmac_init(&ctx, YACA_ENC_AES, key) != YACA_ERROR_NONE)
+       if (yaca_sign_initialize_cmac(&ctx, YACA_ENCRYPT_AES, key) != YACA_ERROR_NONE)
                goto exit;
 
        if (yaca_sign_update(ctx, lorem4096, LOREM4096_SIZE))
@@ -318,17 +318,17 @@ void sign_verify_cmac(void)
        if (yaca_malloc(signature_len, (void**)&signature1) != YACA_ERROR_NONE)
                goto exit;
 
-       if (yaca_sign_final(ctx, signature1, &signature_len))
+       if (yaca_sign_finalize(ctx, signature1, &signature_len))
                goto exit;
 
        dump_hex(signature1, signature_len, "[Advanced API] CMAC Signature of lorem4096:");
 
        // CLEANUP
-       yaca_ctx_free(ctx);
-       ctx = YACA_CTX_NULL;
+       yaca_context_destroy(ctx);
+       ctx = YACA_CONTEXT_NULL;
 
        // VERIFY
-       if (yaca_sign_cmac_init(&ctx, YACA_ENC_AES, key) != YACA_ERROR_NONE)
+       if (yaca_sign_initialize_cmac(&ctx, YACA_ENCRYPT_AES, key) != YACA_ERROR_NONE)
                goto exit;
 
        if (yaca_sign_update(ctx, lorem4096, LOREM4096_SIZE))
@@ -340,7 +340,7 @@ void sign_verify_cmac(void)
        if (yaca_malloc(signature_len, (void**)&signature2) != YACA_ERROR_NONE)
                goto exit;
 
-       if (yaca_sign_final(ctx, signature2, &signature_len))
+       if (yaca_sign_finalize(ctx, signature2, &signature_len))
                goto exit;
 
        if (yaca_memcmp(signature1, signature2, signature_len) != YACA_ERROR_NONE)
@@ -351,15 +351,15 @@ void sign_verify_cmac(void)
 exit:
        yaca_free(signature1);
        yaca_free(signature2);
-       yaca_key_free(key);
-       yaca_ctx_free(ctx);
+       yaca_key_destroy(key);
+       yaca_context_destroy(ctx);
 }
 
 int main()
 {
        yaca_debug_set_error_cb(debug_func);
 
-       int ret = yaca_init();
+       int ret = yaca_initialize();
        if (ret != YACA_ERROR_NONE)
                return ret;
 
@@ -373,6 +373,6 @@ int main()
        sign_verify_hmac();
        sign_verify_cmac();
 
-       yaca_exit();
+       yaca_cleanup();
        return ret;
 }
index b2649d3..8b4c174 100644 (file)
@@ -68,7 +68,7 @@ static void destroy_mutexes(int count)
        }
 }
 
-API int yaca_init(void)
+API int yaca_initialize(void)
 {
        int ret;
        if (mutexes != NULL)
@@ -133,7 +133,7 @@ API int yaca_init(void)
        return YACA_ERROR_NONE;
 }
 
-API int yaca_exit(void)
+API int yaca_cleanup(void)
 {
        ERR_free_strings();
        ERR_remove_thread_state(NULL);
@@ -153,7 +153,7 @@ API int yaca_exit(void)
 API int yaca_malloc(size_t size, void **memory)
 {
        if (size == 0 || memory == NULL)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        *memory = OPENSSL_malloc(size);
        if (*memory == NULL) {
@@ -178,7 +178,7 @@ API int yaca_zalloc(size_t size, void **memory)
 API int yaca_realloc(size_t size, void **memory)
 {
        if (size == 0 || memory == NULL)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        void *tmp = OPENSSL_realloc(*memory, size);
        if (tmp == NULL) {
@@ -198,12 +198,12 @@ API int yaca_free(void *ptr)
        return YACA_ERROR_NONE;
 }
 
-API int yaca_rand_bytes(char *data, size_t data_len)
+API int yaca_randomize_bytes(char *data, size_t data_len)
 {
        int ret;
 
        if (data == NULL || data_len == 0)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        ret = RAND_bytes((unsigned char *)data, data_len);
        if (ret != 1) {
@@ -215,27 +215,27 @@ API int yaca_rand_bytes(char *data, size_t data_len)
        return YACA_ERROR_NONE;
 }
 
-API int yaca_ctx_set_param(yaca_ctx_h ctx, yaca_ex_param_e param,
-                           const void *value, size_t value_len)
+API int yaca_context_set_property(yaca_context_h ctx, yaca_property_e param,
+                                  const void *value, size_t value_len)
 {
-       if (ctx == YACA_CTX_NULL || ctx->set_param == NULL)
-               return YACA_ERROR_INVALID_ARGUMENT;
+       if (ctx == YACA_CONTEXT_NULL || ctx->set_param == NULL)
+               return YACA_ERROR_INVALID_PARAMETER;
 
        return ctx->set_param(ctx, param, value, value_len);
 }
 
-API int yaca_ctx_get_param(const yaca_ctx_h ctx, yaca_ex_param_e param,
-                           void **value, size_t *value_len)
+API int yaca_context_get_property(const yaca_context_h ctx, yaca_property_e param,
+                                  void **value, size_t *value_len)
 {
-       if (ctx == YACA_CTX_NULL || ctx->get_param == NULL)
-               return YACA_ERROR_INVALID_ARGUMENT;
+       if (ctx == YACA_CONTEXT_NULL || ctx->get_param == NULL)
+               return YACA_ERROR_INVALID_PARAMETER;
 
        return ctx->get_param(ctx, param, value, value_len);
 }
 
-API int yaca_ctx_free(yaca_ctx_h ctx)
+API int yaca_context_destroy(yaca_context_h ctx)
 {
-       if (ctx != YACA_CTX_NULL) {
+       if (ctx != YACA_CONTEXT_NULL) {
                assert(ctx->ctx_destroy != NULL);
                ctx->ctx_destroy(ctx);
                yaca_free(ctx);
@@ -244,10 +244,10 @@ API int yaca_ctx_free(yaca_ctx_h ctx)
        return YACA_ERROR_NONE;
 }
 
-API int yaca_get_output_length(const yaca_ctx_h ctx, size_t input_len, size_t *output_len)
+API int yaca_get_output_length(const yaca_context_h ctx, size_t input_len, size_t *output_len)
 {
-       if (ctx == YACA_CTX_NULL)
-               return YACA_ERROR_INVALID_ARGUMENT;
+       if (ctx == YACA_CONTEXT_NULL)
+               return YACA_ERROR_INVALID_PARAMETER;
 
        return ctx->get_output_length(ctx, input_len, output_len);
 }
index 5a23f83..306f7cd 100644 (file)
@@ -46,16 +46,16 @@ char *error_translate(yaca_error_e err)
        switch (err) {
        case YACA_ERROR_NONE:
                return "YACA_ERROR_NONE";
-       case YACA_ERROR_INVALID_ARGUMENT:
-               return "YACA_ERROR_INVALID_ARGUMENT";
+       case YACA_ERROR_INVALID_PARAMETER:
+               return "YACA_ERROR_INVALID_PARAMETER";
        case YACA_ERROR_OUT_OF_MEMORY:
                return "YACA_ERROR_OUT_OF_MEMORY";
        case YACA_ERROR_INTERNAL:
                return "YACA_ERROR_INTERNAL";
        case YACA_ERROR_DATA_MISMATCH:
                return "YACA_ERROR_DATA_MISMATCH";
-       case YACA_ERROR_PASSWORD_INVALID:
-               return "YACA_ERROR_PASSWORD_INVALID";
+       case YACA_ERROR_INVALID_PASSWORD:
+               return "YACA_ERROR_INVALID_PASSWORD";
        default:
                return NULL;
        }
@@ -125,7 +125,7 @@ int error_handle(const char *file, int line, const char *function)
                        break;
                case ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED:
                case ERR_R_PASSED_NULL_PARAMETER:
-                       ret = YACA_ERROR_INVALID_ARGUMENT;
+                       ret = YACA_ERROR_INVALID_PARAMETER;
                        break;
                case ERR_R_INTERNAL_ERROR:
                case ERR_R_DISABLED:
@@ -138,11 +138,11 @@ int error_handle(const char *file, int line, const char *function)
                switch (err) {
                case ERR_PACK(ERR_LIB_RSA, RSA_F_PKEY_RSA_CTRL, RSA_R_INVALID_KEYBITS):
                case ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_PKEY_CTX_CTRL, EVP_R_COMMAND_NOT_SUPPORTED):
-                       ret = YACA_ERROR_INVALID_ARGUMENT;
+                       ret = YACA_ERROR_INVALID_PARAMETER;
                        break;
                case ERR_PACK(ERR_LIB_PEM, PEM_F_PEM_DO_HEADER, PEM_R_BAD_DECRYPT):
                case ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_DECRYPTFINAL_EX, EVP_R_BAD_DECRYPT):
-                       ret = YACA_ERROR_PASSWORD_INVALID;
+                       ret = YACA_ERROR_INVALID_PASSWORD;
                        break;
                default:
                        error_dump(file, line, function, YACA_ERROR_INTERNAL);
index 7b20409..d5d7278 100644 (file)
 #include "internal.h"
 
 struct yaca_digest_ctx_s {
-       struct yaca_ctx_s ctx;
+       struct yaca_context_s ctx;
 
        EVP_MD_CTX *mdctx;
 };
 
-static struct yaca_digest_ctx_s *get_digest_ctx(const yaca_ctx_h ctx)
+static struct yaca_digest_ctx_s *get_digest_ctx(const yaca_context_h ctx)
 {
-       if (ctx == YACA_CTX_NULL)
+       if (ctx == YACA_CONTEXT_NULL)
                return NULL;
 
        switch (ctx->type) {
@@ -50,12 +50,12 @@ static struct yaca_digest_ctx_s *get_digest_ctx(const yaca_ctx_h ctx)
        }
 }
 
-static int get_digest_output_length(const yaca_ctx_h ctx, size_t input_len, size_t *output_len)
+static int get_digest_output_length(const yaca_context_h ctx, size_t input_len, size_t *output_len)
 {
        struct yaca_digest_ctx_s *c = get_digest_ctx(ctx);
 
        if (c == NULL)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        int md_size = EVP_MD_CTX_size(c->mdctx);
        if (md_size <= 0)
@@ -66,7 +66,7 @@ static int get_digest_output_length(const yaca_ctx_h ctx, size_t input_len, size
        return YACA_ERROR_NONE;
 }
 
-static void destroy_digest_context(yaca_ctx_h ctx)
+static void destroy_digest_context(yaca_context_h ctx)
 {
        struct yaca_digest_ctx_s *c = get_digest_ctx(ctx);
 
@@ -77,12 +77,12 @@ static void destroy_digest_context(yaca_ctx_h ctx)
        c->mdctx = NULL;
 }
 
-int digest_get_algorithm(yaca_digest_algo_e algo, const EVP_MD **md)
+int digest_get_algorithm(yaca_digest_algorithm_e algo, const EVP_MD **md)
 {
        int ret = YACA_ERROR_NONE;
 
        if (!md)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        *md = NULL;
 
@@ -106,7 +106,7 @@ int digest_get_algorithm(yaca_digest_algo_e algo, const EVP_MD **md)
                *md = EVP_sha512();
                break;
        default:
-               ret = YACA_ERROR_INVALID_ARGUMENT;
+               ret = YACA_ERROR_INVALID_PARAMETER;
                break;
        }
 
@@ -118,14 +118,14 @@ int digest_get_algorithm(yaca_digest_algo_e algo, const EVP_MD **md)
        return ret;
 }
 
-API int yaca_digest_init(yaca_ctx_h *ctx, yaca_digest_algo_e algo)
+API int yaca_digest_initialize(yaca_context_h *ctx, yaca_digest_algorithm_e algo)
 {
        int ret;
        struct yaca_digest_ctx_s *nc = NULL;
        const EVP_MD *md;
 
        if (ctx == NULL)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        ret = yaca_zalloc(sizeof(struct yaca_digest_ctx_s), (void**)&nc);
        if (ret != YACA_ERROR_NONE)
@@ -153,23 +153,23 @@ API int yaca_digest_init(yaca_ctx_h *ctx, yaca_digest_algo_e algo)
                goto exit;
        }
 
-       *ctx = (yaca_ctx_h)nc;
+       *ctx = (yaca_context_h)nc;
        nc = NULL;
        ret = YACA_ERROR_NONE;
 
 exit:
-       yaca_ctx_free((yaca_ctx_h)nc);
+       yaca_context_destroy((yaca_context_h)nc);
 
        return ret;
 }
 
-API int yaca_digest_update(yaca_ctx_h ctx, const char *data, size_t data_len)
+API int yaca_digest_update(yaca_context_h ctx, const char *data, size_t data_len)
 {
        struct yaca_digest_ctx_s *c = get_digest_ctx(ctx);
        int ret;
 
        if (c == NULL || data == NULL || data_len == 0)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        ret = EVP_DigestUpdate(c->mdctx, data, data_len);
        if (ret != 1) {
@@ -181,17 +181,17 @@ API int yaca_digest_update(yaca_ctx_h ctx, const char *data, size_t data_len)
        return YACA_ERROR_NONE;
 }
 
-API int yaca_digest_final(yaca_ctx_h ctx, char *digest, size_t *digest_len)
+API int yaca_digest_finalize(yaca_context_h ctx, char *digest, size_t *digest_len)
 {
        struct yaca_digest_ctx_s *c = get_digest_ctx(ctx);
        int ret;
        unsigned len = 0;
 
        if (c == NULL || digest == NULL || digest_len == NULL)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        if (*digest_len == 0 || *digest_len > UINT_MAX) // DigestFinal accepts uint
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        ret = EVP_DigestFinal_ex(c->mdctx, (unsigned char*)digest, &len);
        if (ret != 1) {
index b4503ac..2ea785e 100644 (file)
@@ -39,16 +39,16 @@ enum encrypt_op_type {
 };
 
 struct yaca_encrypt_ctx_s {
-       struct yaca_ctx_s ctx;
+       struct yaca_context_s ctx;
 
        EVP_CIPHER_CTX *cipher_ctx;
        enum encrypt_op_type op_type; /* Operation context was created for */
        size_t tag_len;
 };
 
-static struct yaca_encrypt_ctx_s *get_encrypt_ctx(const yaca_ctx_h ctx)
+static struct yaca_encrypt_ctx_s *get_encrypt_ctx(const yaca_context_h ctx)
 {
-       if (ctx == YACA_CTX_NULL)
+       if (ctx == YACA_CONTEXT_NULL)
                return NULL;
 
        switch (ctx->type) {
@@ -59,7 +59,7 @@ static struct yaca_encrypt_ctx_s *get_encrypt_ctx(const yaca_ctx_h ctx)
        }
 }
 
-static void destroy_encrypt_ctx(const yaca_ctx_h ctx)
+static void destroy_encrypt_ctx(const yaca_context_h ctx)
 {
        struct yaca_encrypt_ctx_s *nc = get_encrypt_ctx(ctx);
 
@@ -70,13 +70,13 @@ static void destroy_encrypt_ctx(const yaca_ctx_h ctx)
        nc->cipher_ctx = NULL;
 }
 
-static int get_encrypt_output_length(const yaca_ctx_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)
 {
        struct yaca_encrypt_ctx_s *nc = get_encrypt_ctx(ctx);
        int block_size;
 
        if (nc == NULL)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
        assert(nc->cipher_ctx != NULL);
 
        block_size = EVP_CIPHER_CTX_block_size(nc->cipher_ctx);
@@ -87,7 +87,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_INVALID_ARGUMENT;
+                       return YACA_ERROR_INVALID_PARAMETER;
 
                *output_len = block_size + input_len - 1;
        } else {
@@ -99,8 +99,8 @@ static int get_encrypt_output_length(const yaca_ctx_h ctx, size_t input_len, siz
        return YACA_ERROR_NONE;
 }
 
-static int set_encrypt_param(yaca_ctx_h ctx,
-                             yaca_ex_param_e param,
+static int set_encrypt_param(yaca_context_h ctx,
+                             yaca_property_e param,
                              const void *value,
                              size_t value_len)
 {
@@ -108,18 +108,18 @@ static int set_encrypt_param(yaca_ctx_h ctx,
        int len;
 
        if (c == NULL || value == NULL)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
        assert(c->cipher_ctx != NULL);
 
        switch (param) {
-       case YACA_PARAM_GCM_AAD:
-       case YACA_PARAM_CCM_AAD:
+       case YACA_PROPERTY_GCM_AAD:
+       case YACA_PROPERTY_CCM_AAD:
                if (EVP_EncryptUpdate(c->cipher_ctx, NULL, &len, value, value_len) != 1) {
                        ERROR_DUMP(YACA_ERROR_INTERNAL);
                        return YACA_ERROR_INTERNAL;
                }
                break;
-       case YACA_PARAM_GCM_TAG:
+       case YACA_PROPERTY_GCM_TAG:
                if (EVP_CIPHER_CTX_ctrl(c->cipher_ctx,
                                        EVP_CTRL_GCM_SET_TAG,
                                        value_len, (void*)value) != 1) {
@@ -127,10 +127,10 @@ static int set_encrypt_param(yaca_ctx_h ctx,
                        return YACA_ERROR_INTERNAL;
                }
                break;
-       case YACA_PARAM_GCM_TAG_LEN:
+       case YACA_PROPERTY_GCM_TAG_LEN:
                c->tag_len = *(int*)value;
                break;
-       case YACA_PARAM_CCM_TAG:
+       case YACA_PROPERTY_CCM_TAG:
                // TODO Rebuild context
                if (EVP_CIPHER_CTX_ctrl(c->cipher_ctx,
                                        EVP_CTRL_CCM_SET_TAG,
@@ -139,7 +139,7 @@ static int set_encrypt_param(yaca_ctx_h ctx,
                        return YACA_ERROR_INTERNAL;
                }
                break;
-       case YACA_PARAM_CCM_TAG_LEN:
+       case YACA_PROPERTY_CCM_TAG_LEN:
                //TODO Rebuild context
                if (EVP_CIPHER_CTX_ctrl(c->cipher_ctx,
                                        EVP_CTRL_CCM_SET_TAG,
@@ -150,26 +150,26 @@ static int set_encrypt_param(yaca_ctx_h ctx,
                c->tag_len = *(int*)value;
                break;
        default:
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
        }
        return YACA_ERROR_NONE;
 }
 
-static int get_encrypt_param(const yaca_ctx_h ctx,
-                             yaca_ex_param_e param,
+static int get_encrypt_param(const yaca_context_h ctx,
+                             yaca_property_e param,
                              void **value,
                              size_t *value_len)
 {
        struct yaca_encrypt_ctx_s *c = get_encrypt_ctx(ctx);
 
        if (c == NULL || value == NULL || value_len == NULL)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
        assert(c->cipher_ctx != NULL);
 
        switch (param) {
-       case YACA_PARAM_GCM_TAG:
+       case YACA_PROPERTY_GCM_TAG:
                if (c->tag_len == 0)
-                       return YACA_ERROR_INVALID_ARGUMENT;
+                       return YACA_ERROR_INVALID_PARAMETER;
 
                if (EVP_CIPHER_CTX_ctrl(c->cipher_ctx,
                                        EVP_CTRL_GCM_GET_TAG,
@@ -179,9 +179,9 @@ static int get_encrypt_param(const yaca_ctx_h ctx,
                }
                *value_len = c->tag_len;
                break;
-       case YACA_PARAM_CCM_TAG:
+       case YACA_PROPERTY_CCM_TAG:
                if (c->tag_len == 0)
-                       return YACA_ERROR_INVALID_ARGUMENT;
+                       return YACA_ERROR_INVALID_PARAMETER;
 
                if (EVP_CIPHER_CTX_ctrl(c->cipher_ctx,
                                        EVP_CTRL_CCM_GET_TAG,
@@ -192,28 +192,28 @@ static int get_encrypt_param(const yaca_ctx_h ctx,
                *value_len = c->tag_len;
                break;
        default:
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
                break;
        }
        return YACA_ERROR_NONE;
 }
 
-static const char *encrypt_algo_to_str(yaca_enc_algo_e algo)
+static const char *encrypt_algo_to_str(yaca_encrypt_algorithm_e algo)
 {
        switch (algo) {
-       case YACA_ENC_AES:
+       case YACA_ENCRYPT_AES:
                return "aes";
-       case YACA_ENC_UNSAFE_DES:
+       case YACA_ENCRYPT_UNSAFE_DES:
                return "des";
-       case YACA_ENC_UNSAFE_3DES_2TDEA:
+       case YACA_ENCRYPT_UNSAFE_3DES_2TDEA:
                return "des-ede";
-       case YACA_ENC_3DES_3TDEA:
+       case YACA_ENCRYPT_3DES_3TDEA:
                return "des-ede3";
-       case YACA_ENC_UNSAFE_RC2:
+       case YACA_ENCRYPT_UNSAFE_RC2:
                return "rc2";
-       case YACA_ENC_UNSAFE_RC4:
+       case YACA_ENCRYPT_UNSAFE_RC4:
                return "rc4";
-       case YACA_ENC_CAST5:
+       case YACA_ENCRYPT_CAST5:
                return "cast5";
        default:
                return NULL;
@@ -248,7 +248,7 @@ static const char *bcm_to_str(yaca_block_cipher_mode_e bcm)
        }
 }
 
-int encrypt_get_algorithm(yaca_enc_algo_e algo,
+int encrypt_get_algorithm(yaca_encrypt_algorithm_e algo,
                           yaca_block_cipher_mode_e bcm,
                           size_t key_bits,
                           const EVP_CIPHER **cipher)
@@ -261,38 +261,38 @@ int encrypt_get_algorithm(yaca_enc_algo_e algo,
 
        if (algo_name == NULL || bcm_name == NULL || key_bits == 0 ||
            cipher == NULL)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        switch (algo) {
-       case YACA_ENC_AES:
+       case YACA_ENCRYPT_AES:
                ret = snprintf(cipher_name, sizeof(cipher_name), "%s-%zu-%s",
                               algo_name, key_bits, bcm_name);
                break;
-       case YACA_ENC_UNSAFE_DES:
-       case YACA_ENC_UNSAFE_RC2:
-       case YACA_ENC_CAST5:
+       case YACA_ENCRYPT_UNSAFE_DES:
+       case YACA_ENCRYPT_UNSAFE_RC2:
+       case YACA_ENCRYPT_CAST5:
                ret = snprintf(cipher_name, sizeof(cipher_name), "%s-%s",
                               algo_name, bcm_name);
                break;
-       case YACA_ENC_UNSAFE_3DES_2TDEA:
-       case YACA_ENC_3DES_3TDEA:
+       case YACA_ENCRYPT_UNSAFE_3DES_2TDEA:
+       case YACA_ENCRYPT_3DES_3TDEA:
                if (bcm == YACA_BCM_ECB)
                        ret = snprintf(cipher_name, sizeof(cipher_name), "%s", algo_name);
                else
                        ret = snprintf(cipher_name, sizeof(cipher_name), "%s-%s",
                                       algo_name, bcm_name);
                break;
-       case YACA_ENC_UNSAFE_RC4:
+       case YACA_ENCRYPT_UNSAFE_RC4:
                ret = snprintf(cipher_name, sizeof(cipher_name), "%s", algo_name);
                break;
        default:
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
        }
 
        if (ret < 0)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
        if ((unsigned)ret >= sizeof(cipher_name)) // output was truncated
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        lcipher = EVP_get_cipherbyname(cipher_name);
        if (lcipher == NULL) {
@@ -305,8 +305,8 @@ int encrypt_get_algorithm(yaca_enc_algo_e algo,
        return YACA_ERROR_NONE;
 }
 
-static int encrypt_init(yaca_ctx_h *ctx,
-                        yaca_enc_algo_e algo,
+static int encrypt_init(yaca_context_h *ctx,
+                        yaca_encrypt_algorithm_e algo,
                         yaca_block_cipher_mode_e bcm,
                         const yaca_key_h sym_key,
                         const yaca_key_h iv,
@@ -323,11 +323,11 @@ static int encrypt_init(yaca_ctx_h *ctx,
        int ret;
 
        if (ctx == NULL || sym_key == YACA_KEY_NULL)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        lkey = key_get_simple(sym_key);
        if (lkey == NULL)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        ret = yaca_zalloc(sizeof(struct yaca_encrypt_ctx_s), (void**)&nc);
        if (ret != YACA_ERROR_NONE)
@@ -341,7 +341,7 @@ static int encrypt_init(yaca_ctx_h *ctx,
        nc->op_type = op_type;
        nc->tag_len = 0;
 
-       ret = yaca_key_get_bits(sym_key, &key_bits);
+       ret = yaca_key_get_bit_length(sym_key, &key_bits);
        if (ret != YACA_ERROR_NONE)
                goto exit;
 
@@ -358,26 +358,26 @@ static int encrypt_init(yaca_ctx_h *ctx,
 
        iv_bits = ret * 8;
        if (iv_bits == 0 && iv != NULL) { /* 0 -> cipher doesn't use iv, but it was provided */
-               ret = YACA_ERROR_INVALID_ARGUMENT;
+               ret = YACA_ERROR_INVALID_PARAMETER;
                goto exit;
        }
 
        if (iv_bits != 0) { /* cipher requires iv*/
                liv = key_get_simple(iv);
                if (liv == NULL) { /* iv was not provided */
-                       ret = YACA_ERROR_INVALID_ARGUMENT;
+                       ret = YACA_ERROR_INVALID_PARAMETER;
                        goto exit;
                }
-               ret = yaca_key_get_bits(iv, &iv_bits_check);
+               ret = yaca_key_get_bit_length(iv, &iv_bits_check);
                if (ret != YACA_ERROR_NONE) {
-                       ret = YACA_ERROR_INVALID_ARGUMENT;
+                       ret = YACA_ERROR_INVALID_PARAMETER;
                        goto exit;
                }
                /* IV length doesn't match cipher (GCM & CCM supports variable IV length) */
                if (iv_bits != iv_bits_check &&
                    bcm != YACA_BCM_GCM &&
                    bcm != YACA_BCM_CCM) {
-                       ret = YACA_ERROR_INVALID_ARGUMENT;
+                       ret = YACA_ERROR_INVALID_PARAMETER;
                        goto exit;
                }
                iv_data = (unsigned char*)liv->d;
@@ -398,7 +398,7 @@ static int encrypt_init(yaca_ctx_h *ctx,
                ret = EVP_DecryptInit_ex(nc->cipher_ctx, cipher, NULL, NULL, NULL);
                break;
        default:
-               ret = YACA_ERROR_INVALID_ARGUMENT;
+               ret = YACA_ERROR_INVALID_PARAMETER;
                goto exit;
        }
 
@@ -411,7 +411,7 @@ static int encrypt_init(yaca_ctx_h *ctx,
        /* Handling of algorithms with variable key length */
        ret = EVP_CIPHER_CTX_set_key_length(nc->cipher_ctx, key_bits / 8);
        if (ret != 1) {
-               ret = YACA_ERROR_INVALID_ARGUMENT;
+               ret = YACA_ERROR_INVALID_PARAMETER;
                ERROR_DUMP(ret);
                goto exit;
        }
@@ -427,7 +427,7 @@ static int encrypt_init(yaca_ctx_h *ctx,
                                                  iv_bits_check / 8, NULL);
 
                if (ret != 1) {
-                       ret = YACA_ERROR_INVALID_ARGUMENT;
+                       ret = YACA_ERROR_INVALID_PARAMETER;
                        ERROR_DUMP(ret);
                        goto exit;
                }
@@ -445,7 +445,7 @@ static int encrypt_init(yaca_ctx_h *ctx,
                                         iv_data);
                break;
        default:
-               ret = YACA_ERROR_INVALID_ARGUMENT;
+               ret = YACA_ERROR_INVALID_PARAMETER;
                goto exit;
        }
 
@@ -455,17 +455,17 @@ static int encrypt_init(yaca_ctx_h *ctx,
                goto exit;
        }
 
-       *ctx = (yaca_ctx_h)nc;
+       *ctx = (yaca_context_h)nc;
        nc = NULL;
        ret = YACA_ERROR_NONE;
 
 exit:
-       yaca_ctx_free((yaca_ctx_h)nc);
+       yaca_context_destroy((yaca_context_h)nc);
 
        return ret;
 }
 
-static int encrypt_update(yaca_ctx_h ctx,
+static int encrypt_update(yaca_context_h ctx,
                           const unsigned char *input,
                           size_t input_len,
                           unsigned char *output,
@@ -477,7 +477,7 @@ static int encrypt_update(yaca_ctx_h ctx,
        int loutput_len;
 
        if (c == NULL || input_len == 0 || output_len == NULL || op_type != c->op_type)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        loutput_len = *output_len;
 
@@ -491,7 +491,7 @@ static int encrypt_update(yaca_ctx_h ctx,
                                        input, input_len);
                break;
        default:
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
        }
 
        if (ret != 1) {
@@ -504,7 +504,7 @@ static int encrypt_update(yaca_ctx_h ctx,
        return YACA_ERROR_NONE;
 }
 
-static int encrypt_final(yaca_ctx_h ctx,
+static int encrypt_final(yaca_context_h ctx,
                          unsigned char *output,
                          size_t *output_len,
                          enum encrypt_op_type op_type)
@@ -515,7 +515,7 @@ static int encrypt_final(yaca_ctx_h ctx,
 
        if (c == NULL || output == NULL || output_len == NULL ||
            op_type != c->op_type)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        loutput_len = *output_len;
 
@@ -527,7 +527,7 @@ static int encrypt_final(yaca_ctx_h ctx,
                ret = EVP_DecryptFinal(c->cipher_ctx, output, &loutput_len);
                break;
        default:
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
        }
 
        if (ret != 1) {
@@ -540,10 +540,10 @@ static int encrypt_final(yaca_ctx_h ctx,
        return YACA_ERROR_NONE;
 }
 
-API int yaca_get_iv_bits(yaca_enc_algo_e algo,
-                         yaca_block_cipher_mode_e bcm,
-                         size_t key_bits,
-                         size_t *iv_bits)
+API int yaca_encrypt_get_iv_bit_length(yaca_encrypt_algorithm_e algo,
+                                       yaca_block_cipher_mode_e bcm,
+                                       size_t key_bits,
+                                       size_t *iv_bits)
 {
        const EVP_CIPHER *cipher;
        int ret;
@@ -562,16 +562,16 @@ API int yaca_get_iv_bits(yaca_enc_algo_e algo,
        return YACA_ERROR_NONE;
 }
 
-API int yaca_encrypt_init(yaca_ctx_h *ctx,
-                          yaca_enc_algo_e algo,
-                          yaca_block_cipher_mode_e bcm,
-                          const yaca_key_h sym_key,
-                          const yaca_key_h iv)
+API int yaca_encrypt_initialize(yaca_context_h *ctx,
+                                yaca_encrypt_algorithm_e algo,
+                                yaca_block_cipher_mode_e bcm,
+                                const yaca_key_h sym_key,
+                                const yaca_key_h iv)
 {
        return encrypt_init(ctx, algo, bcm, sym_key, iv, OP_ENCRYPT);
 }
 
-API int yaca_encrypt_update(yaca_ctx_h ctx,
+API int yaca_encrypt_update(yaca_context_h ctx,
                             const char *plain,
                             size_t plain_len,
                             char *cipher,
@@ -581,24 +581,24 @@ API int yaca_encrypt_update(yaca_ctx_h ctx,
                              (unsigned char*)cipher, cipher_len, OP_ENCRYPT);
 }
 
-API int yaca_encrypt_final(yaca_ctx_h ctx,
-                           char *cipher,
-                           size_t *cipher_len)
+API int yaca_encrypt_finalize(yaca_context_h ctx,
+                              char *cipher,
+                              size_t *cipher_len)
 {
        return encrypt_final(ctx, (unsigned char*)cipher,
                             cipher_len, OP_ENCRYPT);
 }
 
-API int yaca_decrypt_init(yaca_ctx_h *ctx,
-                          yaca_enc_algo_e algo,
-                          yaca_block_cipher_mode_e bcm,
-                          const yaca_key_h sym_key,
-                          const yaca_key_h iv)
+API int yaca_decrypt_initialize(yaca_context_h *ctx,
+                                yaca_encrypt_algorithm_e algo,
+                                yaca_block_cipher_mode_e bcm,
+                                const yaca_key_h sym_key,
+                                const yaca_key_h iv)
 {
        return encrypt_init(ctx, algo, bcm, sym_key, iv, OP_DECRYPT);
 }
 
-API int yaca_decrypt_update(yaca_ctx_h ctx,
+API int yaca_decrypt_update(yaca_context_h ctx,
                             const char *cipher,
                             size_t cipher_len,
                             char *plain,
@@ -608,9 +608,9 @@ API int yaca_decrypt_update(yaca_ctx_h ctx,
                              (unsigned char*)plain, plain_len, OP_DECRYPT);
 }
 
-API int yaca_decrypt_final(yaca_ctx_h ctx,
-                           char *plain,
-                           size_t *plain_len)
+API int yaca_decrypt_finalize(yaca_context_h ctx,
+                              char *plain,
+                              size_t *plain_len)
 {
        return encrypt_final(ctx, (unsigned char*)plain, plain_len,
                             OP_DECRYPT);
index 6a1af1d..d9cea2e 100644 (file)
@@ -42,14 +42,14 @@ enum yaca_ctx_type_e {
 };
 
 /* Base structure for crypto contexts - to be inherited */
-struct yaca_ctx_s {
+struct yaca_context_s {
        enum yaca_ctx_type_e type;
 
-       void (*ctx_destroy)(const yaca_ctx_h ctx);
-       int (*get_output_length)(const yaca_ctx_h ctx, size_t input_len, size_t *output_len);
-       int (*set_param)(yaca_ctx_h ctx, yaca_ex_param_e param,
+       void (*ctx_destroy)(const yaca_context_h ctx);
+       int (*get_output_length)(const yaca_context_h ctx, size_t input_len, size_t *output_len);
+       int (*set_param)(yaca_context_h ctx, yaca_property_e param,
                         const void *value, size_t value_len);
-       int (*get_param)(const yaca_ctx_h ctx, yaca_ex_param_e param,
+       int (*get_param)(const yaca_context_h ctx, yaca_property_e param,
                         void **value, size_t *value_len);
 };
 
@@ -86,9 +86,9 @@ struct yaca_key_evp_s {
        EVP_PKEY *evp;
 };
 
-int digest_get_algorithm(yaca_digest_algo_e algo, const EVP_MD **md);
+int digest_get_algorithm(yaca_digest_algorithm_e algo, const EVP_MD **md);
 
-int encrypt_get_algorithm(yaca_enc_algo_e algo,
+int encrypt_get_algorithm(yaca_encrypt_algorithm_e algo,
                           yaca_block_cipher_mode_e bcm,
                           size_t key_bits,
                           const EVP_CIPHER **cipher);
index 0642409..6e45c93 100644 (file)
--- a/src/key.c
+++ b/src/key.c
@@ -61,7 +61,7 @@ int base64_decode_length(const char *data, size_t data_len, size_t *len)
        size_t tmp_len = data_len;
 
        if (data_len % 4 != 0)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        if (data[tmp_len - 1] == '=') {
                padded = 1;
@@ -92,7 +92,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_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        /* First phase of correctness checking, calculate expected output length */
        ret = base64_decode_length(data, data_len, &b64_len);
@@ -153,7 +153,7 @@ int base64_decode(const char *data, size_t data_len, BIO **output)
                goto exit;
        }
        if ((size_t)out_len != b64_len) {
-               ret = YACA_ERROR_INVALID_ARGUMENT;
+               ret = YACA_ERROR_INVALID_PARAMETER;
                goto exit;
        }
 
@@ -193,7 +193,7 @@ int import_simple(yaca_key_h *key,
                        return ret;
                }
                key_data_len = len;
-       } else if (ret == YACA_ERROR_INVALID_ARGUMENT) {
+       } else if (ret == YACA_ERROR_INVALID_PARAMETER) {
                /* This was not BASE64 or it was corrupted, treat as RAW */
                key_data_len = data_len;
                key_data = data;
@@ -204,17 +204,17 @@ int import_simple(yaca_key_h *key,
 
        /* key_bits has to fit in size_t */
        if (key_data_len > SIZE_MAX / 8) {
-               ret = YACA_ERROR_INVALID_ARGUMENT;
+               ret = YACA_ERROR_INVALID_PARAMETER;
                goto exit;
        }
 
        /* DES key length verification */
        if (key_type == YACA_KEY_TYPE_DES) {
                size_t key_bits = key_data_len * 8;
-               if (key_bits != YACA_KEY_UNSAFE_64BIT &&
-                   key_bits != YACA_KEY_UNSAFE_128BIT &&
-                   key_bits != YACA_KEY_192BIT) {
-                       ret = YACA_ERROR_INVALID_ARGUMENT;
+               if (key_bits != YACA_KEY_LENGTH_UNSAFE_64BIT &&
+                   key_bits != YACA_KEY_LENGTH_UNSAFE_128BIT &&
+                   key_bits != YACA_KEY_LENGTH_192BIT) {
+                       ret = YACA_ERROR_INVALID_PARAMETER;
                        goto exit;
                }
        }
@@ -274,11 +274,11 @@ int import_evp(yaca_key_h *key,
         * sure we have at least 4 bytes for strncmp() below.
         */
        if (data_len < 4)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        /* This is because of BIO_new_mem_buf() having its length param typed int */
        if (data_len > INT_MAX)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        src = BIO_new_mem_buf(data, data_len);
        if (src == NULL) {
@@ -351,10 +351,10 @@ int import_evp(yaca_key_h *key,
        BIO_free(src);
 
        if (wrong_pass)
-               return YACA_ERROR_PASSWORD_INVALID;
+               return YACA_ERROR_INVALID_PASSWORD;
 
        if (pkey == NULL)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        switch (EVP_PKEY_type(pkey->type)) {
        case EVP_PKEY_RSA:
@@ -370,12 +370,12 @@ int import_evp(yaca_key_h *key,
 //             break;
 
        default:
-               ret = YACA_ERROR_INVALID_ARGUMENT;
+               ret = YACA_ERROR_INVALID_PARAMETER;
                goto exit;
        }
 
        if (type != key_type) {
-               ret = YACA_ERROR_INVALID_ARGUMENT;
+               ret = YACA_ERROR_INVALID_PARAMETER;
                goto exit;
        }
 
@@ -487,7 +487,7 @@ exit:
 }
 
 int export_evp_default_bio(struct yaca_key_evp_s *evp_key,
-                           yaca_key_file_fmt_e key_file_fmt,
+                           yaca_key_file_format_e key_file_fmt,
                            const char *password,
                            BIO *mem)
 {
@@ -526,7 +526,7 @@ int export_evp_default_bio(struct yaca_key_evp_s *evp_key,
 //             case YACA_KEY_TYPE_EC_PUB:
 //                     TODO NOT_IMPLEMENTED
                default:
-                       return YACA_ERROR_INVALID_ARGUMENT;
+                       return YACA_ERROR_INVALID_PARAMETER;
                }
 
                break;
@@ -553,13 +553,13 @@ int export_evp_default_bio(struct yaca_key_evp_s *evp_key,
 //             case YACA_KEY_TYPE_EC_PUB:
 //                     TODO NOT_IMPLEMENTED
                default:
-                       return YACA_ERROR_INVALID_ARGUMENT;
+                       return YACA_ERROR_INVALID_PARAMETER;
                }
 
                break;
 
        default:
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
        }
 
        if (ret <= 0) {
@@ -572,7 +572,7 @@ int export_evp_default_bio(struct yaca_key_evp_s *evp_key,
 }
 
 int export_evp_pkcs8_bio(struct yaca_key_evp_s *evp_key,
-                         yaca_key_file_fmt_e key_file_fmt,
+                         yaca_key_file_format_e key_file_fmt,
                          const char *password,
                          BIO *mem)
 {
@@ -601,7 +601,7 @@ int export_evp_pkcs8_bio(struct yaca_key_evp_s *evp_key,
 //                     TODO NOT_IMPLEMENTED
                default:
                        /* Public keys are not supported by PKCS8 */
-                       return YACA_ERROR_INVALID_ARGUMENT;
+                       return YACA_ERROR_INVALID_PARAMETER;
                }
 
                break;
@@ -620,13 +620,13 @@ int export_evp_pkcs8_bio(struct yaca_key_evp_s *evp_key,
 //                     TODO NOT_IMPLEMENTED
                default:
                        /* Public keys are not supported by PKCS8 */
-                       return YACA_ERROR_INVALID_ARGUMENT;
+                       return YACA_ERROR_INVALID_PARAMETER;
                }
 
                break;
 
        default:
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
        }
 
        if (ret <= 0) {
@@ -639,8 +639,8 @@ int export_evp_pkcs8_bio(struct yaca_key_evp_s *evp_key,
 }
 
 int export_evp(struct yaca_key_evp_s *evp_key,
-               yaca_key_fmt_e key_fmt,
-               yaca_key_file_fmt_e key_file_fmt,
+               yaca_key_format_e key_fmt,
+               yaca_key_file_format_e key_file_fmt,
                const char *password,
                char **data,
                size_t *data_len)
@@ -670,7 +670,7 @@ int export_evp(struct yaca_key_evp_s *evp_key,
                ret = export_evp_pkcs8_bio(evp_key, key_file_fmt, password, mem);
                break;
        default:
-               ret = YACA_ERROR_INVALID_ARGUMENT;
+               ret = YACA_ERROR_INVALID_PARAMETER;
                break;
        }
 
@@ -719,7 +719,7 @@ int gen_simple(struct yaca_key_simple_s **out, size_t key_bits)
 
        nk->bits = key_bits;
 
-       ret = yaca_rand_bytes(nk->d, key_byte_len);
+       ret = yaca_randomize_bytes(nk->d, key_byte_len);
        if (ret != YACA_ERROR_NONE)
                return ret;
 
@@ -731,10 +731,10 @@ int gen_simple_des(struct yaca_key_simple_s **out, size_t key_bits)
 {
        assert(out != NULL);
 
-       if (key_bits != YACA_KEY_UNSAFE_64BIT &&
-           key_bits != YACA_KEY_UNSAFE_128BIT &&
-           key_bits != YACA_KEY_192BIT)
-               return YACA_ERROR_INVALID_ARGUMENT;
+       if (key_bits != YACA_KEY_LENGTH_UNSAFE_64BIT &&
+           key_bits != YACA_KEY_LENGTH_UNSAFE_128BIT &&
+           key_bits != YACA_KEY_LENGTH_192BIT)
+               return YACA_ERROR_INVALID_PARAMETER;
 
        int ret;
        struct yaca_key_simple_s *nk;
@@ -847,7 +847,7 @@ int gen_evp_dsa(struct yaca_key_evp_s **out, size_t key_bits)
        /* Openssl generates 512-bit key for key lengths smaller than 512. It also
         * rounds key size to multiplication of 64. */
        if(key_bits < 512 || key_bits % 64 != 0)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        int ret;
        struct yaca_key_evp_s *nk;
@@ -976,19 +976,19 @@ API int yaca_key_get_type(const yaca_key_h key, yaca_key_type_e *key_type)
        const struct yaca_key_s *lkey = (const struct yaca_key_s *)key;
 
        if (lkey == NULL || key_type == NULL)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        *key_type = lkey->type;
        return YACA_ERROR_NONE;
 }
 
-API int yaca_key_get_bits(const yaca_key_h key, size_t *key_bits)
+API int yaca_key_get_bit_length(const yaca_key_h key, size_t *key_bits)
 {
        const struct yaca_key_simple_s *simple_key = key_get_simple(key);
        const struct yaca_key_evp_s *evp_key = key_get_evp(key);
 
        if (key_bits == NULL)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        if (simple_key != NULL) {
                *key_bits = simple_key->bits;
@@ -1010,7 +1010,7 @@ API int yaca_key_get_bits(const yaca_key_h key, size_t *key_bits)
                return YACA_ERROR_NONE;
        }
 
-       return YACA_ERROR_INVALID_ARGUMENT;
+       return YACA_ERROR_INVALID_PARAMETER;
 }
 
 API int yaca_key_import(yaca_key_type_e key_type,
@@ -1020,7 +1020,7 @@ API int yaca_key_import(yaca_key_type_e key_type,
                         yaca_key_h *key)
 {
        if (key == NULL || data == NULL || data_len == 0)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        /* allow an empty password, OpenSSL returns an error with "" */
        if (password != NULL && password[0] == '\0')
@@ -1031,7 +1031,7 @@ API int yaca_key_import(yaca_key_type_e key_type,
        case YACA_KEY_TYPE_DES:
        case YACA_KEY_TYPE_IV:
                if (password != NULL)
-                       return YACA_ERROR_INVALID_ARGUMENT;
+                       return YACA_ERROR_INVALID_PARAMETER;
                return import_simple(key, key_type, data, data_len);
        case YACA_KEY_TYPE_RSA_PUB:
        case YACA_KEY_TYPE_RSA_PRIV:
@@ -1044,13 +1044,13 @@ API int yaca_key_import(yaca_key_type_e key_type,
 //     case YACA_KEY_TYPE_EC_PRIV:
 //             TODO NOT_IMPLEMENTED
        default:
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
        }
 }
 
 API int yaca_key_export(const yaca_key_h key,
-                        yaca_key_fmt_e key_fmt,
-                        yaca_key_file_fmt_e key_file_fmt,
+                        yaca_key_format_e key_fmt,
+                        yaca_key_file_format_e key_file_fmt,
                         const char *password,
                         char **data,
                         size_t *data_len)
@@ -1059,14 +1059,14 @@ API int yaca_key_export(const yaca_key_h key,
        struct yaca_key_evp_s *evp_key = key_get_evp(key);
 
        if (data == NULL || data_len == NULL)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        /* allow an empty password, OpenSSL returns an error with "" */
        if (password != NULL && password[0] == '\0')
                password = NULL;
 
        if (password != NULL && simple_key != NULL)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        if (key_fmt == YACA_KEY_FORMAT_DEFAULT &&
            key_file_fmt == YACA_KEY_FILE_FORMAT_RAW &&
@@ -1082,19 +1082,19 @@ API int yaca_key_export(const yaca_key_h key,
                return export_evp(evp_key, key_fmt, key_file_fmt,
                                  password, data, data_len);
 
-       return YACA_ERROR_INVALID_ARGUMENT;
+       return YACA_ERROR_INVALID_PARAMETER;
 }
 
-API int yaca_key_gen(yaca_key_type_e key_type,
-                     size_t key_bits,
-                     yaca_key_h *key)
+API int yaca_key_generate(yaca_key_type_e key_type,
+                          size_t key_bits,
+                          yaca_key_h *key)
 {
        int ret;
        struct yaca_key_simple_s *nk_simple = NULL;
        struct yaca_key_evp_s *nk_evp = NULL;
 
        if (key == NULL || key_bits == 0 || key_bits % 8 != 0)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        switch (key_type) {
        case YACA_KEY_TYPE_SYMMETRIC:
@@ -1114,7 +1114,7 @@ API int yaca_key_gen(yaca_key_type_e key_type,
 //     case YACA_KEY_TYPE_EC_PRIV:
 //             TODO NOT_IMPLEMENTED
        default:
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
        }
 
        if (ret != YACA_ERROR_NONE)
@@ -1141,7 +1141,7 @@ API int yaca_key_extract_public(const yaca_key_h prv_key, yaca_key_h *pub_key)
        EVP_PKEY *pkey = NULL;
 
        if (prv_key == YACA_KEY_NULL || evp_key == NULL || pub_key == NULL)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        ret = yaca_zalloc(sizeof(struct yaca_key_evp_s), (void**)&nk);
        if (ret != YACA_ERROR_NONE)
@@ -1182,7 +1182,7 @@ API int yaca_key_extract_public(const yaca_key_h prv_key, yaca_key_h *pub_key)
 //             nk->key.type = YACA_KEY_TYPE_EC_PUB;
 //             break;
        default:
-               ret = YACA_ERROR_INVALID_ARGUMENT;
+               ret = YACA_ERROR_INVALID_PARAMETER;
                goto exit;
        }
 
@@ -1200,7 +1200,7 @@ exit:
        return ret;
 }
 
-API int yaca_key_free(yaca_key_h key)
+API int yaca_key_destroy(yaca_key_h key)
 {
        struct yaca_key_simple_s *simple_key = key_get_simple(key);
        struct yaca_key_evp_s *evp_key = key_get_evp(key);
@@ -1220,7 +1220,7 @@ API int yaca_key_derive_pbkdf2(const char *password,
                                const char *salt,
                                size_t salt_len,
                                int iter,
-                               yaca_digest_algo_e algo,
+                               yaca_digest_algorithm_e algo,
                                size_t key_bits,
                                yaca_key_h *key)
 {
@@ -1231,10 +1231,10 @@ API int yaca_key_derive_pbkdf2(const char *password,
 
        if (password == NULL || salt == NULL || salt_len == 0 ||
            iter == 0 || key_bits == 0 || key == NULL)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        if (key_bits % 8) /* Key length must be multiple of 8-bits */
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        ret = digest_get_algorithm(algo, &md);
        if (ret != YACA_ERROR_NONE)
index aab049b..89387b7 100644 (file)
@@ -39,15 +39,15 @@ enum seal_op_type {
 };
 
 struct yaca_seal_ctx_s {
-       struct yaca_ctx_s ctx;
+       struct yaca_context_s ctx;
 
        EVP_CIPHER_CTX *cipher_ctx;
        enum seal_op_type op_type; /* Operation context was created for */
 };
 
-static struct yaca_seal_ctx_s *get_seal_ctx(const yaca_ctx_h ctx)
+static struct yaca_seal_ctx_s *get_seal_ctx(const yaca_context_h ctx)
 {
-       if (ctx == YACA_CTX_NULL)
+       if (ctx == YACA_CONTEXT_NULL)
                return NULL;
 
        switch (ctx->type) {
@@ -58,7 +58,7 @@ static struct yaca_seal_ctx_s *get_seal_ctx(const yaca_ctx_h ctx)
        }
 }
 
-static void destroy_seal_ctx(const yaca_ctx_h ctx)
+static void destroy_seal_ctx(const yaca_context_h ctx)
 {
        struct yaca_seal_ctx_s *nc = get_seal_ctx(ctx);
 
@@ -69,13 +69,13 @@ static void destroy_seal_ctx(const yaca_ctx_h ctx)
        nc->cipher_ctx = NULL;
 }
 
-static int get_seal_output_length(const yaca_ctx_h ctx, size_t input_len, size_t *output_len)
+static int get_seal_output_length(const yaca_context_h ctx, size_t input_len, size_t *output_len)
 {
        struct yaca_seal_ctx_s *nc = get_seal_ctx(ctx);
        int block_size;
 
        if (nc == NULL)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
        assert(nc->cipher_ctx);
 
        block_size = EVP_CIPHER_CTX_block_size(nc->cipher_ctx);
@@ -86,7 +86,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_INVALID_ARGUMENT;
+                       return YACA_ERROR_INVALID_PARAMETER;
 
                *output_len = block_size + input_len - 1;
        } else {
@@ -96,11 +96,11 @@ static int get_seal_output_length(const yaca_ctx_h ctx, size_t input_len, size_t
        return YACA_ERROR_NONE;
 }
 
-static int seal_init(yaca_ctx_h *ctx,
+static int seal_init(yaca_context_h *ctx,
                      const yaca_key_h pub_key,
-                     yaca_enc_algo_e algo,
+                     yaca_encrypt_algorithm_e algo,
                      yaca_block_cipher_mode_e bcm,
-                     yaca_key_bits_e sym_key_bits,
+                     yaca_key_bit_length_e sym_key_bits,
                      yaca_key_h *sym_key,
                      yaca_key_h *iv)
 {
@@ -117,10 +117,10 @@ static int seal_init(yaca_ctx_h *ctx,
        int ret;
 
        if (ctx == NULL || pub_key == YACA_KEY_NULL)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        if (pub_key->type != YACA_KEY_TYPE_RSA_PUB)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
        lpub = key_get_evp(pub_key);
        assert(lpub);
 
@@ -199,23 +199,23 @@ static int seal_init(yaca_ctx_h *ctx,
        } else {
                *iv = NULL;
        }
-       *ctx = (yaca_ctx_h)nc;
+       *ctx = (yaca_context_h)nc;
        nc = NULL;
        ret = YACA_ERROR_NONE;
 
 exit:
        yaca_free(liv);
        yaca_free(lkey);
-       yaca_ctx_free((yaca_ctx_h)nc);
+       yaca_context_destroy((yaca_context_h)nc);
 
        return ret;
 }
 
-static int open_init(yaca_ctx_h *ctx,
+static int open_init(yaca_context_h *ctx,
                      const yaca_key_h prv_key,
-                     yaca_enc_algo_e algo,
+                     yaca_encrypt_algorithm_e algo,
                      yaca_block_cipher_mode_e bcm,
-                     yaca_key_bits_e sym_key_bits,
+                     yaca_key_bit_length_e sym_key_bits,
                      const yaca_key_h sym_key,
                      const yaca_key_h iv)
 {
@@ -230,16 +230,16 @@ static int open_init(yaca_ctx_h *ctx,
        int ret;
 
        if (ctx == NULL || prv_key == YACA_KEY_NULL || sym_key == YACA_KEY_NULL)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        if (prv_key->type != YACA_KEY_TYPE_RSA_PRIV)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
        lprv = key_get_evp(prv_key);
        assert(lprv);
 
        lkey = key_get_simple(sym_key);
        if (lkey == NULL || lkey->key.type != YACA_KEY_TYPE_SYMMETRIC)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        ret = yaca_zalloc(sizeof(struct yaca_seal_ctx_s), (void**)&nc);
        if (ret != YACA_ERROR_NONE)
@@ -263,24 +263,24 @@ static int open_init(yaca_ctx_h *ctx,
 
        iv_bits = ret * 8;
        if (iv_bits == 0 && iv != NULL) { /* 0 -> cipher doesn't use iv, but it was provided */
-               ret = YACA_ERROR_INVALID_ARGUMENT;
+               ret = YACA_ERROR_INVALID_PARAMETER;
                goto exit;
        }
 
        if (iv_bits > 0) { /* cipher requires iv*/
                liv = key_get_simple(iv);
                if (liv == NULL || liv->key.type != YACA_KEY_TYPE_IV) { /* iv was not provided */
-                       ret = YACA_ERROR_INVALID_ARGUMENT;
+                       ret = YACA_ERROR_INVALID_PARAMETER;
                        goto exit;
                }
-               ret = yaca_key_get_bits(iv, &iv_bits_check);
+               ret = yaca_key_get_bit_length(iv, &iv_bits_check);
                if (ret != YACA_ERROR_NONE) {
-                       ret = YACA_ERROR_INVALID_ARGUMENT;
+                       ret = YACA_ERROR_INVALID_PARAMETER;
                        goto exit;
                }
                /* IV length doesn't match cipher */
                if (iv_bits != iv_bits_check) {
-                       ret = YACA_ERROR_INVALID_ARGUMENT;
+                       ret = YACA_ERROR_INVALID_PARAMETER;
                        goto exit;
                }
                iv_data = (unsigned char*)liv->d;
@@ -304,17 +304,17 @@ static int open_init(yaca_ctx_h *ctx,
                goto exit;
        }
 
-       *ctx = (yaca_ctx_h)nc;
+       *ctx = (yaca_context_h)nc;
        nc = NULL;
        ret = YACA_ERROR_NONE;
 
 exit:
-       yaca_ctx_free((yaca_ctx_h)nc);
+       yaca_context_destroy((yaca_context_h)nc);
 
        return ret;
 }
 
-static int seal_update(yaca_ctx_h ctx,
+static int seal_update(yaca_context_h ctx,
                        const unsigned char *input,
                        size_t input_len,
                        unsigned char *output,
@@ -326,7 +326,7 @@ static int seal_update(yaca_ctx_h ctx,
 
        if (c == NULL || input == NULL || input_len == 0 ||
            output == NULL || output_len == NULL || op_type != c->op_type)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        switch (op_type) {
        case OP_SEAL:
@@ -336,7 +336,7 @@ static int seal_update(yaca_ctx_h ctx,
                ret = EVP_OpenUpdate(c->cipher_ctx, output, (int*)output_len, input, input_len);
                break;
        default:
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
        }
 
        if (ret != 1) {
@@ -348,7 +348,7 @@ static int seal_update(yaca_ctx_h ctx,
        return YACA_ERROR_NONE;
 }
 
-static int seal_final(yaca_ctx_h ctx,
+static int seal_final(yaca_context_h ctx,
                       unsigned char *output,
                       size_t *output_len,
                       enum seal_op_type op_type)
@@ -357,7 +357,7 @@ static int seal_final(yaca_ctx_h ctx,
        int ret;
 
        if (c == NULL || output == NULL || output_len == NULL || op_type != c->op_type)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        switch (op_type) {
        case OP_SEAL:
@@ -367,7 +367,7 @@ static int seal_final(yaca_ctx_h ctx,
                ret = EVP_OpenFinal(c->cipher_ctx, output, (int*)output_len);
                break;
        default:
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
        }
 
        if (ret != 1) {
@@ -379,18 +379,18 @@ static int seal_final(yaca_ctx_h ctx,
        return YACA_ERROR_NONE;
 }
 
-API int yaca_seal_init(yaca_ctx_h *ctx,
-                       const yaca_key_h pub_key,
-                       yaca_enc_algo_e algo,
-                       yaca_block_cipher_mode_e bcm,
-                       yaca_key_bits_e sym_key_bits,
-                       yaca_key_h *sym_key,
-                       yaca_key_h *iv)
+API int yaca_seal_initialize(yaca_context_h *ctx,
+                             const yaca_key_h pub_key,
+                             yaca_encrypt_algorithm_e algo,
+                             yaca_block_cipher_mode_e bcm,
+                             yaca_key_bit_length_e sym_key_bits,
+                             yaca_key_h *sym_key,
+                             yaca_key_h *iv)
 {
        return seal_init(ctx, pub_key, algo, bcm, sym_key_bits, sym_key, iv);
 }
 
-API int yaca_seal_update(yaca_ctx_h ctx,
+API int yaca_seal_update(yaca_context_h ctx,
                          const char *plain,
                          size_t plain_len,
                          char *cipher,
@@ -404,9 +404,9 @@ API int yaca_seal_update(yaca_ctx_h ctx,
                           OP_SEAL);
 }
 
-API int yaca_seal_final(yaca_ctx_h ctx,
-                        char *cipher,
-                        size_t *cipher_len)
+API int yaca_seal_finalize(yaca_context_h ctx,
+                           char *cipher,
+                           size_t *cipher_len)
 {
        return seal_final(ctx,
                          (unsigned char*)cipher,
@@ -414,18 +414,18 @@ API int yaca_seal_final(yaca_ctx_h ctx,
                          OP_SEAL);
 }
 
-API int yaca_open_init(yaca_ctx_h *ctx,
-                       const yaca_key_h prv_key,
-                       yaca_enc_algo_e algo,
-                       yaca_block_cipher_mode_e bcm,
-                       yaca_key_bits_e sym_key_bits,
-                       const yaca_key_h sym_key,
-                       const yaca_key_h iv)
+API int yaca_open_initialize(yaca_context_h *ctx,
+                             const yaca_key_h prv_key,
+                             yaca_encrypt_algorithm_e algo,
+                             yaca_block_cipher_mode_e bcm,
+                             yaca_key_bit_length_e sym_key_bits,
+                             const yaca_key_h sym_key,
+                             const yaca_key_h iv)
 {
        return open_init(ctx, prv_key, algo, bcm, sym_key_bits, sym_key, iv);
 }
 
-API int yaca_open_update(yaca_ctx_h ctx,
+API int yaca_open_update(yaca_context_h ctx,
                          const char *cipher,
                          size_t cipher_len,
                          char *plain,
@@ -439,9 +439,9 @@ API int yaca_open_update(yaca_ctx_h ctx,
                           OP_OPEN);
 }
 
-API int yaca_open_final(yaca_ctx_h ctx,
-                        char *plain,
-                        size_t *plain_len)
+API int yaca_open_finalize(yaca_context_h ctx,
+                           char *plain,
+                           size_t *plain_len)
 {
        return seal_final(ctx, (unsigned char*)plain, plain_len, OP_OPEN);
 }
index 47f65a8..9da9385 100644 (file)
@@ -44,15 +44,15 @@ enum sign_op_type {
 };
 
 struct yaca_sign_ctx_s {
-       struct yaca_ctx_s ctx;
+       struct yaca_context_s ctx;
 
        EVP_MD_CTX *mdctx;
        enum sign_op_type op_type;
 };
 
-static struct yaca_sign_ctx_s *get_sign_ctx(const yaca_ctx_h ctx)
+static struct yaca_sign_ctx_s *get_sign_ctx(const yaca_context_h ctx)
 {
-       if (ctx == YACA_CTX_NULL)
+       if (ctx == YACA_CONTEXT_NULL)
                return NULL;
 
        switch (ctx->type) {
@@ -63,14 +63,14 @@ static struct yaca_sign_ctx_s *get_sign_ctx(const yaca_ctx_h ctx)
        }
 }
 
-static int get_sign_output_length(const yaca_ctx_h ctx,
+static int get_sign_output_length(const yaca_context_h ctx,
                                   size_t input_len,
                                   size_t *output_len)
 {
        struct yaca_sign_ctx_s *c = get_sign_ctx(ctx);
 
        if (c == NULL)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        assert(c->mdctx != NULL);
 
@@ -93,7 +93,7 @@ static int get_sign_output_length(const yaca_ctx_h ctx,
        return YACA_ERROR_NONE;
 }
 
-static void destroy_sign_context(yaca_ctx_h ctx)
+static void destroy_sign_context(yaca_context_h ctx)
 {
        struct yaca_sign_ctx_s *c = get_sign_ctx(ctx);
 
@@ -104,8 +104,8 @@ static void destroy_sign_context(yaca_ctx_h ctx)
        c->mdctx = NULL;
 }
 
-int set_sign_param(yaca_ctx_h ctx,
-                   yaca_ex_param_e param,
+int set_sign_param(yaca_context_h ctx,
+                   yaca_property_e param,
                    const void *value,
                    size_t value_len)
 {
@@ -116,7 +116,7 @@ int set_sign_param(yaca_ctx_h ctx,
        EVP_PKEY *pkey;
 
        if (c == NULL || value == NULL)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        assert(c->mdctx != NULL);
 
@@ -124,8 +124,8 @@ int set_sign_param(yaca_ctx_h ctx,
                return YACA_ERROR_INTERNAL;
 
        /* this function only supports padding */
-       if (param != YACA_PARAM_PADDING || value_len != sizeof(yaca_padding_e))
-               return YACA_ERROR_INVALID_ARGUMENT;
+       if (param != YACA_PROPERTY_PADDING || value_len != sizeof(yaca_padding_e))
+               return YACA_ERROR_INVALID_PARAMETER;
 
        padding = *(yaca_padding_e *)(value);
 
@@ -142,7 +142,7 @@ int set_sign_param(yaca_ctx_h ctx,
                pad = RSA_PKCS1_PSS_PADDING;
                break;
        default:
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
        }
 
        pkey = EVP_PKEY_CTX_get0_pkey(c->mdctx->pctx);
@@ -154,7 +154,7 @@ int set_sign_param(yaca_ctx_h ctx,
 
        /* padding only works for RSA */
        if (pkey->type != EVP_PKEY_RSA)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        ret = EVP_PKEY_CTX_set_rsa_padding(c->mdctx->pctx, pad);
        if (ret <= 0) {
@@ -166,8 +166,8 @@ int set_sign_param(yaca_ctx_h ctx,
        return YACA_ERROR_NONE;
 }
 
-int get_sign_param(const yaca_ctx_h ctx,
-                   yaca_ex_param_e param,
+int get_sign_param(const yaca_context_h ctx,
+                   yaca_property_e param,
                    void **value,
                    size_t *value_len)
 {
@@ -178,7 +178,7 @@ int get_sign_param(const yaca_ctx_h ctx,
        yaca_padding_e padding;
 
        if (c == NULL || value == NULL || value_len == NULL)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        assert(c->mdctx != NULL);
 
@@ -186,8 +186,8 @@ int get_sign_param(const yaca_ctx_h ctx,
                return YACA_ERROR_INTERNAL;
 
        /* this function only supports padding */
-       if (param != YACA_PARAM_PADDING)
-               return YACA_ERROR_INVALID_ARGUMENT;
+       if (param != YACA_PROPERTY_PADDING)
+               return YACA_ERROR_INVALID_PARAMETER;
 
        pkey = EVP_PKEY_CTX_get0_pkey(c->mdctx->pctx);
        if (pkey == NULL) {
@@ -198,7 +198,7 @@ int get_sign_param(const yaca_ctx_h ctx,
 
        /* padding only works for RSA */
        if (pkey->type != EVP_PKEY_RSA)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        ret = EVP_PKEY_CTX_get_rsa_padding(c->mdctx->pctx, &pad);
        if (ret <= 0) {
@@ -233,9 +233,9 @@ int get_sign_param(const yaca_ctx_h ctx,
        return YACA_ERROR_NONE;
 }
 
-API int yaca_sign_init(yaca_ctx_h *ctx,
-                       yaca_digest_algo_e algo,
-                       const yaca_key_h key)
+API int yaca_sign_initialize(yaca_context_h *ctx,
+                             yaca_digest_algorithm_e algo,
+                             const yaca_key_h key)
 {
        struct yaca_sign_ctx_s *nc = NULL;
        const EVP_MD *md = NULL;
@@ -243,7 +243,7 @@ API int yaca_sign_init(yaca_ctx_h *ctx,
        const struct yaca_key_evp_s *evp_key = key_get_evp(key);
 
        if (ctx == NULL || evp_key == NULL)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        switch (key->type) {
        case YACA_KEY_TYPE_RSA_PRIV:
@@ -252,7 +252,7 @@ API int yaca_sign_init(yaca_ctx_h *ctx,
 //     case YACA_KEY_TYPE_EC_PRIV:
 //             TODO NOT_IMPLEMENTED
        default:
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
        }
 
        ret = yaca_zalloc(sizeof(struct yaca_sign_ctx_s), (void**)&nc);
@@ -284,19 +284,19 @@ API int yaca_sign_init(yaca_ctx_h *ctx,
                goto exit;
        }
 
-       *ctx = (yaca_ctx_h)nc;
+       *ctx = (yaca_context_h)nc;
        nc = NULL;
        ret = YACA_ERROR_NONE;
 
 exit:
-       yaca_ctx_free((yaca_ctx_h)nc);
+       yaca_context_destroy((yaca_context_h)nc);
 
        return ret;
 }
 
-API int yaca_sign_hmac_init(yaca_ctx_h *ctx,
-                            yaca_digest_algo_e algo,
-                            const yaca_key_h key)
+API int yaca_sign_initialize_hmac(yaca_context_h *ctx,
+                                  yaca_digest_algorithm_e algo,
+                                  const yaca_key_h key)
 {
        struct yaca_sign_ctx_s *nc = NULL;
        EVP_PKEY *pkey = NULL;
@@ -306,7 +306,7 @@ API int yaca_sign_hmac_init(yaca_ctx_h *ctx,
 
        if (ctx == NULL || simple_key == NULL ||
            (key->type != YACA_KEY_TYPE_SYMMETRIC && key->type != YACA_KEY_TYPE_DES))
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        ret = yaca_zalloc(sizeof(struct yaca_sign_ctx_s), (void**)&nc);
        if (ret != YACA_ERROR_NONE)
@@ -347,20 +347,20 @@ API int yaca_sign_hmac_init(yaca_ctx_h *ctx,
 
        pkey = NULL;
 
-       *ctx = (yaca_ctx_h)nc;
+       *ctx = (yaca_context_h)nc;
        nc = NULL;
        ret = YACA_ERROR_NONE;
 
 exit:
        EVP_PKEY_free(pkey);
-       yaca_ctx_free((yaca_ctx_h)nc);
+       yaca_context_destroy((yaca_context_h)nc);
 
        return ret;
 }
 
-API int yaca_sign_cmac_init(yaca_ctx_h *ctx,
-                            yaca_enc_algo_e algo,
-                            const yaca_key_h key)
+API int yaca_sign_initialize_cmac(yaca_context_h *ctx,
+                                  yaca_encrypt_algorithm_e algo,
+                                  const yaca_key_h key)
 {
        struct yaca_sign_ctx_s *nc = NULL;
        CMAC_CTX* cmac_ctx = NULL;
@@ -371,7 +371,7 @@ API int yaca_sign_cmac_init(yaca_ctx_h *ctx,
 
        if (ctx == NULL || simple_key == NULL ||
            (key->type != YACA_KEY_TYPE_SYMMETRIC && key->type != YACA_KEY_TYPE_DES))
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        ret = yaca_zalloc(sizeof(struct yaca_sign_ctx_s), (void**)&nc);
        if (ret != YACA_ERROR_NONE)
@@ -431,19 +431,19 @@ API int yaca_sign_cmac_init(yaca_ctx_h *ctx,
 
        pkey = NULL;
 
-       *ctx = (yaca_ctx_h)nc;
+       *ctx = (yaca_context_h)nc;
        nc = NULL;
        ret = YACA_ERROR_NONE;
 
 exit:
        EVP_PKEY_free(pkey);
        CMAC_CTX_free(cmac_ctx);
-       yaca_ctx_free((yaca_ctx_h)nc);
+       yaca_context_destroy((yaca_context_h)nc);
 
        return ret;
 }
 
-API int yaca_sign_update(yaca_ctx_h ctx,
+API int yaca_sign_update(yaca_context_h ctx,
                          const char *data,
                          size_t data_len)
 {
@@ -452,7 +452,7 @@ API int yaca_sign_update(yaca_ctx_h ctx,
 
        if (c == NULL || c->op_type != OP_SIGN ||
            data == NULL || data_len == 0)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        ret = EVP_DigestSignUpdate(c->mdctx, data, data_len);
        if (ret != 1) {
@@ -464,16 +464,16 @@ API int yaca_sign_update(yaca_ctx_h ctx,
        return YACA_ERROR_NONE;
 }
 
-API int yaca_sign_final(yaca_ctx_h ctx,
-                        char *signature,
-                        size_t *signature_len)
+API int yaca_sign_finalize(yaca_context_h ctx,
+                           char *signature,
+                           size_t *signature_len)
 {
        struct yaca_sign_ctx_s *c = get_sign_ctx(ctx);
        int ret;
 
        if (c == NULL ||  c->op_type != OP_SIGN ||
            signature == NULL || signature_len == NULL || *signature_len == 0)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        ret = EVP_DigestSignFinal(c->mdctx, (unsigned char *)signature, signature_len);
        if (ret != 1) {
@@ -485,9 +485,9 @@ API int yaca_sign_final(yaca_ctx_h ctx,
        return YACA_ERROR_NONE;
 }
 
-API int yaca_verify_init(yaca_ctx_h *ctx,
-                         yaca_digest_algo_e algo,
-                         const yaca_key_h key)
+API int yaca_verify_initialize(yaca_context_h *ctx,
+                               yaca_digest_algorithm_e algo,
+                               const yaca_key_h key)
 {
        struct yaca_sign_ctx_s *nc = NULL;
        const EVP_MD *md = NULL;
@@ -495,7 +495,7 @@ API int yaca_verify_init(yaca_ctx_h *ctx,
        const struct yaca_key_evp_s *evp_key = key_get_evp(key);
 
        if (ctx == NULL || evp_key == NULL)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        switch (key->type) {
        case YACA_KEY_TYPE_RSA_PUB:
@@ -504,7 +504,7 @@ API int yaca_verify_init(yaca_ctx_h *ctx,
 //     case YACA_KEY_TYPE_EC_PUB:
 //             TODO NOT_IMPLEMENTED
        default:
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
        }
 
        ret = yaca_zalloc(sizeof(struct yaca_sign_ctx_s), (void**)&nc);
@@ -536,17 +536,17 @@ API int yaca_verify_init(yaca_ctx_h *ctx,
                goto exit;
        }
 
-       *ctx = (yaca_ctx_h)nc;
+       *ctx = (yaca_context_h)nc;
        nc = NULL;
        ret = YACA_ERROR_NONE;
 
 exit:
-       yaca_ctx_free((yaca_ctx_h)nc);
+       yaca_context_destroy((yaca_context_h)nc);
 
        return ret;
 }
 
-API int yaca_verify_update(yaca_ctx_h ctx,
+API int yaca_verify_update(yaca_context_h ctx,
                            const char *data,
                            size_t data_len)
 {
@@ -554,7 +554,7 @@ API int yaca_verify_update(yaca_ctx_h ctx,
        int ret;
 
        if (c == NULL || data == NULL || data_len == 0 || c->op_type != OP_VERIFY)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        ret = EVP_DigestVerifyUpdate(c->mdctx, data, data_len);
        if (ret != 1) {
@@ -566,15 +566,15 @@ API int yaca_verify_update(yaca_ctx_h ctx,
        return YACA_ERROR_NONE;
 }
 
-API int yaca_verify_final(yaca_ctx_h ctx,
-                          const char *signature,
-                          size_t signature_len)
+API int yaca_verify_finalize(yaca_context_h ctx,
+                             const char *signature,
+                             size_t signature_len)
 {
        struct yaca_sign_ctx_s *c = get_sign_ctx(ctx);
        int ret;
 
        if (c == NULL || signature == NULL || signature_len == 0 || c->op_type != OP_VERIFY)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
        ret = EVP_DigestVerifyFinal(c->mdctx,
                                    (unsigned char *)signature,
index 52be84d..19c0f1a 100644 (file)
 
 #include "internal.h"
 
-API int yaca_digest_calc(yaca_digest_algo_e algo,
-                         const char *data,
-                         size_t data_len,
-                         char **digest,
-                         size_t *digest_len)
+API int yaca_simple_calculate_digest(yaca_digest_algorithm_e algo,
+                                     const char *data,
+                                     size_t data_len,
+                                     char **digest,
+                                     size_t *digest_len)
 {
-       yaca_ctx_h ctx;
+       yaca_context_h ctx;
        int ret;
        char *ldigest = NULL;
        size_t ldigest_len;
 
        if (data == NULL || data_len == 0 || digest == NULL || digest_len == NULL)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
-       ret = yaca_digest_init(&ctx, algo);
+       ret = yaca_digest_initialize(&ctx, algo);
        if (ret != YACA_ERROR_NONE)
                return ret;
 
@@ -65,7 +65,7 @@ API int yaca_digest_calc(yaca_digest_algo_e algo,
        if (ret != YACA_ERROR_NONE)
                goto exit;
 
-       ret = yaca_digest_final(ctx, ldigest, &ldigest_len);
+       ret = yaca_digest_finalize(ctx, ldigest, &ldigest_len);
        if (ret != YACA_ERROR_NONE)
                goto exit;
 
@@ -75,30 +75,30 @@ API int yaca_digest_calc(yaca_digest_algo_e algo,
 
 exit:
        yaca_free(ldigest);
-       yaca_ctx_free(ctx);
+       yaca_context_destroy(ctx);
 
        return ret;
 }
 
-API int yaca_encrypt(yaca_enc_algo_e algo,
-                     yaca_block_cipher_mode_e bcm,
-                     const yaca_key_h sym_key,
-                     const yaca_key_h iv,
-                     const char *plain,
-                     size_t plain_len,
-                     char **cipher,
-                     size_t *cipher_len)
+API int yaca_simple_encrypt(yaca_encrypt_algorithm_e algo,
+                            yaca_block_cipher_mode_e bcm,
+                            const yaca_key_h sym_key,
+                            const yaca_key_h iv,
+                            const char *plain,
+                            size_t plain_len,
+                            char **cipher,
+                            size_t *cipher_len)
 {
-       yaca_ctx_h ctx;
+       yaca_context_h ctx;
        int ret;
        char *lcipher = NULL;
        size_t out_len, lcipher_len, written;
 
        if (plain == NULL || plain_len == 0 || cipher == NULL || cipher_len == NULL ||
            sym_key == YACA_KEY_NULL)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
-       ret = yaca_encrypt_init(&ctx, algo, bcm, sym_key, iv);
+       ret = yaca_encrypt_initialize(&ctx, algo, bcm, sym_key, iv);
        if (ret != YACA_ERROR_NONE)
                return ret;
 
@@ -111,7 +111,7 @@ API int yaca_encrypt(yaca_enc_algo_e algo,
                goto exit;
 
        if (out_len > SIZE_MAX - lcipher_len) {
-               ret = YACA_ERROR_INVALID_ARGUMENT;
+               ret = YACA_ERROR_INVALID_PARAMETER;
                goto exit;
        }
 
@@ -132,7 +132,7 @@ API int yaca_encrypt(yaca_enc_algo_e algo,
 
        written = out_len;
        out_len = lcipher_len - written;
-       ret = yaca_encrypt_final(ctx, lcipher + written, &out_len);
+       ret = yaca_encrypt_finalize(ctx, lcipher + written, &out_len);
        if (ret != YACA_ERROR_NONE)
                goto exit;
 
@@ -150,30 +150,30 @@ API int yaca_encrypt(yaca_enc_algo_e algo,
 
 exit:
        yaca_free(lcipher);
-       yaca_ctx_free(ctx);
+       yaca_context_destroy(ctx);
 
        return ret;
 }
 
-API int yaca_decrypt(yaca_enc_algo_e algo,
-                     yaca_block_cipher_mode_e bcm,
-                     const yaca_key_h sym_key,
-                     const yaca_key_h iv,
-                     const char *cipher,
-                     size_t cipher_len,
-                     char **plain,
-                     size_t *plain_len)
+API int yaca_simple_decrypt(yaca_encrypt_algorithm_e algo,
+                            yaca_block_cipher_mode_e bcm,
+                            const yaca_key_h sym_key,
+                            const yaca_key_h iv,
+                            const char *cipher,
+                            size_t cipher_len,
+                            char **plain,
+                            size_t *plain_len)
 {
-       yaca_ctx_h ctx;
+       yaca_context_h ctx;
        int ret;
        char *lplain = NULL;
        size_t out_len, lplain_len, written;
 
        if (cipher == NULL || cipher_len == 0 || plain == NULL || plain_len == NULL ||
            sym_key == YACA_KEY_NULL)
-               return YACA_ERROR_INVALID_ARGUMENT;
+               return YACA_ERROR_INVALID_PARAMETER;
 
-       ret = yaca_decrypt_init(&ctx, algo, bcm, sym_key, iv);
+       ret = yaca_decrypt_initialize(&ctx, algo, bcm, sym_key, iv);
        if (ret != YACA_ERROR_NONE)
                return ret;
 
@@ -186,7 +186,7 @@ API int yaca_decrypt(yaca_enc_algo_e algo,
                goto exit;
 
        if (out_len > SIZE_MAX - lplain_len) {
-               ret = YACA_ERROR_INVALID_ARGUMENT;
+               ret = YACA_ERROR_INVALID_PARAMETER;
                goto exit;
        }
 
@@ -206,7 +206,7 @@ API int yaca_decrypt(yaca_enc_algo_e algo,
 
        written = out_len;
        out_len = lplain_len - written;
-       ret = yaca_decrypt_final(ctx, lplain + written, &out_len);
+       ret = yaca_decrypt_finalize(ctx, lplain + written, &out_len);
        if (ret != YACA_ERROR_NONE)
                goto exit;
 
@@ -224,12 +224,12 @@ API int yaca_decrypt(yaca_enc_algo_e algo,
 
 exit:
        yaca_free(lplain);
-       yaca_ctx_free(ctx);
+       yaca_context_destroy(ctx);
 
        return ret;
 }
 
-static int sign(const yaca_ctx_h ctx, const char *data, size_t data_len,
+static int sign(const yaca_context_h ctx, const char *data, size_t data_len,
                 char **signature, size_t *signature_len)
 {
        int ret;
@@ -251,7 +251,7 @@ static int sign(const yaca_ctx_h ctx, const char *data, size_t data_len,
        if (ret != YACA_ERROR_NONE)
                return ret;
 
-       ret = yaca_sign_final(ctx, *signature, signature_len);
+       ret = yaca_sign_finalize(ctx, *signature, signature_len);
        if (ret != YACA_ERROR_NONE) {
                yaca_free(*signature);
                *signature = NULL;
@@ -260,38 +260,38 @@ static int sign(const yaca_ctx_h ctx, const char *data, size_t data_len,
        return ret;
 }
 
-API int yaca_sign(yaca_digest_algo_e algo,
-                  const yaca_key_h key,
-                  const char *data,
-                  size_t data_len,
-                  char **signature,
-                  size_t *signature_len)
+API int yaca_simple_calculate_signature(yaca_digest_algorithm_e algo,
+                                        const yaca_key_h key,
+                                        const char *data,
+                                        size_t data_len,
+                                        char **signature,
+                                        size_t *signature_len)
 {
        int ret;
-       yaca_ctx_h ctx = YACA_CTX_NULL;
+       yaca_context_h ctx = YACA_CONTEXT_NULL;
 
-       ret = yaca_sign_init(&ctx, algo, key);
+       ret = yaca_sign_initialize(&ctx, algo, key);
        if (ret != YACA_ERROR_NONE)
                return ret;
 
        ret = sign(ctx, data, data_len, signature, signature_len);
 
-       yaca_ctx_free(ctx);
+       yaca_context_destroy(ctx);
 
        return ret;
 }
 
-API int yaca_verify(yaca_digest_algo_e algo,
-                    const yaca_key_h key,
-                    const char *data,
-                    size_t data_len,
-                    const char *signature,
-                    size_t signature_len)
+API int yaca_simple_verify_signature(yaca_digest_algorithm_e algo,
+                                     const yaca_key_h key,
+                                     const char *data,
+                                     size_t data_len,
+                                     const char *signature,
+                                     size_t signature_len)
 {
        int ret;
-       yaca_ctx_h ctx = YACA_CTX_NULL;
+       yaca_context_h ctx = YACA_CONTEXT_NULL;
 
-       ret = yaca_verify_init(&ctx, algo, key);
+       ret = yaca_verify_initialize(&ctx, algo, key);
        if (ret != YACA_ERROR_NONE)
                return ret;
 
@@ -299,52 +299,52 @@ API int yaca_verify(yaca_digest_algo_e algo,
        if (ret != YACA_ERROR_NONE)
                goto exit;
 
-       ret = yaca_verify_final(ctx, signature, signature_len);
+       ret = yaca_verify_finalize(ctx, signature, signature_len);
 
 exit:
-       yaca_ctx_free(ctx);
+       yaca_context_destroy(ctx);
 
        return ret;
 }
 
-API int yaca_hmac(yaca_digest_algo_e algo,
-                  const yaca_key_h key,
-                  const char *data,
-                  size_t data_len,
-                  char **mac,
-                  size_t *mac_len)
+API int yaca_simple_calculate_hmac(yaca_digest_algorithm_e algo,
+                                   const yaca_key_h key,
+                                   const char *data,
+                                   size_t data_len,
+                                   char **mac,
+                                   size_t *mac_len)
 {
        int ret;
-       yaca_ctx_h ctx = YACA_CTX_NULL;
+       yaca_context_h ctx = YACA_CONTEXT_NULL;
 
-       ret = yaca_sign_hmac_init(&ctx, algo, key);
+       ret = yaca_sign_initialize_hmac(&ctx, algo, key);
        if (ret != YACA_ERROR_NONE)
                return ret;
 
        ret = sign(ctx, data, data_len, mac, mac_len);
 
-       yaca_ctx_free(ctx);
+       yaca_context_destroy(ctx);
 
        return ret;
 }
 
-API int yaca_cmac(yaca_enc_algo_e algo,
-                  const yaca_key_h key,
-                  const char *data,
-                  size_t data_len,
-                  char **mac,
-                  size_t *mac_len)
+API int yaca_simple_calculate_cmac(yaca_encrypt_algorithm_e algo,
+                                   const yaca_key_h key,
+                                   const char *data,
+                                   size_t data_len,
+                                   char **mac,
+                                   size_t *mac_len)
 {
        int ret;
-       yaca_ctx_h ctx = YACA_CTX_NULL;
+       yaca_context_h ctx = YACA_CONTEXT_NULL;
 
-       ret = yaca_sign_cmac_init(&ctx, algo, key);
+       ret = yaca_sign_initialize_cmac(&ctx, algo, key);
        if (ret != YACA_ERROR_NONE)
                return ret;
 
        ret = sign(ctx, data, data_len, mac, mac_len);
 
-       yaca_ctx_free(ctx);
+       yaca_context_destroy(ctx);
 
        return ret;
 }