Replace spaces with tabs 98/95998/2 accepted/tizen_4.0_unified accepted/tizen_5.0_unified accepted/tizen_common accepted/tizen_ivi accepted/tizen_mobile accepted/tizen_tv accepted/tizen_wearable accepted/tizen/4.0/unified/20170816.011448 accepted/tizen/4.0/unified/20170829.020006 accepted/tizen/5.0/unified/20181102.020909 accepted/tizen/common/20161108.131525 accepted/tizen/ivi/20161108.001450 accepted/tizen/mobile/20161108.001352 accepted/tizen/tv/20161108.001407 accepted/tizen/unified/20170309.033544 accepted/tizen/wearable/20161108.001429 submit/tizen/20161107.233654 submit/tizen_4.0/20170811.094300 submit/tizen_4.0/20170828.100004 submit/tizen_4.0/20170828.110004 submit/tizen_5.0/20181101.000004 submit/tizen_unified/20170308.100409 tizen_4.0.IoT.p1_release tizen_4.0.IoT.p2_release tizen_4.0.m1_release tizen_4.0.m2_release
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Mon, 7 Nov 2016 08:21:36 +0000 (09:21 +0100)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Mon, 7 Nov 2016 09:16:17 +0000 (01:16 -0800)
Tab policy [IDT_M_TAB] have changed from optional to mandatory and whole code
has to be adjusted.
doc/coding_rules.txt updated.
File access rights fixed

Change-Id: I7b855be9560e9b4f134294a1f97a70a50af578c1

39 files changed:
api/yaca/yaca_crypto.h [changed mode: 0755->0644]
api/yaca/yaca_digest.h [changed mode: 0755->0644]
api/yaca/yaca_encrypt.h [changed mode: 0755->0644]
api/yaca/yaca_error.h [changed mode: 0755->0644]
api/yaca/yaca_key.h [changed mode: 0755->0644]
api/yaca/yaca_rsa.h [changed mode: 0755->0644]
api/yaca/yaca_seal.h [changed mode: 0755->0644]
api/yaca/yaca_sign.h [changed mode: 0755->0644]
api/yaca/yaca_simple.h [changed mode: 0755->0644]
api/yaca/yaca_types.h [changed mode: 0755->0644]
doc/coding-rules.txt
doc/yaca_doc.h [changed mode: 0755->0644]
doc/yaca_encryption_doc.h [changed mode: 0755->0644]
doc/yaca_integrity_doc.h [changed mode: 0755->0644]
doc/yaca_key_doc.h [changed mode: 0755->0644]
doc/yaca_rsa_doc.h [changed mode: 0755->0644]
doc/yaca_simple_doc.h [changed mode: 0755->0644]
examples/digest_simple.c
examples/encrypt_simple.c
examples/key_exchange.c
examples/key_import_export_asym.c
examples/key_import_export_sym.c
examples/key_password.c
examples/key_wrap.c
examples/rsa_private.c
examples/rsa_public.c
examples/seal.c
examples/sign_simple.c
examples/sign_simple_cmac.c
src/crypto.c
src/debug.c
src/digest.c
src/encrypt.c
src/internal.h
src/key.c
src/rsa.c
src/seal.c
src/sign.c
src/simple.c

old mode 100755 (executable)
new mode 100644 (file)
index e2b2d5a..56425eb
@@ -206,9 +206,9 @@ int yaca_randomize_bytes(char *data, size_t data_len);
  * @see yaca_context_get_property()
  */
 int yaca_context_set_property(yaca_context_h ctx,
-                              yaca_property_e property,
-                              const void *value,
-                              size_t value_len);
+                                                         yaca_property_e property,
+                                                         const void *value,
+                                                         size_t value_len);
 
 /**
  * @brief  Returns the non-standard context properties. Can only be called on an
@@ -241,9 +241,9 @@ int yaca_context_set_property(yaca_context_h ctx,
  * @see yaca_free()
  */
 int yaca_context_get_property(const yaca_context_h ctx,
-                              yaca_property_e property,
-                              void **value,
-                              size_t *value_len);
+                                                         yaca_property_e property,
+                                                         void **value,
+                                                         size_t *value_len);
 
 /**
  * @brief  Returns the minimum required size of the output buffer for a single crypto function call.
@@ -271,8 +271,8 @@ int yaca_context_get_property(const yaca_context_h ctx,
  * @retval #YACA_ERROR_INTERNAL Internal error
  */
 int yaca_context_get_output_length(const yaca_context_h ctx,
-                                   size_t input_len,
-                                   size_t *output_len);
+                                                                  size_t input_len,
+                                                                  size_t *output_len);
 
 /**
  * @brief  Destroys the crypto context. Must be called on all contexts that are
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 3395013..4031f2c
@@ -58,9 +58,9 @@ extern "C" {
  *
  */
 int yaca_encrypt_get_iv_bit_length(yaca_encrypt_algorithm_e algo,
-                                   yaca_block_cipher_mode_e bcm,
-                                   size_t key_bit_len,
-                                   size_t *iv_bit_len);
+                                                                  yaca_block_cipher_mode_e bcm,
+                                                                  size_t key_bit_len,
+                                                                  size_t *iv_bit_len);
 
 /**
  * @brief  Initializes an encryption context.
@@ -89,10 +89,10 @@ int yaca_encrypt_get_iv_bit_length(yaca_encrypt_algorithm_e algo,
  * @see yaca_context_destroy()
  */
 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);
+                                                       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.
@@ -118,10 +118,10 @@ int yaca_encrypt_initialize(yaca_context_h *ctx,
  * @see yaca_context_get_output_length()
  */
 int yaca_encrypt_update(yaca_context_h ctx,
-                        const char *plaintext,
-                        size_t plaintext_len,
-                        char *ciphertext,
-                        size_t *ciphertext_len);
+                                               const char *plaintext,
+                                               size_t plaintext_len,
+                                               char *ciphertext,
+                                               size_t *ciphertext_len);
 
 /**
  * @brief  Encrypts the final chunk of the data.
@@ -148,8 +148,8 @@ int yaca_encrypt_update(yaca_context_h ctx,
  * @see yaca_context_get_output_length()
  */
 int yaca_encrypt_finalize(yaca_context_h ctx,
-                          char *ciphertext,
-                          size_t *ciphertext_len);
+                                                 char *ciphertext,
+                                                 size_t *ciphertext_len);
 
 /**
  * @brief  Initializes an decryption context.
@@ -178,10 +178,10 @@ int yaca_encrypt_finalize(yaca_context_h ctx,
  * @see yaca_context_destroy()
  */
 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);
+                                                       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.
@@ -208,10 +208,10 @@ int yaca_decrypt_initialize(yaca_context_h *ctx,
  * @see yaca_context_get_output_length()
  */
 int yaca_decrypt_update(yaca_context_h ctx,
-                        const char *ciphertext,
-                        size_t ciphertext_len,
-                        char *plaintext,
-                        size_t *plaintext_len);
+                                               const char *ciphertext,
+                                               size_t ciphertext_len,
+                                               char *plaintext,
+                                               size_t *plaintext_len);
 
 /**
  * @brief  Decrypts the final chunk of the data.
@@ -239,8 +239,8 @@ int yaca_decrypt_update(yaca_context_h ctx,
  * @see yaca_context_get_output_length()
  */
 int yaca_decrypt_finalize(yaca_context_h ctx,
-                          char *plaintext,
-                          size_t *plaintext_len);
+                                                 char *plaintext,
+                                                 size_t *plaintext_len);
 
 /**
  * @}
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 4f50550..5c87944
@@ -138,10 +138,10 @@ int yaca_key_get_bit_length(const yaca_key_h key, size_t *key_bit_len);
  * @see yaca_key_destroy()
  */
 int yaca_key_import(yaca_key_type_e key_type,
-                    const char *password,
-                    const char *data,
-                    size_t data_len,
-                    yaca_key_h *key);
+                                       const char *password,
+                                       const char *data,
+                                       size_t data_len,
+                                       yaca_key_h *key);
 
 /**
  * @brief  Exports a key or key generation parameters to arbitrary format.
@@ -201,11 +201,11 @@ int yaca_key_import(yaca_key_type_e key_type,
  * @see yaca_key_destroy()
  */
 int yaca_key_export(const yaca_key_h key,
-                    yaca_key_format_e key_fmt,
-                    yaca_key_file_format_e key_file_fmt,
-                    const char *password,
-                    char **data,
-                    size_t *data_len);
+                                       yaca_key_format_e key_fmt,
+                                       yaca_key_file_format_e key_file_fmt,
+                                       const char *password,
+                                       char **data,
+                                       size_t *data_len);
 
 /**
  * @brief  Generates a secure key or key generation parameters (or an Initialization Vector).
@@ -245,8 +245,8 @@ int yaca_key_export(const yaca_key_h key,
  * @see yaca_key_destroy()
  */
 int yaca_key_generate(yaca_key_type_e key_type,
-                      size_t key_bit_len,
-                      yaca_key_h *key);
+                                         size_t key_bit_len,
+                                         yaca_key_h *key);
 
 /**
  * @brief  Generates a secure private asymmetric key from parameters.
@@ -346,9 +346,9 @@ int yaca_key_extract_parameters(const yaca_key_h key, yaca_key_h *params);
  * @see yaca_free()
  */
 int yaca_key_derive_dh(const yaca_key_h prv_key,
-                       const yaca_key_h pub_key,
-                       char **secret,
-                       size_t *secret_len);
+                                          const yaca_key_h pub_key,
+                                          char **secret,
+                                          size_t *secret_len);
 
 /**
  * @brief  Derives a key material from shared secret.
@@ -386,13 +386,13 @@ int yaca_key_derive_dh(const yaca_key_h prv_key,
  * @see yaca_free()
  */
 int yaca_key_derive_kdf(yaca_kdf_e kdf,
-                        yaca_digest_algorithm_e algo,
-                        const char *secret,
-                        size_t secret_len,
-                        const char *info,
-                        size_t info_len,
-                        size_t key_material_len,
-                        char **key_material);
+                                               yaca_digest_algorithm_e algo,
+                                               const char *secret,
+                                               size_t secret_len,
+                                               const char *info,
+                                               size_t info_len,
+                                               size_t key_material_len,
+                                               char **key_material);
 
 /**
  * @brief  Derives a key from user password (PKCS #5 a.k.a. pbkdf2 algorithm).
@@ -420,12 +420,12 @@ int yaca_key_derive_kdf(yaca_kdf_e kdf,
  * @see yaca_key_destroy()
  */
 int yaca_key_derive_pbkdf2(const char *password,
-                           const char *salt,
-                           size_t salt_len,
-                           size_t iterations,
-                           yaca_digest_algorithm_e algo,
-                           size_t key_bit_len,
-                           yaca_key_h *key);
+                                                  const char *salt,
+                                                  size_t salt_len,
+                                                  size_t iterations,
+                                                  yaca_digest_algorithm_e algo,
+                                                  size_t key_bit_len,
+                                                  yaca_key_h *key);
 
 /**
  * @brief  Release the key created by the library. Passing YACA_KEY_NULL is allowed.
old mode 100755 (executable)
new mode 100644 (file)
index 20b1b4d..a57bfd7
@@ -70,11 +70,11 @@ extern "C" {
  * @see yaca_free()
  */
 int yaca_rsa_public_encrypt(yaca_padding_e padding,
-                            const yaca_key_h pub_key,
-                            const char *plaintext,
-                            size_t plaintext_len,
-                            char **ciphertext,
-                            size_t *ciphertext_len);
+                                                       const yaca_key_h pub_key,
+                                                       const char *plaintext,
+                                                       size_t plaintext_len,
+                                                       char **ciphertext,
+                                                       size_t *ciphertext_len);
 
 /**
  * @brief  Decrypts data using a RSA private key (low-level decrypt equivalent).
@@ -105,11 +105,11 @@ int yaca_rsa_public_encrypt(yaca_padding_e padding,
  * @see yaca_free()
  */
 int yaca_rsa_private_decrypt(yaca_padding_e padding,
-                             const yaca_key_h prv_key,
-                             const char *ciphertext,
-                             size_t ciphertext_len,
-                             char **plaintext,
-                             size_t *plaintext_len);
+                                                        const yaca_key_h prv_key,
+                                                        const char *ciphertext,
+                                                        size_t ciphertext_len,
+                                                        char **plaintext,
+                                                        size_t *plaintext_len);
 
 /**
  * @brief  Encrypts data using a RSA private key (low-level sign equivalent).
@@ -145,11 +145,11 @@ int yaca_rsa_private_decrypt(yaca_padding_e padding,
  * @see yaca_free()
  */
 int yaca_rsa_private_encrypt(yaca_padding_e padding,
-                             const yaca_key_h prv_key,
-                             const char *plaintext,
-                             size_t plaintext_len,
-                             char **ciphertext,
-                             size_t *ciphertext_len);
+                                                        const yaca_key_h prv_key,
+                                                        const char *plaintext,
+                                                        size_t plaintext_len,
+                                                        char **ciphertext,
+                                                        size_t *ciphertext_len);
 
 /**
  * @brief  Decrypts data using a RSA public key (low-level verify equivalent).
@@ -180,11 +180,11 @@ int yaca_rsa_private_encrypt(yaca_padding_e padding,
  * @see yaca_free()
  */
 int yaca_rsa_public_decrypt(yaca_padding_e padding,
-                            const yaca_key_h pub_key,
-                            const char *ciphertext,
-                            size_t ciphertext_len,
-                            char **plaintext,
-                            size_t *plaintext_len);
+                                                       const yaca_key_h pub_key,
+                                                       const char *ciphertext,
+                                                       size_t ciphertext_len,
+                                                       char **plaintext,
+                                                       size_t *plaintext_len);
 
 /**
  * @}
old mode 100755 (executable)
new mode 100644 (file)
index 7fab958..5db810e
@@ -87,12 +87,12 @@ extern "C" {
  * @see yaca_context_destroy()
  */
 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,
-                         size_t sym_key_bit_len,
-                         yaca_key_h *sym_key,
-                         yaca_key_h *iv);
+                                                const yaca_key_h pub_key,
+                                                yaca_encrypt_algorithm_e algo,
+                                                yaca_block_cipher_mode_e bcm,
+                                                size_t sym_key_bit_len,
+                                                yaca_key_h *sym_key,
+                                                yaca_key_h *iv);
 
 /**
  * @brief  Encrypts piece of the data.
@@ -118,10 +118,10 @@ int yaca_seal_initialize(yaca_context_h *ctx,
  * @see yaca_context_get_output_length()
  */
 int yaca_seal_update(yaca_context_h ctx,
-                     const char *plaintext,
-                     size_t plaintext_len,
-                     char *ciphertext,
-                     size_t *ciphertext_len);
+                                        const char *plaintext,
+                                        size_t plaintext_len,
+                                        char *ciphertext,
+                                        size_t *ciphertext_len);
 
 /**
  * @brief  Encrypts the final piece of the data.
@@ -148,8 +148,8 @@ int yaca_seal_update(yaca_context_h ctx,
  * @see yaca_context_get_output_length()
  */
 int yaca_seal_finalize(yaca_context_h ctx,
-                       char *ciphertext,
-                       size_t *ciphertext_len);
+                                          char *ciphertext,
+                                          size_t *ciphertext_len);
 
 /**
  * @brief  Initializes an asymmetric decryption context.
@@ -185,12 +185,12 @@ int yaca_seal_finalize(yaca_context_h ctx,
  * @see yaca_context_destroy()
  */
 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,
-                         size_t sym_key_bit_len,
-                         const yaca_key_h sym_key,
-                         const yaca_key_h iv);
+                                                const yaca_key_h prv_key,
+                                                yaca_encrypt_algorithm_e algo,
+                                                yaca_block_cipher_mode_e bcm,
+                                                size_t sym_key_bit_len,
+                                                const yaca_key_h sym_key,
+                                                const yaca_key_h iv);
 
 /**
  * @brief  Decrypts piece of the data.
@@ -217,10 +217,10 @@ int yaca_open_initialize(yaca_context_h *ctx,
  * @see yaca_context_get_output_length()
  */
 int yaca_open_update(yaca_context_h ctx,
-                     const char *ciphertext,
-                     size_t ciphertext_len,
-                     char *plaintext,
-                     size_t *plaintext_len);
+                                        const char *ciphertext,
+                                        size_t ciphertext_len,
+                                        char *plaintext,
+                                        size_t *plaintext_len);
 
 /**
  * @brief  Decrypts last chunk of sealed message.
@@ -248,8 +248,8 @@ int yaca_open_update(yaca_context_h ctx,
  * @see yaca_context_get_output_length()
  */
 int yaca_open_finalize(yaca_context_h ctx,
-                       char *plaintext,
-                       size_t *plaintext_len);
+                                          char *plaintext,
+                                          size_t *plaintext_len);
 
 /**
  * @}
old mode 100755 (executable)
new mode 100644 (file)
index e627262..0fcbec3
@@ -83,8 +83,8 @@ extern "C" {
  * @see yaca_context_destroy()
  */
 int yaca_sign_initialize(yaca_context_h *ctx,
-                         yaca_digest_algorithm_e algo,
-                         const yaca_key_h prv_key);
+                                                yaca_digest_algorithm_e algo,
+                                                const yaca_key_h prv_key);
 
 /**
  * @brief  Initializes a signature context for HMAC.
@@ -117,8 +117,8 @@ int yaca_sign_initialize(yaca_context_h *ctx,
  * @see yaca_context_destroy()
  */
 int yaca_sign_initialize_hmac(yaca_context_h *ctx,
-                              yaca_digest_algorithm_e algo,
-                              const yaca_key_h sym_key);
+                                                         yaca_digest_algorithm_e algo,
+                                                         const yaca_key_h sym_key);
 
 /**
  * @brief  Initializes a signature context for CMAC.
@@ -151,8 +151,8 @@ int yaca_sign_initialize_hmac(yaca_context_h *ctx,
  * @see yaca_context_destroy()
  */
 int yaca_sign_initialize_cmac(yaca_context_h *ctx,
-                              yaca_encrypt_algorithm_e algo,
-                              const yaca_key_h sym_key);
+                                                         yaca_encrypt_algorithm_e algo,
+                                                         const yaca_key_h sym_key);
 
 /**
  * @brief  Feeds the message into the digital signature or MAC algorithm.
@@ -176,8 +176,8 @@ int yaca_sign_initialize_cmac(yaca_context_h *ctx,
  * @see yaca_sign_initialize_cmac()
  */
 int yaca_sign_update(yaca_context_h ctx,
-                     const char *message,
-                     size_t message_len);
+                                        const char *message,
+                                        size_t message_len);
 
 /**
  * @brief  Calculates the final signature or MAC.
@@ -206,8 +206,8 @@ int yaca_sign_update(yaca_context_h ctx,
  * @see yaca_context_get_output_length()
  */
 int yaca_sign_finalize(yaca_context_h ctx,
-                       char *signature,
-                       size_t *signature_len);
+                                          char *signature,
+                                          size_t *signature_len);
 
 /**
  * @brief  Initializes a signature verification context for asymmetric signatures.
@@ -244,8 +244,8 @@ int yaca_sign_finalize(yaca_context_h ctx,
  * @see yaca_context_destroy()
  */
 int yaca_verify_initialize(yaca_context_h *ctx,
-                           yaca_digest_algorithm_e algo,
-                           const yaca_key_h pub_key);
+                                                  yaca_digest_algorithm_e algo,
+                                                  const yaca_key_h pub_key);
 
 /**
  * @brief  Feeds the message into the digital signature verification algorithm.
@@ -266,8 +266,8 @@ int yaca_verify_initialize(yaca_context_h *ctx,
  * @see yaca_verify_finalize()
  */
 int yaca_verify_update(yaca_context_h ctx,
-                       const char *message,
-                       size_t message_len);
+                                          const char *message,
+                                          size_t message_len);
 
 /**
  * @brief  Performs the verification.
@@ -293,8 +293,8 @@ int yaca_verify_update(yaca_context_h ctx,
  * @see yaca_sign_finalize()
  */
 int yaca_verify_finalize(yaca_context_h ctx,
-                         const char *signature,
-                         size_t signature_len);
+                                                const char *signature,
+                                                size_t signature_len);
 
 /**
  * @}
old mode 100755 (executable)
new mode 100644 (file)
index b77e9bc..97a9826
@@ -80,13 +80,13 @@ extern "C" {
  * @see yaca_free()
  */
 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 *plaintext,
-                        size_t plaintext_len,
-                        char **ciphertext,
-                        size_t *ciphertext_len);
+                                               yaca_block_cipher_mode_e bcm,
+                                               const yaca_key_h sym_key,
+                                               const yaca_key_h iv,
+                                               const char *plaintext,
+                                               size_t plaintext_len,
+                                               char **ciphertext,
+                                               size_t *ciphertext_len);
 
 /**
  * @brief  Decrypts data using a symmetric cipher.
@@ -121,13 +121,13 @@ int yaca_simple_encrypt(yaca_encrypt_algorithm_e algo,
  * @see yaca_free()
  */
 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 *ciphertext,
-                        size_t ciphertext_len,
-                        char **plaintext,
-                        size_t *plaintext_len);
+                                               yaca_block_cipher_mode_e bcm,
+                                               const yaca_key_h sym_key,
+                                               const yaca_key_h iv,
+                                               const char *ciphertext,
+                                               size_t ciphertext_len,
+                                               char **plaintext,
+                                               size_t *plaintext_len);
 
 /**
  * @brief  Calculates a digest of a message.
@@ -155,10 +155,10 @@ int yaca_simple_decrypt(yaca_encrypt_algorithm_e algo,
  * @see yaca_free()
  */
 int yaca_simple_calculate_digest(yaca_digest_algorithm_e algo,
-                                 const char *message,
-                                 size_t message_len,
-                                 char **digest,
-                                 size_t *digest_len);
+                                                                const char *message,
+                                                                size_t message_len,
+                                                                char **digest,
+                                                                size_t *digest_len);
 
 /**
  * @brief  Creates a signature using asymmetric private key.
@@ -198,11 +198,11 @@ int yaca_simple_calculate_digest(yaca_digest_algorithm_e algo,
  * @see yaca_free()
  */
 int yaca_simple_calculate_signature(yaca_digest_algorithm_e algo,
-                                    const yaca_key_h prv_key,
-                                    const char *message,
-                                    size_t message_len,
-                                    char **signature,
-                                    size_t *signature_len);
+                                                                       const yaca_key_h prv_key,
+                                                                       const char *message,
+                                                                       size_t message_len,
+                                                                       char **signature,
+                                                                       size_t *signature_len);
 
 /**
  * @brief  Verifies a signature using asymmetric public key.
@@ -235,11 +235,11 @@ int yaca_simple_calculate_signature(yaca_digest_algorithm_e algo,
  * @see yaca_simple_calculate_signature()
  */
 int yaca_simple_verify_signature(yaca_digest_algorithm_e algo,
-                                 const yaca_key_h pub_key,
-                                 const char *message,
-                                 size_t message_len,
-                                 const char *signature,
-                                 size_t signature_len);
+                                                                const yaca_key_h pub_key,
+                                                                const char *message,
+                                                                size_t message_len,
+                                                                const char *signature,
+                                                                size_t signature_len);
 
 /**
  * @brief  Calculates a HMAC of given message using symmetric key.
@@ -275,11 +275,11 @@ int yaca_simple_verify_signature(yaca_digest_algorithm_e algo,
  * @see yaca_free()
  */
 int yaca_simple_calculate_hmac(yaca_digest_algorithm_e algo,
-                               const yaca_key_h sym_key,
-                               const char *message,
-                               size_t message_len,
-                               char **mac,
-                               size_t *mac_len);
+                                                          const yaca_key_h sym_key,
+                                                          const char *message,
+                                                          size_t message_len,
+                                                          char **mac,
+                                                          size_t *mac_len);
 
 /**
  * @brief  Calculates a CMAC of given message using symmetric key.
@@ -315,11 +315,11 @@ int yaca_simple_calculate_hmac(yaca_digest_algorithm_e algo,
  * @see yaca_free()
  */
 int yaca_simple_calculate_cmac(yaca_encrypt_algorithm_e algo,
-                               const yaca_key_h sym_key,
-                               const char *message,
-                               size_t message_len,
-                               char **mac,
-                               size_t *mac_len);
+                                                          const yaca_key_h sym_key,
+                                                          const char *message,
+                                                          size_t message_len,
+                                                          char **mac,
+                                                          size_t *mac_len);
 
 /**
  * @}
old mode 100755 (executable)
new mode 100644 (file)
index 4f55843..9f8b70e 100644 (file)
@@ -4,24 +4,24 @@
 Differences from Tizen rules are included as "Notes". For full description of
 each rule - please refer to Tizen documentation.
 
-[R01] [CMT_M_C89] Style for comment is the C89 "/* â€¦ */" style.
+[R01] [CMT_M_C89] Both comment styles are allowed : C89 "/* ... */" style & C99 "//" style
 Note: Temporary comments may use C99 style (TODO, FIXME etc.)
 
 [R02] [DEC_R_INL] inline keyword should sit between storage class and type.
 
-[R03] [IDT_R_TAB] Use tabs. All tabs are 4 characters. Indentation use only tab (No space key).
-Note: If possible use Smart Tabs, if not - 4-character tabs + alignment spaces
+[M01] [IDT_M_TAB] Use tabs. All tabs are 4 characters. Indentation use only tab (No space key).
+Note: If necessary use 4-character tabs + alignment spaces
 
-[R04] [IDT_R_SCH] Switch and case should be at the same indent.
+[M02] [IDT_M_SCH] Switch and case should be at the same indent.
 
-[R05] [IDT_R_LBL] goto labels aren't indented, allow a single space however.
+[R03] [IDT_R_LBL] goto labels aren't indented, allow a single space however.
 Note: No single space allowed
 
-[M01] [SPC_M_KWD] Keywords have following space rules
+[M03] [SPC_M_KWD] Keywords have following space rules
 -Put a space after (most) keywords (ex: if, switch, case, for, do, while).
 -Exception: Do not put a space after function like keywords, such as sizeof, typeof, alignof, __attribute__. -
 
-[M02] [SPC_M_OPR] Operators have following space rules
+[M04] [SPC_M_OPR] Operators have following space rules
 -Put a space around(on each side of) most binary and ternary operators
 -Example: = + -< > * / % | & ^ <= >= == != ? :
 -Do not put a space after unary operators
@@ -30,7 +30,7 @@ Note: No single space allowed
 -Do not put a space after cast operator
 -Do not put a space around the "." and "->" structure member operators.
 
-[M03] [SPC_M_SEP] Seperators have following space rules
+[M05] [SPC_M_SEP] Seperators have following space rules
 -Put a space after closing brace when it has anything on the line.
 -Exception : comma after closing brace '},'
 -Put a space after comma
@@ -38,50 +38,50 @@ Note: No single space allowed
 -Do not put a space after the function name in function calls.
 -Do not put space before open square bracket '['; and inside square bracket '[', ']'.
 
-[M04] [BRC_M_FTN] functions have the opening brace at the beginning of the next line.
+[M06] [BRC_M_FTN] functions have the opening brace at the beginning of the next line.
 
-[M05] [BRC_M_SMT] Statement brace: Open brace last on the line. The closing brace is empty on a line of its own.
+[M07] [BRC_M_SMT] Statement brace: Open brace last on the line. The closing brace is empty on a line of its own.
 -Exception: Where the closing race is followed by a continuation of the same statement, else should follow close brace '}',
 while should follow close brace '}'
 
-[M06] [BRC_M_EUS] Open braces for enum, union and struct go on the same line.
+[M08] [BRC_M_EUS] Open braces for enum, union and struct go on the same line.
 
-[R06] [BRC_R_SST] Do not unnecessarily use braces where a single statement will do.
+[R04] [BRC_R_SST] Do not unnecessarily use braces where a single statement will do.
 -Exception: if one branch of a conditional statement is a single statement, use braces in both branches.
 
-[R07] [LNE_R_TWS] No trailing whitespaces at the ends of lines.
+[R05] [LNE_R_TWS] No trailing whitespaces at the ends of lines.
 
-[R08] [LNE_R_EOF] Check for adding lines without a newline at end of file.
-Notes: File should end with '\n' (single newline at the end of file)
+[R06] [LNE_R_EOF] Check for adding lines without a newline at end of file.
+Note: File should end with '\n' (single newline at the end of file)
 
-[R09] In source file, the sequence of the code organization : Copyright File comments Header files Define constant and macros Declare static (private) functions Define exported (public) functions Define static (private) functions Define protected functions.
-Notes: Static (private) function code first, then functions used by other objects in library; API (public) functions at the end
+[R07] In source file, the sequence of the code organization : Copyright, File comments, Header files, Define constant and macros, Declare static (private) functions, Define exported (public) functions, Define static (private) functions, Define protected functions.
+Note: Static (private) function code first, then functions used by other objects in library; API (public) functions at the end
 
 ******** Public API should use 'API' macro - other functions are not visible outside of library
 
-[M07] Separate external public header(API) and internal header(declare protected functions that are not exported but use for many files)
+[M09] Separate external public header(API) and internal header(declare protected functions that are not exported but use for many files)
 
-[M08] External public headers include the Doxygen style for comment. ex) Variable, Function, Struct.
+[M10] External public headers include the Doxygen style for comment. ex) Variable, Function, Struct.
 
-[M09] In function prototypes, include parameter names with their data types and return type.
+[M11] In function prototypes, include parameter names with their data types and return type.
 
-[R10] Macros with multiple statements should be enclosed in a "do -while" block.
+[R08] Macros with multiple statements should be enclosed in a "do -while" block.
 
-[R11] ''#' symbol for macro shall be located at the first column.
+[R09] ''#' symbol for macro shall be located at the first column.
 
-[R12] In macro definition, every expression and the arguments in the expressions shall be enclosed by '(' and ')' for each.
+[R10] In macro definition, every expression and the arguments in the expressions shall be enclosed by '(' and ')' for each.
 
-[R13] Don’t declare both a structure tag and variables or typedefs in the same declaration.
+[R11] Don’t declare both a structure tag and variables or typedefs in the same declaration.
 Note: Avoid use of typedefs for structures/enums unless it's needed (for handles in API etc.)
 
-[R14] Each variable shall be declared in the new line.
+[R12] Each variable shall be declared in the new line.
 Notes: except for counters (like i, j, k, etc.).
 
-[M10] No mixed-case, Use underscores('_') to separate words in a name.
+[M12] No mixed-case, Use underscores('_') to separate words in a name.
 
-[R15] Names of macros defining constants and labels in enums are composed of capital letters, numbers and '_' character.
+[R13] Names of macros defining constants and labels in enums are composed of capital letters, numbers and '_' character.
 
-[R16] Name of functions are Verb + Noun to have a good representation of features.
+[R14] Name of functions are Verb + Noun to have a good representation of features.
 Note: this is rule of thumb except for Public API. Public API has prefix (<library>_<module>_fcn).
 
 --------------------------------------------------------------------------------
@@ -98,8 +98,8 @@ Note: this is rule of thumb except for Public API. Public API has prefix (<libra
 3. Tizen rules that should NOT be followed
 --------------------------------------------------------------------------------
 
-[R17] Local functions whose scope is limited to the current source file have "static" keyword and names started with "__".
-Note: static functions should not include "prefix" but can have arbitrary names (see R16).
+[R15] Local functions whose scope is limited to the current source file have "static" keyword and names started with "__".
+Note: static functions should not include "prefix" but can have arbitrary names (see R14).
 
-[R18] Names of protected(global) functions in internal header are started with '_' character.
-Note: Functions shared between multiple objects can have arbitrary naming (see R16)
+[R16] Names of protected(global) functions in internal header are started with '_' character.
+Note: Functions shared between multiple objects can have arbitrary naming (see R14)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 083d537..a629f07 100644 (file)
@@ -45,7 +45,7 @@ int main()
 
        /* Calculate digest */
        ret = yaca_simple_calculate_digest(YACA_DIGEST_SHA256, INPUT_DATA, INPUT_DATA_SIZE,
-                                          &digest, &digest_len);
+                                                                          &digest, &digest_len);
        if (ret != YACA_ERROR_NONE)
                goto exit;
 
index dadab7c..a1c29c8 100644 (file)
@@ -53,13 +53,13 @@ int main()
 
        /* Key generation */
        ret = yaca_key_derive_pbkdf2("foo bar", "123456789", 10, 1000,
-                                    YACA_DIGEST_SHA256, YACA_KEY_LENGTH_256BIT, &key);
+                                                                YACA_DIGEST_SHA256, YACA_KEY_LENGTH_256BIT, &key);
        if (ret != YACA_ERROR_NONE)
                goto exit;
 
        /* IV generation */
        ret = yaca_encrypt_get_iv_bit_length(YACA_ENCRYPT_AES, YACA_BCM_CTR, YACA_KEY_LENGTH_256BIT,
-                                            &iv_bit_len);
+                                                                                &iv_bit_len);
        if (ret != YACA_ERROR_NONE)
                goto exit;
 
@@ -72,7 +72,7 @@ int main()
        /* Encryption */
        {
                ret = yaca_simple_encrypt(YACA_ENCRYPT_AES, YACA_BCM_CTR, key, iv,
-                                         INPUT_DATA, INPUT_DATA_SIZE, &encrypted, &encrypted_len);
+                                                                 INPUT_DATA, INPUT_DATA_SIZE, &encrypted, &encrypted_len);
                if (ret != YACA_ERROR_NONE)
                        goto exit;
 
@@ -83,7 +83,7 @@ int main()
        /* Decryption */
        {
                ret = yaca_simple_decrypt(YACA_ENCRYPT_AES, YACA_BCM_CTR, key, iv,
-                                         encrypted, encrypted_len, &decrypted, &decrypted_len);
+                                                                 encrypted, encrypted_len, &decrypted, &decrypted_len);
                if (ret != YACA_ERROR_NONE)
                        goto exit;
 
index 1520a4c..89540f8 100644 (file)
@@ -101,7 +101,7 @@ int main()
        iv_material_len = YACA_KEY_LENGTH_IV_128BIT / 8;
        temp_material_len = key_material_len + iv_material_len;
        ret = yaca_key_derive_kdf(YACA_KDF_X942, YACA_DIGEST_SHA512, secret, secret_len,
-                                 NULL, 0, temp_material_len, &temp_material);
+                                                         NULL, 0, temp_material_len, &temp_material);
        if (ret != YACA_ERROR_NONE)
                goto exit;
 
index 7d97532..c7fc38e 100644 (file)
@@ -58,7 +58,7 @@ int main()
 
        /* PEM private */
        ret = yaca_key_export(rsa_priv, YACA_KEY_FORMAT_DEFAULT, YACA_KEY_FILE_FORMAT_PEM, NULL,
-                             &pem_priv, &pem_priv_len);
+                                                 &pem_priv, &pem_priv_len);
        if (ret != YACA_ERROR_NONE)
                goto exit;
 
@@ -71,7 +71,7 @@ int main()
        pem_priv = NULL;
 
        ret = yaca_key_export(pem_priv_imported, YACA_KEY_FORMAT_DEFAULT, YACA_KEY_FILE_FORMAT_PEM,
-                             NULL, &pem_priv, &pem_priv_len);
+                                                 NULL, &pem_priv, &pem_priv_len);
        if (ret != YACA_ERROR_NONE)
                goto exit;
 
@@ -79,7 +79,7 @@ int main()
 
        /* DER public */
        ret = yaca_key_export(rsa_pub, YACA_KEY_FORMAT_DEFAULT, YACA_KEY_FILE_FORMAT_DER, NULL,
-                             &der_pub, &der_pub_len);
+                                                 &der_pub, &der_pub_len);
        if (ret != YACA_ERROR_NONE)
                goto exit;
 
@@ -93,7 +93,7 @@ int main()
        der_pub = NULL;
 
        ret = yaca_key_export(der_pub_imported, YACA_KEY_FORMAT_DEFAULT, YACA_KEY_FILE_FORMAT_DER,
-                             NULL, &der_pub, &der_pub_len);
+                                                 NULL, &der_pub, &der_pub_len);
        if (ret != YACA_ERROR_NONE)
                goto exit;
 
index 3dafd9f..422818d 100644 (file)
@@ -53,7 +53,7 @@ int main()
 
        /* BASE64 */
        ret = yaca_key_export(sym_key, YACA_KEY_FORMAT_DEFAULT, YACA_KEY_FILE_FORMAT_BASE64, NULL,
-                             &b64, &b64_len);
+                                                 &b64, &b64_len);
        if (ret != YACA_ERROR_NONE)
                goto exit;
 
@@ -66,7 +66,7 @@ int main()
        b64 = NULL;
 
        ret = yaca_key_export(b64_imported, YACA_KEY_FORMAT_DEFAULT, YACA_KEY_FILE_FORMAT_BASE64, NULL,
-                             &b64, &b64_len);
+                                                 &b64, &b64_len);
        if (ret != YACA_ERROR_NONE)
                goto exit;
 
@@ -74,7 +74,7 @@ int main()
 
        /* RAW */
        ret = yaca_key_export(sym_key, YACA_KEY_FORMAT_DEFAULT, YACA_KEY_FILE_FORMAT_RAW, NULL,
-                             &raw, &raw_len);
+                                                 &raw, &raw_len);
        if (ret != YACA_ERROR_NONE)
                goto exit;
 
@@ -88,7 +88,7 @@ int main()
        raw = NULL;
 
        ret = yaca_key_export(raw_imported, YACA_KEY_FORMAT_DEFAULT, YACA_KEY_FILE_FORMAT_RAW, NULL,
-                             &raw, &raw_len);
+                                                 &raw, &raw_len);
        if (ret != YACA_ERROR_NONE)
                goto exit;
 
index 9c9df78..a4f1bc6 100644 (file)
@@ -54,7 +54,7 @@ int main()
                        goto exit;
 
                ret = yaca_key_export(key, YACA_KEY_FORMAT_PKCS8, YACA_KEY_FILE_FORMAT_PEM, password,
-                                     &key_data, &key_data_len);
+                                                         &key_data, &key_data_len);
                if (ret == YACA_ERROR_INVALID_PARAMETER)
                        printf("invalid parameter, probably a missing password for PKCS8\n");
                if (ret != YACA_ERROR_NONE)
@@ -82,7 +82,7 @@ int main()
                key_data = NULL;
 
                ret = yaca_key_export(key, YACA_KEY_FORMAT_PKCS8, YACA_KEY_FILE_FORMAT_PEM, password,
-                                     &key_data, &key_data_len);
+                                                         &key_data, &key_data_len);
                if (ret != YACA_ERROR_NONE)
                        goto exit;
 
index 5363268..15eddcc 100644 (file)
@@ -60,7 +60,7 @@ int main()
 
        /* IV generation */
        ret = yaca_encrypt_get_iv_bit_length(YACA_ENCRYPT_AES, YACA_BCM_WRAP, YACA_KEY_LENGTH_256BIT,
-                                            &iv_bit_len);
+                                                                                &iv_bit_len);
        if (ret != YACA_ERROR_NONE)
                goto exit;
 
@@ -73,13 +73,13 @@ int main()
        /* Key wrapping */
        {
                ret = yaca_key_export(aes_key, YACA_KEY_FORMAT_DEFAULT, YACA_KEY_FILE_FORMAT_RAW, NULL,
-                                     &aes_key_data, &aes_key_data_len);
+                                                         &aes_key_data, &aes_key_data_len);
                if (ret != YACA_ERROR_NONE)
                        goto exit;
 
                ret = yaca_simple_encrypt(YACA_ENCRYPT_AES, YACA_BCM_WRAP, key, iv,
-                                         aes_key_data, aes_key_data_len,
-                                         &wrapped_key_data, &wrapped_key_data_len);
+                                                                 aes_key_data, aes_key_data_len,
+                                                                 &wrapped_key_data, &wrapped_key_data_len);
                if (ret != YACA_ERROR_NONE)
                        goto exit;
 
@@ -96,13 +96,13 @@ int main()
        /* Key unwrapping */
        {
                ret = yaca_simple_decrypt(YACA_ENCRYPT_AES, YACA_BCM_WRAP, key, iv,
-                                         wrapped_key_data, wrapped_key_data_len,
-                                         &aes_key_data, &aes_key_data_len);
+                                                                 wrapped_key_data, wrapped_key_data_len,
+                                                                 &aes_key_data, &aes_key_data_len);
                if (ret != YACA_ERROR_NONE)
                        goto exit;
 
                ret = yaca_key_import(YACA_KEY_TYPE_SYMMETRIC, NULL, aes_key_data, aes_key_data_len,
-                                     &aes_key);
+                                                         &aes_key);
                if (ret != YACA_ERROR_NONE)
                        goto exit;
 
index d8b9818..ea60dba 100644 (file)
@@ -64,7 +64,7 @@ int main()
        /* Encryption */
        {
                ret = yaca_rsa_private_encrypt(YACA_PADDING_PKCS1, rsa_priv, INPUT_DATA, input_len,
-                                              &encrypted, &encrypted_len);
+                                                                          &encrypted, &encrypted_len);
                if (ret != YACA_ERROR_NONE)
                        goto exit;
 
@@ -75,7 +75,7 @@ int main()
        /* Decryption */
        {
                ret = yaca_rsa_public_decrypt(YACA_PADDING_PKCS1, rsa_pub, encrypted, encrypted_len,
-                                             &decrypted, &decrypted_len);
+                                                                         &decrypted, &decrypted_len);
                if (ret != YACA_ERROR_NONE)
                        goto exit;
 
index 08c788a..e025c97 100644 (file)
@@ -64,7 +64,7 @@ int main()
        /* Encryption */
        {
                ret = yaca_rsa_public_encrypt(YACA_PADDING_PKCS1, rsa_pub, INPUT_DATA, input_len,
-                                             &encrypted, &encrypted_len);
+                                                                         &encrypted, &encrypted_len);
                if (ret != YACA_ERROR_NONE)
                        goto exit;
 
@@ -81,7 +81,7 @@ int main()
        /* Decryption */
        {
                ret = yaca_rsa_private_decrypt(YACA_PADDING_PKCS1, rsa_priv, encrypted, encrypted_len,
-                                              &decrypted, &decrypted_len);
+                                                                          &decrypted, &decrypted_len);
                if (ret != YACA_ERROR_NONE)
                        goto exit;
 
index 821df48..325d743 100644 (file)
@@ -69,7 +69,7 @@ int main()
        {
                /* Initialize encryption context */
                ret = yaca_seal_initialize(&ctx, rsa_pub, YACA_ENCRYPT_AES, YACA_BCM_CBC,
-                                          YACA_KEY_LENGTH_256BIT, &sym_key, &iv);
+                                                                  YACA_KEY_LENGTH_256BIT, &sym_key, &iv);
                if (ret != YACA_ERROR_NONE)
                        goto exit;
 
@@ -118,7 +118,7 @@ int main()
        {
                /* Initialize decryption context */
                ret = yaca_open_initialize(&ctx, rsa_priv, YACA_ENCRYPT_AES, YACA_BCM_CBC,
-                                          YACA_KEY_LENGTH_256BIT, sym_key, iv);
+                                                                  YACA_KEY_LENGTH_256BIT, sym_key, iv);
                if (ret != YACA_ERROR_NONE)
                        goto exit;
 
index 04e1ff3..10af256 100644 (file)
@@ -57,8 +57,8 @@ int main()
        /* Sign */
        {
                ret = yaca_simple_calculate_signature(YACA_DIGEST_SHA384, priv_key,
-                                                     INPUT_DATA, INPUT_DATA_SIZE,
-                                                     &signature, &signature_len);
+                                                                                         INPUT_DATA, INPUT_DATA_SIZE,
+                                                                                         &signature, &signature_len);
                if (ret != YACA_ERROR_NONE)
                        goto exit;
 
@@ -69,8 +69,8 @@ int main()
        /* Verify */
        {
                ret = yaca_simple_verify_signature(YACA_DIGEST_SHA384, pub_key,
-                                                  INPUT_DATA, INPUT_DATA_SIZE,
-                                                  signature, signature_len);
+                                                                                  INPUT_DATA, INPUT_DATA_SIZE,
+                                                                                  signature, signature_len);
                if (ret != YACA_ERROR_NONE) {
                        printf("Verification failed\n");
                        goto exit;
index 882c0bc..292fb71 100644 (file)
@@ -53,8 +53,8 @@ int main()
        /* Sign */
        {
                ret = yaca_simple_calculate_cmac(YACA_ENCRYPT_AES, sym_key,
-                                                INPUT_DATA, INPUT_DATA_SIZE,
-                                                &signature1, &signature_len);
+                                                                                INPUT_DATA, INPUT_DATA_SIZE,
+                                                                                &signature1, &signature_len);
                if (ret != YACA_ERROR_NONE)
                        goto exit;
 
@@ -65,8 +65,8 @@ int main()
        /* Verify */
        {
                ret = yaca_simple_calculate_cmac(YACA_ENCRYPT_AES, sym_key,
-                                                INPUT_DATA, INPUT_DATA_SIZE,
-                                                &signature2, &signature_len);
+                                                                                INPUT_DATA, INPUT_DATA_SIZE,
+                                                                                &signature2, &signature_len);
                if (ret != YACA_ERROR_NONE)
                        goto exit;
 
index a13a594..10d313c 100644 (file)
@@ -236,7 +236,7 @@ API int yaca_initialize(void)
 
                        if (CRYPTO_num_locks() > 0) {
                                ret = yaca_malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t),
-                                                 (void**)&mutexes);
+                                                                 (void**)&mutexes);
 
                                if (ret != YACA_ERROR_NONE)
                                        goto exit;
@@ -393,7 +393,7 @@ API int yaca_randomize_bytes(char *data, size_t data_len)
 }
 
 API int yaca_context_set_property(yaca_context_h ctx, yaca_property_e property,
-                                  const void *value, size_t value_len)
+                                                                 const void *value, size_t value_len)
 {
        if (ctx == YACA_CONTEXT_NULL || ctx->set_property == NULL)
                return YACA_ERROR_INVALID_PARAMETER;
@@ -402,7 +402,7 @@ API int yaca_context_set_property(yaca_context_h ctx, yaca_property_e property,
 }
 
 API int yaca_context_get_property(const yaca_context_h ctx, yaca_property_e property,
-                                  void **value, size_t *value_len)
+                                                                 void **value, size_t *value_len)
 {
        if (ctx == YACA_CONTEXT_NULL || ctx->get_property == NULL)
                return YACA_ERROR_INVALID_PARAMETER;
@@ -420,10 +420,10 @@ API void yaca_context_destroy(yaca_context_h ctx)
 }
 
 API int yaca_context_get_output_length(const yaca_context_h ctx,
-                                       size_t input_len, size_t *output_len)
+                                                                          size_t input_len, size_t *output_len)
 {
        if (ctx == YACA_CONTEXT_NULL || output_len == NULL ||
-           ctx->get_output_length == NULL)
+               ctx->get_output_length == NULL)
                return YACA_ERROR_INVALID_PARAMETER;
 
        return ctx->get_output_length(ctx, input_len, output_len);
index 80edb1d..e49a4ca 100644 (file)
@@ -81,7 +81,7 @@ void error_dump(const char *file, int line, const char *function, int code)
        }
 
        written = snprintf(buf, BUF_SIZE, "%s:%d %s() API error: %s0x%02X (%s)\n", file,
-                          line, function, sign, code, err_str);
+                                          line, function, sign, code, err_str);
 
        while ((err = ERR_get_error()) != 0 && written < BUF_SIZE - 1) {
                if (!error_strings_loaded) {
@@ -151,9 +151,9 @@ int error_handle(const char *file, int line, const char *function)
 
                while ((err = ERR_get_error()) != 0)
                        if (err == ERR_PACK(ERR_LIB_PKCS12, PKCS12_F_PKCS12_ITEM_DECRYPT_D2I, PKCS12_R_DECODE_ERROR) ||
-                           err == ERR_PACK(ERR_LIB_PKCS12, PKCS12_F_PKCS12_PBE_CRYPT, PKCS12_R_PKCS12_CIPHERFINAL_ERROR) ||
-                           err == ERR_PACK(ERR_LIB_DSA, DSA_F_OLD_DSA_PRIV_DECODE, ERR_R_DSA_LIB) ||
-                           err == ERR_PACK(ERR_LIB_RSA, RSA_F_OLD_RSA_PRIV_DECODE, ERR_R_RSA_LIB)) {
+                               err == ERR_PACK(ERR_LIB_PKCS12, PKCS12_F_PKCS12_PBE_CRYPT, PKCS12_R_PKCS12_CIPHERFINAL_ERROR) ||
+                               err == ERR_PACK(ERR_LIB_DSA, DSA_F_OLD_DSA_PRIV_DECODE, ERR_R_DSA_LIB) ||
+                               err == ERR_PACK(ERR_LIB_RSA, RSA_F_OLD_RSA_PRIV_DECODE, ERR_R_RSA_LIB)) {
                                found_crypto_error = true;
                                break;
                        }
index 7b14ad2..1d7cbad 100644 (file)
@@ -80,8 +80,8 @@ static struct yaca_digest_context_s *get_digest_context(const yaca_context_h ctx
 }
 
 static int get_digest_output_length(const yaca_context_h ctx,
-                                    size_t input_len,
-                                    size_t *output_len)
+                                                                       size_t input_len,
+                                                                       size_t *output_len)
 {
        assert(output_len != NULL);
 
index 5b0e9f5..f4a21f3 100644 (file)
@@ -320,8 +320,8 @@ int get_wrap_output_length(const yaca_context_h ctx, size_t input_len, size_t *o
 }
 
 static int encrypt_ctx_create(struct yaca_encrypt_context_s **c,
-                              enum encrypt_op_type_e op_type,
-                              const EVP_CIPHER *cipher)
+                                                         enum encrypt_op_type_e op_type,
+                                                         const EVP_CIPHER *cipher)
 {
        int ret;
        int mode;
@@ -340,8 +340,8 @@ static int encrypt_ctx_create(struct yaca_encrypt_context_s **c,
        nc->backup_ctx = NULL;
        nc->ctx.context_destroy = destroy_encrypt_context;
        nc->ctx.get_output_length = (mode == EVP_CIPH_WRAP_MODE) ?
-                                   get_wrap_output_length :
-                                   get_encrypt_output_length;
+                                                               get_wrap_output_length :
+                                                               get_encrypt_output_length;
        nc->ctx.set_property = set_encrypt_property;
        nc->ctx.get_property = get_encrypt_property;
        nc->op_type = op_type;
@@ -374,8 +374,8 @@ exit:
 }
 
 static int encrypt_ctx_init(struct yaca_encrypt_context_s *c,
-                            const EVP_CIPHER *cipher,
-                            size_t key_bit_len)
+                                                       const EVP_CIPHER *cipher,
+                                                       size_t key_bit_len)
 {
        int ret;
 
@@ -386,11 +386,11 @@ static int encrypt_ctx_init(struct yaca_encrypt_context_s *c,
                return YACA_ERROR_INVALID_PARAMETER;
 
        ret = EVP_CipherInit_ex(c->cipher_ctx,
-                               cipher,
-                               NULL,
-                               NULL,
-                               NULL,
-                               is_encryption_op(c->op_type) ? 1 : 0);
+                                                       cipher,
+                                                       NULL,
+                                                       NULL,
+                                                       NULL,
+                                                       is_encryption_op(c->op_type) ? 1 : 0);
        if (ret != 1) {
                ret = YACA_ERROR_INTERNAL;
                ERROR_DUMP(ret);
@@ -409,8 +409,8 @@ static int encrypt_ctx_init(struct yaca_encrypt_context_s *c,
 }
 
 static int encrypt_ctx_setup_iv(struct yaca_encrypt_context_s *c,
-                                const EVP_CIPHER *cipher,
-                                const struct yaca_key_simple_s *iv)
+                                                               const EVP_CIPHER *cipher,
+                                                               const struct yaca_key_simple_s *iv)
 {
        int ret;
        size_t default_iv_bit_len;
@@ -445,10 +445,10 @@ static int encrypt_ctx_setup_iv(struct yaca_encrypt_context_s *c,
 
                        if (mode == EVP_CIPH_GCM_MODE) {
                                ret = EVP_CIPHER_CTX_ctrl(c->cipher_ctx, EVP_CTRL_GCM_SET_IVLEN,
-                                                         iv->bit_len / 8, NULL);
+                                                                                 iv->bit_len / 8, NULL);
                        } else if (mode == EVP_CIPH_CCM_MODE) {
                                ret = EVP_CIPHER_CTX_ctrl(c->cipher_ctx, EVP_CTRL_CCM_SET_IVLEN,
-                                                         iv->bit_len / 8, NULL);
+                                                                                 iv->bit_len / 8, NULL);
                        } else {
                                return YACA_ERROR_INVALID_PARAMETER;
                        }
@@ -462,8 +462,8 @@ static int encrypt_ctx_setup_iv(struct yaca_encrypt_context_s *c,
 }
 
 static int encrypt_ctx_setup(struct yaca_encrypt_context_s *c,
-                             const yaca_key_h key,
-                             const yaca_key_h iv)
+                                                        const yaca_key_h key,
+                                                        const yaca_key_h iv)
 {
        int ret;
        unsigned char *iv_data = NULL;
@@ -499,11 +499,11 @@ static int encrypt_ctx_setup(struct yaca_encrypt_context_s *c,
                iv_data = (unsigned char*)liv->d;
 
        ret = EVP_CipherInit_ex(c->cipher_ctx,
-                               NULL,
-                               NULL,
-                               (unsigned char*)lkey->d,
-                               iv_data,
-                               is_encryption_op(c->op_type) ? 1 : 0);
+                                                       NULL,
+                                                       NULL,
+                                                       (unsigned char*)lkey->d,
+                                                       iv_data,
+                                                       is_encryption_op(c->op_type) ? 1 : 0);
        if (ret != 1) {
                ret = YACA_ERROR_INTERNAL;
                ERROR_DUMP(ret);
@@ -514,9 +514,9 @@ static int encrypt_ctx_setup(struct yaca_encrypt_context_s *c,
 }
 
 static int encrypt_ctx_backup(struct yaca_encrypt_context_s *c,
-                              const EVP_CIPHER *cipher,
-                              const yaca_key_h sym_key,
-                              const yaca_key_h iv)
+                                                         const EVP_CIPHER *cipher,
+                                                         const yaca_key_h sym_key,
+                                                         const yaca_key_h iv)
 {
        int ret;
        struct yaca_backup_context_s *bc;
@@ -562,7 +562,7 @@ static int encrypt_ctx_restore(struct yaca_encrypt_context_s *c)
        assert(ret != YACA_ERROR_INVALID_PARAMETER);
 
        if (c->backup_ctx->padding == YACA_PADDING_NONE &&
-           EVP_CIPHER_CTX_set_padding(c->cipher_ctx, 0) != 1) {
+               EVP_CIPHER_CTX_set_padding(c->cipher_ctx, 0) != 1) {
                ret = YACA_ERROR_INTERNAL;
                ERROR_DUMP(ret);
                return ret;
@@ -648,9 +648,9 @@ static int encrypt_ctx_set_rc2_effective_key_bits(struct yaca_encrypt_context_s
 }
 
 int set_encrypt_property(yaca_context_h ctx,
-                         yaca_property_e property,
-                         const void *value,
-                         size_t value_len)
+                                                yaca_property_e property,
+                                                const void *value,
+                                                size_t value_len)
 {
        struct yaca_encrypt_context_s *c = get_encrypt_context(ctx);
        int len;
@@ -666,7 +666,7 @@ int set_encrypt_property(yaca_context_h ctx,
        switch (property) {
        case YACA_PROPERTY_GCM_AAD:
                if (mode != EVP_CIPH_GCM_MODE ||
-                   !verify_state_change(c, ENC_CTX_AAD_UPDATED))
+                       !verify_state_change(c, ENC_CTX_AAD_UPDATED))
                        return YACA_ERROR_INVALID_PARAMETER;
 
                if (EVP_CipherUpdate(c->cipher_ctx, NULL, &len, value, value_len) != 1) {
@@ -677,7 +677,7 @@ int set_encrypt_property(yaca_context_h ctx,
                break;
        case YACA_PROPERTY_CCM_AAD:
                if (mode != EVP_CIPH_CCM_MODE ||
-                   !verify_state_change(c, ENC_CTX_AAD_UPDATED))
+                       !verify_state_change(c, ENC_CTX_AAD_UPDATED))
                        return YACA_ERROR_INVALID_PARAMETER;
 
                if (EVP_CipherUpdate(c->cipher_ctx, NULL, &len, value, value_len) != 1) {
@@ -688,8 +688,8 @@ int set_encrypt_property(yaca_context_h ctx,
                break;
        case YACA_PROPERTY_GCM_TAG:
                if (mode != EVP_CIPH_GCM_MODE || is_encryption_op(c->op_type) ||
-                   !is_valid_tag_len(mode, value_len) ||
-                   !verify_state_change(c, ENC_CTX_TAG_SET))
+                       !is_valid_tag_len(mode, value_len) ||
+                       !verify_state_change(c, ENC_CTX_TAG_SET))
                        return YACA_ERROR_INVALID_PARAMETER;
 
                if (EVP_CIPHER_CTX_ctrl(c->cipher_ctx, EVP_CTRL_GCM_SET_TAG, value_len, (void*)value) != 1) {
@@ -700,9 +700,9 @@ int set_encrypt_property(yaca_context_h ctx,
                break;
        case YACA_PROPERTY_GCM_TAG_LEN:
                if (value_len != sizeof(size_t) || mode != EVP_CIPH_GCM_MODE ||
-                   !is_encryption_op(c->op_type) ||
-                   !is_valid_tag_len(mode, *(size_t*)value) ||
-                   !verify_state_change(c, ENC_CTX_TAG_LENGTH_SET))
+                       !is_encryption_op(c->op_type) ||
+                       !is_valid_tag_len(mode, *(size_t*)value) ||
+                       !verify_state_change(c, ENC_CTX_TAG_LENGTH_SET))
                        return YACA_ERROR_INVALID_PARAMETER;
 
                c->tag_len = *(size_t*)value;
@@ -710,8 +710,8 @@ int set_encrypt_property(yaca_context_h ctx,
                break;
        case YACA_PROPERTY_CCM_TAG:
                if (mode != EVP_CIPH_CCM_MODE || is_encryption_op(c->op_type) ||
-                   !is_valid_tag_len(mode, value_len) ||
-                   !verify_state_change(c, ENC_CTX_TAG_SET))
+                       !is_valid_tag_len(mode, value_len) ||
+                       !verify_state_change(c, ENC_CTX_TAG_SET))
                        return YACA_ERROR_INVALID_PARAMETER;
 
                ret = encrypt_ctx_set_ccm_tag(c, (char*)value, value_len);
@@ -722,9 +722,9 @@ int set_encrypt_property(yaca_context_h ctx,
                break;
        case YACA_PROPERTY_CCM_TAG_LEN:
                if (value_len != sizeof(size_t) || mode != EVP_CIPH_CCM_MODE ||
-                   !is_encryption_op(c->op_type) ||
-                   !is_valid_tag_len(mode, *(size_t*)value) ||
-                   !verify_state_change(c, ENC_CTX_TAG_LENGTH_SET))
+                       !is_encryption_op(c->op_type) ||
+                       !is_valid_tag_len(mode, *(size_t*)value) ||
+                       !verify_state_change(c, ENC_CTX_TAG_LENGTH_SET))
                        return YACA_ERROR_INVALID_PARAMETER;
 
                ret = encrypt_ctx_set_ccm_tag_len(c, *(size_t*)value);
@@ -735,10 +735,10 @@ int set_encrypt_property(yaca_context_h ctx,
                break;
        case YACA_PROPERTY_PADDING:
                if ((mode != EVP_CIPH_ECB_MODE && mode != EVP_CIPH_CBC_MODE) ||
-                   value_len != sizeof(yaca_padding_e) ||
-                   (*(yaca_padding_e*)value != YACA_PADDING_NONE &&
-                   *(yaca_padding_e*)value != YACA_PADDING_PKCS7) ||
-                   c->state == ENC_CTX_FINALIZED)
+                       value_len != sizeof(yaca_padding_e) ||
+                       (*(yaca_padding_e*)value != YACA_PADDING_NONE &&
+                       *(yaca_padding_e*)value != YACA_PADDING_PKCS7) ||
+                       c->state == ENC_CTX_FINALIZED)
                        return YACA_ERROR_INVALID_PARAMETER;
 
                int padding = *(yaca_padding_e*)value == YACA_PADDING_NONE ? 0 : 1;
@@ -751,8 +751,8 @@ int set_encrypt_property(yaca_context_h ctx,
                break;
        case YACA_PROPERTY_RC2_EFFECTIVE_KEY_BITS:
                if (value_len != sizeof(size_t) ||
-                   (nid != NID_rc2_cbc && nid != NID_rc2_ecb && nid != NID_rc2_cfb64 && nid != NID_rc2_ofb64) ||
-                   c->state != ENC_CTX_INITIALIZED)
+                       (nid != NID_rc2_cbc && nid != NID_rc2_ecb && nid != NID_rc2_cfb64 && nid != NID_rc2_ofb64) ||
+                       c->state != ENC_CTX_INITIALIZED)
                        return YACA_ERROR_INVALID_PARAMETER;
 
                ret = encrypt_ctx_set_rc2_effective_key_bits(c, *(size_t*)value);
@@ -765,7 +765,7 @@ int set_encrypt_property(yaca_context_h ctx,
 }
 
 int get_encrypt_property(const yaca_context_h ctx, yaca_property_e property,
-                         void **value, size_t *value_len)
+                                                void **value, size_t *value_len)
 {
        struct yaca_encrypt_context_s *c = get_encrypt_context(ctx);
        int mode;
@@ -779,17 +779,17 @@ int get_encrypt_property(const yaca_context_h ctx, yaca_property_e property,
        switch (property) {
        case YACA_PROPERTY_GCM_TAG:
                if (value_len == NULL ||
-                   !is_encryption_op(c->op_type) ||
-                   mode != EVP_CIPH_GCM_MODE ||
-                   (c->state != ENC_CTX_TAG_LENGTH_SET && c->state != ENC_CTX_FINALIZED))
+                       !is_encryption_op(c->op_type) ||
+                       mode != EVP_CIPH_GCM_MODE ||
+                       (c->state != ENC_CTX_TAG_LENGTH_SET && c->state != ENC_CTX_FINALIZED))
                        return YACA_ERROR_INVALID_PARAMETER;
 
                assert(c->tag_len <= INT_MAX);
 
                if (EVP_CIPHER_CTX_ctrl(c->cipher_ctx,
-                                       EVP_CTRL_GCM_GET_TAG,
-                                       c->tag_len,
-                                       value) != 1) {
+                                                               EVP_CTRL_GCM_GET_TAG,
+                                                               c->tag_len,
+                                                               value) != 1) {
                        ERROR_DUMP(YACA_ERROR_INTERNAL);
                        return YACA_ERROR_INTERNAL;
                }
@@ -797,17 +797,17 @@ int get_encrypt_property(const yaca_context_h ctx, yaca_property_e property,
                break;
        case YACA_PROPERTY_CCM_TAG:
                if (value_len == NULL ||
-                   !is_encryption_op(c->op_type) ||
-                   mode != EVP_CIPH_CCM_MODE ||
-                   c->state != ENC_CTX_FINALIZED)
+                       !is_encryption_op(c->op_type) ||
+                       mode != EVP_CIPH_CCM_MODE ||
+                       c->state != ENC_CTX_FINALIZED)
                        return YACA_ERROR_INVALID_PARAMETER;
 
                assert(c->tag_len <= INT_MAX);
 
                if (EVP_CIPHER_CTX_ctrl(c->cipher_ctx,
-                                       EVP_CTRL_CCM_GET_TAG,
-                                       c->tag_len,
-                                       value) != 1) {
+                                                               EVP_CTRL_CCM_GET_TAG,
+                                                               c->tag_len,
+                                                               value) != 1) {
                        ERROR_DUMP(YACA_ERROR_INTERNAL);
                        return YACA_ERROR_INTERNAL;
                }
@@ -829,8 +829,8 @@ static int check_key_bit_length_for_algo(yaca_encrypt_algorithm_e algo, size_t k
        switch (algo) {
        case YACA_ENCRYPT_AES:
                if (key_bit_len != YACA_KEY_LENGTH_UNSAFE_128BIT &&
-                   key_bit_len != YACA_KEY_LENGTH_192BIT &&
-                   key_bit_len != YACA_KEY_LENGTH_256BIT)
+                       key_bit_len != YACA_KEY_LENGTH_192BIT &&
+                       key_bit_len != YACA_KEY_LENGTH_256BIT)
                        ret = YACA_ERROR_INVALID_PARAMETER;
                break;
        case YACA_ENCRYPT_UNSAFE_DES:
@@ -866,9 +866,9 @@ static int check_key_bit_length_for_algo(yaca_encrypt_algorithm_e algo, size_t k
 }
 
 int encrypt_get_algorithm(yaca_encrypt_algorithm_e algo,
-                          yaca_block_cipher_mode_e bcm,
-                          size_t key_bit_len,
-                          const EVP_CIPHER **cipher)
+                                                 yaca_block_cipher_mode_e bcm,
+                                                 size_t key_bit_len,
+                                                 const EVP_CIPHER **cipher)
 {
        int ret;
        size_t i;
@@ -884,9 +884,9 @@ int encrypt_get_algorithm(yaca_encrypt_algorithm_e algo,
 
        for (i = 0; i < ENCRYPTION_CIPHERS_SIZE; ++i)
                if (ENCRYPTION_CIPHERS[i].algo == algo &&
-                   ENCRYPTION_CIPHERS[i].bcm == bcm &&
-                   (ENCRYPTION_CIPHERS[i].key_bit_len == key_bit_len ||
-                    ENCRYPTION_CIPHERS[i].key_bit_len == (size_t)-1)) {
+                       ENCRYPTION_CIPHERS[i].bcm == bcm &&
+                       (ENCRYPTION_CIPHERS[i].key_bit_len == key_bit_len ||
+                        ENCRYPTION_CIPHERS[i].key_bit_len == (size_t)-1)) {
                        *cipher = ENCRYPTION_CIPHERS[i].cipher();
                        ret = YACA_ERROR_NONE;
                        break;
@@ -901,10 +901,10 @@ int encrypt_get_algorithm(yaca_encrypt_algorithm_e algo,
 }
 
 int encrypt_initialize(yaca_context_h *ctx,
-                       const EVP_CIPHER *cipher,
-                       const yaca_key_h sym_key,
-                       const yaca_key_h iv,
-                       enum encrypt_op_type_e op_type)
+                                          const EVP_CIPHER *cipher,
+                                          const yaca_key_h sym_key,
+                                          const yaca_key_h iv,
+                                          enum encrypt_op_type_e op_type)
 {
        struct yaca_encrypt_context_s *nc;
        struct yaca_key_simple_s *lsym_key;
@@ -918,7 +918,7 @@ int encrypt_initialize(yaca_context_h *ctx,
                return YACA_ERROR_INVALID_PARAMETER;
 
        if (lsym_key->key.type != YACA_KEY_TYPE_DES &&
-           lsym_key->key.type != YACA_KEY_TYPE_SYMMETRIC)
+               lsym_key->key.type != YACA_KEY_TYPE_SYMMETRIC)
                return YACA_ERROR_INVALID_PARAMETER;
 
        ret = encrypt_ctx_create(&nc, op_type, cipher);
@@ -936,7 +936,7 @@ int encrypt_initialize(yaca_context_h *ctx,
        int mode = EVP_CIPHER_CTX_mode(nc->cipher_ctx);
        int nid = EVP_CIPHER_CTX_nid(nc->cipher_ctx);
        if (mode == EVP_CIPH_CCM_MODE ||
-           nid == NID_rc2_cbc || nid == NID_rc2_ecb || nid == NID_rc2_cfb64 || nid == NID_rc2_ofb64) {
+               nid == NID_rc2_cbc || nid == NID_rc2_ecb || nid == NID_rc2_cfb64 || nid == NID_rc2_ofb64) {
                ret = encrypt_ctx_backup(nc, cipher, sym_key, iv);
                if (ret != YACA_ERROR_NONE)
                        goto exit;
@@ -955,9 +955,9 @@ exit:
 }
 
 int encrypt_update(yaca_context_h ctx,
-                   const unsigned char *input, size_t input_len,
-                   unsigned char *output, size_t *output_len,
-                   enum encrypt_op_type_e op_type)
+                                  const unsigned char *input, size_t input_len,
+                                  unsigned char *output, size_t *output_len,
+                                  enum encrypt_op_type_e op_type)
 {
        struct yaca_encrypt_context_s *c = get_encrypt_context(ctx);
        int ret;
@@ -989,7 +989,7 @@ int encrypt_update(yaca_context_h ctx,
                                        return YACA_ERROR_INVALID_PARAMETER;
                        } else if (nid == NID_id_smime_alg_CMS3DESwrap) {
                                if (input_len != (YACA_KEY_LENGTH_UNSAFE_128BIT / 8) &&
-                                   input_len != (YACA_KEY_LENGTH_192BIT / 8))
+                                       input_len != (YACA_KEY_LENGTH_192BIT / 8))
                                        return YACA_ERROR_INVALID_PARAMETER;
                        } else {
                                assert(false);
@@ -1001,7 +1001,7 @@ int encrypt_update(yaca_context_h ctx,
                                        return YACA_ERROR_INVALID_PARAMETER;
                        } else if (nid == NID_id_smime_alg_CMS3DESwrap) {
                                if (input_len != (YACA_KEY_LENGTH_UNSAFE_128BIT / 8 + 16) &&
-                                   input_len != (YACA_KEY_LENGTH_192BIT / 8 + 16))
+                                       input_len != (YACA_KEY_LENGTH_192BIT / 8 + 16))
                                        return YACA_ERROR_INVALID_PARAMETER;
                        } else {
                                assert(false);
@@ -1048,8 +1048,8 @@ int encrypt_update(yaca_context_h ctx,
 }
 
 int encrypt_finalize(yaca_context_h ctx,
-                     unsigned char *output, size_t *output_len,
-                     enum encrypt_op_type_e op_type)
+                                        unsigned char *output, size_t *output_len,
+                                        enum encrypt_op_type_e op_type)
 {
        struct yaca_encrypt_context_s *c = get_encrypt_context(ctx);
        int ret;
@@ -1088,9 +1088,9 @@ int encrypt_finalize(yaca_context_h ctx,
 }
 
 API int yaca_encrypt_get_iv_bit_length(yaca_encrypt_algorithm_e algo,
-                                       yaca_block_cipher_mode_e bcm,
-                                       size_t key_bit_len,
-                                       size_t *iv_bit_len)
+                                                                          yaca_block_cipher_mode_e bcm,
+                                                                          size_t key_bit_len,
+                                                                          size_t *iv_bit_len)
 {
        const EVP_CIPHER *cipher;
        int ret;
@@ -1113,10 +1113,10 @@ API int yaca_encrypt_get_iv_bit_length(yaca_encrypt_algorithm_e algo,
 }
 
 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)
+                                                               yaca_encrypt_algorithm_e algo,
+                                                               yaca_block_cipher_mode_e bcm,
+                                                               const yaca_key_h sym_key,
+                                                               const yaca_key_h iv)
 {
        int ret;
        const EVP_CIPHER *cipher;
@@ -1133,27 +1133,27 @@ API int yaca_encrypt_initialize(yaca_context_h *ctx,
 }
 
 API int yaca_encrypt_update(yaca_context_h ctx,
-                            const char *plaintext,
-                            size_t plaintext_len,
-                            char *ciphertext,
-                            size_t *ciphertext_len)
+                                                       const char *plaintext,
+                                                       size_t plaintext_len,
+                                                       char *ciphertext,
+                                                       size_t *ciphertext_len)
 {
        return encrypt_update(ctx, (const unsigned char*)plaintext, plaintext_len,
-                             (unsigned char*)ciphertext, ciphertext_len, OP_ENCRYPT);
+                                                 (unsigned char*)ciphertext, ciphertext_len, OP_ENCRYPT);
 }
 
 API int yaca_encrypt_finalize(yaca_context_h ctx,
-                              char *ciphertext,
-                              size_t *ciphertext_len)
+                                                         char *ciphertext,
+                                                         size_t *ciphertext_len)
 {
        return encrypt_finalize(ctx, (unsigned char*)ciphertext, ciphertext_len, OP_ENCRYPT);
 }
 
 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)
+                                                               yaca_encrypt_algorithm_e algo,
+                                                               yaca_block_cipher_mode_e bcm,
+                                                               const yaca_key_h sym_key,
+                                                               const yaca_key_h iv)
 {
        int ret;
        const EVP_CIPHER *cipher;
@@ -1170,18 +1170,18 @@ API int yaca_decrypt_initialize(yaca_context_h *ctx,
 }
 
 API int yaca_decrypt_update(yaca_context_h ctx,
-                            const char *ciphertext,
-                            size_t ciphertext_len,
-                            char *plaintext,
-                            size_t *plaintext_len)
+                                                       const char *ciphertext,
+                                                       size_t ciphertext_len,
+                                                       char *plaintext,
+                                                       size_t *plaintext_len)
 {
        return encrypt_update(ctx, (const unsigned char*)ciphertext, ciphertext_len,
-                             (unsigned char*)plaintext, plaintext_len, OP_DECRYPT);
+                                                 (unsigned char*)plaintext, plaintext_len, OP_DECRYPT);
 }
 
 API int yaca_decrypt_finalize(yaca_context_h ctx,
-                              char *plaintext,
-                              size_t *plaintext_len)
+                                                         char *plaintext,
+                                                         size_t *plaintext_len)
 {
        return encrypt_finalize(ctx, (unsigned char*)plaintext, plaintext_len, OP_DECRYPT);
 }
index 4bae2aa..ac8062b 100644 (file)
@@ -85,9 +85,9 @@ struct yaca_context_s {
        void (*context_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_property)(yaca_context_h ctx, yaca_property_e property,
-                           const void *value, size_t value_len);
+                                               const void *value, size_t value_len);
        int (*get_property)(const yaca_context_h ctx, yaca_property_e property,
-                           void **value, size_t *value_len);
+                                               void **value, size_t *value_len);
 };
 
 struct yaca_backup_context_s {
@@ -172,30 +172,30 @@ void destroy_encrypt_context(const yaca_context_h ctx);
 int get_encrypt_output_length(const yaca_context_h ctx, size_t input_len, size_t *output_len);
 
 int set_encrypt_property(yaca_context_h ctx, yaca_property_e property,
-                         const void *value, size_t value_len);
+                                                const void *value, size_t value_len);
 
 int get_encrypt_property(const yaca_context_h ctx, yaca_property_e property,
-                         void **value, size_t *value_len);
+                                                void **value, size_t *value_len);
 
 int encrypt_get_algorithm(yaca_encrypt_algorithm_e algo,
-                          yaca_block_cipher_mode_e bcm,
-                          size_t key_bit_len,
-                          const EVP_CIPHER **cipher);
+                                                 yaca_block_cipher_mode_e bcm,
+                                                 size_t key_bit_len,
+                                                 const EVP_CIPHER **cipher);
 
 int encrypt_initialize(yaca_context_h *ctx,
-                       const EVP_CIPHER *cipher,
-                       const yaca_key_h sym_key,
-                       const yaca_key_h iv,
-                       enum encrypt_op_type_e op_type);
+                                          const EVP_CIPHER *cipher,
+                                          const yaca_key_h sym_key,
+                                          const yaca_key_h iv,
+                                          enum encrypt_op_type_e op_type);
 
 int encrypt_update(yaca_context_h ctx,
-                   const unsigned char *input, size_t input_len,
-                   unsigned char *output, size_t *output_len,
-                   enum encrypt_op_type_e op_type);
+                                  const unsigned char *input, size_t input_len,
+                                  unsigned char *output, size_t *output_len,
+                                  enum encrypt_op_type_e op_type);
 
 int encrypt_finalize(yaca_context_h ctx,
-                     unsigned char *output, size_t *output_len,
-                     enum encrypt_op_type_e op_type);
+                                        unsigned char *output, size_t *output_len,
+                                        enum encrypt_op_type_e op_type);
 
 struct yaca_key_simple_s *key_get_simple(const yaca_key_h key);
 struct yaca_key_evp_s *key_get_evp(const yaca_key_h key);
index 404840a..a9fdfef 100644 (file)
--- a/src/key.c
+++ b/src/key.c
@@ -246,9 +246,9 @@ exit:
 }
 
 static int import_simple(yaca_key_h *key,
-                         yaca_key_type_e key_type,
-                         const char *data,
-                         size_t data_len)
+                                                yaca_key_type_e key_type,
+                                                const char *data,
+                                                size_t data_len)
 {
        assert(key != NULL);
        assert(data != NULL);
@@ -289,8 +289,8 @@ static int import_simple(yaca_key_h *key,
        if (key_type == YACA_KEY_TYPE_DES) {
                size_t key_bit_len = key_data_len * 8;
                if (key_bit_len != YACA_KEY_LENGTH_UNSAFE_64BIT &&
-                   key_bit_len != YACA_KEY_LENGTH_UNSAFE_128BIT &&
-                   key_bit_len != YACA_KEY_LENGTH_192BIT) {
+                       key_bit_len != YACA_KEY_LENGTH_UNSAFE_128BIT &&
+                       key_bit_len != YACA_KEY_LENGTH_192BIT) {
                        ret = YACA_ERROR_INVALID_PARAMETER;
                        goto exit;
                }
@@ -405,10 +405,10 @@ exit:
 }
 
 static int import_evp(yaca_key_h *key,
-                      yaca_key_type_e key_type,
-                      const char *password,
-                      const char *data,
-                      size_t data_len)
+                                         yaca_key_type_e key_type,
+                                         const char *password,
+                                         const char *data,
+                                         size_t data_len)
 {
        assert(key != NULL);
        assert(password == NULL || password[0] != '\0');
@@ -594,7 +594,7 @@ static int import_evp(yaca_key_h *key,
        }
 
        if ((key_type == YACA_KEY_TYPE_RSA_PRIV || key_type == YACA_KEY_TYPE_RSA_PUB) &&
-           (EVP_PKEY_size(pkey) < YACA_KEY_LENGTH_512BIT / 8)) {
+               (EVP_PKEY_size(pkey) < YACA_KEY_LENGTH_512BIT / 8)) {
                ret = YACA_ERROR_INVALID_PARAMETER;
                goto exit;
        }
@@ -617,8 +617,8 @@ exit:
 }
 
 static int export_simple_raw(struct yaca_key_simple_s *simple_key,
-                             char **data,
-                             size_t *data_len)
+                                                        char **data,
+                                                        size_t *data_len)
 {
        int ret;
        assert(simple_key != NULL);
@@ -640,8 +640,8 @@ static int export_simple_raw(struct yaca_key_simple_s *simple_key,
 }
 
 static int export_simple_base64(struct yaca_key_simple_s *simple_key,
-                                char **data,
-                                size_t *data_len)
+                                                               char **data,
+                                                               size_t *data_len)
 {
        assert(simple_key != NULL);
        assert(data != NULL);
@@ -707,9 +707,9 @@ exit:
 }
 
 static int export_evp_default_bio(struct yaca_key_evp_s *evp_key,
-                                  yaca_key_file_format_e key_file_fmt,
-                                  const char *password,
-                                  BIO *mem)
+                                                                 yaca_key_file_format_e key_file_fmt,
+                                                                 const char *password,
+                                                                 BIO *mem)
 {
        assert(evp_key != NULL);
        assert(password == NULL || password[0] != '\0');
@@ -731,7 +731,7 @@ static int export_evp_default_bio(struct yaca_key_evp_s *evp_key,
                case YACA_KEY_TYPE_DH_PRIV:
                case YACA_KEY_TYPE_EC_PRIV:
                        ret = PEM_write_bio_PrivateKey(mem, evp_key->evp, enc,
-                                                      NULL, 0, NULL, (void*)password);
+                                                                                  NULL, 0, NULL, (void*)password);
                        break;
 
                case YACA_KEY_TYPE_RSA_PUB:
@@ -811,9 +811,9 @@ static int export_evp_default_bio(struct yaca_key_evp_s *evp_key,
 }
 
 static int export_evp_pkcs8_bio(struct yaca_key_evp_s *evp_key,
-                                yaca_key_file_format_e key_file_fmt,
-                                const char *password,
-                                BIO *mem)
+                                                               yaca_key_file_format_e key_file_fmt,
+                                                               const char *password,
+                                                               BIO *mem)
 {
        assert(evp_key != NULL);
        assert(password == NULL || password[0] != '\0');
@@ -836,7 +836,7 @@ static int export_evp_pkcs8_bio(struct yaca_key_evp_s *evp_key,
                case YACA_KEY_TYPE_DH_PRIV:
                case YACA_KEY_TYPE_EC_PRIV:
                        ret = PEM_write_bio_PKCS8PrivateKey(mem, evp_key->evp, enc,
-                                                           NULL, 0, NULL, (void*)password);
+                                                                                               NULL, 0, NULL, (void*)password);
                        break;
 
                default:
@@ -853,7 +853,7 @@ static int export_evp_pkcs8_bio(struct yaca_key_evp_s *evp_key,
                case YACA_KEY_TYPE_DH_PRIV:
                case YACA_KEY_TYPE_EC_PRIV:
                        ret = i2d_PKCS8PrivateKey_bio(mem, evp_key->evp, enc,
-                                                     NULL, 0, NULL, (void*)password);
+                                                                                 NULL, 0, NULL, (void*)password);
                        break;
 
                default:
@@ -876,11 +876,11 @@ static int export_evp_pkcs8_bio(struct yaca_key_evp_s *evp_key,
 }
 
 static int export_evp(struct yaca_key_evp_s *evp_key,
-                      yaca_key_format_e key_fmt,
-                      yaca_key_file_format_e key_file_fmt,
-                      const char *password,
-                      char **data,
-                      size_t *data_len)
+                                         yaca_key_format_e key_fmt,
+                                         yaca_key_file_format_e key_file_fmt,
+                                         const char *password,
+                                         char **data,
+                                         size_t *data_len)
 {
        assert(evp_key != NULL);
        assert(password == NULL || password[0] != '\0');
@@ -972,8 +972,8 @@ static int generate_simple_des(struct yaca_key_simple_s **out, size_t key_bit_le
        assert(out != NULL);
 
        if (key_bit_len != YACA_KEY_LENGTH_UNSAFE_64BIT &&
-           key_bit_len != YACA_KEY_LENGTH_UNSAFE_128BIT &&
-           key_bit_len != YACA_KEY_LENGTH_192BIT)
+               key_bit_len != YACA_KEY_LENGTH_UNSAFE_128BIT &&
+               key_bit_len != YACA_KEY_LENGTH_192BIT)
                return YACA_ERROR_INVALID_PARAMETER;
 
        int ret;
@@ -1037,7 +1037,7 @@ static int generate_evp_pkey_params(int evp_id, size_t key_bit_len, EVP_PKEY **p
        switch (evp_id) {
        case EVP_PKEY_DSA:
                if ((key_bit_len & YACA_KEYLEN_COMPONENT_TYPE_MASK) != YACA_KEYLEN_COMPONENT_TYPE_BITS ||
-                   key_bit_len > INT_MAX || key_bit_len < 512 || key_bit_len % 64 != 0)
+                       key_bit_len > INT_MAX || key_bit_len < 512 || key_bit_len % 64 != 0)
                        return YACA_ERROR_INVALID_PARAMETER;
 
                bit_len = key_bit_len;
@@ -1113,7 +1113,7 @@ static int generate_evp_pkey_params(int evp_id, size_t key_bit_len, EVP_PKEY **p
                         * fact that the _set_dh_ variant actually passes EVP_PKEY_DHX:
                         * ret = EVP_PKEY_CTX_set_dh_rfc5114(pctx, dh_rfc5114); */
                        ret = EVP_PKEY_CTX_ctrl(pctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN,
-                                               EVP_PKEY_CTRL_DH_RFC5114, dh_rfc5114, NULL);
+                                                                       EVP_PKEY_CTRL_DH_RFC5114, dh_rfc5114, NULL);
                } else {
                        ret = EVP_PKEY_CTX_set_dh_paramgen_prime_len(pctx, dh_prime_len);
                        if (ret == 1)
@@ -1191,7 +1191,7 @@ static int generate_evp_pkey_key(int evp_id, size_t key_bit_len, EVP_PKEY *param
 
        if (evp_id == EVP_PKEY_RSA) {
                if ((key_bit_len & YACA_KEYLEN_COMPONENT_TYPE_MASK) != YACA_KEYLEN_COMPONENT_TYPE_BITS ||
-                   key_bit_len > INT_MAX || key_bit_len < 512 || key_bit_len % 8 != 0) {
+                       key_bit_len > INT_MAX || key_bit_len < 512 || key_bit_len % 8 != 0) {
                        ret = YACA_ERROR_INVALID_PARAMETER;
                        goto exit;
                }
@@ -1219,7 +1219,7 @@ exit:
 }
 
 static int generate_evp(yaca_key_type_e out_type, size_t key_bit_len,
-                        struct yaca_key_evp_s *params, struct yaca_key_evp_s **out)
+                                               struct yaca_key_evp_s *params, struct yaca_key_evp_s **out)
 {
        assert(out != NULL);
        assert(key_bit_len > 0 || params != NULL);
@@ -1459,10 +1459,10 @@ API int yaca_key_get_bit_length(const yaca_key_h key, size_t *key_bit_len)
 }
 
 API int yaca_key_import(yaca_key_type_e key_type,
-                        const char *password,
-                        const char *data,
-                        size_t data_len,
-                        yaca_key_h *key)
+                                               const char *password,
+                                               const char *data,
+                                               size_t data_len,
+                                               yaca_key_h *key)
 {
        if (key == NULL || data == NULL || data_len == 0)
                return YACA_ERROR_INVALID_PARAMETER;
@@ -1496,11 +1496,11 @@ API int yaca_key_import(yaca_key_type_e key_type,
 }
 
 API int yaca_key_export(const yaca_key_h key,
-                        yaca_key_format_e key_fmt,
-                        yaca_key_file_format_e key_file_fmt,
-                        const char *password,
-                        char **data,
-                        size_t *data_len)
+                                               yaca_key_format_e key_fmt,
+                                               yaca_key_file_format_e key_file_fmt,
+                                               const char *password,
+                                               char **data,
+                                               size_t *data_len)
 {
        struct yaca_key_simple_s *simple_key = key_get_simple(key);
        struct yaca_key_evp_s *evp_key = key_get_evp(key);
@@ -1516,25 +1516,25 @@ API int yaca_key_export(const yaca_key_h key,
                return YACA_ERROR_INVALID_PARAMETER;
 
        if (key_fmt == YACA_KEY_FORMAT_DEFAULT &&
-           key_file_fmt == YACA_KEY_FILE_FORMAT_RAW &&
-           simple_key != NULL)
+               key_file_fmt == YACA_KEY_FILE_FORMAT_RAW &&
+               simple_key != NULL)
                return export_simple_raw(simple_key, data, data_len);
 
        if (key_fmt == YACA_KEY_FORMAT_DEFAULT &&
-           key_file_fmt == YACA_KEY_FILE_FORMAT_BASE64 &&
-           simple_key != NULL)
+               key_file_fmt == YACA_KEY_FILE_FORMAT_BASE64 &&
+               simple_key != NULL)
                return export_simple_base64(simple_key, data, data_len);
 
        if (evp_key != NULL)
                return export_evp(evp_key, key_fmt, key_file_fmt,
-                                 password, data, data_len);
+                                                 password, data, data_len);
 
        return YACA_ERROR_INVALID_PARAMETER;
 }
 
 API int yaca_key_generate(yaca_key_type_e key_type,
-                          size_t key_bit_len,
-                          yaca_key_h *key)
+                                                 size_t key_bit_len,
+                                                 yaca_key_h *key)
 {
        int ret;
        struct yaca_key_simple_s *nk_simple = NULL;
@@ -1758,9 +1758,9 @@ API void yaca_key_destroy(yaca_key_h key)
 }
 
 API int yaca_key_derive_dh(const yaca_key_h prv_key,
-                           const yaca_key_h pub_key,
-                           char **secret,
-                           size_t *secret_len)
+                                                  const yaca_key_h pub_key,
+                                                  char **secret,
+                                                  size_t *secret_len)
 {
        int ret;
        struct yaca_key_evp_s *lprv_key = key_get_evp(prv_key);
@@ -1770,11 +1770,11 @@ API int yaca_key_derive_dh(const yaca_key_h prv_key,
        size_t data_len;
 
        if (lprv_key == NULL || lpub_key == NULL || secret == NULL || secret_len == NULL ||
-           (!(lprv_key->key.type == YACA_KEY_TYPE_DH_PRIV &&
-              lpub_key->key.type == YACA_KEY_TYPE_DH_PUB)
-           &&
-            !(lprv_key->key.type == YACA_KEY_TYPE_EC_PRIV &&
-              lpub_key->key.type == YACA_KEY_TYPE_EC_PUB)))
+               (!(lprv_key->key.type == YACA_KEY_TYPE_DH_PRIV &&
+                  lpub_key->key.type == YACA_KEY_TYPE_DH_PUB)
+               &&
+                !(lprv_key->key.type == YACA_KEY_TYPE_EC_PRIV &&
+                  lpub_key->key.type == YACA_KEY_TYPE_EC_PUB)))
                return YACA_ERROR_INVALID_PARAMETER;
 
        ctx = EVP_PKEY_CTX_new(lprv_key->evp, NULL);
@@ -1833,21 +1833,21 @@ exit:
 }
 
 API int yaca_key_derive_kdf(yaca_kdf_e kdf,
-                            yaca_digest_algorithm_e algo,
-                            const char *secret,
-                            size_t secret_len,
-                            const char *info,
-                            size_t info_len,
-                            size_t key_material_len,
-                            char **key_material)
+                                                       yaca_digest_algorithm_e algo,
+                                                       const char *secret,
+                                                       size_t secret_len,
+                                                       const char *info,
+                                                       size_t info_len,
+                                                       size_t key_material_len,
+                                                       char **key_material)
 {
        int ret;
        char *out = NULL;
        const EVP_MD *md;
 
        if (secret == NULL || secret_len == 0 ||
-           (info == NULL && info_len > 0) || (info != NULL && info_len == 0) ||
-           key_material_len == 0 || key_material == NULL)
+               (info == NULL && info_len > 0) || (info != NULL && info_len == 0) ||
+               key_material_len == 0 || key_material == NULL)
                return YACA_ERROR_INVALID_PARAMETER;
 
        ret = yaca_zalloc(key_material_len, (void**)&out);
@@ -1861,8 +1861,8 @@ API int yaca_key_derive_kdf(yaca_kdf_e kdf,
        switch (kdf) {
        case YACA_KDF_X942:
                ret = DH_KDF_X9_42((unsigned char*)out, key_material_len,
-                                  (unsigned char*)secret, secret_len,
-                                  OBJ_nid2obj(NID_id_smime_alg_ESDH), (unsigned char*)info, info_len, md);
+                                                  (unsigned char*)secret, secret_len,
+                                                  OBJ_nid2obj(NID_id_smime_alg_ESDH), (unsigned char*)info, info_len, md);
                if (ret != 1 || out == NULL) {
                        ret = YACA_ERROR_INTERNAL;
                        ERROR_DUMP(ret);
@@ -1871,8 +1871,8 @@ API int yaca_key_derive_kdf(yaca_kdf_e kdf,
                break;
        case YACA_KDF_X962:
                ret = ECDH_KDF_X9_62((unsigned char*)out, key_material_len,
-                                    (unsigned char*)secret, secret_len,
-                                    (unsigned char*)info, info_len, md);
+                                                        (unsigned char*)secret, secret_len,
+                                                        (unsigned char*)info, info_len, md);
                if (ret != 1 || out == NULL) {
                        ret = YACA_ERROR_INTERNAL;
                        ERROR_DUMP(ret);
@@ -1894,12 +1894,12 @@ exit:
 }
 
 API int yaca_key_derive_pbkdf2(const char *password,
-                               const char *salt,
-                               size_t salt_len,
-                               size_t iterations,
-                               yaca_digest_algorithm_e algo,
-                               size_t key_bit_len,
-                               yaca_key_h *key)
+                                                          const char *salt,
+                                                          size_t salt_len,
+                                                          size_t iterations,
+                                                          yaca_digest_algorithm_e algo,
+                                                          size_t key_bit_len,
+                                                          yaca_key_h *key)
 {
        const EVP_MD *md;
        struct yaca_key_simple_s *nk;
@@ -1907,8 +1907,8 @@ API int yaca_key_derive_pbkdf2(const char *password,
        int ret;
 
        if (password == NULL ||
-           (salt == NULL && salt_len > 0) || (salt != NULL && salt_len == 0) ||
-           iterations == 0 || key_bit_len == 0 || key == NULL)
+               (salt == NULL && salt_len > 0) || (salt != NULL && salt_len == 0) ||
+               iterations == 0 || key_bit_len == 0 || key == NULL)
                return YACA_ERROR_INVALID_PARAMETER;
 
        if (key_bit_len % 8) /* Key length must be multiple of 8-bit_len */
@@ -1929,8 +1929,8 @@ API int yaca_key_derive_pbkdf2(const char *password,
        nk->key.type = YACA_KEY_TYPE_SYMMETRIC;
 
        ret = PKCS5_PBKDF2_HMAC(password, -1, (const unsigned char*)salt,
-                               salt_len, iterations, md, key_byte_len,
-                               (unsigned char*)nk->d);
+                                                       salt_len, iterations, md, key_byte_len,
+                                                       (unsigned char*)nk->d);
        if (ret != 1) {
                ret = YACA_ERROR_INTERNAL;
                ERROR_DUMP(ret);
index 436c3b9..7fbb6e4 100644 (file)
--- a/src/rsa.c
+++ b/src/rsa.c
@@ -57,12 +57,12 @@ int rsa_padding2openssl(yaca_padding_e padding)
 typedef int (*encrypt_decrypt_fn)(int, const unsigned char*, unsigned char*, RSA*, int);
 
 static int encrypt_decrypt(yaca_padding_e padding,
-                           const yaca_key_h key,
-                           const char *input,
-                           size_t input_len,
-                           char **output,
-                           size_t *output_len,
-                           encrypt_decrypt_fn fn)
+                                                  const yaca_key_h key,
+                                                  const char *input,
+                                                  size_t input_len,
+                                                  char **output,
+                                                  size_t *output_len,
+                                                  encrypt_decrypt_fn fn)
 {
        int ret;
        size_t max_len;
@@ -71,7 +71,7 @@ static int encrypt_decrypt(yaca_padding_e padding,
        int lpadding;
 
        if ((input == NULL && input_len > 0) || (input != NULL && input_len == 0) ||
-           output == NULL || output_len == NULL)
+               output == NULL || output_len == NULL)
                return YACA_ERROR_INVALID_PARAMETER;
 
        lpadding = rsa_padding2openssl(padding);
@@ -94,10 +94,10 @@ static int encrypt_decrypt(yaca_padding_e padding,
                return ret;
 
        ret = fn(input_len,
-                (const unsigned char*)input,
-                (unsigned char*)loutput,
-                EVP_PKEY_get0_RSA(lasym_key->evp),
-                lpadding);
+                        (const unsigned char*)input,
+                        (unsigned char*)loutput,
+                        EVP_PKEY_get0_RSA(lasym_key->evp),
+                        lpadding);
 
        if (ret < 0) {
                ret = ERROR_HANDLE();
@@ -121,11 +121,11 @@ exit:
 
 
 API int yaca_rsa_public_encrypt(yaca_padding_e padding,
-                                const yaca_key_h pub_key,
-                                const char *plaintext,
-                                size_t plaintext_len,
-                                char **ciphertext,
-                                size_t *ciphertext_len)
+                                                               const yaca_key_h pub_key,
+                                                               const char *plaintext,
+                                                               size_t plaintext_len,
+                                                               char **ciphertext,
+                                                               size_t *ciphertext_len)
 {
        if (pub_key == YACA_KEY_NULL || pub_key->type != YACA_KEY_TYPE_RSA_PUB)
                return YACA_ERROR_INVALID_PARAMETER;
@@ -141,20 +141,20 @@ API int yaca_rsa_public_encrypt(yaca_padding_e padding,
        }
 
        return encrypt_decrypt(padding,
-                              pub_key,
-                              plaintext,
-                              plaintext_len,
-                              ciphertext,
-                              ciphertext_len,
-                              RSA_public_encrypt);
+                                                  pub_key,
+                                                  plaintext,
+                                                  plaintext_len,
+                                                  ciphertext,
+                                                  ciphertext_len,
+                                                  RSA_public_encrypt);
 }
 
 API int yaca_rsa_private_decrypt(yaca_padding_e padding,
-                                 const yaca_key_h prv_key,
-                                 const char *ciphertext,
-                                 size_t ciphertext_len,
-                                 char **plaintext,
-                                 size_t *plaintext_len)
+                                                                const yaca_key_h prv_key,
+                                                                const char *ciphertext,
+                                                                size_t ciphertext_len,
+                                                                char **plaintext,
+                                                                size_t *plaintext_len)
 {
        if (prv_key == YACA_KEY_NULL || prv_key->type != YACA_KEY_TYPE_RSA_PRIV)
                return YACA_ERROR_INVALID_PARAMETER;
@@ -170,20 +170,20 @@ API int yaca_rsa_private_decrypt(yaca_padding_e padding,
        }
 
        return encrypt_decrypt(padding,
-                              prv_key,
-                              ciphertext,
-                              ciphertext_len,
-                              plaintext,
-                              plaintext_len,
-                              RSA_private_decrypt);
+                                                  prv_key,
+                                                  ciphertext,
+                                                  ciphertext_len,
+                                                  plaintext,
+                                                  plaintext_len,
+                                                  RSA_private_decrypt);
 }
 
 API int yaca_rsa_private_encrypt(yaca_padding_e padding,
-                                 const yaca_key_h prv_key,
-                                 const char *plaintext,
-                                 size_t plaintext_len,
-                                 char **ciphertext,
-                                 size_t *ciphertext_len)
+                                                                const yaca_key_h prv_key,
+                                                                const char *plaintext,
+                                                                size_t plaintext_len,
+                                                                char **ciphertext,
+                                                                size_t *ciphertext_len)
 {
        if (prv_key == YACA_KEY_NULL || prv_key->type != YACA_KEY_TYPE_RSA_PRIV)
                return YACA_ERROR_INVALID_PARAMETER;
@@ -197,20 +197,20 @@ API int yaca_rsa_private_encrypt(yaca_padding_e padding,
        }
 
        return encrypt_decrypt(padding,
-                              prv_key,
-                              plaintext,
-                              plaintext_len,
-                              ciphertext,
-                              ciphertext_len,
-                              RSA_private_encrypt);
+                                                  prv_key,
+                                                  plaintext,
+                                                  plaintext_len,
+                                                  ciphertext,
+                                                  ciphertext_len,
+                                                  RSA_private_encrypt);
 }
 
 API int yaca_rsa_public_decrypt(yaca_padding_e padding,
-                                const yaca_key_h pub_key,
-                                const char *ciphertext,
-                                size_t ciphertext_len,
-                                char **plaintext,
-                                size_t *plaintext_len)
+                                                               const yaca_key_h pub_key,
+                                                               const char *ciphertext,
+                                                               size_t ciphertext_len,
+                                                               char **plaintext,
+                                                               size_t *plaintext_len)
 {
        if (pub_key == YACA_KEY_NULL || pub_key->type != YACA_KEY_TYPE_RSA_PUB)
                return YACA_ERROR_INVALID_PARAMETER;
@@ -224,10 +224,10 @@ API int yaca_rsa_public_decrypt(yaca_padding_e padding,
        }
 
        return encrypt_decrypt(padding,
-                              pub_key,
-                              ciphertext,
-                              ciphertext_len,
-                              plaintext,
-                              plaintext_len,
-                              RSA_public_decrypt);
+                                                  pub_key,
+                                                  ciphertext,
+                                                  ciphertext_len,
+                                                  plaintext,
+                                                  plaintext_len,
+                                                  RSA_public_decrypt);
 }
index f9b16a4..a7c3b50 100644 (file)
 #include "internal.h"
 
 static int seal_generate_sym_key(yaca_encrypt_algorithm_e algo,
-                                 size_t sym_key_bit_len,
-                                 yaca_key_h *sym_key)
+                                                                size_t sym_key_bit_len,
+                                                                yaca_key_h *sym_key)
 {
        assert(sym_key != NULL);
 
        if (algo == YACA_ENCRYPT_3DES_3TDEA ||
-           algo == YACA_ENCRYPT_UNSAFE_3DES_2TDEA ||
-           algo == YACA_ENCRYPT_UNSAFE_DES)
+               algo == YACA_ENCRYPT_UNSAFE_3DES_2TDEA ||
+               algo == YACA_ENCRYPT_UNSAFE_DES)
                return yaca_key_generate(YACA_KEY_TYPE_DES, sym_key_bit_len, sym_key);
        else
                return yaca_key_generate(YACA_KEY_TYPE_SYMMETRIC, sym_key_bit_len, sym_key);
@@ -74,8 +74,8 @@ static int seal_generate_iv(const EVP_CIPHER *cipher, yaca_key_h *iv)
 
 /* used for asymmetric encryption and decryption */
 static int seal_encrypt_decrypt_key(const yaca_key_h asym_key,
-                                    const yaca_key_h in_key,
-                                    yaca_key_h *out_key)
+                                                                       const yaca_key_h in_key,
+                                                                       yaca_key_h *out_key)
 {
        int ret;
        const struct yaca_key_evp_s *lasym_key;
@@ -112,14 +112,14 @@ static int seal_encrypt_decrypt_key(const yaca_key_h asym_key,
 
        if (asym_key->type == YACA_KEY_TYPE_RSA_PRIV)
                ret = EVP_PKEY_decrypt_old((unsigned char*)lout_key->d,
-                                          (unsigned char*)lin_key->d,
-                                          lin_key->bit_len / 8,
-                                          lasym_key->evp);
+                                                                  (unsigned char*)lin_key->d,
+                                                                  lin_key->bit_len / 8,
+                                                                  lasym_key->evp);
        else
                ret = EVP_PKEY_encrypt_old((unsigned char*)lout_key->d,
-                                          (unsigned char*)lin_key->d,
-                                          lin_key->bit_len / 8,
-                                          lasym_key->evp);
+                                                                  (unsigned char*)lin_key->d,
+                                                                  lin_key->bit_len / 8,
+                                                                  lasym_key->evp);
 
        if (ret <= 0) {
                ret = ERROR_HANDLE();
@@ -143,12 +143,12 @@ exit:
 }
 
 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,
-                             size_t sym_key_bit_len,
-                             yaca_key_h *sym_key,
-                             yaca_key_h *iv)
+                                                        const yaca_key_h pub_key,
+                                                        yaca_encrypt_algorithm_e algo,
+                                                        yaca_block_cipher_mode_e bcm,
+                                                        size_t sym_key_bit_len,
+                                                        yaca_key_h *sym_key,
+                                                        yaca_key_h *iv)
 {
        int ret;
        const EVP_CIPHER *cipher;
@@ -157,7 +157,7 @@ API int yaca_seal_initialize(yaca_context_h *ctx,
        yaca_key_h lenc_sym_key = YACA_KEY_NULL;
 
        if (pub_key == YACA_KEY_NULL || pub_key->type != YACA_KEY_TYPE_RSA_PUB ||
-           sym_key == NULL || bcm == YACA_BCM_WRAP || sym_key_bit_len % 8 != 0)
+               sym_key == NULL || bcm == YACA_BCM_WRAP || sym_key_bit_len % 8 != 0)
                return YACA_ERROR_INVALID_PARAMETER;
 
        ret = encrypt_get_algorithm(algo, bcm, sym_key_bit_len, &cipher);
@@ -201,36 +201,36 @@ exit:
 }
 
 API int yaca_seal_update(yaca_context_h ctx,
-                         const char *plaintext,
-                         size_t plaintext_len,
-                         char *ciphertext,
-                         size_t *ciphertext_len)
+                                                const char *plaintext,
+                                                size_t plaintext_len,
+                                                char *ciphertext,
+                                                size_t *ciphertext_len)
 {
        return encrypt_update(ctx, (const unsigned char*)plaintext,  plaintext_len,
-                             (unsigned char*)ciphertext, ciphertext_len, OP_SEAL);
+                                                 (unsigned char*)ciphertext, ciphertext_len, OP_SEAL);
 }
 
 API int yaca_seal_finalize(yaca_context_h ctx,
-                           char *ciphertext,
-                           size_t *ciphertext_len)
+                                                  char *ciphertext,
+                                                  size_t *ciphertext_len)
 {
        return encrypt_finalize(ctx, (unsigned char*)ciphertext, ciphertext_len, OP_SEAL);
 }
 
 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,
-                             size_t sym_key_bit_len,
-                             const yaca_key_h sym_key,
-                             const yaca_key_h iv)
+                                                        const yaca_key_h prv_key,
+                                                        yaca_encrypt_algorithm_e algo,
+                                                        yaca_block_cipher_mode_e bcm,
+                                                        size_t sym_key_bit_len,
+                                                        const yaca_key_h sym_key,
+                                                        const yaca_key_h iv)
 {
        int ret;
        const EVP_CIPHER *cipher;
        yaca_key_h lsym_key = YACA_KEY_NULL;
 
        if (prv_key == YACA_KEY_NULL || prv_key->type != YACA_KEY_TYPE_RSA_PRIV ||
-           sym_key == YACA_KEY_NULL || bcm == YACA_BCM_WRAP || sym_key_bit_len % 8 != 0)
+               sym_key == YACA_KEY_NULL || bcm == YACA_BCM_WRAP || sym_key_bit_len % 8 != 0)
                return YACA_ERROR_INVALID_PARAMETER;
 
        ret = encrypt_get_algorithm(algo, bcm, sym_key_bit_len, &cipher);
@@ -254,18 +254,18 @@ exit:
 }
 
 API int yaca_open_update(yaca_context_h ctx,
-                         const char *ciphertext,
-                         size_t ciphertext_len,
-                         char *plaintext,
-                         size_t *plaintext_len)
+                                                const char *ciphertext,
+                                                size_t ciphertext_len,
+                                                char *plaintext,
+                                                size_t *plaintext_len)
 {
        return encrypt_update(ctx, (const unsigned char*)ciphertext, ciphertext_len,
-                             (unsigned char*)plaintext, plaintext_len, OP_OPEN);
+                                                 (unsigned char*)plaintext, plaintext_len, OP_OPEN);
 }
 
 API int yaca_open_finalize(yaca_context_h ctx,
-                           char *plaintext,
-                           size_t *plaintext_len)
+                                                  char *plaintext,
+                                                  size_t *plaintext_len)
 {
        return encrypt_finalize(ctx, (unsigned char*)plaintext, plaintext_len, OP_OPEN);
 }
index 6ef23df..23c9fa0 100644 (file)
@@ -79,8 +79,8 @@ static struct yaca_sign_context_s *get_sign_context(const yaca_context_h ctx)
 }
 
 static int get_sign_output_length(const yaca_context_h ctx,
-                                  size_t input_len,
-                                  size_t *output_len)
+                                                                 size_t input_len,
+                                                                 size_t *output_len)
 {
        assert(output_len != NULL);
 
@@ -124,9 +124,9 @@ static void destroy_sign_context(yaca_context_h ctx)
 }
 
 int set_sign_property(yaca_context_h ctx,
-                      yaca_property_e property,
-                      const void *value,
-                      size_t value_len)
+                                         yaca_property_e property,
+                                         const void *value,
+                                         size_t value_len)
 {
        int ret;
        struct yaca_sign_context_s *c = get_sign_context(ctx);
@@ -183,8 +183,8 @@ int set_sign_property(yaca_context_h ctx,
 }
 
 API int yaca_sign_initialize(yaca_context_h *ctx,
-                             yaca_digest_algorithm_e algo,
-                             const yaca_key_h prv_key)
+                                                        yaca_digest_algorithm_e algo,
+                                                        const yaca_key_h prv_key)
 {
        struct yaca_sign_context_s *nc = NULL;
        const EVP_MD *md = NULL;
@@ -201,7 +201,7 @@ API int yaca_sign_initialize(yaca_context_h *ctx,
        switch (prv_key->type) {
        case YACA_KEY_TYPE_RSA_PRIV:
                if (EVP_MD_size(md) >= EVP_PKEY_size(evp_key->evp) ||
-                   (algo == YACA_DIGEST_SHA384 && (EVP_PKEY_size(evp_key->evp) <= YACA_KEY_LENGTH_512BIT / 8)))
+                       (algo == YACA_DIGEST_SHA384 && (EVP_PKEY_size(evp_key->evp) <= YACA_KEY_LENGTH_512BIT / 8)))
                        return YACA_ERROR_INVALID_PARAMETER;
                break;
        case YACA_KEY_TYPE_DSA_PRIV:
@@ -247,8 +247,8 @@ exit:
 }
 
 API int yaca_sign_initialize_hmac(yaca_context_h *ctx,
-                                  yaca_digest_algorithm_e algo,
-                                  const yaca_key_h sym_key)
+                                                                 yaca_digest_algorithm_e algo,
+                                                                 const yaca_key_h sym_key)
 {
        struct yaca_sign_context_s *nc = NULL;
        EVP_PKEY *pkey = NULL;
@@ -257,7 +257,7 @@ API int yaca_sign_initialize_hmac(yaca_context_h *ctx,
        const struct yaca_key_simple_s *simple_key = key_get_simple(sym_key);
 
        if (ctx == NULL || simple_key == NULL ||
-           (sym_key->type != YACA_KEY_TYPE_SYMMETRIC && sym_key->type != YACA_KEY_TYPE_DES))
+               (sym_key->type != YACA_KEY_TYPE_SYMMETRIC && sym_key->type != YACA_KEY_TYPE_DES))
                return YACA_ERROR_INVALID_PARAMETER;
 
        ret = yaca_zalloc(sizeof(struct yaca_sign_context_s), (void**)&nc);
@@ -272,9 +272,9 @@ API int yaca_sign_initialize_hmac(yaca_context_h *ctx,
        nc->ctx.get_property = NULL;
 
        pkey = EVP_PKEY_new_mac_key(EVP_PKEY_HMAC,
-                                   NULL,
-                                   (unsigned char *)simple_key->d,
-                                   simple_key->bit_len / 8);
+                                                               NULL,
+                                                               (unsigned char *)simple_key->d,
+                                                               simple_key->bit_len / 8);
        if (pkey == NULL) {
                ret = YACA_ERROR_INTERNAL;
                ERROR_DUMP(ret);
@@ -312,8 +312,8 @@ exit:
 }
 
 API int yaca_sign_initialize_cmac(yaca_context_h *ctx,
-                                  yaca_encrypt_algorithm_e algo,
-                                  const yaca_key_h sym_key)
+                                                                 yaca_encrypt_algorithm_e algo,
+                                                                 const yaca_key_h sym_key)
 {
        struct yaca_sign_context_s *nc = NULL;
        CMAC_CTX* cmac_ctx = NULL;
@@ -323,7 +323,7 @@ API int yaca_sign_initialize_cmac(yaca_context_h *ctx,
        const struct yaca_key_simple_s *simple_key = key_get_simple(sym_key);
 
        if (ctx == NULL || simple_key == NULL ||
-           (sym_key->type != YACA_KEY_TYPE_SYMMETRIC && sym_key->type != YACA_KEY_TYPE_DES))
+               (sym_key->type != YACA_KEY_TYPE_SYMMETRIC && sym_key->type != YACA_KEY_TYPE_DES))
                return YACA_ERROR_INVALID_PARAMETER;
 
        ret = yaca_zalloc(sizeof(struct yaca_sign_context_s), (void**)&nc);
@@ -398,14 +398,14 @@ exit:
 }
 
 API int yaca_sign_update(yaca_context_h ctx,
-                         const char *message,
-                         size_t message_len)
+                                                const char *message,
+                                                size_t message_len)
 {
        struct yaca_sign_context_s *c = get_sign_context(ctx);
        int ret;
 
        if (c == NULL || c->op_type != OP_SIGN ||
-           message == NULL || message_len == 0)
+               message == NULL || message_len == 0)
                return YACA_ERROR_INVALID_PARAMETER;
 
        if (!verify_state_change(c, CTX_MSG_UPDATED))
@@ -423,14 +423,14 @@ API int yaca_sign_update(yaca_context_h ctx,
 }
 
 API int yaca_sign_finalize(yaca_context_h ctx,
-                           char *signature,
-                           size_t *signature_len)
+                                                  char *signature,
+                                                  size_t *signature_len)
 {
        struct yaca_sign_context_s *c = get_sign_context(ctx);
        int ret;
 
        if (c == NULL ||  c->op_type != OP_SIGN ||
-           signature == NULL || signature_len == NULL || *signature_len == 0)
+               signature == NULL || signature_len == NULL || *signature_len == 0)
                return YACA_ERROR_INVALID_PARAMETER;
 
        if (!verify_state_change(c, CTX_FINALIZED))
@@ -448,8 +448,8 @@ API int yaca_sign_finalize(yaca_context_h ctx,
 }
 
 API int yaca_verify_initialize(yaca_context_h *ctx,
-                               yaca_digest_algorithm_e algo,
-                               const yaca_key_h pub_key)
+                                                          yaca_digest_algorithm_e algo,
+                                                          const yaca_key_h pub_key)
 {
        struct yaca_sign_context_s *nc = NULL;
        const EVP_MD *md = NULL;
@@ -466,7 +466,7 @@ API int yaca_verify_initialize(yaca_context_h *ctx,
        switch (pub_key->type) {
        case YACA_KEY_TYPE_RSA_PUB:
                if (EVP_MD_size(md) >= EVP_PKEY_size(evp_key->evp) ||
-                   (algo == YACA_DIGEST_SHA384 && (EVP_PKEY_size(evp_key->evp) <= YACA_KEY_LENGTH_512BIT / 8)))
+                       (algo == YACA_DIGEST_SHA384 && (EVP_PKEY_size(evp_key->evp) <= YACA_KEY_LENGTH_512BIT / 8)))
                        return YACA_ERROR_INVALID_PARAMETER;
                break;
        case YACA_KEY_TYPE_DSA_PUB:
@@ -512,8 +512,8 @@ exit:
 }
 
 API int yaca_verify_update(yaca_context_h ctx,
-                           const char *message,
-                           size_t message_len)
+                                                  const char *message,
+                                                  size_t message_len)
 {
        struct yaca_sign_context_s *c = get_sign_context(ctx);
        int ret;
@@ -536,8 +536,8 @@ API int yaca_verify_update(yaca_context_h ctx,
 }
 
 API int yaca_verify_finalize(yaca_context_h ctx,
-                             const char *signature,
-                             size_t signature_len)
+                                                        const char *signature,
+                                                        size_t signature_len)
 {
        struct yaca_sign_context_s *c = get_sign_context(ctx);
        int ret;
@@ -549,8 +549,8 @@ API int yaca_verify_finalize(yaca_context_h ctx,
                return YACA_ERROR_INVALID_PARAMETER;
 
        ret = EVP_DigestVerifyFinal(c->md_ctx,
-                                   (unsigned char *)signature,
-                                   signature_len);
+                                                               (unsigned char *)signature,
+                                                               signature_len);
 
        if (ret == 1) {
                c->state = CTX_FINALIZED;
index 00d9b3c..e4c7a38 100644 (file)
 #include "internal.h"
 
 API int yaca_simple_calculate_digest(yaca_digest_algorithm_e algo,
-                                     const char *data,
-                                     size_t data_len,
-                                     char **digest,
-                                     size_t *digest_len)
+                                                                        const char *data,
+                                                                        size_t data_len,
+                                                                        char **digest,
+                                                                        size_t *digest_len)
 {
        yaca_context_h ctx;
        int ret;
@@ -45,7 +45,7 @@ API int yaca_simple_calculate_digest(yaca_digest_algorithm_e algo,
        size_t ldigest_len;
 
        if ((data == NULL && data_len > 0) || (data != NULL && data_len == 0) ||
-           digest == NULL || digest_len == NULL)
+               digest == NULL || digest_len == NULL)
                return YACA_ERROR_INVALID_PARAMETER;
 
        ret = yaca_digest_initialize(&ctx, algo);
@@ -84,13 +84,13 @@ exit:
 }
 
 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 *plaintext,
-                            size_t plaintext_len,
-                            char **ciphertext,
-                            size_t *ciphertext_len)
+                                                       yaca_block_cipher_mode_e bcm,
+                                                       const yaca_key_h sym_key,
+                                                       const yaca_key_h iv,
+                                                       const char *plaintext,
+                                                       size_t plaintext_len,
+                                                       char **ciphertext,
+                                                       size_t *ciphertext_len)
 {
        yaca_context_h ctx;
        int ret;
@@ -100,9 +100,9 @@ API int yaca_simple_encrypt(yaca_encrypt_algorithm_e algo,
        size_t written = 0;
 
        if ((plaintext == NULL && plaintext_len > 0) || (plaintext != NULL && plaintext_len == 0) ||
-           ciphertext == NULL || ciphertext_len == NULL ||
-           sym_key == YACA_KEY_NULL ||
-           bcm == YACA_BCM_CCM || bcm == YACA_BCM_GCM)
+               ciphertext == NULL || ciphertext_len == NULL ||
+               sym_key == YACA_KEY_NULL ||
+               bcm == YACA_BCM_CCM || bcm == YACA_BCM_GCM)
                return YACA_ERROR_INVALID_PARAMETER;
 
        ret = yaca_encrypt_initialize(&ctx, algo, bcm, sym_key, iv);
@@ -148,7 +148,7 @@ API int yaca_simple_encrypt(yaca_encrypt_algorithm_e algo,
        assert(written <= lciphertext_len);
 
        if (((bcm == YACA_BCM_CBC || bcm == YACA_BCM_ECB) && written == 0) ||
-           (bcm != YACA_BCM_CBC && bcm != YACA_BCM_ECB && plaintext_len == 0 && written > 0)) {
+               (bcm != YACA_BCM_CBC && bcm != YACA_BCM_ECB && plaintext_len == 0 && written > 0)) {
                ret = YACA_ERROR_INTERNAL;
                goto exit;
        }
@@ -175,13 +175,13 @@ exit:
 }
 
 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 *ciphertext,
-                            size_t ciphertext_len,
-                            char **plaintext,
-                            size_t *plaintext_len)
+                                                       yaca_block_cipher_mode_e bcm,
+                                                       const yaca_key_h sym_key,
+                                                       const yaca_key_h iv,
+                                                       const char *ciphertext,
+                                                       size_t ciphertext_len,
+                                                       char **plaintext,
+                                                       size_t *plaintext_len)
 {
        yaca_context_h ctx;
        int ret;
@@ -191,10 +191,10 @@ API int yaca_simple_decrypt(yaca_encrypt_algorithm_e algo,
        size_t written = 0;
 
        if ((ciphertext == NULL && ciphertext_len > 0) || (ciphertext != NULL && ciphertext_len == 0) ||
-           ((bcm == YACA_BCM_ECB || bcm == YACA_BCM_CBC) && ciphertext == NULL && ciphertext_len == 0) ||
-           plaintext == NULL || plaintext_len == NULL ||
-           sym_key == YACA_KEY_NULL ||
-           bcm == YACA_BCM_CCM || bcm == YACA_BCM_GCM)
+               ((bcm == YACA_BCM_ECB || bcm == YACA_BCM_CBC) && ciphertext == NULL && ciphertext_len == 0) ||
+               plaintext == NULL || plaintext_len == NULL ||
+               sym_key == YACA_KEY_NULL ||
+               bcm == YACA_BCM_CCM || bcm == YACA_BCM_GCM)
                return YACA_ERROR_INVALID_PARAMETER;
 
        ret = yaca_decrypt_initialize(&ctx, algo, bcm, sym_key, iv);
@@ -266,7 +266,7 @@ exit:
 }
 
 static int sign(const yaca_context_h ctx, const char *data, size_t data_len,
-                char **signature, size_t *signature_len)
+                               char **signature, size_t *signature_len)
 {
        int ret;
 
@@ -299,17 +299,17 @@ static int sign(const yaca_context_h ctx, const char *data, size_t data_len,
 }
 
 API int yaca_simple_calculate_signature(yaca_digest_algorithm_e algo,
-                                        const yaca_key_h prv_key,
-                                        const char *data,
-                                        size_t data_len,
-                                        char **signature,
-                                        size_t *signature_len)
+                                                                               const yaca_key_h prv_key,
+                                                                               const char *data,
+                                                                               size_t data_len,
+                                                                               char **signature,
+                                                                               size_t *signature_len)
 {
        int ret;
        yaca_context_h ctx = YACA_CONTEXT_NULL;
 
        if ((data == NULL && data_len > 0) || (data != NULL && data_len == 0) ||
-           signature == NULL || signature_len == NULL)
+               signature == NULL || signature_len == NULL)
                return YACA_ERROR_INVALID_PARAMETER;
 
        ret = yaca_sign_initialize(&ctx, algo, prv_key);
@@ -324,17 +324,17 @@ API int yaca_simple_calculate_signature(yaca_digest_algorithm_e algo,
 }
 
 API int yaca_simple_verify_signature(yaca_digest_algorithm_e algo,
-                                     const yaca_key_h pub_key,
-                                     const char *data,
-                                     size_t data_len,
-                                     const char *signature,
-                                     size_t signature_len)
+                                                                        const yaca_key_h pub_key,
+                                                                        const char *data,
+                                                                        size_t data_len,
+                                                                        const char *signature,
+                                                                        size_t signature_len)
 {
        int ret;
        yaca_context_h ctx = YACA_CONTEXT_NULL;
 
        if ((data == NULL && data_len > 0) || (data != NULL && data_len == 0) ||
-           signature == NULL || signature_len == 0)
+               signature == NULL || signature_len == 0)
                return YACA_ERROR_INVALID_PARAMETER;
 
        ret = yaca_verify_initialize(&ctx, algo, pub_key);
@@ -356,17 +356,17 @@ exit:
 }
 
 API int yaca_simple_calculate_hmac(yaca_digest_algorithm_e algo,
-                                   const yaca_key_h sym_key,
-                                   const char *data,
-                                   size_t data_len,
-                                   char **mac,
-                                   size_t *mac_len)
+                                                                  const yaca_key_h sym_key,
+                                                                  const char *data,
+                                                                  size_t data_len,
+                                                                  char **mac,
+                                                                  size_t *mac_len)
 {
        int ret;
        yaca_context_h ctx = YACA_CONTEXT_NULL;
 
        if ((data == NULL && data_len > 0) || (data != NULL && data_len == 0) ||
-           mac == NULL || mac_len == NULL)
+               mac == NULL || mac_len == NULL)
                return YACA_ERROR_INVALID_PARAMETER;
 
        ret = yaca_sign_initialize_hmac(&ctx, algo, sym_key);
@@ -381,17 +381,17 @@ API int yaca_simple_calculate_hmac(yaca_digest_algorithm_e algo,
 }
 
 API int yaca_simple_calculate_cmac(yaca_encrypt_algorithm_e algo,
-                                   const yaca_key_h sym_key,
-                                   const char *data,
-                                   size_t data_len,
-                                   char **mac,
-                                   size_t *mac_len)
+                                                                  const yaca_key_h sym_key,
+                                                                  const char *data,
+                                                                  size_t data_len,
+                                                                  char **mac,
+                                                                  size_t *mac_len)
 {
        int ret;
        yaca_context_h ctx = YACA_CONTEXT_NULL;
 
        if ((data == NULL && data_len > 0) || (data != NULL && data_len == 0) ||
-           mac == NULL || mac_len == NULL)
+               mac == NULL || mac_len == NULL)
                return YACA_ERROR_INVALID_PARAMETER;
 
        ret = yaca_sign_initialize_cmac(&ctx, algo, sym_key);