From b9e4e2c97a2e448090ff3fcc0f99b8f6dbc08897 Mon Sep 17 00:00:00 2001 From: Paul Bakker Date: Thu, 1 May 2014 14:18:25 +0200 Subject: [PATCH] Fix formatting: fix some 'easy' > 80 length lines --- include/polarssl/aes.h | 8 +- include/polarssl/arc4.h | 5 +- include/polarssl/asn1write.h | 8 +- include/polarssl/bignum.h | 9 ++- include/polarssl/blowfish.h | 10 ++- include/polarssl/camellia.h | 14 ++-- include/polarssl/cipher.h | 37 +++++---- include/polarssl/ctr_drbg.h | 11 ++- include/polarssl/des.h | 14 ++-- include/polarssl/entropy.h | 5 +- include/polarssl/md.h | 27 ++++--- include/polarssl/md2.h | 8 +- include/polarssl/md4.h | 8 +- include/polarssl/oid.h | 4 +- include/polarssl/padlock.h | 5 +- include/polarssl/pkcs11.h | 9 ++- include/polarssl/rsa.h | 10 +-- include/polarssl/sha1.h | 8 +- include/polarssl/sha256.h | 8 +- include/polarssl/sha512.h | 8 +- include/polarssl/ssl.h | 13 +-- include/polarssl/x509.h | 6 +- include/polarssl/x509_csr.h | 5 +- library/aes.c | 12 ++- library/arc4.c | 3 +- library/asn1parse.c | 3 +- library/bignum.c | 3 +- library/blowfish.c | 6 +- library/camellia.c | 146 ++++++++++++++++++---------------- library/cipher.c | 4 +- library/cipher_wrap.c | 123 +++++++++++++++++----------- library/ctr_drbg.c | 3 +- library/des.c | 12 ++- library/dhm.c | 3 +- library/gcm.c | 6 +- library/md2.c | 6 +- library/md4.c | 6 +- library/md5.c | 6 +- library/md_wrap.c | 81 ++++++++++++------- library/memory_buffer_alloc.c | 3 +- library/net.c | 7 +- library/pem.c | 3 +- library/pkcs11.c | 6 +- library/pkcs12.c | 5 +- library/pkcs5.c | 5 +- library/pkwrite.c | 12 ++- library/sha1.c | 6 +- library/sha256.c | 6 +- library/sha512.c | 3 +- library/ssl_cache.c | 10 ++- library/ssl_ciphersuites.c | 3 +- library/ssl_cli.c | 10 ++- library/ssl_srv.c | 13 +-- library/ssl_tls.c | 42 ++++++---- library/version.c | 8 +- library/x509_create.c | 27 ++++--- library/x509_crl.c | 6 +- library/x509_crt.c | 11 ++- library/x509write_crt.c | 26 +++--- library/x509write_csr.c | 20 +++-- 60 files changed, 548 insertions(+), 347 deletions(-) diff --git a/include/polarssl/aes.h b/include/polarssl/aes.h index 9b8a5fa78..58b348e7c 100644 --- a/include/polarssl/aes.h +++ b/include/polarssl/aes.h @@ -3,7 +3,7 @@ * * \brief AES block cipher * - * Copyright (C) 2006-2013, Brainspark B.V. + * Copyright (C) 2006-2014, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker @@ -82,7 +82,8 @@ aes_context; * * \return 0 if successful, or POLARSSL_ERR_AES_INVALID_KEY_LENGTH */ -int aes_setkey_enc( aes_context *ctx, const unsigned char *key, unsigned int keysize ); +int aes_setkey_enc( aes_context *ctx, const unsigned char *key, + unsigned int keysize ); /** * \brief AES key schedule (decryption) @@ -93,7 +94,8 @@ int aes_setkey_enc( aes_context *ctx, const unsigned char *key, unsigned int key * * \return 0 if successful, or POLARSSL_ERR_AES_INVALID_KEY_LENGTH */ -int aes_setkey_dec( aes_context *ctx, const unsigned char *key, unsigned int keysize ); +int aes_setkey_dec( aes_context *ctx, const unsigned char *key, + unsigned int keysize ); /** * \brief AES-ECB block encryption/decryption diff --git a/include/polarssl/arc4.h b/include/polarssl/arc4.h index baa4f6c4f..c6c676b3c 100644 --- a/include/polarssl/arc4.h +++ b/include/polarssl/arc4.h @@ -3,7 +3,7 @@ * * \brief The ARCFOUR stream cipher * - * Copyright (C) 2006-2013, Brainspark B.V. + * Copyright (C) 2006-2014, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker @@ -61,7 +61,8 @@ arc4_context; * \param key the secret key * \param keylen length of the key, in bytes */ -void arc4_setup( arc4_context *ctx, const unsigned char *key, unsigned int keylen ); +void arc4_setup( arc4_context *ctx, const unsigned char *key, + unsigned int keylen ); /** * \brief ARC4 cipher function diff --git a/include/polarssl/asn1write.h b/include/polarssl/asn1write.h index 9c36030b0..7a7fbf7b3 100644 --- a/include/polarssl/asn1write.h +++ b/include/polarssl/asn1write.h @@ -3,7 +3,7 @@ * * \brief ASN.1 buffer writing functionality * - * Copyright (C) 2006-2013, Brainspark B.V. + * Copyright (C) 2006-2014, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker @@ -29,7 +29,8 @@ #include "asn1.h" -#define ASN1_CHK_ADD(g, f) do { if( ( ret = f ) < 0 ) return( ret ); else g += ret; } while( 0 ) +#define ASN1_CHK_ADD(g, f) do { if( ( ret = f ) < 0 ) return( ret ); else \ + g += ret; } while( 0 ) #ifdef __cplusplus extern "C" { @@ -57,7 +58,8 @@ int asn1_write_len( unsigned char **p, unsigned char *start, size_t len ); * * \return the length written or a negative error code */ -int asn1_write_tag( unsigned char **p, unsigned char *start, unsigned char tag ); +int asn1_write_tag( unsigned char **p, unsigned char *start, + unsigned char tag ); /** * \brief Write raw buffer data diff --git a/include/polarssl/bignum.h b/include/polarssl/bignum.h index 2c3f4b4ab..da18599dc 100644 --- a/include/polarssl/bignum.h +++ b/include/polarssl/bignum.h @@ -3,7 +3,7 @@ * * \brief Multi-precision integer library * - * Copyright (C) 2006-2013, Brainspark B.V. + * Copyright (C) 2006-2014, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker @@ -652,8 +652,8 @@ int mpi_mod_int( t_uint *r, const mpi *A, t_sint b ); * * \return 0 if successful, * POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed, - * POLARSSL_ERR_MPI_BAD_INPUT_DATA if N is negative or even or if - * E is negative + * POLARSSL_ERR_MPI_BAD_INPUT_DATA if N is negative or even or + * if E is negative * * \note _RR is used to avoid re-computing R*R mod N across * multiple calls, which speeds up things a bit. It can @@ -721,7 +721,8 @@ int mpi_is_prime( mpi *X, * \brief Prime number generation * * \param X Destination MPI - * \param nbits Required size of X in bits ( 3 <= nbits <= POLARSSL_MPI_MAX_BITS ) + * \param nbits Required size of X in bits + * ( 3 <= nbits <= POLARSSL_MPI_MAX_BITS ) * \param dh_flag If 1, then (X-1)/2 will be prime too * \param f_rng RNG function * \param p_rng RNG parameter diff --git a/include/polarssl/blowfish.h b/include/polarssl/blowfish.h index 8c470ed31..c9c867289 100644 --- a/include/polarssl/blowfish.h +++ b/include/polarssl/blowfish.h @@ -3,7 +3,7 @@ * * \brief Blowfish block cipher * - * Copyright (C) 2012-2013, Brainspark B.V. + * Copyright (C) 2012-2014, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker @@ -46,7 +46,7 @@ typedef UINT32 uint32_t; #define BLOWFISH_DECRYPT 0 #define BLOWFISH_MAX_KEY 448 #define BLOWFISH_MIN_KEY 32 -#define BLOWFISH_ROUNDS 16 /* when increasing this value, make sure to extend the initialisation vectors */ +#define BLOWFISH_ROUNDS 16 /**< Rounds to use. When increasing this value, make sure to extend the initialisation vectors */ #define BLOWFISH_BLOCKSIZE 8 /* Blowfish uses 64 bit blocks */ #define POLARSSL_ERR_BLOWFISH_INVALID_KEY_LENGTH -0x0016 /**< Invalid key length. */ @@ -79,7 +79,8 @@ blowfish_context; * * \return 0 if successful, or POLARSSL_ERR_BLOWFISH_INVALID_KEY_LENGTH */ -int blowfish_setkey( blowfish_context *ctx, const unsigned char *key, unsigned int keysize ); +int blowfish_setkey( blowfish_context *ctx, const unsigned char *key, + unsigned int keysize ); /** * \brief Blowfish-ECB block encryption/decryption @@ -109,7 +110,8 @@ int blowfish_crypt_ecb( blowfish_context *ctx, * \param input buffer holding the input data * \param output buffer holding the output data * - * \return 0 if successful, or POLARSSL_ERR_BLOWFISH_INVALID_INPUT_LENGTH + * \return 0 if successful, or + * POLARSSL_ERR_BLOWFISH_INVALID_INPUT_LENGTH */ int blowfish_crypt_cbc( blowfish_context *ctx, int mode, diff --git a/include/polarssl/camellia.h b/include/polarssl/camellia.h index 9dbdb8570..34c199068 100644 --- a/include/polarssl/camellia.h +++ b/include/polarssl/camellia.h @@ -3,7 +3,7 @@ * * \brief Camellia block cipher * - * Copyright (C) 2006-2013, Brainspark B.V. + * Copyright (C) 2006-2014, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker @@ -75,7 +75,8 @@ camellia_context; * * \return 0 if successful, or POLARSSL_ERR_CAMELLIA_INVALID_KEY_LENGTH */ -int camellia_setkey_enc( camellia_context *ctx, const unsigned char *key, unsigned int keysize ); +int camellia_setkey_enc( camellia_context *ctx, const unsigned char *key, + unsigned int keysize ); /** * \brief CAMELLIA key schedule (decryption) @@ -86,7 +87,8 @@ int camellia_setkey_enc( camellia_context *ctx, const unsigned char *key, unsign * * \return 0 if successful, or POLARSSL_ERR_CAMELLIA_INVALID_KEY_LENGTH */ -int camellia_setkey_dec( camellia_context *ctx, const unsigned char *key, unsigned int keysize ); +int camellia_setkey_dec( camellia_context *ctx, const unsigned char *key, + unsigned int keysize ); /** * \brief CAMELLIA-ECB block encryption/decryption @@ -116,7 +118,8 @@ int camellia_crypt_ecb( camellia_context *ctx, * \param input buffer holding the input data * \param output buffer holding the output data * - * \return 0 if successful, or POLARSSL_ERR_CAMELLIA_INVALID_INPUT_LENGTH + * \return 0 if successful, or + * POLARSSL_ERR_CAMELLIA_INVALID_INPUT_LENGTH */ int camellia_crypt_cbc( camellia_context *ctx, int mode, @@ -142,7 +145,8 @@ int camellia_crypt_cbc( camellia_context *ctx, * \param input buffer holding the input data * \param output buffer holding the output data * - * \return 0 if successful, or POLARSSL_ERR_CAMELLIA_INVALID_INPUT_LENGTH + * \return 0 if successful, or + * POLARSSL_ERR_CAMELLIA_INVALID_INPUT_LENGTH */ int camellia_crypt_cfb128( camellia_context *ctx, int mode, diff --git a/include/polarssl/cipher.h b/include/polarssl/cipher.h index e034facc9..d26b20607 100644 --- a/include/polarssl/cipher.h +++ b/include/polarssl/cipher.h @@ -5,7 +5,7 @@ * * \author Adriaan de Jong * - * Copyright (C) 2006-2013, Brainspark B.V. + * Copyright (C) 2006-2014, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker @@ -173,29 +173,34 @@ typedef struct { /** Encrypt using ECB */ int (*ecb_func)( void *ctx, operation_t mode, - const unsigned char *input, unsigned char *output ); + const unsigned char *input, unsigned char *output ); /** Encrypt using CBC */ - int (*cbc_func)( void *ctx, operation_t mode, size_t length, unsigned char *iv, - const unsigned char *input, unsigned char *output ); + int (*cbc_func)( void *ctx, operation_t mode, size_t length, + unsigned char *iv, const unsigned char *input, + unsigned char *output ); /** Encrypt using CFB (Full length) */ int (*cfb_func)( void *ctx, operation_t mode, size_t length, size_t *iv_off, - unsigned char *iv, const unsigned char *input, unsigned char *output ); + unsigned char *iv, const unsigned char *input, + unsigned char *output ); /** Encrypt using CTR */ - int (*ctr_func)( void *ctx, size_t length, size_t *nc_off, unsigned char *nonce_counter, - unsigned char *stream_block, const unsigned char *input, unsigned char *output ); + int (*ctr_func)( void *ctx, size_t length, size_t *nc_off, + unsigned char *nonce_counter, unsigned char *stream_block, + const unsigned char *input, unsigned char *output ); /** Encrypt using STREAM */ int (*stream_func)( void *ctx, size_t length, const unsigned char *input, unsigned char *output ); /** Set key for encryption purposes */ - int (*setkey_enc_func)( void *ctx, const unsigned char *key, unsigned int key_length); + int (*setkey_enc_func)( void *ctx, const unsigned char *key, + unsigned int key_length ); /** Set key for decryption purposes */ - int (*setkey_dec_func)( void *ctx, const unsigned char *key, unsigned int key_length); + int (*setkey_dec_func)( void *ctx, const unsigned char *key, + unsigned int key_length); /** Allocate a new context */ void * (*ctx_alloc_func)( void ); @@ -323,9 +328,9 @@ const cipher_info_t *cipher_info_from_values( const cipher_id_t cipher_id, * \param ctx context to initialise. May not be NULL. * \param cipher_info cipher to use. * - * \return \c 0 on success, - * \c POLARSSL_ERR_CIPHER_BAD_INPUT_DATA on parameter failure, - * \c POLARSSL_ERR_CIPHER_ALLOC_FAILED if allocation of the + * \return 0 on success, + * POLARSSL_ERR_CIPHER_BAD_INPUT_DATA on parameter failure, + * POLARSSL_ERR_CIPHER_ALLOC_FAILED if allocation of the * cipher-specific context failed. */ int cipher_init_ctx( cipher_context_t *ctx, const cipher_info_t *cipher_info ); @@ -474,8 +479,8 @@ static inline operation_t cipher_get_operation( const cipher_context_t *ctx ) * parameter verification fails or a cipher specific * error code. */ -int cipher_setkey( cipher_context_t *ctx, const unsigned char *key, int key_length, - const operation_t operation ); +int cipher_setkey( cipher_context_t *ctx, const unsigned char *key, + int key_length, const operation_t operation ); #if defined(POLARSSL_CIPHER_MODE_WITH_PADDING) /** @@ -568,8 +573,8 @@ int cipher_update_ad( cipher_context_t *ctx, * function, except the last one before cipher_finish(), * must have ilen a multiple of the block size. */ -int cipher_update( cipher_context_t *ctx, const unsigned char *input, size_t ilen, - unsigned char *output, size_t *olen ); +int cipher_update( cipher_context_t *ctx, const unsigned char *input, + size_t ilen, unsigned char *output, size_t *olen ); /** * \brief Generic cipher finalisation function. If data still diff --git a/include/polarssl/ctr_drbg.h b/include/polarssl/ctr_drbg.h index a71b0fffb..4b5a444a5 100644 --- a/include/polarssl/ctr_drbg.h +++ b/include/polarssl/ctr_drbg.h @@ -3,7 +3,7 @@ * * \brief CTR_DRBG based on AES-256 (NIST SP 800-90) * - * Copyright (C) 2006-2013, Brainspark B.V. + * Copyright (C) 2006-2014, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker @@ -91,8 +91,9 @@ typedef struct unsigned char counter[16]; /*!< counter (V) */ int reseed_counter; /*!< reseed counter */ int prediction_resistance; /*!< enable prediction resistance (Automatic - reseed before every random generation) */ - size_t entropy_len; /*!< amount of entropy grabbed on each (re)seed */ + reseed before every random generation) */ + size_t entropy_len; /*!< amount of entropy grabbed on each + (re)seed */ int reseed_interval; /*!< reseed interval */ aes_context aes_ctx; /*!< AES context */ @@ -255,7 +256,9 @@ int ctr_drbg_update_seed_file( ctr_drbg_context *ctx, const char *path ); int ctr_drbg_self_test( int verbose ); /* Internal functions (do not call directly) */ -int ctr_drbg_init_entropy_len( ctr_drbg_context *, int (*)(void *, unsigned char *, size_t), void *, const unsigned char *, size_t, size_t ); +int ctr_drbg_init_entropy_len( ctr_drbg_context *, + int (*)(void *, unsigned char *, size_t), void *, + const unsigned char *, size_t, size_t ); #ifdef __cplusplus } diff --git a/include/polarssl/des.h b/include/polarssl/des.h index 7499b5328..78729750f 100644 --- a/include/polarssl/des.h +++ b/include/polarssl/des.h @@ -3,7 +3,7 @@ * * \brief DES block cipher * - * Copyright (C) 2006-2013, Brainspark B.V. + * Copyright (C) 2006-2014, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker @@ -136,7 +136,8 @@ int des_setkey_dec( des_context *ctx, const unsigned char key[DES_KEY_SIZE] ); * * \return 0 */ -int des3_set2key_enc( des3_context *ctx, const unsigned char key[DES_KEY_SIZE * 2] ); +int des3_set2key_enc( des3_context *ctx, + const unsigned char key[DES_KEY_SIZE * 2] ); /** * \brief Triple-DES key schedule (112-bit, decryption) @@ -146,7 +147,8 @@ int des3_set2key_enc( des3_context *ctx, const unsigned char key[DES_KEY_SIZE * * * \return 0 */ -int des3_set2key_dec( des3_context *ctx, const unsigned char key[DES_KEY_SIZE * 2] ); +int des3_set2key_dec( des3_context *ctx, + const unsigned char key[DES_KEY_SIZE * 2] ); /** * \brief Triple-DES key schedule (168-bit, encryption) @@ -156,7 +158,8 @@ int des3_set2key_dec( des3_context *ctx, const unsigned char key[DES_KEY_SIZE * * * \return 0 */ -int des3_set3key_enc( des3_context *ctx, const unsigned char key[DES_KEY_SIZE * 3] ); +int des3_set3key_enc( des3_context *ctx, + const unsigned char key[DES_KEY_SIZE * 3] ); /** * \brief Triple-DES key schedule (168-bit, decryption) @@ -166,7 +169,8 @@ int des3_set3key_enc( des3_context *ctx, const unsigned char key[DES_KEY_SIZE * * * \return 0 */ -int des3_set3key_dec( des3_context *ctx, const unsigned char key[DES_KEY_SIZE * 3] ); +int des3_set3key_dec( des3_context *ctx, + const unsigned char key[DES_KEY_SIZE * 3] ); /** * \brief DES-ECB block encryption/decryption diff --git a/include/polarssl/entropy.h b/include/polarssl/entropy.h index 784be16b6..55b262f8f 100644 --- a/include/polarssl/entropy.h +++ b/include/polarssl/entropy.h @@ -3,7 +3,7 @@ * * \brief Entropy accumulator implementation * - * Copyright (C) 2006-2013, Brainspark B.V. + * Copyright (C) 2006-2014, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker @@ -177,7 +177,8 @@ int entropy_add_source( entropy_context *ctx, int entropy_gather( entropy_context *ctx ); /** - * \brief Retrieve entropy from the accumulator (Max ENTROPY_BLOCK_SIZE) + * \brief Retrieve entropy from the accumulator + * (Maximum length: ENTROPY_BLOCK_SIZE) * (Thread-safe if POLARSSL_THREADING_C is enabled) * * \param data Entropy context diff --git a/include/polarssl/md.h b/include/polarssl/md.h index 796c0dfcd..8de233a51 100644 --- a/include/polarssl/md.h +++ b/include/polarssl/md.h @@ -5,7 +5,7 @@ * * \author Adriaan de Jong * - * Copyright (C) 2006-2013, Brainspark B.V. + * Copyright (C) 2006-2014, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker @@ -92,16 +92,18 @@ typedef struct { /** Generic digest function */ void (*digest_func)( const unsigned char *input, size_t ilen, - unsigned char *output ); + unsigned char *output ); /** Generic file digest function */ int (*file_func)( const char *path, unsigned char *output ); /** HMAC Initialisation function */ - void (*hmac_starts_func)( void *ctx, const unsigned char *key, size_t keylen ); + void (*hmac_starts_func)( void *ctx, const unsigned char *key, + size_t keylen ); /** HMAC update function */ - void (*hmac_update_func)( void *ctx, const unsigned char *input, size_t ilen ); + void (*hmac_update_func)( void *ctx, const unsigned char *input, + size_t ilen ); /** HMAC finalisation function */ void (*hmac_finish_func)( void *ctx, unsigned char *output); @@ -111,8 +113,8 @@ typedef struct { /** Generic HMAC function */ void (*hmac_func)( const unsigned char *key, size_t keylen, - const unsigned char *input, size_t ilen, - unsigned char *output ); + const unsigned char *input, size_t ilen, + unsigned char *output ); /** Allocate a new context */ void * (*ctx_alloc_func)( void ); @@ -171,8 +173,8 @@ const md_info_t *md_info_from_string( const char *md_name ); const md_info_t *md_info_from_type( md_type_t md_type ); /** - * \brief Initialises and fills the message digest context structure with - * the appropriate values. + * \brief Initialises and fills the message digest context structure + * with the appropriate values. * * \param ctx context to initialise. May not be NULL. The * digest-specific context (ctx->md_ctx) must be NULL. It will @@ -299,7 +301,8 @@ int md( const md_info_t *md_info, const unsigned char *input, size_t ilen, * failed, POLARSSL_ERR_MD_FILE_READ_FAILED if fread failed, * POLARSSL_ERR_MD_BAD_INPUT_DATA if md_info was NULL. */ -int md_file( const md_info_t *md_info, const char *path, unsigned char *output ); +int md_file( const md_info_t *md_info, const char *path, + unsigned char *output ); /** * \brief Generic HMAC context setup @@ -311,7 +314,8 @@ int md_file( const md_info_t *md_info, const char *path, unsigned char *output ) * \returns 0 on success, POLARSSL_ERR_MD_BAD_INPUT_DATA if parameter * verification fails. */ -int md_hmac_starts( md_context_t *ctx, const unsigned char *key, size_t keylen ); +int md_hmac_starts( md_context_t *ctx, const unsigned char *key, + size_t keylen ); /** * \brief Generic HMAC process buffer @@ -323,7 +327,8 @@ int md_hmac_starts( md_context_t *ctx, const unsigned char *key, size_t keylen ) * \returns 0 on success, POLARSSL_ERR_MD_BAD_INPUT_DATA if parameter * verification fails. */ -int md_hmac_update( md_context_t *ctx, const unsigned char *input, size_t ilen ); +int md_hmac_update( md_context_t *ctx, const unsigned char *input, + size_t ilen ); /** * \brief Generic HMAC final digest diff --git a/include/polarssl/md2.h b/include/polarssl/md2.h index 3792a4dc3..96da06ce5 100644 --- a/include/polarssl/md2.h +++ b/include/polarssl/md2.h @@ -3,7 +3,7 @@ * * \brief MD2 message digest algorithm (hash function) * - * Copyright (C) 2006-2013, Brainspark B.V. + * Copyright (C) 2006-2014, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker @@ -122,7 +122,8 @@ int md2_file( const char *path, unsigned char output[16] ); * \param key HMAC secret key * \param keylen length of the HMAC key */ -void md2_hmac_starts( md2_context *ctx, const unsigned char *key, size_t keylen ); +void md2_hmac_starts( md2_context *ctx, const unsigned char *key, + size_t keylen ); /** * \brief MD2 HMAC process buffer @@ -131,7 +132,8 @@ void md2_hmac_starts( md2_context *ctx, const unsigned char *key, size_t keylen * \param input buffer holding the data * \param ilen length of the input data */ -void md2_hmac_update( md2_context *ctx, const unsigned char *input, size_t ilen ); +void md2_hmac_update( md2_context *ctx, const unsigned char *input, + size_t ilen ); /** * \brief MD2 HMAC final digest diff --git a/include/polarssl/md4.h b/include/polarssl/md4.h index b0434dd5c..6302c3c28 100644 --- a/include/polarssl/md4.h +++ b/include/polarssl/md4.h @@ -3,7 +3,7 @@ * * \brief MD4 message digest algorithm (hash function) * - * Copyright (C) 2006-2013, Brainspark B.V. + * Copyright (C) 2006-2014, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker @@ -128,7 +128,8 @@ int md4_file( const char *path, unsigned char output[16] ); * \param key HMAC secret key * \param keylen length of the HMAC key */ -void md4_hmac_starts( md4_context *ctx, const unsigned char *key, size_t keylen ); +void md4_hmac_starts( md4_context *ctx, const unsigned char *key, + size_t keylen ); /** * \brief MD4 HMAC process buffer @@ -137,7 +138,8 @@ void md4_hmac_starts( md4_context *ctx, const unsigned char *key, size_t keylen * \param input buffer holding the data * \param ilen length of the input data */ -void md4_hmac_update( md4_context *ctx, const unsigned char *input, size_t ilen ); +void md4_hmac_update( md4_context *ctx, const unsigned char *input, + size_t ilen ); /** * \brief MD4 HMAC final digest diff --git a/include/polarssl/oid.h b/include/polarssl/oid.h index b1d33b66b..32b0340c7 100644 --- a/include/polarssl/oid.h +++ b/include/polarssl/oid.h @@ -3,7 +3,7 @@ * * \brief Object Identifier (OID) database * - * Copyright (C) 2006-2013, Brainspark B.V. + * Copyright (C) 2006-2014, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker @@ -63,7 +63,7 @@ */ #define OID_COUNTRY_US "\x86\x48" /* {us(840)} */ #define OID_ORG_RSA_DATA_SECURITY "\x86\xf7\x0d" /* {rsadsi(113549)} */ -#define OID_RSA_COMPANY OID_ISO_MEMBER_BODIES OID_COUNTRY_US \ +#define OID_RSA_COMPANY OID_ISO_MEMBER_BODIES OID_COUNTRY_US \ OID_ORG_RSA_DATA_SECURITY /* {iso(1) member-body(2) us(840) rsadsi(113549)} */ #define OID_ORG_ANSI_X9_62 "\xce\x3d" /* ansi-X9-62(10045) */ #define OID_ANSI_X9_62 OID_ISO_MEMBER_BODIES OID_COUNTRY_US \ diff --git a/include/polarssl/padlock.h b/include/polarssl/padlock.h index 545120fe3..3c5f7258b 100644 --- a/include/polarssl/padlock.h +++ b/include/polarssl/padlock.h @@ -1,9 +1,10 @@ /** * \file padlock.h * - * \brief VIA PadLock ACE for HW encryption/decryption supported by some processors + * \brief VIA PadLock ACE for HW encryption/decryption supported by some + * processors * - * Copyright (C) 2006-2010, Brainspark B.V. + * Copyright (C) 2006-2014, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker diff --git a/include/polarssl/pkcs11.h b/include/polarssl/pkcs11.h index 74859c042..84f862dd9 100644 --- a/include/polarssl/pkcs11.h +++ b/include/polarssl/pkcs11.h @@ -5,7 +5,7 @@ * * \author Adriaan de Jong * - * Copyright (C) 2006-2013, Brainspark B.V. + * Copyright (C) 2006-2014, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker @@ -93,7 +93,8 @@ int pkcs11_priv_key_init( pkcs11_context *priv_key, void pkcs11_priv_key_free( pkcs11_context *priv_key ); /** - * \brief Do an RSA private key decrypt, then remove the message padding + * \brief Do an RSA private key decrypt, then remove the message + * padding * * \param ctx PKCS #11 context * \param mode must be RSA_PRIVATE, for compatibility with rsa.c's signature @@ -119,8 +120,8 @@ int pkcs11_decrypt( pkcs11_context *ctx, * * \param ctx PKCS #11 context * \param mode must be RSA_PRIVATE, for compatibility with rsa.c's signature - * \param hash_id SIG_RSA_RAW, SIG_RSA_MD{2,4,5} or SIG_RSA_SHA{1,224,256,384,512} - * \param hashlen message digest length (for SIG_RSA_RAW only) + * \param md_alg a POLARSSL_MD_* (use POLARSSL_MD_NONE for signing raw data) + * \param hashlen message digest length (for POLARSSL_MD_NONE only) * \param hash buffer holding the message digest * \param sig buffer that will hold the ciphertext * diff --git a/include/polarssl/rsa.h b/include/polarssl/rsa.h index ce84c1c27..1c697fbc3 100644 --- a/include/polarssl/rsa.h +++ b/include/polarssl/rsa.h @@ -3,7 +3,7 @@ * * \brief The RSA public-key cryptosystem * - * Copyright (C) 2006-2013, Brainspark B.V. + * Copyright (C) 2006-2014, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker @@ -503,8 +503,8 @@ int rsa_rsassa_pss_sign( rsa_context *ctx, * * \note In case of PKCS#1 v2.1 encoding keep in mind that * the hash_id in the RSA context is the one used for the - * verification. hash_id in the function call is the type of hash - * that is verified. According to RFC 3447 it is advised to + * verification. hash_id in the function call is the type of + * hash that is verified. According to RFC 3447 it is advised to * keep both hashes the same. */ int rsa_pkcs1_verify( rsa_context *ctx, @@ -563,8 +563,8 @@ int rsa_rsassa_pkcs1_v15_verify( rsa_context *ctx, * * \note In case of PKCS#1 v2.1 encoding keep in mind that * the hash_id in the RSA context is the one used for the - * verification. hash_id in the function call is the type of hash - * that is verified. According to RFC 3447 it is advised to + * verification. hash_id in the function call is the type of + * hash that is verified. According to RFC 3447 it is advised to * keep both hashes the same. */ int rsa_rsassa_pss_verify( rsa_context *ctx, diff --git a/include/polarssl/sha1.h b/include/polarssl/sha1.h index f5e91a464..57a731bfa 100644 --- a/include/polarssl/sha1.h +++ b/include/polarssl/sha1.h @@ -3,7 +3,7 @@ * * \brief SHA-1 cryptographic hash function * - * Copyright (C) 2006-2013, Brainspark B.V. + * Copyright (C) 2006-2014, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker @@ -131,7 +131,8 @@ int sha1_file( const char *path, unsigned char output[20] ); * \param key HMAC secret key * \param keylen length of the HMAC key */ -void sha1_hmac_starts( sha1_context *ctx, const unsigned char *key, size_t keylen ); +void sha1_hmac_starts( sha1_context *ctx, const unsigned char *key, + size_t keylen ); /** * \brief SHA-1 HMAC process buffer @@ -140,7 +141,8 @@ void sha1_hmac_starts( sha1_context *ctx, const unsigned char *key, size_t keyle * \param input buffer holding the data * \param ilen length of the input data */ -void sha1_hmac_update( sha1_context *ctx, const unsigned char *input, size_t ilen ); +void sha1_hmac_update( sha1_context *ctx, const unsigned char *input, + size_t ilen ); /** * \brief SHA-1 HMAC final digest diff --git a/include/polarssl/sha256.h b/include/polarssl/sha256.h index f3c00fa20..80a022487 100644 --- a/include/polarssl/sha256.h +++ b/include/polarssl/sha256.h @@ -3,7 +3,7 @@ * * \brief SHA-224 and SHA-256 cryptographic hash function * - * Copyright (C) 2006-2013, Brainspark B.V. + * Copyright (C) 2006-2014, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker @@ -82,7 +82,8 @@ void sha256_starts( sha256_context *ctx, int is224 ); * \param input buffer holding the data * \param ilen length of the input data */ -void sha256_update( sha256_context *ctx, const unsigned char *input, size_t ilen ); +void sha256_update( sha256_context *ctx, const unsigned char *input, + size_t ilen ); /** * \brief SHA-256 final digest @@ -147,7 +148,8 @@ void sha256_hmac_starts( sha256_context *ctx, const unsigned char *key, * \param input buffer holding the data * \param ilen length of the input data */ -void sha256_hmac_update( sha256_context *ctx, const unsigned char *input, size_t ilen ); +void sha256_hmac_update( sha256_context *ctx, const unsigned char *input, + size_t ilen ); /** * \brief SHA-256 HMAC final digest diff --git a/include/polarssl/sha512.h b/include/polarssl/sha512.h index b8908af22..c60564f48 100644 --- a/include/polarssl/sha512.h +++ b/include/polarssl/sha512.h @@ -3,7 +3,7 @@ * * \brief SHA-384 and SHA-512 cryptographic hash function * - * Copyright (C) 2006-2013, Brainspark B.V. + * Copyright (C) 2006-2014, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker @@ -83,7 +83,8 @@ void sha512_starts( sha512_context *ctx, int is384 ); * \param input buffer holding the data * \param ilen length of the input data */ -void sha512_update( sha512_context *ctx, const unsigned char *input, size_t ilen ); +void sha512_update( sha512_context *ctx, const unsigned char *input, + size_t ilen ); /** * \brief SHA-512 final digest @@ -145,7 +146,8 @@ void sha512_hmac_starts( sha512_context *ctx, const unsigned char *key, * \param input buffer holding the data * \param ilen length of the input data */ -void sha512_hmac_update( sha512_context *ctx, const unsigned char *input, size_t ilen ); +void sha512_hmac_update( sha512_context *ctx, const unsigned char *input, + size_t ilen ); /** * \brief SHA-512 HMAC final digest diff --git a/include/polarssl/ssl.h b/include/polarssl/ssl.h index 9cbd512c3..21ed42ead 100644 --- a/include/polarssl/ssl.h +++ b/include/polarssl/ssl.h @@ -3,7 +3,7 @@ * * \brief SSL/TLS functions. * - * Copyright (C) 2006-2013, Brainspark B.V. + * Copyright (C) 2006-2014, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker @@ -825,8 +825,8 @@ extern int (*ssl_hw_record_finish)(ssl_context *ssl); const int *ssl_list_ciphersuites( void ); /** - * \brief Return the name of the ciphersuite associated with the given - * ID + * \brief Return the name of the ciphersuite associated with the + * given ID * * \param ciphersuite_id SSL ciphersuite ID * @@ -835,8 +835,8 @@ const int *ssl_list_ciphersuites( void ); const char *ssl_get_ciphersuite_name( const int ciphersuite_id ); /** - * \brief Return the ID of the ciphersuite associated with the given - * name + * \brief Return the ID of the ciphersuite associated with the + * given name * * \param ciphersuite_name SSL ciphersuite name * @@ -1642,7 +1642,8 @@ int ssl_write_change_cipher_spec( ssl_context *ssl ); int ssl_parse_finished( ssl_context *ssl ); int ssl_write_finished( ssl_context *ssl ); -void ssl_optimize_checksum( ssl_context *ssl, const ssl_ciphersuite_t *ciphersuite_info ); +void ssl_optimize_checksum( ssl_context *ssl, + const ssl_ciphersuite_t *ciphersuite_info ); #if defined(POLARSSL_KEY_EXCHANGE__SOME__PSK_ENABLED) int ssl_psk_derive_premaster( ssl_context *ssl, key_exchange_type_t key_ex ); diff --git a/include/polarssl/x509.h b/include/polarssl/x509.h index e13f38f78..759234816 100644 --- a/include/polarssl/x509.h +++ b/include/polarssl/x509.h @@ -3,7 +3,7 @@ * * \brief X.509 generic defines and structures * - * Copyright (C) 2006-2013, Brainspark B.V. + * Copyright (C) 2006-2014, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker @@ -288,7 +288,9 @@ int x509_get_ext( unsigned char **p, const unsigned char *end, int x509_load_file( const char *path, unsigned char **buf, size_t *n ); int x509_key_size_helper( char *buf, size_t size, const char *name ); int x509_string_to_names( asn1_named_data **head, const char *name ); -int x509_set_extension( asn1_named_data **head, const char *oid, size_t oid_len, int critical, const unsigned char *val, size_t val_len ); +int x509_set_extension( asn1_named_data **head, const char *oid, size_t oid_len, + int critical, const unsigned char *val, + size_t val_len ); int x509_write_extensions( unsigned char **p, unsigned char *start, asn1_named_data *first ); int x509_write_names( unsigned char **p, unsigned char *start, diff --git a/include/polarssl/x509_csr.h b/include/polarssl/x509_csr.h index b66058760..8b4892aea 100644 --- a/include/polarssl/x509_csr.h +++ b/include/polarssl/x509_csr.h @@ -3,7 +3,7 @@ * * \brief X.509 certificate signing request parsing and writing * - * Copyright (C) 2006-2013, Brainspark B.V. + * Copyright (C) 2006-2014, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker @@ -204,7 +204,8 @@ int x509write_csr_set_ns_cert_type( x509write_csr *ctx, unsigned char ns_cert_type ); /** - * \brief Generic function to add to or replace an extension in the CSR + * \brief Generic function to add to or replace an extension in the + * CSR * * \param ctx CSR context to use * \param oid OID of the extension diff --git a/library/aes.c b/library/aes.c index 7fc7af4a2..ca5c90692 100644 --- a/library/aes.c +++ b/library/aes.c @@ -461,7 +461,8 @@ static void aes_gen_tables( void ) /* * AES key schedule (encryption) */ -int aes_setkey_enc( aes_context *ctx, const unsigned char *key, unsigned int keysize ) +int aes_setkey_enc( aes_context *ctx, const unsigned char *key, + unsigned int keysize ) { unsigned int i; uint32_t *RK; @@ -576,7 +577,8 @@ int aes_setkey_enc( aes_context *ctx, const unsigned char *key, unsigned int key /* * AES key schedule (decryption) */ -int aes_setkey_dec( aes_context *ctx, const unsigned char *key, unsigned int keysize ) +int aes_setkey_dec( aes_context *ctx, const unsigned char *key, + unsigned int keysize ) { int i, j; aes_context cty; @@ -1387,7 +1389,8 @@ int aes_self_test( int verbose ) len = aes_test_ctr_len[u]; memcpy( buf, aes_test_ctr_ct[u], len ); - aes_crypt_ctr( &ctx, len, &offset, nonce_counter, stream_block, buf, buf ); + aes_crypt_ctr( &ctx, len, &offset, nonce_counter, stream_block, + buf, buf ); if( memcmp( buf, aes_test_ctr_pt[u], len ) != 0 ) { @@ -1402,7 +1405,8 @@ int aes_self_test( int verbose ) len = aes_test_ctr_len[u]; memcpy( buf, aes_test_ctr_pt[u], len ); - aes_crypt_ctr( &ctx, len, &offset, nonce_counter, stream_block, buf, buf ); + aes_crypt_ctr( &ctx, len, &offset, nonce_counter, stream_block, + buf, buf ); if( memcmp( buf, aes_test_ctr_ct[u], len ) != 0 ) { diff --git a/library/arc4.c b/library/arc4.c index 464f800a9..d722c56ea 100644 --- a/library/arc4.c +++ b/library/arc4.c @@ -49,7 +49,8 @@ /* * ARC4 key schedule */ -void arc4_setup( arc4_context *ctx, const unsigned char *key, unsigned int keylen ) +void arc4_setup( arc4_context *ctx, const unsigned char *key, + unsigned int keylen ) { int i, j, a; unsigned int k; diff --git a/library/asn1parse.c b/library/asn1parse.c index ed024de42..7cd9bf649 100644 --- a/library/asn1parse.c +++ b/library/asn1parse.c @@ -91,7 +91,8 @@ int asn1_get_len( unsigned char **p, if( ( end - *p ) < 5 ) return( POLARSSL_ERR_ASN1_OUT_OF_DATA ); - *len = ( (*p)[1] << 24 ) | ( (*p)[2] << 16 ) | ( (*p)[3] << 8 ) | (*p)[4]; + *len = ( (*p)[1] << 24 ) | ( (*p)[2] << 16 ) | ( (*p)[3] << 8 ) | + (*p)[4]; (*p) += 5; break; diff --git a/library/bignum.c b/library/bignum.c index 5a8d17d85..8b63ba8ac 100644 --- a/library/bignum.c +++ b/library/bignum.c @@ -1469,7 +1469,8 @@ static void mpi_montg_init( t_uint *mm, const mpi *N ) /* * Montgomery multiplication: A = A * B * R^-1 mod N (HAC 14.36) */ -static void mpi_montmul( mpi *A, const mpi *B, const mpi *N, t_uint mm, const mpi *T ) +static void mpi_montmul( mpi *A, const mpi *B, const mpi *N, t_uint mm, + const mpi *T ) { size_t i, n, m; t_uint u0, u1, *d; diff --git a/library/blowfish.c b/library/blowfish.c index adbabce3e..7271471ed 100644 --- a/library/blowfish.c +++ b/library/blowfish.c @@ -155,7 +155,8 @@ static void blowfish_dec(blowfish_context *ctx, uint32_t *xl, uint32_t *xr) /* * Blowfish key schedule */ -int blowfish_setkey( blowfish_context *ctx, const unsigned char *key, unsigned int keysize ) +int blowfish_setkey( blowfish_context *ctx, const unsigned char *key, + unsigned int keysize ) { unsigned int i, j, k; uint32_t data, datal, datar; @@ -357,7 +358,8 @@ int blowfish_crypt_ctr( blowfish_context *ctx, while( length-- ) { if( n == 0 ) { - blowfish_crypt_ecb( ctx, BLOWFISH_ENCRYPT, nonce_counter, stream_block ); + blowfish_crypt_ecb( ctx, BLOWFISH_ENCRYPT, nonce_counter, + stream_block ); for( i = BLOWFISH_BLOCKSIZE; i > 0; i-- ) if( ++nonce_counter[i - 1] != 0 ) diff --git a/library/camellia.c b/library/camellia.c index caa2965a3..524e6ffae 100644 --- a/library/camellia.c +++ b/library/camellia.c @@ -111,82 +111,82 @@ static const unsigned char FSb[256] = static const unsigned char FSb[256] = { - 112, 130, 44, 236, 179, 39, 192, 229, 228, 133, 87, 53, 234, 12, 174, 65, - 35, 239, 107, 147, 69, 25, 165, 33, 237, 14, 79, 78, 29, 101, 146, 189, - 134, 184, 175, 143, 124, 235, 31, 206, 62, 48, 220, 95, 94, 197, 11, 26, - 166, 225, 57, 202, 213, 71, 93, 61, 217, 1, 90, 214, 81, 86, 108, 77, - 139, 13, 154, 102, 251, 204, 176, 45, 116, 18, 43, 32, 240, 177, 132, 153, - 223, 76, 203, 194, 52, 126, 118, 5, 109, 183, 169, 49, 209, 23, 4, 215, - 20, 88, 58, 97, 222, 27, 17, 28, 50, 15, 156, 22, 83, 24, 242, 34, - 254, 68, 207, 178, 195, 181, 122, 145, 36, 8, 232, 168, 96, 252, 105, 80, - 170, 208, 160, 125, 161, 137, 98, 151, 84, 91, 30, 149, 224, 255, 100, 210, - 16, 196, 0, 72, 163, 247, 117, 219, 138, 3, 230, 218, 9, 63, 221, 148, - 135, 92, 131, 2, 205, 74, 144, 51, 115, 103, 246, 243, 157, 127, 191, 226, - 82, 155, 216, 38, 200, 55, 198, 59, 129, 150, 111, 75, 19, 190, 99, 46, - 233, 121, 167, 140, 159, 110, 188, 142, 41, 245, 249, 182, 47, 253, 180, 89, - 120, 152, 6, 106, 231, 70, 113, 186, 212, 37, 171, 66, 136, 162, 141, 250, - 114, 7, 185, 85, 248, 238, 172, 10, 54, 73, 42, 104, 60, 56, 241, 164, - 64, 40, 211, 123, 187, 201, 67, 193, 21, 227, 173, 244, 119, 199, 128, 158 + 112, 130, 44, 236, 179, 39, 192, 229, 228, 133, 87, 53, 234, 12, 174, 65, + 35, 239, 107, 147, 69, 25, 165, 33, 237, 14, 79, 78, 29, 101, 146, 189, + 134, 184, 175, 143, 124, 235, 31, 206, 62, 48, 220, 95, 94, 197, 11, 26, + 166, 225, 57, 202, 213, 71, 93, 61, 217, 1, 90, 214, 81, 86, 108, 77, + 139, 13, 154, 102, 251, 204, 176, 45, 116, 18, 43, 32, 240, 177, 132, 153, + 223, 76, 203, 194, 52, 126, 118, 5, 109, 183, 169, 49, 209, 23, 4, 215, + 20, 88, 58, 97, 222, 27, 17, 28, 50, 15, 156, 22, 83, 24, 242, 34, + 254, 68, 207, 178, 195, 181, 122, 145, 36, 8, 232, 168, 96, 252, 105, 80, + 170, 208, 160, 125, 161, 137, 98, 151, 84, 91, 30, 149, 224, 255, 100, 210, + 16, 196, 0, 72, 163, 247, 117, 219, 138, 3, 230, 218, 9, 63, 221, 148, + 135, 92, 131, 2, 205, 74, 144, 51, 115, 103, 246, 243, 157, 127, 191, 226, + 82, 155, 216, 38, 200, 55, 198, 59, 129, 150, 111, 75, 19, 190, 99, 46, + 233, 121, 167, 140, 159, 110, 188, 142, 41, 245, 249, 182, 47, 253, 180, 89, + 120, 152, 6, 106, 231, 70, 113, 186, 212, 37, 171, 66, 136, 162, 141, 250, + 114, 7, 185, 85, 248, 238, 172, 10, 54, 73, 42, 104, 60, 56, 241, 164, + 64, 40, 211, 123, 187, 201, 67, 193, 21, 227, 173, 244, 119, 199, 128, 158 }; static const unsigned char FSb2[256] = { - 224, 5, 88, 217, 103, 78, 129, 203, 201, 11, 174, 106, 213, 24, 93, 130, - 70, 223, 214, 39, 138, 50, 75, 66, 219, 28, 158, 156, 58, 202, 37, 123, - 13, 113, 95, 31, 248, 215, 62, 157, 124, 96, 185, 190, 188, 139, 22, 52, - 77, 195, 114, 149, 171, 142, 186, 122, 179, 2, 180, 173, 162, 172, 216, 154, - 23, 26, 53, 204, 247, 153, 97, 90, 232, 36, 86, 64, 225, 99, 9, 51, - 191, 152, 151, 133, 104, 252, 236, 10, 218, 111, 83, 98, 163, 46, 8, 175, - 40, 176, 116, 194, 189, 54, 34, 56, 100, 30, 57, 44, 166, 48, 229, 68, - 253, 136, 159, 101, 135, 107, 244, 35, 72, 16, 209, 81, 192, 249, 210, 160, - 85, 161, 65, 250, 67, 19, 196, 47, 168, 182, 60, 43, 193, 255, 200, 165, - 32, 137, 0, 144, 71, 239, 234, 183, 21, 6, 205, 181, 18, 126, 187, 41, - 15, 184, 7, 4, 155, 148, 33, 102, 230, 206, 237, 231, 59, 254, 127, 197, - 164, 55, 177, 76, 145, 110, 141, 118, 3, 45, 222, 150, 38, 125, 198, 92, - 211, 242, 79, 25, 63, 220, 121, 29, 82, 235, 243, 109, 94, 251, 105, 178, - 240, 49, 12, 212, 207, 140, 226, 117, 169, 74, 87, 132, 17, 69, 27, 245, - 228, 14, 115, 170, 241, 221, 89, 20, 108, 146, 84, 208, 120, 112, 227, 73, - 128, 80, 167, 246, 119, 147, 134, 131, 42, 199, 91, 233, 238, 143, 1, 61 + 224, 5, 88, 217, 103, 78, 129, 203, 201, 11, 174, 106, 213, 24, 93, 130, + 70, 223, 214, 39, 138, 50, 75, 66, 219, 28, 158, 156, 58, 202, 37, 123, + 13, 113, 95, 31, 248, 215, 62, 157, 124, 96, 185, 190, 188, 139, 22, 52, + 77, 195, 114, 149, 171, 142, 186, 122, 179, 2, 180, 173, 162, 172, 216, 154, + 23, 26, 53, 204, 247, 153, 97, 90, 232, 36, 86, 64, 225, 99, 9, 51, + 191, 152, 151, 133, 104, 252, 236, 10, 218, 111, 83, 98, 163, 46, 8, 175, + 40, 176, 116, 194, 189, 54, 34, 56, 100, 30, 57, 44, 166, 48, 229, 68, + 253, 136, 159, 101, 135, 107, 244, 35, 72, 16, 209, 81, 192, 249, 210, 160, + 85, 161, 65, 250, 67, 19, 196, 47, 168, 182, 60, 43, 193, 255, 200, 165, + 32, 137, 0, 144, 71, 239, 234, 183, 21, 6, 205, 181, 18, 126, 187, 41, + 15, 184, 7, 4, 155, 148, 33, 102, 230, 206, 237, 231, 59, 254, 127, 197, + 164, 55, 177, 76, 145, 110, 141, 118, 3, 45, 222, 150, 38, 125, 198, 92, + 211, 242, 79, 25, 63, 220, 121, 29, 82, 235, 243, 109, 94, 251, 105, 178, + 240, 49, 12, 212, 207, 140, 226, 117, 169, 74, 87, 132, 17, 69, 27, 245, + 228, 14, 115, 170, 241, 221, 89, 20, 108, 146, 84, 208, 120, 112, 227, 73, + 128, 80, 167, 246, 119, 147, 134, 131, 42, 199, 91, 233, 238, 143, 1, 61 }; static const unsigned char FSb3[256] = { - 56, 65, 22, 118, 217, 147, 96, 242, 114, 194, 171, 154, 117, 6, 87, 160, - 145, 247, 181, 201, 162, 140, 210, 144, 246, 7, 167, 39, 142, 178, 73, 222, - 67, 92, 215, 199, 62, 245, 143, 103, 31, 24, 110, 175, 47, 226, 133, 13, - 83, 240, 156, 101, 234, 163, 174, 158, 236, 128, 45, 107, 168, 43, 54, 166, - 197, 134, 77, 51, 253, 102, 88, 150, 58, 9, 149, 16, 120, 216, 66, 204, - 239, 38, 229, 97, 26, 63, 59, 130, 182, 219, 212, 152, 232, 139, 2, 235, - 10, 44, 29, 176, 111, 141, 136, 14, 25, 135, 78, 11, 169, 12, 121, 17, - 127, 34, 231, 89, 225, 218, 61, 200, 18, 4, 116, 84, 48, 126, 180, 40, - 85, 104, 80, 190, 208, 196, 49, 203, 42, 173, 15, 202, 112, 255, 50, 105, - 8, 98, 0, 36, 209, 251, 186, 237, 69, 129, 115, 109, 132, 159, 238, 74, - 195, 46, 193, 1, 230, 37, 72, 153, 185, 179, 123, 249, 206, 191, 223, 113, - 41, 205, 108, 19, 100, 155, 99, 157, 192, 75, 183, 165, 137, 95, 177, 23, - 244, 188, 211, 70, 207, 55, 94, 71, 148, 250, 252, 91, 151, 254, 90, 172, - 60, 76, 3, 53, 243, 35, 184, 93, 106, 146, 213, 33, 68, 81, 198, 125, - 57, 131, 220, 170, 124, 119, 86, 5, 27, 164, 21, 52, 30, 28, 248, 82, - 32, 20, 233, 189, 221, 228, 161, 224, 138, 241, 214, 122, 187, 227, 64, 79 + 56, 65, 22, 118, 217, 147, 96, 242, 114, 194, 171, 154, 117, 6, 87, 160, + 145, 247, 181, 201, 162, 140, 210, 144, 246, 7, 167, 39, 142, 178, 73, 222, + 67, 92, 215, 199, 62, 245, 143, 103, 31, 24, 110, 175, 47, 226, 133, 13, + 83, 240, 156, 101, 234, 163, 174, 158, 236, 128, 45, 107, 168, 43, 54, 166, + 197, 134, 77, 51, 253, 102, 88, 150, 58, 9, 149, 16, 120, 216, 66, 204, + 239, 38, 229, 97, 26, 63, 59, 130, 182, 219, 212, 152, 232, 139, 2, 235, + 10, 44, 29, 176, 111, 141, 136, 14, 25, 135, 78, 11, 169, 12, 121, 17, + 127, 34, 231, 89, 225, 218, 61, 200, 18, 4, 116, 84, 48, 126, 180, 40, + 85, 104, 80, 190, 208, 196, 49, 203, 42, 173, 15, 202, 112, 255, 50, 105, + 8, 98, 0, 36, 209, 251, 186, 237, 69, 129, 115, 109, 132, 159, 238, 74, + 195, 46, 193, 1, 230, 37, 72, 153, 185, 179, 123, 249, 206, 191, 223, 113, + 41, 205, 108, 19, 100, 155, 99, 157, 192, 75, 183, 165, 137, 95, 177, 23, + 244, 188, 211, 70, 207, 55, 94, 71, 148, 250, 252, 91, 151, 254, 90, 172, + 60, 76, 3, 53, 243, 35, 184, 93, 106, 146, 213, 33, 68, 81, 198, 125, + 57, 131, 220, 170, 124, 119, 86, 5, 27, 164, 21, 52, 30, 28, 248, 82, + 32, 20, 233, 189, 221, 228, 161, 224, 138, 241, 214, 122, 187, 227, 64, 79 }; static const unsigned char FSb4[256] = { - 112, 44, 179, 192, 228, 87, 234, 174, 35, 107, 69, 165, 237, 79, 29, 146, - 134, 175, 124, 31, 62, 220, 94, 11, 166, 57, 213, 93, 217, 90, 81, 108, - 139, 154, 251, 176, 116, 43, 240, 132, 223, 203, 52, 118, 109, 169, 209, 4, - 20, 58, 222, 17, 50, 156, 83, 242, 254, 207, 195, 122, 36, 232, 96, 105, - 170, 160, 161, 98, 84, 30, 224, 100, 16, 0, 163, 117, 138, 230, 9, 221, - 135, 131, 205, 144, 115, 246, 157, 191, 82, 216, 200, 198, 129, 111, 19, 99, - 233, 167, 159, 188, 41, 249, 47, 180, 120, 6, 231, 113, 212, 171, 136, 141, - 114, 185, 248, 172, 54, 42, 60, 241, 64, 211, 187, 67, 21, 173, 119, 128, - 130, 236, 39, 229, 133, 53, 12, 65, 239, 147, 25, 33, 14, 78, 101, 189, - 184, 143, 235, 206, 48, 95, 197, 26, 225, 202, 71, 61, 1, 214, 86, 77, - 13, 102, 204, 45, 18, 32, 177, 153, 76, 194, 126, 5, 183, 49, 23, 215, - 88, 97, 27, 28, 15, 22, 24, 34, 68, 178, 181, 145, 8, 168, 252, 80, - 208, 125, 137, 151, 91, 149, 255, 210, 196, 72, 247, 219, 3, 218, 63, 148, - 92, 2, 74, 51, 103, 243, 127, 226, 155, 38, 55, 59, 150, 75, 190, 46, - 121, 140, 110, 142, 245, 182, 253, 89, 152, 106, 70, 186, 37, 66, 162, 250, - 7, 85, 238, 10, 73, 104, 56, 164, 40, 123, 201, 193, 227, 244, 199, 158 + 112, 44, 179, 192, 228, 87, 234, 174, 35, 107, 69, 165, 237, 79, 29, 146, + 134, 175, 124, 31, 62, 220, 94, 11, 166, 57, 213, 93, 217, 90, 81, 108, + 139, 154, 251, 176, 116, 43, 240, 132, 223, 203, 52, 118, 109, 169, 209, 4, + 20, 58, 222, 17, 50, 156, 83, 242, 254, 207, 195, 122, 36, 232, 96, 105, + 170, 160, 161, 98, 84, 30, 224, 100, 16, 0, 163, 117, 138, 230, 9, 221, + 135, 131, 205, 144, 115, 246, 157, 191, 82, 216, 200, 198, 129, 111, 19, 99, + 233, 167, 159, 188, 41, 249, 47, 180, 120, 6, 231, 113, 212, 171, 136, 141, + 114, 185, 248, 172, 54, 42, 60, 241, 64, 211, 187, 67, 21, 173, 119, 128, + 130, 236, 39, 229, 133, 53, 12, 65, 239, 147, 25, 33, 14, 78, 101, 189, + 184, 143, 235, 206, 48, 95, 197, 26, 225, 202, 71, 61, 1, 214, 86, 77, + 13, 102, 204, 45, 18, 32, 177, 153, 76, 194, 126, 5, 183, 49, 23, 215, + 88, 97, 27, 28, 15, 22, 24, 34, 68, 178, 181, 145, 8, 168, 252, 80, + 208, 125, 137, 151, 91, 149, 255, 210, 196, 72, 247, 219, 3, 218, 63, 148, + 92, 2, 74, 51, 103, 243, 127, 226, 155, 38, 55, 59, 150, 75, 190, 46, + 121, 140, 110, 142, 245, 182, 253, 89, 152, 106, 70, 186, 37, 66, 162, 250, + 7, 85, 238, 10, 73, 104, 56, 164, 40, 123, 201, 193, 227, 244, 199, 158 }; #define SBOX1(n) FSb[(n)] @@ -292,7 +292,8 @@ static const signed char transposes[2][20] = } \ } -static void camellia_feistel(const uint32_t x[2], const uint32_t k[2], uint32_t z[2]) +static void camellia_feistel( const uint32_t x[2], const uint32_t k[2], + uint32_t z[2]) { uint32_t I0, I1; I0 = x[0] ^ k[0]; @@ -319,7 +320,8 @@ static void camellia_feistel(const uint32_t x[2], const uint32_t k[2], uint32_t /* * Camellia key schedule (encryption) */ -int camellia_setkey_enc( camellia_context *ctx, const unsigned char *key, unsigned int keysize ) +int camellia_setkey_enc( camellia_context *ctx, const unsigned char *key, + unsigned int keysize ) { int idx; size_t i; @@ -423,7 +425,8 @@ int camellia_setkey_enc( camellia_context *ctx, const unsigned char *key, unsign /* * Camellia key schedule (decryption) */ -int camellia_setkey_dec( camellia_context *ctx, const unsigned char *key, unsigned int keysize ) +int camellia_setkey_dec( camellia_context *ctx, const unsigned char *key, + unsigned int keysize ) { int idx; size_t i; @@ -653,7 +656,8 @@ int camellia_crypt_ctr( camellia_context *ctx, while( length-- ) { if( n == 0 ) { - camellia_crypt_ecb( ctx, CAMELLIA_ENCRYPT, nonce_counter, stream_block ); + camellia_crypt_ecb( ctx, CAMELLIA_ENCRYPT, nonce_counter, + stream_block ); for( i = 16; i > 0; i-- ) if( ++nonce_counter[i - 1] != 0 ) @@ -1011,7 +1015,8 @@ int camellia_self_test( int verbose ) len = camellia_test_ctr_len[u]; memcpy( buf, camellia_test_ctr_ct[u], len ); - camellia_crypt_ctr( &ctx, len, &offset, nonce_counter, stream_block, buf, buf ); + camellia_crypt_ctr( &ctx, len, &offset, nonce_counter, stream_block, + buf, buf ); if( memcmp( buf, camellia_test_ctr_pt[u], len ) != 0 ) { @@ -1026,7 +1031,8 @@ int camellia_self_test( int verbose ) len = camellia_test_ctr_len[u]; memcpy( buf, camellia_test_ctr_pt[u], len ); - camellia_crypt_ctr( &ctx, len, &offset, nonce_counter, stream_block, buf, buf ); + camellia_crypt_ctr( &ctx, len, &offset, nonce_counter, stream_block, + buf, buf ); if( memcmp( buf, camellia_test_ctr_ct[u], len ) != 0 ) { diff --git a/library/cipher.c b/library/cipher.c index d3687d77a..069330180 100644 --- a/library/cipher.c +++ b/library/cipher.c @@ -240,8 +240,8 @@ int cipher_update_ad( cipher_context_t *ctx, } #endif /* POLARSSL_CIPHER_MODE_AEAD */ -int cipher_update( cipher_context_t *ctx, const unsigned char *input, size_t ilen, - unsigned char *output, size_t *olen ) +int cipher_update( cipher_context_t *ctx, const unsigned char *input, + size_t ilen, unsigned char *output, size_t *olen ) { int ret; diff --git a/library/cipher_wrap.c b/library/cipher_wrap.c index be4437109..a8bf4abef 100644 --- a/library/cipher_wrap.c +++ b/library/cipher_wrap.c @@ -96,7 +96,8 @@ static int aes_crypt_cbc_wrap( void *ctx, operation_t operation, size_t length, unsigned char *iv, const unsigned char *input, unsigned char *output ) { #if defined(POLARSSL_CIPHER_MODE_CBC) - return aes_crypt_cbc( (aes_context *) ctx, operation, length, iv, input, output ); + return aes_crypt_cbc( (aes_context *) ctx, operation, length, iv, input, + output ); #else ((void) ctx); ((void) operation); @@ -109,11 +110,13 @@ static int aes_crypt_cbc_wrap( void *ctx, operation_t operation, size_t length, #endif /* POLARSSL_CIPHER_MODE_CBC */ } -static int aes_crypt_cfb128_wrap( void *ctx, operation_t operation, size_t length, - size_t *iv_off, unsigned char *iv, const unsigned char *input, unsigned char *output ) +static int aes_crypt_cfb128_wrap( void *ctx, operation_t operation, + size_t length, size_t *iv_off, unsigned char *iv, + const unsigned char *input, unsigned char *output ) { #if defined(POLARSSL_CIPHER_MODE_CFB) - return aes_crypt_cfb128( (aes_context *) ctx, operation, length, iv_off, iv, input, output ); + return aes_crypt_cfb128( (aes_context *) ctx, operation, length, iv_off, iv, + input, output ); #else ((void) ctx); ((void) operation); @@ -127,8 +130,8 @@ static int aes_crypt_cfb128_wrap( void *ctx, operation_t operation, size_t lengt #endif /* POLARSSL_CIPHER_MODE_CFB */ } -static int aes_crypt_ctr_wrap( void *ctx, size_t length, - size_t *nc_off, unsigned char *nonce_counter, unsigned char *stream_block, +static int aes_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off, + unsigned char *nonce_counter, unsigned char *stream_block, const unsigned char *input, unsigned char *output ) { #if defined(POLARSSL_CIPHER_MODE_CTR) @@ -147,12 +150,14 @@ static int aes_crypt_ctr_wrap( void *ctx, size_t length, #endif /* POLARSSL_CIPHER_MODE_CTR */ } -static int aes_setkey_dec_wrap( void *ctx, const unsigned char *key, unsigned int key_length ) +static int aes_setkey_dec_wrap( void *ctx, const unsigned char *key, + unsigned int key_length ) { return aes_setkey_dec( (aes_context *) ctx, key, key_length ); } -static int aes_setkey_enc_wrap( void *ctx, const unsigned char *key, unsigned int key_length ) +static int aes_setkey_enc_wrap( void *ctx, const unsigned char *key, + unsigned int key_length ) { return aes_setkey_enc( (aes_context *) ctx, key, key_length ); } @@ -319,7 +324,8 @@ const cipher_info_t aes_256_ctr_info = { #endif /* POLARSSL_CIPHER_MODE_CTR */ #if defined(POLARSSL_GCM_C) -static int gcm_aes_setkey_wrap( void *ctx, const unsigned char *key, unsigned int key_length ) +static int gcm_aes_setkey_wrap( void *ctx, const unsigned char *key, + unsigned int key_length ) { return gcm_init( (gcm_context *) ctx, POLARSSL_CIPHER_ID_AES, key, key_length ); @@ -379,14 +385,17 @@ const cipher_info_t aes_256_gcm_info = { static int camellia_crypt_ecb_wrap( void *ctx, operation_t operation, const unsigned char *input, unsigned char *output ) { - return camellia_crypt_ecb( (camellia_context *) ctx, operation, input, output ); + return camellia_crypt_ecb( (camellia_context *) ctx, operation, input, + output ); } -static int camellia_crypt_cbc_wrap( void *ctx, operation_t operation, size_t length, - unsigned char *iv, const unsigned char *input, unsigned char *output ) +static int camellia_crypt_cbc_wrap( void *ctx, operation_t operation, + size_t length, unsigned char *iv, + const unsigned char *input, unsigned char *output ) { #if defined(POLARSSL_CIPHER_MODE_CBC) - return camellia_crypt_cbc( (camellia_context *) ctx, operation, length, iv, input, output ); + return camellia_crypt_cbc( (camellia_context *) ctx, operation, length, iv, + input, output ); #else ((void) ctx); ((void) operation); @@ -399,11 +408,13 @@ static int camellia_crypt_cbc_wrap( void *ctx, operation_t operation, size_t len #endif /* POLARSSL_CIPHER_MODE_CBC */ } -static int camellia_crypt_cfb128_wrap( void *ctx, operation_t operation, size_t length, - size_t *iv_off, unsigned char *iv, const unsigned char *input, unsigned char *output ) +static int camellia_crypt_cfb128_wrap( void *ctx, operation_t operation, + size_t length, size_t *iv_off, unsigned char *iv, + const unsigned char *input, unsigned char *output ) { #if defined(POLARSSL_CIPHER_MODE_CFB) - return camellia_crypt_cfb128( (camellia_context *) ctx, operation, length, iv_off, iv, input, output ); + return camellia_crypt_cfb128( (camellia_context *) ctx, operation, length, + iv_off, iv, input, output ); #else ((void) ctx); ((void) operation); @@ -417,13 +428,13 @@ static int camellia_crypt_cfb128_wrap( void *ctx, operation_t operation, size_t #endif /* POLARSSL_CIPHER_MODE_CFB */ } -static int camellia_crypt_ctr_wrap( void *ctx, size_t length, - size_t *nc_off, unsigned char *nonce_counter, unsigned char *stream_block, +static int camellia_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off, + unsigned char *nonce_counter, unsigned char *stream_block, const unsigned char *input, unsigned char *output ) { #if defined(POLARSSL_CIPHER_MODE_CTR) - return camellia_crypt_ctr( (camellia_context *) ctx, length, nc_off, nonce_counter, - stream_block, input, output ); + return camellia_crypt_ctr( (camellia_context *) ctx, length, nc_off, + nonce_counter, stream_block, input, output ); #else ((void) ctx); ((void) length); @@ -437,12 +448,14 @@ static int camellia_crypt_ctr_wrap( void *ctx, size_t length, #endif /* POLARSSL_CIPHER_MODE_CTR */ } -static int camellia_setkey_dec_wrap( void *ctx, const unsigned char *key, unsigned int key_length ) +static int camellia_setkey_dec_wrap( void *ctx, const unsigned char *key, + unsigned int key_length ) { return camellia_setkey_dec( (camellia_context *) ctx, key, key_length ); } -static int camellia_setkey_enc_wrap( void *ctx, const unsigned char *key, unsigned int key_length ) +static int camellia_setkey_enc_wrap( void *ctx, const unsigned char *key, + unsigned int key_length ) { return camellia_setkey_enc( (camellia_context *) ctx, key, key_length ); } @@ -609,7 +622,8 @@ const cipher_info_t camellia_256_ctr_info = { #endif /* POLARSSL_CIPHER_MODE_CTR */ #if defined(POLARSSL_GCM_C) -static int gcm_camellia_setkey_wrap( void *ctx, const unsigned char *key, unsigned int key_length ) +static int gcm_camellia_setkey_wrap( void *ctx, const unsigned char *key, + unsigned int key_length ) { return gcm_init( (gcm_context *) ctx, POLARSSL_CIPHER_ID_CAMELLIA, key, key_length ); @@ -684,7 +698,8 @@ static int des_crypt_cbc_wrap( void *ctx, operation_t operation, size_t length, unsigned char *iv, const unsigned char *input, unsigned char *output ) { #if defined(POLARSSL_CIPHER_MODE_CBC) - return des_crypt_cbc( (des_context *) ctx, operation, length, iv, input, output ); + return des_crypt_cbc( (des_context *) ctx, operation, length, iv, input, + output ); #else ((void) ctx); ((void) operation); @@ -701,7 +716,8 @@ static int des3_crypt_cbc_wrap( void *ctx, operation_t operation, size_t length, unsigned char *iv, const unsigned char *input, unsigned char *output ) { #if defined(POLARSSL_CIPHER_MODE_CBC) - return des3_crypt_cbc( (des3_context *) ctx, operation, length, iv, input, output ); + return des3_crypt_cbc( (des3_context *) ctx, operation, length, iv, input, + output ); #else ((void) ctx); ((void) operation); @@ -714,8 +730,9 @@ static int des3_crypt_cbc_wrap( void *ctx, operation_t operation, size_t length, #endif /* POLARSSL_CIPHER_MODE_CBC */ } -static int des_crypt_cfb128_wrap( void *ctx, operation_t operation, size_t length, - size_t *iv_off, unsigned char *iv, const unsigned char *input, unsigned char *output ) +static int des_crypt_cfb128_wrap( void *ctx, operation_t operation, + size_t length, size_t *iv_off, unsigned char *iv, + const unsigned char *input, unsigned char *output ) { ((void) ctx); ((void) operation); @@ -728,8 +745,8 @@ static int des_crypt_cfb128_wrap( void *ctx, operation_t operation, size_t lengt return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE; } -static int des_crypt_ctr_wrap( void *ctx, size_t length, - size_t *nc_off, unsigned char *nonce_counter, unsigned char *stream_block, +static int des_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off, + unsigned char *nonce_counter, unsigned char *stream_block, const unsigned char *input, unsigned char *output ) { ((void) ctx); @@ -743,42 +760,48 @@ static int des_crypt_ctr_wrap( void *ctx, size_t length, return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE; } -static int des_setkey_dec_wrap( void *ctx, const unsigned char *key, unsigned int key_length ) +static int des_setkey_dec_wrap( void *ctx, const unsigned char *key, + unsigned int key_length ) { ((void) key_length); return des_setkey_dec( (des_context *) ctx, key ); } -static int des_setkey_enc_wrap( void *ctx, const unsigned char *key, unsigned int key_length ) +static int des_setkey_enc_wrap( void *ctx, const unsigned char *key, + unsigned int key_length ) { ((void) key_length); return des_setkey_enc( (des_context *) ctx, key ); } -static int des3_set2key_dec_wrap( void *ctx, const unsigned char *key, unsigned int key_length ) +static int des3_set2key_dec_wrap( void *ctx, const unsigned char *key, + unsigned int key_length ) { ((void) key_length); return des3_set2key_dec( (des3_context *) ctx, key ); } -static int des3_set2key_enc_wrap( void *ctx, const unsigned char *key, unsigned int key_length ) +static int des3_set2key_enc_wrap( void *ctx, const unsigned char *key, + unsigned int key_length ) { ((void) key_length); return des3_set2key_enc( (des3_context *) ctx, key ); } -static int des3_set3key_dec_wrap( void *ctx, const unsigned char *key, unsigned int key_length ) +static int des3_set3key_dec_wrap( void *ctx, const unsigned char *key, + unsigned int key_length ) { ((void) key_length); return des3_set3key_dec( (des3_context *) ctx, key ); } -static int des3_set3key_enc_wrap( void *ctx, const unsigned char *key, unsigned int key_length ) +static int des3_set3key_enc_wrap( void *ctx, const unsigned char *key, + unsigned int key_length ) { ((void) key_length); @@ -916,14 +939,17 @@ const cipher_info_t des_ede3_cbc_info = { static int blowfish_crypt_ecb_wrap( void *ctx, operation_t operation, const unsigned char *input, unsigned char *output ) { - return blowfish_crypt_ecb( (blowfish_context *) ctx, operation, input, output ); + return blowfish_crypt_ecb( (blowfish_context *) ctx, operation, input, + output ); } -static int blowfish_crypt_cbc_wrap( void *ctx, operation_t operation, size_t length, - unsigned char *iv, const unsigned char *input, unsigned char *output ) +static int blowfish_crypt_cbc_wrap( void *ctx, operation_t operation, + size_t length, unsigned char *iv, const unsigned char *input, + unsigned char *output ) { #if defined(POLARSSL_CIPHER_MODE_CBC) - return blowfish_crypt_cbc( (blowfish_context *) ctx, operation, length, iv, input, output ); + return blowfish_crypt_cbc( (blowfish_context *) ctx, operation, length, iv, + input, output ); #else ((void) ctx); ((void) operation); @@ -936,11 +962,13 @@ static int blowfish_crypt_cbc_wrap( void *ctx, operation_t operation, size_t len #endif /* POLARSSL_CIPHER_MODE_CBC */ } -static int blowfish_crypt_cfb64_wrap( void *ctx, operation_t operation, size_t length, - size_t *iv_off, unsigned char *iv, const unsigned char *input, unsigned char *output ) +static int blowfish_crypt_cfb64_wrap( void *ctx, operation_t operation, + size_t length, size_t *iv_off, unsigned char *iv, + const unsigned char *input, unsigned char *output ) { #if defined(POLARSSL_CIPHER_MODE_CFB) - return blowfish_crypt_cfb64( (blowfish_context *) ctx, operation, length, iv_off, iv, input, output ); + return blowfish_crypt_cfb64( (blowfish_context *) ctx, operation, length, + iv_off, iv, input, output ); #else ((void) ctx); ((void) operation); @@ -954,13 +982,13 @@ static int blowfish_crypt_cfb64_wrap( void *ctx, operation_t operation, size_t l #endif /* POLARSSL_CIPHER_MODE_CFB */ } -static int blowfish_crypt_ctr_wrap( void *ctx, size_t length, - size_t *nc_off, unsigned char *nonce_counter, unsigned char *stream_block, +static int blowfish_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off, + unsigned char *nonce_counter, unsigned char *stream_block, const unsigned char *input, unsigned char *output ) { #if defined(POLARSSL_CIPHER_MODE_CTR) - return blowfish_crypt_ctr( (blowfish_context *) ctx, length, nc_off, nonce_counter, - stream_block, input, output ); + return blowfish_crypt_ctr( (blowfish_context *) ctx, length, nc_off, + nonce_counter, stream_block, input, output ); #else ((void) ctx); ((void) length); @@ -974,7 +1002,8 @@ static int blowfish_crypt_ctr_wrap( void *ctx, size_t length, #endif /* POLARSSL_CIPHER_MODE_CTR */ } -static int blowfish_setkey_wrap( void *ctx, const unsigned char *key, unsigned int key_length ) +static int blowfish_setkey_wrap( void *ctx, const unsigned char *key, + unsigned int key_length ) { return blowfish_setkey( (blowfish_context *) ctx, key, key_length ); } diff --git a/library/ctr_drbg.c b/library/ctr_drbg.c index 6203fce02..2b507d268 100644 --- a/library/ctr_drbg.c +++ b/library/ctr_drbg.c @@ -336,7 +336,8 @@ int ctr_drbg_random_with_add( void *p_rng, */ aes_crypt_ecb( &ctx->aes_ctx, AES_ENCRYPT, ctx->counter, tmp ); - use_len = (output_len > CTR_DRBG_BLOCKSIZE ) ? CTR_DRBG_BLOCKSIZE : output_len; + use_len = (output_len > CTR_DRBG_BLOCKSIZE ) ? CTR_DRBG_BLOCKSIZE : + output_len; /* * Copy random block to destination */ diff --git a/library/des.c b/library/des.c index 6d207584d..79c81bc2f 100644 --- a/library/des.c +++ b/library/des.c @@ -513,7 +513,8 @@ static void des3_set2key( uint32_t esk[96], /* * Triple-DES key schedule (112-bit, encryption) */ -int des3_set2key_enc( des3_context *ctx, const unsigned char key[DES_KEY_SIZE * 2] ) +int des3_set2key_enc( des3_context *ctx, + const unsigned char key[DES_KEY_SIZE * 2] ) { uint32_t sk[96]; @@ -526,7 +527,8 @@ int des3_set2key_enc( des3_context *ctx, const unsigned char key[DES_KEY_SIZE * /* * Triple-DES key schedule (112-bit, decryption) */ -int des3_set2key_dec( des3_context *ctx, const unsigned char key[DES_KEY_SIZE * 2] ) +int des3_set2key_dec( des3_context *ctx, + const unsigned char key[DES_KEY_SIZE * 2] ) { uint32_t sk[96]; @@ -562,7 +564,8 @@ static void des3_set3key( uint32_t esk[96], /* * Triple-DES key schedule (168-bit, encryption) */ -int des3_set3key_enc( des3_context *ctx, const unsigned char key[DES_KEY_SIZE * 3] ) +int des3_set3key_enc( des3_context *ctx, + const unsigned char key[DES_KEY_SIZE * 3] ) { uint32_t sk[96]; @@ -575,7 +578,8 @@ int des3_set3key_enc( des3_context *ctx, const unsigned char key[DES_KEY_SIZE * /* * Triple-DES key schedule (168-bit, decryption) */ -int des3_set3key_dec( des3_context *ctx, const unsigned char key[DES_KEY_SIZE * 3] ) +int des3_set3key_dec( des3_context *ctx, + const unsigned char key[DES_KEY_SIZE * 3] ) { uint32_t sk[96]; diff --git a/library/dhm.c b/library/dhm.c index f86945631..41c573d29 100644 --- a/library/dhm.c +++ b/library/dhm.c @@ -402,7 +402,8 @@ void dhm_free( dhm_context *ctx ) /* * Parse DHM parameters */ -int dhm_parse_dhm( dhm_context *dhm, const unsigned char *dhmin, size_t dhminlen ) +int dhm_parse_dhm( dhm_context *dhm, const unsigned char *dhmin, + size_t dhminlen ) { int ret; size_t len; diff --git a/library/gcm.c b/library/gcm.c index d5761d279..a89207615 100644 --- a/library/gcm.c +++ b/library/gcm.c @@ -808,7 +808,8 @@ int gcm_self_test( int verbose ) return( 1 ); } - ret = gcm_update( &ctx, rest_len, pt[pt_index[i]] + 32, buf + 32 ); + ret = gcm_update( &ctx, rest_len, pt[pt_index[i]] + 32, + buf + 32 ); if( ret != 0 ) { if( verbose != 0 ) @@ -874,7 +875,8 @@ int gcm_self_test( int verbose ) return( 1 ); } - ret = gcm_update( &ctx, rest_len, ct[j * 6 + i] + 32, buf + 32 ); + ret = gcm_update( &ctx, rest_len, ct[j * 6 + i] + 32, + buf + 32 ); if( ret != 0 ) { if( verbose != 0 ) diff --git a/library/md2.c b/library/md2.c index af6b595c9..71f8d0b42 100644 --- a/library/md2.c +++ b/library/md2.c @@ -228,7 +228,8 @@ int md2_file( const char *path, unsigned char output[16] ) /* * MD2 HMAC context setup */ -void md2_hmac_starts( md2_context *ctx, const unsigned char *key, size_t keylen ) +void md2_hmac_starts( md2_context *ctx, const unsigned char *key, + size_t keylen ) { size_t i; unsigned char sum[16]; @@ -258,7 +259,8 @@ void md2_hmac_starts( md2_context *ctx, const unsigned char *key, size_t keylen /* * MD2 HMAC process buffer */ -void md2_hmac_update( md2_context *ctx, const unsigned char *input, size_t ilen ) +void md2_hmac_update( md2_context *ctx, const unsigned char *input, + size_t ilen ) { md2_update( ctx, input, ilen ); } diff --git a/library/md4.c b/library/md4.c index 5d3315f1f..37056d966 100644 --- a/library/md4.c +++ b/library/md4.c @@ -324,7 +324,8 @@ int md4_file( const char *path, unsigned char output[16] ) /* * MD4 HMAC context setup */ -void md4_hmac_starts( md4_context *ctx, const unsigned char *key, size_t keylen ) +void md4_hmac_starts( md4_context *ctx, const unsigned char *key, + size_t keylen ) { size_t i; unsigned char sum[16]; @@ -354,7 +355,8 @@ void md4_hmac_starts( md4_context *ctx, const unsigned char *key, size_t keylen /* * MD4 HMAC process buffer */ -void md4_hmac_update( md4_context *ctx, const unsigned char *input, size_t ilen ) +void md4_hmac_update( md4_context *ctx, const unsigned char *input, + size_t ilen ) { md4_update( ctx, input, ilen ); } diff --git a/library/md5.c b/library/md5.c index cc6567f54..88d50c6c9 100644 --- a/library/md5.c +++ b/library/md5.c @@ -341,7 +341,8 @@ int md5_file( const char *path, unsigned char output[16] ) /* * MD5 HMAC context setup */ -void md5_hmac_starts( md5_context *ctx, const unsigned char *key, size_t keylen ) +void md5_hmac_starts( md5_context *ctx, const unsigned char *key, + size_t keylen ) { size_t i; unsigned char sum[16]; @@ -371,7 +372,8 @@ void md5_hmac_starts( md5_context *ctx, const unsigned char *key, size_t keylen /* * MD5 HMAC process buffer */ -void md5_hmac_update( md5_context *ctx, const unsigned char *input, size_t ilen ) +void md5_hmac_update( md5_context *ctx, const unsigned char *input, + size_t ilen ) { md5_update( ctx, input, ilen ); } diff --git a/library/md_wrap.c b/library/md_wrap.c index b67b7096f..9627878aa 100644 --- a/library/md_wrap.c +++ b/library/md_wrap.c @@ -81,7 +81,8 @@ static void md2_starts_wrap( void *ctx ) md2_starts( (md2_context *) ctx ); } -static void md2_update_wrap( void *ctx, const unsigned char *input, size_t ilen ) +static void md2_update_wrap( void *ctx, const unsigned char *input, + size_t ilen ) { md2_update( (md2_context *) ctx, input, ilen ); } @@ -102,12 +103,14 @@ static int md2_file_wrap( const char *path, unsigned char *output ) #endif } -static void md2_hmac_starts_wrap( void *ctx, const unsigned char *key, size_t keylen ) +static void md2_hmac_starts_wrap( void *ctx, const unsigned char *key, + size_t keylen ) { md2_hmac_starts( (md2_context *) ctx, key, keylen ); } -static void md2_hmac_update_wrap( void *ctx, const unsigned char *input, size_t ilen ) +static void md2_hmac_update_wrap( void *ctx, const unsigned char *input, + size_t ilen ) { md2_hmac_update( (md2_context *) ctx, input, ilen ); } @@ -167,7 +170,8 @@ static void md4_starts_wrap( void *ctx ) md4_starts( (md4_context *) ctx ); } -static void md4_update_wrap( void *ctx, const unsigned char *input, size_t ilen ) +static void md4_update_wrap( void *ctx, const unsigned char *input, + size_t ilen ) { md4_update( (md4_context *) ctx, input, ilen ); } @@ -188,12 +192,14 @@ static int md4_file_wrap( const char *path, unsigned char *output ) #endif } -static void md4_hmac_starts_wrap( void *ctx, const unsigned char *key, size_t keylen ) +static void md4_hmac_starts_wrap( void *ctx, const unsigned char *key, + size_t keylen ) { md4_hmac_starts( (md4_context *) ctx, key, keylen ); } -static void md4_hmac_update_wrap( void *ctx, const unsigned char *input, size_t ilen ) +static void md4_hmac_update_wrap( void *ctx, const unsigned char *input, + size_t ilen ) { md4_hmac_update( (md4_context *) ctx, input, ilen ); } @@ -251,7 +257,8 @@ static void md5_starts_wrap( void *ctx ) md5_starts( (md5_context *) ctx ); } -static void md5_update_wrap( void *ctx, const unsigned char *input, size_t ilen ) +static void md5_update_wrap( void *ctx, const unsigned char *input, + size_t ilen ) { md5_update( (md5_context *) ctx, input, ilen ); } @@ -272,12 +279,14 @@ static int md5_file_wrap( const char *path, unsigned char *output ) #endif } -static void md5_hmac_starts_wrap( void *ctx, const unsigned char *key, size_t keylen ) +static void md5_hmac_starts_wrap( void *ctx, const unsigned char *key, + size_t keylen ) { md5_hmac_starts( (md5_context *) ctx, key, keylen ); } -static void md5_hmac_update_wrap( void *ctx, const unsigned char *input, size_t ilen ) +static void md5_hmac_update_wrap( void *ctx, const unsigned char *input, + size_t ilen ) { md5_hmac_update( (md5_context *) ctx, input, ilen ); } @@ -335,7 +344,8 @@ static void ripemd160_starts_wrap( void *ctx ) ripemd160_starts( (ripemd160_context *) ctx ); } -static void ripemd160_update_wrap( void *ctx, const unsigned char *input, size_t ilen ) +static void ripemd160_update_wrap( void *ctx, const unsigned char *input, + size_t ilen ) { ripemd160_update( (ripemd160_context *) ctx, input, ilen ); } @@ -356,12 +366,14 @@ static int ripemd160_file_wrap( const char *path, unsigned char *output ) #endif } -static void ripemd160_hmac_starts_wrap( void *ctx, const unsigned char *key, size_t keylen ) +static void ripemd160_hmac_starts_wrap( void *ctx, const unsigned char *key, + size_t keylen ) { ripemd160_hmac_starts( (ripemd160_context *) ctx, key, keylen ); } -static void ripemd160_hmac_update_wrap( void *ctx, const unsigned char *input, size_t ilen ) +static void ripemd160_hmac_update_wrap( void *ctx, const unsigned char *input, + size_t ilen ) { ripemd160_hmac_update( (ripemd160_context *) ctx, input, ilen ); } @@ -419,7 +431,8 @@ static void sha1_starts_wrap( void *ctx ) sha1_starts( (sha1_context *) ctx ); } -static void sha1_update_wrap( void *ctx, const unsigned char *input, size_t ilen ) +static void sha1_update_wrap( void *ctx, const unsigned char *input, + size_t ilen ) { sha1_update( (sha1_context *) ctx, input, ilen ); } @@ -440,12 +453,14 @@ static int sha1_file_wrap( const char *path, unsigned char *output ) #endif } -static void sha1_hmac_starts_wrap( void *ctx, const unsigned char *key, size_t keylen ) +static void sha1_hmac_starts_wrap( void *ctx, const unsigned char *key, + size_t keylen ) { sha1_hmac_starts( (sha1_context *) ctx, key, keylen ); } -static void sha1_hmac_update_wrap( void *ctx, const unsigned char *input, size_t ilen ) +static void sha1_hmac_update_wrap( void *ctx, const unsigned char *input, + size_t ilen ) { sha1_hmac_update( (sha1_context *) ctx, input, ilen ); } @@ -506,7 +521,8 @@ static void sha224_starts_wrap( void *ctx ) sha256_starts( (sha256_context *) ctx, 1 ); } -static void sha224_update_wrap( void *ctx, const unsigned char *input, size_t ilen ) +static void sha224_update_wrap( void *ctx, const unsigned char *input, + size_t ilen ) { sha256_update( (sha256_context *) ctx, input, ilen ); } @@ -533,12 +549,14 @@ static int sha224_file_wrap( const char *path, unsigned char *output ) #endif } -static void sha224_hmac_starts_wrap( void *ctx, const unsigned char *key, size_t keylen ) +static void sha224_hmac_starts_wrap( void *ctx, const unsigned char *key, + size_t keylen ) { sha256_hmac_starts( (sha256_context *) ctx, key, keylen, 1 ); } -static void sha224_hmac_update_wrap( void *ctx, const unsigned char *input, size_t ilen ) +static void sha224_hmac_update_wrap( void *ctx, const unsigned char *input, + size_t ilen ) { sha256_hmac_update( (sha256_context *) ctx, input, ilen ); } @@ -599,7 +617,8 @@ static void sha256_starts_wrap( void *ctx ) sha256_starts( (sha256_context *) ctx, 0 ); } -static void sha256_update_wrap( void *ctx, const unsigned char *input, size_t ilen ) +static void sha256_update_wrap( void *ctx, const unsigned char *input, + size_t ilen ) { sha256_update( (sha256_context *) ctx, input, ilen ); } @@ -626,12 +645,14 @@ static int sha256_file_wrap( const char *path, unsigned char *output ) #endif } -static void sha256_hmac_starts_wrap( void *ctx, const unsigned char *key, size_t keylen ) +static void sha256_hmac_starts_wrap( void *ctx, const unsigned char *key, + size_t keylen ) { sha256_hmac_starts( (sha256_context *) ctx, key, keylen, 0 ); } -static void sha256_hmac_update_wrap( void *ctx, const unsigned char *input, size_t ilen ) +static void sha256_hmac_update_wrap( void *ctx, const unsigned char *input, + size_t ilen ) { sha256_hmac_update( (sha256_context *) ctx, input, ilen ); } @@ -696,7 +717,8 @@ static void sha384_starts_wrap( void *ctx ) sha512_starts( (sha512_context *) ctx, 1 ); } -static void sha384_update_wrap( void *ctx, const unsigned char *input, size_t ilen ) +static void sha384_update_wrap( void *ctx, const unsigned char *input, + size_t ilen ) { sha512_update( (sha512_context *) ctx, input, ilen ); } @@ -723,12 +745,14 @@ static int sha384_file_wrap( const char *path, unsigned char *output ) #endif } -static void sha384_hmac_starts_wrap( void *ctx, const unsigned char *key, size_t keylen ) +static void sha384_hmac_starts_wrap( void *ctx, const unsigned char *key, + size_t keylen ) { sha512_hmac_starts( (sha512_context *) ctx, key, keylen, 1 ); } -static void sha384_hmac_update_wrap( void *ctx, const unsigned char *input, size_t ilen ) +static void sha384_hmac_update_wrap( void *ctx, const unsigned char *input, + size_t ilen ) { sha512_hmac_update( (sha512_context *) ctx, input, ilen ); } @@ -789,7 +813,8 @@ static void sha512_starts_wrap( void *ctx ) sha512_starts( (sha512_context *) ctx, 0 ); } -static void sha512_update_wrap( void *ctx, const unsigned char *input, size_t ilen ) +static void sha512_update_wrap( void *ctx, const unsigned char *input, + size_t ilen ) { sha512_update( (sha512_context *) ctx, input, ilen ); } @@ -816,12 +841,14 @@ static int sha512_file_wrap( const char *path, unsigned char *output ) #endif } -static void sha512_hmac_starts_wrap( void *ctx, const unsigned char *key, size_t keylen ) +static void sha512_hmac_starts_wrap( void *ctx, const unsigned char *key, + size_t keylen ) { sha512_hmac_starts( (sha512_context *) ctx, key, keylen, 0 ); } -static void sha512_hmac_update_wrap( void *ctx, const unsigned char *input, size_t ilen ) +static void sha512_hmac_update_wrap( void *ctx, const unsigned char *input, + size_t ilen ) { sha512_hmac_update( (sha512_context *) ctx, input, ilen ); } diff --git a/library/memory_buffer_alloc.c b/library/memory_buffer_alloc.c index 5409a935a..caeaa4643 100644 --- a/library/memory_buffer_alloc.c +++ b/library/memory_buffer_alloc.c @@ -281,7 +281,8 @@ static void *buffer_alloc_malloc( size_t len ) // Found location, split block if > memory_header + 4 room left // - if( cur->size - len < sizeof(memory_header) + POLARSSL_MEMORY_ALIGN_MULTIPLE ) + if( cur->size - len < sizeof(memory_header) + + POLARSSL_MEMORY_ALIGN_MULTIPLE ) { cur->alloc = 1; diff --git a/library/net.c b/library/net.c index 4a4cf5f05..be30fbd30 100644 --- a/library/net.c +++ b/library/net.c @@ -114,10 +114,11 @@ typedef UINT32 uint32_t; /* * htons() is not always available. - * By default go for LITTLE_ENDIAN variant. Otherwise hope for _BYTE_ORDER and __BIG_ENDIAN - * to help determine endianness. + * By default go for LITTLE_ENDIAN variant. Otherwise hope for _BYTE_ORDER and + * __BIG_ENDIAN to help determine endianness. */ -#if defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && __BYTE_ORDER == __BIG_ENDIAN +#if defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && \ + __BYTE_ORDER == __BIG_ENDIAN #define POLARSSL_HTONS(n) (n) #define POLARSSL_HTONL(n) (n) #else diff --git a/library/pem.c b/library/pem.c index 2f639d04f..2775ef90f 100644 --- a/library/pem.c +++ b/library/pem.c @@ -57,7 +57,8 @@ void pem_init( pem_context *ctx ) /* * Read a 16-byte hex string and convert it to binary */ -static int pem_get_iv( const unsigned char *s, unsigned char *iv, size_t iv_len ) +static int pem_get_iv( const unsigned char *s, unsigned char *iv, + size_t iv_len ) { size_t i, j, k; diff --git a/library/pkcs11.c b/library/pkcs11.c index 3dacaf578..c61287a0c 100644 --- a/library/pkcs11.c +++ b/library/pkcs11.c @@ -54,7 +54,8 @@ int pkcs11_x509_cert_init( x509_crt *cert, pkcs11h_certificate_t pkcs11_cert ) goto cleanup; } - if( pkcs11h_certificate_getCertificateBlob( pkcs11_cert, NULL, &cert_blob_size ) != CKR_OK ) + if( pkcs11h_certificate_getCertificateBlob( pkcs11_cert, NULL, + &cert_blob_size ) != CKR_OK ) { ret = 3; goto cleanup; @@ -67,7 +68,8 @@ int pkcs11_x509_cert_init( x509_crt *cert, pkcs11h_certificate_t pkcs11_cert ) goto cleanup; } - if( pkcs11h_certificate_getCertificateBlob( pkcs11_cert, cert_blob, &cert_blob_size ) != CKR_OK ) + if( pkcs11h_certificate_getCertificateBlob( pkcs11_cert, cert_blob, + &cert_blob_size ) != CKR_OK ) { ret = 5; goto cleanup; diff --git a/library/pkcs12.c b/library/pkcs12.c index 637c0578e..2b130a2b2 100644 --- a/library/pkcs12.c +++ b/library/pkcs12.c @@ -1,7 +1,7 @@ /* * PKCS#12 Personal Information Exchange Syntax * - * Copyright (C) 2006-2013, Brainspark B.V. + * Copyright (C) 2006-2014, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker @@ -96,7 +96,8 @@ static int pkcs12_pbe_derive_key_iv( asn1_buf *pbe_params, md_type_t md_type, memset(&salt, 0, sizeof(asn1_buf)); memset(&unipwd, 0, sizeof(unipwd)); - if( ( ret = pkcs12_parse_pbe_params( pbe_params, &salt, &iterations ) ) != 0 ) + if( ( ret = pkcs12_parse_pbe_params( pbe_params, &salt, + &iterations ) ) != 0 ) return( ret ); for(i = 0; i < pwdlen; i++) diff --git a/library/pkcs5.c b/library/pkcs5.c index 2271d9734..e8642a609 100644 --- a/library/pkcs5.c +++ b/library/pkcs5.c @@ -162,8 +162,11 @@ int pkcs5_pbes2( asn1_buf *pbe_params, int mode, if( md_info == NULL ) return( POLARSSL_ERR_PKCS5_FEATURE_UNAVAILABLE ); - if( ( ret = asn1_get_alg( &p, end, &enc_scheme_oid, &enc_scheme_params ) ) != 0 ) + if( ( ret = asn1_get_alg( &p, end, &enc_scheme_oid, + &enc_scheme_params ) ) != 0 ) + { return( POLARSSL_ERR_PKCS5_INVALID_FORMAT + ret ); + } if ( oid_get_cipher_alg( &enc_scheme_oid, &cipher_alg ) != 0 ) return( POLARSSL_ERR_PKCS5_FEATURE_UNAVAILABLE ); diff --git a/library/pkwrite.c b/library/pkwrite.c index 81ac7feaf..3b0bbdb4e 100644 --- a/library/pkwrite.c +++ b/library/pkwrite.c @@ -73,7 +73,8 @@ static int pk_write_rsa_pubkey( unsigned char **p, unsigned char *start, ASN1_CHK_ADD( len, asn1_write_mpi( p, start, &rsa->N ) ); ASN1_CHK_ADD( len, asn1_write_len( p, start, len ) ); - ASN1_CHK_ADD( len, asn1_write_tag( p, start, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ); + ASN1_CHK_ADD( len, asn1_write_tag( p, start, ASN1_CONSTRUCTED | + ASN1_SEQUENCE ) ); return( (int) len ); } @@ -191,7 +192,8 @@ int pk_write_pubkey_der( pk_context *key, unsigned char *buf, size_t size ) par_len ) ); ASN1_CHK_ADD( len, asn1_write_len( &c, buf, len ) ); - ASN1_CHK_ADD( len, asn1_write_tag( &c, buf, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ); + ASN1_CHK_ADD( len, asn1_write_tag( &c, buf, ASN1_CONSTRUCTED | + ASN1_SEQUENCE ) ); return( (int) len ); } @@ -218,7 +220,8 @@ int pk_write_key_der( pk_context *key, unsigned char *buf, size_t size ) ASN1_CHK_ADD( len, asn1_write_int( &c, buf, 0 ) ); ASN1_CHK_ADD( len, asn1_write_len( &c, buf, len ) ); - ASN1_CHK_ADD( len, asn1_write_tag( &c, buf, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ); + ASN1_CHK_ADD( len, asn1_write_tag( &c, buf, ASN1_CONSTRUCTED | + ASN1_SEQUENCE ) ); } else #endif /* POLARSSL_RSA_C */ @@ -271,7 +274,8 @@ int pk_write_key_der( pk_context *key, unsigned char *buf, size_t size ) ASN1_CHK_ADD( len, asn1_write_int( &c, buf, 1 ) ); ASN1_CHK_ADD( len, asn1_write_len( &c, buf, len ) ); - ASN1_CHK_ADD( len, asn1_write_tag( &c, buf, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ); + ASN1_CHK_ADD( len, asn1_write_tag( &c, buf, ASN1_CONSTRUCTED | + ASN1_SEQUENCE ) ); } else #endif /* POLARSSL_ECP_C */ diff --git a/library/sha1.c b/library/sha1.c index ee5cdc38e..4b2d0636d 100644 --- a/library/sha1.c +++ b/library/sha1.c @@ -374,7 +374,8 @@ int sha1_file( const char *path, unsigned char output[20] ) /* * SHA-1 HMAC context setup */ -void sha1_hmac_starts( sha1_context *ctx, const unsigned char *key, size_t keylen ) +void sha1_hmac_starts( sha1_context *ctx, const unsigned char *key, + size_t keylen ) { size_t i; unsigned char sum[20]; @@ -404,7 +405,8 @@ void sha1_hmac_starts( sha1_context *ctx, const unsigned char *key, size_t keyle /* * SHA-1 HMAC process buffer */ -void sha1_hmac_update( sha1_context *ctx, const unsigned char *input, size_t ilen ) +void sha1_hmac_update( sha1_context *ctx, const unsigned char *input, + size_t ilen ) { sha1_update( ctx, input, ilen ); } diff --git a/library/sha256.c b/library/sha256.c index 064ba3b13..9e70ff90c 100644 --- a/library/sha256.c +++ b/library/sha256.c @@ -243,7 +243,8 @@ void sha256_process( sha256_context *ctx, const unsigned char data[64] ) /* * SHA-256 process buffer */ -void sha256_update( sha256_context *ctx, const unsigned char *input, size_t ilen ) +void sha256_update( sha256_context *ctx, const unsigned char *input, + size_t ilen ) { size_t fill; uint32_t left; @@ -407,7 +408,8 @@ void sha256_hmac_starts( sha256_context *ctx, const unsigned char *key, /* * SHA-256 HMAC process buffer */ -void sha256_hmac_update( sha256_context *ctx, const unsigned char *input, size_t ilen ) +void sha256_hmac_update( sha256_context *ctx, const unsigned char *input, + size_t ilen ) { sha256_update( ctx, input, ilen ); } diff --git a/library/sha512.c b/library/sha512.c index a55a94ba8..5537e8de9 100644 --- a/library/sha512.c +++ b/library/sha512.c @@ -236,7 +236,8 @@ void sha512_process( sha512_context *ctx, const unsigned char data[128] ) /* * SHA-512 process buffer */ -void sha512_update( sha512_context *ctx, const unsigned char *input, size_t ilen ) +void sha512_update( sha512_context *ctx, const unsigned char *input, + size_t ilen ) { size_t fill; unsigned int left; diff --git a/library/ssl_cache.c b/library/ssl_cache.c index 69f7114de..9e49b9a5f 100644 --- a/library/ssl_cache.c +++ b/library/ssl_cache.c @@ -105,7 +105,9 @@ int ssl_cache_get( void *data, ssl_session *session ) */ if( entry->peer_cert.p != NULL ) { - session->peer_cert = (x509_crt *) polarssl_malloc( sizeof(x509_crt) ); + session->peer_cert = + (x509_crt *) polarssl_malloc( sizeof(x509_crt) ); + if( session->peer_cert == NULL ) { ret = 1; @@ -224,7 +226,8 @@ int ssl_cache_set( void *data, const ssl_session *session ) /* * max_entries not reached, create new entry */ - cur = (ssl_cache_entry *) polarssl_malloc( sizeof(ssl_cache_entry) ); + cur = (ssl_cache_entry *) + polarssl_malloc( sizeof(ssl_cache_entry) ); if( cur == NULL ) { ret = 1; @@ -261,7 +264,8 @@ int ssl_cache_set( void *data, const ssl_session *session ) */ if( session->peer_cert != NULL ) { - cur->peer_cert.p = (unsigned char *) polarssl_malloc( session->peer_cert->raw.len ); + cur->peer_cert.p = (unsigned char *) + polarssl_malloc( session->peer_cert->raw.len ); if( cur->peer_cert.p == NULL ) { ret = 1; diff --git a/library/ssl_ciphersuites.c b/library/ssl_ciphersuites.c index 6688989d6..e88c5d4c5 100644 --- a/library/ssl_ciphersuites.c +++ b/library/ssl_ciphersuites.c @@ -1575,7 +1575,8 @@ const int *ssl_list_ciphersuites( void ) return supported_ciphersuites; }; -const ssl_ciphersuite_t *ssl_ciphersuite_from_string( const char *ciphersuite_name ) +const ssl_ciphersuite_t *ssl_ciphersuite_from_string( + const char *ciphersuite_name ) { const ssl_ciphersuite_t *cur = ciphersuite_definitions; diff --git a/library/ssl_cli.c b/library/ssl_cli.c index b23743b7f..6f21f622b 100644 --- a/library/ssl_cli.c +++ b/library/ssl_cli.c @@ -918,8 +918,8 @@ static int ssl_parse_server_hello( ssl_context *ssl ) if( ssl->minor_ver < ssl->min_minor_ver ) { SSL_DEBUG_MSG( 1, ( "server only supports ssl smaller than minimum" - " [%d:%d] < [%d:%d]", ssl->major_ver, ssl->minor_ver, - buf[4], buf[5] ) ); + " [%d:%d] < [%d:%d]", ssl->major_ver, + ssl->minor_ver, buf[4], buf[5] ) ); ssl_send_alert_message( ssl, SSL_ALERT_LEVEL_FATAL, SSL_ALERT_MSG_PROTOCOL_VERSION ); @@ -1074,7 +1074,8 @@ static int ssl_parse_server_hello( ssl_context *ssl ) SSL_DEBUG_MSG( 3, ( "found renegotiation extension" ) ); renegotiation_info_seen = 1; - if( ( ret = ssl_parse_renegotiation_info( ssl, ext + 4, ext_size ) ) != 0 ) + if( ( ret = ssl_parse_renegotiation_info( ssl, ext + 4, + ext_size ) ) != 0 ) return( ret ); break; @@ -1751,7 +1752,8 @@ static int ssl_parse_server_key_exchange( ssl_context *ssl ) * ServerDHParams params; * }; */ - if( ( ret = md_init_ctx( &ctx, md_info_from_type( md_alg ) ) ) != 0 ) + if( ( ret = md_init_ctx( &ctx, + md_info_from_type( md_alg ) ) ) != 0 ) { SSL_DEBUG_RET( 1, "md_init_ctx", ret ); return( ret ); diff --git a/library/ssl_srv.c b/library/ssl_srv.c index 13057ab63..be56f21d5 100644 --- a/library/ssl_srv.c +++ b/library/ssl_srv.c @@ -953,7 +953,8 @@ static int ssl_parse_client_hello_v2( ssl_context *ssl ) if( ssl->minor_ver < ssl->min_minor_ver ) { SSL_DEBUG_MSG( 1, ( "client only supports ssl smaller than minimum" - " [%d:%d] < [%d:%d]", ssl->major_ver, ssl->minor_ver, + " [%d:%d] < [%d:%d]", + ssl->major_ver, ssl->minor_ver, ssl->min_major_ver, ssl->min_minor_ver ) ); ssl_send_alert_message( ssl, SSL_ALERT_LEVEL_FATAL, @@ -1028,7 +1029,8 @@ static int ssl_parse_client_hello_v2( ssl_context *ssl ) p = buf + 6 + ciph_len; ssl->session_negotiate->length = sess_len; - memset( ssl->session_negotiate->id, 0, sizeof( ssl->session_negotiate->id ) ); + memset( ssl->session_negotiate->id, 0, + sizeof( ssl->session_negotiate->id ) ); memcpy( ssl->session_negotiate->id, p, ssl->session_negotiate->length ); p += sess_len; @@ -2222,9 +2224,8 @@ static int ssl_write_server_key_exchange( ssl_context *ssl ) } if( ( ret = dhm_make_params( &ssl->handshake->dhm_ctx, - (int) mpi_size( &ssl->handshake->dhm_ctx.P ), - p, - &len, ssl->f_rng, ssl->p_rng ) ) != 0 ) + (int) mpi_size( &ssl->handshake->dhm_ctx.P ), + p, &len, ssl->f_rng, ssl->p_rng ) ) != 0 ) { SSL_DEBUG_RET( 1, "dhm_make_params", ret ); return( ret ); @@ -2758,7 +2759,7 @@ static int ssl_parse_client_key_exchange( ssl_context *ssl ) ciphersuite_info->key_exchange == POLARSSL_KEY_EXCHANGE_ECDH_ECDSA ) { if( ( ret = ecdh_read_public( &ssl->handshake->ecdh_ctx, - ssl->in_msg + 4, ssl->in_hslen - 4 ) ) != 0 ) + ssl->in_msg + 4, ssl->in_hslen - 4 ) ) != 0 ) { SSL_DEBUG_RET( 1, "ecdh_read_public", ret ); return( POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_RP ); diff --git a/library/ssl_tls.c b/library/ssl_tls.c index f3e082b05..480c5e587 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -722,7 +722,8 @@ int ssl_derive_keys( ssl_context *ssl ) memset( &transform->ctx_deflate, 0, sizeof( transform->ctx_deflate ) ); memset( &transform->ctx_inflate, 0, sizeof( transform->ctx_inflate ) ); - if( deflateInit( &transform->ctx_deflate, Z_DEFAULT_COMPRESSION ) != Z_OK || + if( deflateInit( &transform->ctx_deflate, + Z_DEFAULT_COMPRESSION ) != Z_OK || inflateInit( &transform->ctx_inflate ) != Z_OK ) { SSL_DEBUG_MSG( 1, ( "Failed to initialize compression" ) ); @@ -1123,8 +1124,8 @@ static int ssl_encrypt_buf( ssl_context *ssl ) * Generate IV */ ret = ssl->f_rng( ssl->p_rng, - ssl->transform_out->iv_enc + ssl->transform_out->fixed_ivlen, - ssl->transform_out->ivlen - ssl->transform_out->fixed_ivlen ); + ssl->transform_out->iv_enc + ssl->transform_out->fixed_ivlen, + ssl->transform_out->ivlen - ssl->transform_out->fixed_ivlen ); if( ret != 0 ) return( ret ); @@ -1133,7 +1134,7 @@ static int ssl_encrypt_buf( ssl_context *ssl ) ssl->transform_out->ivlen - ssl->transform_out->fixed_ivlen ); SSL_DEBUG_BUF( 4, "IV used", ssl->out_iv, - ssl->transform_out->ivlen - ssl->transform_out->fixed_ivlen ); + ssl->transform_out->ivlen - ssl->transform_out->fixed_ivlen ); /* * Fix pointer positions and message length with added IV @@ -1254,7 +1255,8 @@ static int ssl_encrypt_buf( ssl_context *ssl ) SSL_DEBUG_MSG( 3, ( "before encrypt: msglen = %d, " "including %d bytes of IV and %d bytes of padding", - ssl->out_msglen, ssl->transform_out->ivlen, padlen + 1 ) ); + ssl->out_msglen, ssl->transform_out->ivlen, + padlen + 1 ) ); SSL_DEBUG_BUF( 4, "before encrypt: output payload", ssl->out_iv, ssl->out_msglen ); @@ -1524,8 +1526,10 @@ static int ssl_decrypt_buf( ssl_context *ssl ) if( ssl->in_msglen < minlen + ssl->transform_in->ivlen || ssl->in_msglen < minlen + ssl->transform_in->maclen + 1 ) { - SSL_DEBUG_MSG( 1, ( "msglen (%d) < max( ivlen(%d), maclen (%d) + 1 ) ( + expl IV )", - ssl->in_msglen, ssl->transform_in->ivlen, ssl->transform_in->maclen ) ); + SSL_DEBUG_MSG( 1, ( "msglen (%d) < max( ivlen(%d), maclen (%d) " + "+ 1 ) ( + expl IV )", ssl->in_msglen, + ssl->transform_in->ivlen, + ssl->transform_in->maclen ) ); return( POLARSSL_ERR_SSL_INVALID_MAC ); } @@ -1843,7 +1847,8 @@ static int ssl_compress_buf( ssl_context *ssl ) return( POLARSSL_ERR_SSL_COMPRESSION_FAILED ); } - ssl->out_msglen = SSL_BUFFER_LEN - ssl->transform_out->ctx_deflate.avail_out; + ssl->out_msglen = SSL_BUFFER_LEN - + ssl->transform_out->ctx_deflate.avail_out; SSL_DEBUG_MSG( 3, ( "after compression: msglen = %d, ", ssl->out_msglen ) ); @@ -1888,7 +1893,8 @@ static int ssl_decompress_buf( ssl_context *ssl ) return( POLARSSL_ERR_SSL_COMPRESSION_FAILED ); } - ssl->in_msglen = SSL_MAX_CONTENT_LEN - ssl->transform_in->ctx_inflate.avail_out; + ssl->in_msglen = SSL_MAX_CONTENT_LEN - + ssl->transform_in->ctx_inflate.avail_out; SSL_DEBUG_MSG( 3, ( "after decompression: msglen = %d, ", ssl->in_msglen ) ); @@ -2183,7 +2189,8 @@ int ssl_read_record( ssl_context *ssl ) * TLS encrypted messages can have up to 256 bytes of padding */ if( ssl->minor_ver >= SSL_MINOR_VERSION_1 && - ssl->in_msglen > ssl->transform_in->minlen + SSL_MAX_CONTENT_LEN + 256 ) + ssl->in_msglen > ssl->transform_in->minlen + + SSL_MAX_CONTENT_LEN + 256 ) { SSL_DEBUG_MSG( 1, ( "bad message length" ) ); return( POLARSSL_ERR_SSL_INVALID_RECORD ); @@ -3236,7 +3243,8 @@ int ssl_write_finished( ssl_context *ssl ) ssl->state++; /* - * Switch to our negotiated transform and session parameters for outbound data. + * Switch to our negotiated transform and session parameters for outbound + * data. */ SSL_DEBUG_MSG( 3, ( "switching to new transform spec for outbound data" ) ); ssl->transform_out = ssl->transform_negotiate; @@ -3276,7 +3284,8 @@ int ssl_parse_finished( ssl_context *ssl ) ssl->handshake->calc_finished( ssl, buf, ssl->endpoint ^ 1 ); /* - * Switch to our negotiated transform and session parameters for inbound data. + * Switch to our negotiated transform and session parameters for inbound + * data. */ SSL_DEBUG_MSG( 3, ( "switching to new transform spec for inbound data" ) ); ssl->transform_in = ssl->transform_negotiate; @@ -3707,7 +3716,8 @@ void ssl_set_ciphersuites( ssl_context *ssl, const int *ciphersuites ) ssl->ciphersuite_list[SSL_MINOR_VERSION_3] = ciphersuites; } -void ssl_set_ciphersuites_for_version( ssl_context *ssl, const int *ciphersuites, +void ssl_set_ciphersuites_for_version( ssl_context *ssl, + const int *ciphersuites, int major, int minor ) { if( major != SSL_MAJOR_VERSION_3 ) @@ -3855,7 +3865,8 @@ int ssl_set_psk( ssl_context *ssl, const unsigned char *psk, size_t psk_len, ssl->psk_identity_len = psk_identity_len; ssl->psk = (unsigned char *) polarssl_malloc( ssl->psk_len ); - ssl->psk_identity = (unsigned char *) polarssl_malloc( ssl->psk_identity_len ); + ssl->psk_identity = (unsigned char *) + polarssl_malloc( ssl->psk_identity_len ); if( ssl->psk == NULL || ssl->psk_identity == NULL ) return( POLARSSL_ERR_SSL_MALLOC_FAILED ); @@ -4344,7 +4355,8 @@ int ssl_read( ssl_context *ssl, unsigned char *buf, size_t len ) if( ssl->disable_renegotiation == SSL_RENEGOTIATION_DISABLED || ( ssl->secure_renegotiation == SSL_LEGACY_RENEGOTIATION && - ssl->allow_legacy_renegotiation == SSL_LEGACY_NO_RENEGOTIATION ) ) + ssl->allow_legacy_renegotiation == + SSL_LEGACY_NO_RENEGOTIATION ) ) { SSL_DEBUG_MSG( 3, ( "ignoring renegotiation, sending alert" ) ); diff --git a/library/version.c b/library/version.c index 120d62de4..400a8fedc 100644 --- a/library/version.c +++ b/library/version.c @@ -1,7 +1,7 @@ /* * Version information * - * Copyright (C) 2006-2010, Brainspark B.V. + * Copyright (C) 2006-2014, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker @@ -43,12 +43,14 @@ unsigned int version_get_number() void version_get_string( char *string ) { - memcpy( string, POLARSSL_VERSION_STRING, sizeof( POLARSSL_VERSION_STRING ) ); + memcpy( string, POLARSSL_VERSION_STRING, + sizeof( POLARSSL_VERSION_STRING ) ); } void version_get_string_full( char *string ) { - memcpy( string, POLARSSL_VERSION_STRING_FULL, sizeof( POLARSSL_VERSION_STRING_FULL ) ); + memcpy( string, POLARSSL_VERSION_STRING_FULL, + sizeof( POLARSSL_VERSION_STRING_FULL ) ); } #endif /* POLARSSL_VERSION_C */ diff --git a/library/x509_create.c b/library/x509_create.c index 8f7a789ff..8976c72d2 100644 --- a/library/x509_create.c +++ b/library/x509_create.c @@ -65,7 +65,8 @@ int x509_string_to_names( asn1_named_data **head, const char *name ) oid = OID_AT_COUNTRY; else if( c - s == 1 && strncasecmp( s, "O", 1 ) == 0 ) oid = OID_AT_ORGANIZATION; - else if( c - s == 16 && strncasecmp( s, "organizationName", 16 ) == 0 ) + else if( c - s == 16 && + strncasecmp( s, "organizationName", 16 ) == 0 ) oid = OID_AT_ORGANIZATION; else if( c - s == 1 && strncasecmp( s, "L", 1 ) == 0 ) oid = OID_AT_LOCALITY; @@ -75,11 +76,13 @@ int x509_string_to_names( asn1_named_data **head, const char *name ) oid = OID_PKCS9_EMAIL; else if( c - s == 2 && strncasecmp( s, "OU", 2 ) == 0 ) oid = OID_AT_ORG_UNIT; - else if( c - s == 22 && strncasecmp( s, "organizationalUnitName", 22 ) == 0 ) + else if( c - s == 22 && + strncasecmp( s, "organizationalUnitName", 22 ) == 0 ) oid = OID_AT_ORG_UNIT; else if( c - s == 2 && strncasecmp( s, "ST", 2 ) == 0 ) oid = OID_AT_STATE; - else if( c - s == 19 && strncasecmp( s, "stateOrProvinceName", 19 ) == 0 ) + else if( c - s == 19 && + strncasecmp( s, "stateOrProvinceName", 19 ) == 0 ) oid = OID_AT_STATE; else if( c - s == 12 && strncasecmp( s, "emailAddress", 12 ) == 0 ) oid = OID_PKCS9_EMAIL; @@ -105,9 +108,11 @@ int x509_string_to_names( asn1_named_data **head, const char *name ) oid = OID_AT_INITIALS; else if( c - s == 9 && strncasecmp( s, "pseudonym", 9 ) == 0 ) oid = OID_AT_PSEUDONYM; - else if( c - s == 19 && strncasecmp( s, "generationQualifier", 19 ) == 0 ) + else if( c - s == 19 && + strncasecmp( s, "generationQualifier", 19 ) == 0 ) oid = OID_AT_GENERATION_QUALIFIER; - else if( c - s == 15 && strncasecmp( s, "domainComponent", 15 ) == 0 ) + else if( c - s == 15 && + strncasecmp( s, "domainComponent", 15 ) == 0 ) oid = OID_DOMAIN_COMPONENT; else if( c - s == 2 && strncasecmp( s, "DC", 2 ) == 0 ) oid = OID_DOMAIN_COMPONENT; @@ -204,10 +209,12 @@ static int x509_write_name( unsigned char **p, unsigned char *start, ASN1_CHK_ADD( len, asn1_write_oid( p, start, oid, oid_len ) ); ASN1_CHK_ADD( len, asn1_write_len( p, start, len ) ); - ASN1_CHK_ADD( len, asn1_write_tag( p, start, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ); + ASN1_CHK_ADD( len, asn1_write_tag( p, start, ASN1_CONSTRUCTED | + ASN1_SEQUENCE ) ); ASN1_CHK_ADD( len, asn1_write_len( p, start, len ) ); - ASN1_CHK_ADD( len, asn1_write_tag( p, start, ASN1_CONSTRUCTED | ASN1_SET ) ); + ASN1_CHK_ADD( len, asn1_write_tag( p, start, ASN1_CONSTRUCTED | + ASN1_SET ) ); return( (int) len ); } @@ -228,7 +235,8 @@ int x509_write_names( unsigned char **p, unsigned char *start, } ASN1_CHK_ADD( len, asn1_write_len( p, start, len ) ); - ASN1_CHK_ADD( len, asn1_write_tag( p, start, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ); + ASN1_CHK_ADD( len, asn1_write_tag( p, start, ASN1_CONSTRUCTED | + ASN1_SEQUENCE ) ); return( (int) len ); } @@ -283,7 +291,8 @@ static int x509_write_extension( unsigned char **p, unsigned char *start, ASN1_CHK_ADD( len, asn1_write_tag( p, start, ASN1_OID ) ); ASN1_CHK_ADD( len, asn1_write_len( p, start, len ) ); - ASN1_CHK_ADD( len, asn1_write_tag( p, start, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ); + ASN1_CHK_ADD( len, asn1_write_tag( p, start, ASN1_CONSTRUCTED | + ASN1_SEQUENCE ) ); return( (int) len ); } diff --git a/library/x509_crl.c b/library/x509_crl.c index 7ab405657..a63a67975 100644 --- a/library/x509_crl.c +++ b/library/x509_crl.c @@ -224,10 +224,12 @@ static int x509_get_entries( unsigned char **p, if( ( ret = x509_get_serial( p, end2, &cur_entry->serial ) ) != 0 ) return( ret ); - if( ( ret = x509_get_time( p, end2, &cur_entry->revocation_date ) ) != 0 ) + if( ( ret = x509_get_time( p, end2, + &cur_entry->revocation_date ) ) != 0 ) return( ret ); - if( ( ret = x509_get_crl_entry_ext( p, end2, &cur_entry->entry_ext ) ) != 0 ) + if( ( ret = x509_get_crl_entry_ext( p, end2, + &cur_entry->entry_ext ) ) != 0 ) return( ret ); if ( *p < end ) diff --git a/library/x509_crt.c b/library/x509_crt.c index 4278d6ec9..79460682a 100644 --- a/library/x509_crt.c +++ b/library/x509_crt.c @@ -819,7 +819,8 @@ int x509_crt_parse_der( x509_crt *chain, const unsigned char *buf, } /* - * Parse one or more PEM certificates from a buffer and add them to the chained list + * Parse one or more PEM certificates from a buffer and add them to the chained + * list */ int x509_crt_parse( x509_crt *chain, const unsigned char *buf, size_t buflen ) { @@ -970,7 +971,8 @@ int x509_crt_parse_path( x509_crt *chain, const char *path ) p = filename + len; filename[len++] = '*'; - w_ret = MultiByteToWideChar( CP_ACP, 0, filename, len, szDir, MAX_PATH - 3 ); + w_ret = MultiByteToWideChar( CP_ACP, 0, filename, len, szDir, + MAX_PATH - 3 ); hFind = FindFirstFileW( szDir, &file_data ); if (hFind == INVALID_HANDLE_VALUE) @@ -1692,8 +1694,11 @@ static int x509_crt_verify_top( if( NULL != f_vrfy ) { - if( ( ret = f_vrfy( p_vrfy, trust_ca, path_cnt + 1, &ca_flags ) ) != 0 ) + if( ( ret = f_vrfy( p_vrfy, trust_ca, path_cnt + 1, + &ca_flags ) ) != 0 ) + { return( ret ); + } } } diff --git a/library/x509write_crt.c b/library/x509write_crt.c index 302b8771e..df7ab64a2 100644 --- a/library/x509write_crt.c +++ b/library/x509write_crt.c @@ -1,7 +1,7 @@ /* * X.509 certificate writing * - * Copyright (C) 2006-2013, Brainspark B.V. + * Copyright (C) 2006-2014, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker @@ -155,7 +155,8 @@ int x509write_crt_set_basic_constraints( x509write_cert *ctx, } ASN1_CHK_ADD( len, asn1_write_len( &c, buf, len ) ); - ASN1_CHK_ADD( len, asn1_write_tag( &c, buf, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ); + ASN1_CHK_ADD( len, asn1_write_tag( &c, buf, ASN1_CONSTRUCTED | + ASN1_SEQUENCE ) ); return x509write_crt_set_extension( ctx, OID_BASIC_CONSTRAINTS, OID_SIZE( OID_BASIC_CONSTRAINTS ), @@ -203,7 +204,8 @@ int x509write_crt_set_authority_key_identifier( x509write_cert *ctx ) ASN1_CHK_ADD( len, asn1_write_tag( &c, buf, ASN1_CONTEXT_SPECIFIC | 0 ) ); ASN1_CHK_ADD( len, asn1_write_len( &c, buf, len ) ); - ASN1_CHK_ADD( len, asn1_write_tag( &c, buf, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ); + ASN1_CHK_ADD( len, asn1_write_tag( &c, buf, ASN1_CONSTRUCTED | + ASN1_SEQUENCE ) ); return x509write_crt_set_extension( ctx, OID_AUTHORITY_KEY_IDENTIFIER, OID_SIZE( OID_AUTHORITY_KEY_IDENTIFIER ), @@ -317,9 +319,11 @@ int x509write_crt_der( x509write_cert *ctx, unsigned char *buf, size_t size, */ ASN1_CHK_ADD( len, x509_write_extensions( &c, tmp_buf, ctx->extensions ) ); ASN1_CHK_ADD( len, asn1_write_len( &c, tmp_buf, len ) ); - ASN1_CHK_ADD( len, asn1_write_tag( &c, tmp_buf, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ); + ASN1_CHK_ADD( len, asn1_write_tag( &c, tmp_buf, ASN1_CONSTRUCTED | + ASN1_SEQUENCE ) ); ASN1_CHK_ADD( len, asn1_write_len( &c, tmp_buf, len ) ); - ASN1_CHK_ADD( len, asn1_write_tag( &c, tmp_buf, ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTED | 3 ) ); + ASN1_CHK_ADD( len, asn1_write_tag( &c, tmp_buf, ASN1_CONTEXT_SPECIFIC | + ASN1_CONSTRUCTED | 3 ) ); /* * SubjectPublicKeyInfo @@ -349,7 +353,8 @@ int x509write_crt_der( x509write_cert *ctx, unsigned char *buf, size_t size, len += sub_len; ASN1_CHK_ADD( len, asn1_write_len( &c, tmp_buf, sub_len ) ); - ASN1_CHK_ADD( len, asn1_write_tag( &c, tmp_buf, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ); + ASN1_CHK_ADD( len, asn1_write_tag( &c, tmp_buf, ASN1_CONSTRUCTED | + ASN1_SEQUENCE ) ); /* * Issuer ::= Name @@ -374,10 +379,12 @@ int x509write_crt_der( x509write_cert *ctx, unsigned char *buf, size_t size, ASN1_CHK_ADD( sub_len, asn1_write_int( &c, tmp_buf, ctx->version ) ); len += sub_len; ASN1_CHK_ADD( len, asn1_write_len( &c, tmp_buf, sub_len ) ); - ASN1_CHK_ADD( len, asn1_write_tag( &c, tmp_buf, ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTED | 0 ) ); + ASN1_CHK_ADD( len, asn1_write_tag( &c, tmp_buf, ASN1_CONTEXT_SPECIFIC | + ASN1_CONSTRUCTED | 0 ) ); ASN1_CHK_ADD( len, asn1_write_len( &c, tmp_buf, len ) ); - ASN1_CHK_ADD( len, asn1_write_tag( &c, tmp_buf, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ); + ASN1_CHK_ADD( len, asn1_write_tag( &c, tmp_buf, ASN1_CONSTRUCTED | + ASN1_SEQUENCE ) ); /* * Make signature @@ -402,7 +409,8 @@ int x509write_crt_der( x509write_cert *ctx, unsigned char *buf, size_t size, len += sig_and_oid_len; ASN1_CHK_ADD( len, asn1_write_len( &c2, buf, len ) ); - ASN1_CHK_ADD( len, asn1_write_tag( &c2, buf, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ); + ASN1_CHK_ADD( len, asn1_write_tag( &c2, buf, ASN1_CONSTRUCTED | + ASN1_SEQUENCE ) ); return( (int) len ); } diff --git a/library/x509write_csr.c b/library/x509write_csr.c index 6e7bed4a1..ff766e15e 100644 --- a/library/x509write_csr.c +++ b/library/x509write_csr.c @@ -1,7 +1,7 @@ /* * X.509 Certificate Signing Request writing * - * Copyright (C) 2006-2013, Brainspark B.V. + * Copyright (C) 2006-2014, Brainspark B.V. * * This file is part of PolarSSL (http://www.polarssl.org) * Lead Maintainer: Paul Bakker @@ -150,20 +150,24 @@ int x509write_csr_der( x509write_csr *ctx, unsigned char *buf, size_t size, if( len ) { ASN1_CHK_ADD( len, asn1_write_len( &c, tmp_buf, len ) ); - ASN1_CHK_ADD( len, asn1_write_tag( &c, tmp_buf, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ); + ASN1_CHK_ADD( len, asn1_write_tag( &c, tmp_buf, ASN1_CONSTRUCTED | + ASN1_SEQUENCE ) ); ASN1_CHK_ADD( len, asn1_write_len( &c, tmp_buf, len ) ); - ASN1_CHK_ADD( len, asn1_write_tag( &c, tmp_buf, ASN1_CONSTRUCTED | ASN1_SET ) ); + ASN1_CHK_ADD( len, asn1_write_tag( &c, tmp_buf, ASN1_CONSTRUCTED | + ASN1_SET ) ); ASN1_CHK_ADD( len, asn1_write_oid( &c, tmp_buf, OID_PKCS9_CSR_EXT_REQ, OID_SIZE( OID_PKCS9_CSR_EXT_REQ ) ) ); ASN1_CHK_ADD( len, asn1_write_len( &c, tmp_buf, len ) ); - ASN1_CHK_ADD( len, asn1_write_tag( &c, tmp_buf, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ); + ASN1_CHK_ADD( len, asn1_write_tag( &c, tmp_buf, ASN1_CONSTRUCTED | + ASN1_SEQUENCE ) ); } ASN1_CHK_ADD( len, asn1_write_len( &c, tmp_buf, len ) ); - ASN1_CHK_ADD( len, asn1_write_tag( &c, tmp_buf, ASN1_CONSTRUCTED | ASN1_CONTEXT_SPECIFIC ) ); + ASN1_CHK_ADD( len, asn1_write_tag( &c, tmp_buf, ASN1_CONSTRUCTED | + ASN1_CONTEXT_SPECIFIC ) ); ASN1_CHK_ADD( pub_len, pk_write_pubkey_der( ctx->key, tmp_buf, c - tmp_buf ) ); @@ -181,7 +185,8 @@ int x509write_csr_der( x509write_csr *ctx, unsigned char *buf, size_t size, ASN1_CHK_ADD( len, asn1_write_int( &c, tmp_buf, 0 ) ); ASN1_CHK_ADD( len, asn1_write_len( &c, tmp_buf, len ) ); - ASN1_CHK_ADD( len, asn1_write_tag( &c, tmp_buf, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ); + ASN1_CHK_ADD( len, asn1_write_tag( &c, tmp_buf, ASN1_CONSTRUCTED | + ASN1_SEQUENCE ) ); /* * Prepare signature @@ -212,7 +217,8 @@ int x509write_csr_der( x509write_csr *ctx, unsigned char *buf, size_t size, len += sig_and_oid_len; ASN1_CHK_ADD( len, asn1_write_len( &c2, buf, len ) ); - ASN1_CHK_ADD( len, asn1_write_tag( &c2, buf, ASN1_CONSTRUCTED | ASN1_SEQUENCE ) ); + ASN1_CHK_ADD( len, asn1_write_tag( &c2, buf, ASN1_CONSTRUCTED | + ASN1_SEQUENCE ) ); return( (int) len ); }