Fix formatting: fix some 'easy' > 80 length lines

This commit is contained in:
Paul Bakker 2014-05-01 14:18:25 +02:00
parent 9af723cee7
commit b9e4e2c97a
60 changed files with 548 additions and 347 deletions

View file

@ -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 <polarssl_maintainer at polarssl.org>
@ -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

View file

@ -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 <polarssl_maintainer at polarssl.org>
@ -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

View file

@ -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 <polarssl_maintainer at polarssl.org>
@ -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

View file

@ -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 <polarssl_maintainer at polarssl.org>
@ -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

View file

@ -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 <polarssl_maintainer at polarssl.org>
@ -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,

View file

@ -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 <polarssl_maintainer at polarssl.org>
@ -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,

View file

@ -5,7 +5,7 @@
*
* \author Adriaan de Jong <dejong@fox-it.com>
*
* 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 <polarssl_maintainer at polarssl.org>
@ -176,26 +176,31 @@ typedef struct {
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

View file

@ -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 <polarssl_maintainer at polarssl.org>
@ -92,7 +92,8 @@ typedef struct
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 */
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
}

View file

@ -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 <polarssl_maintainer at polarssl.org>
@ -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

View file

@ -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 <polarssl_maintainer at polarssl.org>
@ -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

View file

@ -5,7 +5,7 @@
*
* \author Adriaan de Jong <dejong@fox-it.com>
*
* 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 <polarssl_maintainer at polarssl.org>
@ -98,10 +98,12 @@ typedef struct {
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);
@ -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

View file

@ -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 <polarssl_maintainer at polarssl.org>
@ -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

View file

@ -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 <polarssl_maintainer at polarssl.org>
@ -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

View file

@ -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 <polarssl_maintainer at polarssl.org>

View file

@ -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 <polarssl_maintainer at polarssl.org>

View file

@ -5,7 +5,7 @@
*
* \author Adriaan de Jong <dejong@fox-it.com>
*
* 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 <polarssl_maintainer at polarssl.org>
@ -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
*

View file

@ -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 <polarssl_maintainer at polarssl.org>
@ -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,

View file

@ -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 <polarssl_maintainer at polarssl.org>
@ -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

View file

@ -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 <polarssl_maintainer at polarssl.org>
@ -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

View file

@ -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 <polarssl_maintainer at polarssl.org>
@ -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

View file

@ -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 <polarssl_maintainer at polarssl.org>
@ -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 );

View file

@ -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 <polarssl_maintainer at polarssl.org>
@ -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,

View file

@ -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 <polarssl_maintainer at polarssl.org>
@ -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

View file

@ -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 )
{

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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 )

View file

@ -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 )
{

View file

@ -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;

View file

@ -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 );
}

View file

@ -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
*/

View file

@ -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];

View file

@ -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;

View file

@ -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 )

View file

@ -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 );
}

View file

@ -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 );
}

View file

@ -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 );
}

View file

@ -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 );
}

View file

@ -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;

View file

@ -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

View file

@ -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;

View file

@ -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;

View file

@ -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 <polarssl_maintainer at polarssl.org>
@ -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++)

View file

@ -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 );

View file

@ -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 */

View file

@ -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 );
}

View file

@ -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 );
}

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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 );

View file

@ -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;
@ -2223,8 +2225,7 @@ 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 )
p, &len, ssl->f_rng, ssl->p_rng ) ) != 0 )
{
SSL_DEBUG_RET( 1, "dhm_make_params", ret );
return( ret );

View file

@ -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" ) );
@ -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" ) );

View file

@ -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 <polarssl_maintainer at polarssl.org>
@ -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 */

View file

@ -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 );
}

View file

@ -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 )

View file

@ -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,10 +1694,13 @@ 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 );
}
}
}
/* Call callback on top cert */
if( NULL != f_vrfy )

View file

@ -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 <polarssl_maintainer at polarssl.org>
@ -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 );
}

View file

@ -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 <polarssl_maintainer at polarssl.org>
@ -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 );
}