1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-28 00:21:48 +03:00

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

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

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

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

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

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

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