| cryptolib.h | | cryptolib.h | |
| /* | | /* | |
| * cryptolib.h | | * cryptolib.h | |
|
| * Release $Name: MATRIXSSL-3-1-4-OPEN $ | | * Release $Name: MATRIXSSL-3-2-1-OPEN $ | |
| */ | | */ | |
| /* | | /* | |
| * Copyright (c) PeerSec Networks, 2002-2011. All Rights Reserved. | | * Copyright (c) PeerSec Networks, 2002-2011. All Rights Reserved. | |
| * The latest version of this code is available at http://www.matrixssl
.org | | * The latest version of this code is available at http://www.matrixssl
.org | |
| * | | * | |
| * This software is open source; you can redistribute it and/or modify | | * This software is open source; you can redistribute it and/or modify | |
| * it under the terms of the GNU General Public License as published by | | * it under the terms of the GNU General Public License as published by | |
| * the Free Software Foundation; either version 2 of the License, or | | * the Free Software Foundation; either version 2 of the License, or | |
| * (at your option) any later version. | | * (at your option) any later version. | |
| * | | * | |
| | | | |
| skipping to change at line 104 | | skipping to change at line 104 | |
| RFC 3279 OID | | RFC 3279 OID | |
| PeerSec uses an oid summing mechanism to arrive at these defines. | | PeerSec uses an oid summing mechanism to arrive at these defines. | |
| The byte values of the OID are summed to produce a "relatively uniqu
e" int | | The byte values of the OID are summed to produce a "relatively uniqu
e" int | |
| | | | |
| The duplicate defines do not pose a problem as long as they don't | | The duplicate defines do not pose a problem as long as they don't | |
| exist in the same OID groupings | | exist in the same OID groupings | |
| */ | | */ | |
| #ifdef USE_X509 | | #ifdef USE_X509 | |
| /* Raw digest algorithms */ | | /* Raw digest algorithms */ | |
| #define OID_SHA1_ALG 88 | | #define OID_SHA1_ALG 88 | |
|
| | | #define OID_SHA256_ALG 414 | |
| | | #define OID_SHA512_ALG 416 | |
| #define OID_MD2_ALG 646 | | #define OID_MD2_ALG 646 | |
| #define OID_MD5_ALG 649 | | #define OID_MD5_ALG 649 | |
| | | | |
| /* Signature algorithms */ | | /* Signature algorithms */ | |
| #define OID_MD2_RSA_SIG 646 | | #define OID_MD2_RSA_SIG 646 | |
| #define OID_MD5_RSA_SIG 648 /* 42.134.72.134.247.13.
1.1.4 */ | | #define OID_MD5_RSA_SIG 648 /* 42.134.72.134.247.13.
1.1.4 */ | |
| #define OID_SHA1_RSA_SIG 649 /* 42.134.72.134.247.13.1.1.5 */ | | #define OID_SHA1_RSA_SIG 649 /* 42.134.72.134.247.13.1.1.5 */ | |
|
| | | #define OID_SHA256_RSA_SIG 655 /* 42.134.72.134.247.13.1.1.11 * | |
| | | / | |
| | | #define OID_SHA512_RSA_SIG 657 /* 42.134.72.134.247.13.1.1.13 * | |
| | | / | |
| #define OID_SHA1_ECDSA_SIG 520 /* 42.134.72.206.61.4.1 */ | | #define OID_SHA1_ECDSA_SIG 520 /* 42.134.72.206.61.4.1 */ | |
| #define OID_SHA224_ECDSA_SIG 523 /* 42.134.72.206.61.4.3.1 */ | | #define OID_SHA224_ECDSA_SIG 523 /* 42.134.72.206.61.4.3.1 */ | |
| #define OID_SHA256_ECDSA_SIG 524 /* 42.134.72.206.61.4.3.2 */ | | #define OID_SHA256_ECDSA_SIG 524 /* 42.134.72.206.61.4.3.2 */ | |
|
| | | #define OID_SHA384_ECDSA_SIG 525 /* 42.134.72.206.61.4.3.3 */ | |
| | | #define OID_SHA512_ECDSA_SIG 526 /* 42.134.72.206.61.4.3.4 */ | |
| #endif /* USE_X509 */ | | #endif /* USE_X509 */ | |
| | | | |
| /* Public key algorithms */ | | /* Public key algorithms */ | |
| #define OID_RSA_KEY_ALG 645 /* 42.134.72.134.247.13.
1.1.1 */ | | #define OID_RSA_KEY_ALG 645 /* 42.134.72.134.247.13.
1.1.1 */ | |
| #define OID_ECDSA_KEY_ALG 518 /* 42.134.72.206.61.2.1 */ | | #define OID_ECDSA_KEY_ALG 518 /* 42.134.72.206.61.2.1 */ | |
| | | | |
| #ifdef USE_PKCS5 | | #ifdef USE_PKCS5 | |
| #define OID_DES_EDE3_CBC 652 /* 42.134.72.134.247.13.3.7 */ | | #define OID_DES_EDE3_CBC 652 /* 42.134.72.134.247.13.3.7 */ | |
| | | | |
| #define OID_PKCS_PBKDF2 660 /* 42.134.72.134.247.13.
1.5.12 */ | | #define OID_PKCS_PBKDF2 660 /* 42.134.72.134.247.13.
1.5.12 */ | |
| | | | |
| skipping to change at line 142 | | skipping to change at line 148 | |
| #define CRYPTO_FLAGS_ARC4 0x08 | | #define CRYPTO_FLAGS_ARC4 0x08 | |
| #define CRYPTO_FLAGS_SEED 0x10 | | #define CRYPTO_FLAGS_SEED 0x10 | |
| | | | |
| #define CRYPTO_FLAGS_SHA1 0x20 | | #define CRYPTO_FLAGS_SHA1 0x20 | |
| #define CRYPTO_FLAGS_MD5 0x40 | | #define CRYPTO_FLAGS_MD5 0x40 | |
| | | | |
| #define CRYPTO_FLAGS_TLS 0x80 | | #define CRYPTO_FLAGS_TLS 0x80 | |
| | | | |
| #define CRYPTO_FLAGS_INBOUND 0x100 | | #define CRYPTO_FLAGS_INBOUND 0x100 | |
| #define CRYPTO_FLAGS_ARC4INIT 0x200 | | #define CRYPTO_FLAGS_ARC4INIT 0x200 | |
|
| | | #define CRYPTO_FLAGS_BLOCKING 0x400 | |
| | | | |
| #define CRYPTO_FLAGS_DISABLED 0x800 | | #define CRYPTO_FLAGS_DISABLED 0x800 | |
| | | | |
| /**************************************************************************
****/ | | /**************************************************************************
****/ | |
| | | | |
| #define CRYPT_INVALID_KEYSIZE -21 | | #define CRYPT_INVALID_KEYSIZE -21 | |
| #define CRYPT_INVALID_ROUNDS -22 | | #define CRYPT_INVALID_ROUNDS -22 | |
| | | | |
| /**************************************************************************
****/ | | /**************************************************************************
****/ | |
| /* 32-bit Rotates */ | | /* 32-bit Rotates */ | |
| | | | |
| skipping to change at line 263 | | skipping to change at line 270 | |
| (y)[6] = (unsigned char)(((x)>>48)&255); \ | | (y)[6] = (unsigned char)(((x)>>48)&255); \ | |
| (y)[5] = (unsigned char)(((x)>>40)&255); \ | | (y)[5] = (unsigned char)(((x)>>40)&255); \ | |
| (y)[4] = (unsigned char)(((x)>>32)&255); \ | | (y)[4] = (unsigned char)(((x)>>32)&255); \ | |
| (y)[3] = (unsigned char)(((x)>>24)&255); \ | | (y)[3] = (unsigned char)(((x)>>24)&255); \ | |
| (y)[2] = (unsigned char)(((x)>>16)&255); \ | | (y)[2] = (unsigned char)(((x)>>16)&255); \ | |
| (y)[1] = (unsigned char)(((x)>>8)&255); \ | | (y)[1] = (unsigned char)(((x)>>8)&255); \ | |
| (y)[0] = (unsigned char)((x)&255); \ | | (y)[0] = (unsigned char)((x)&255); \ | |
| } | | } | |
| | | | |
| #define LOAD64L(x, y) { \ | | #define LOAD64L(x, y) { \ | |
|
| x = (((ulong64)((y)[7] & 255))<<56)|(((ulong64)((y)[6] & 255))<<48)| \ | | x = (((uint64)((y)[7] & 255))<<56)|(((uint64)((y)[6] & 255))<<48)| \ | |
| (((ulong64)((y)[5] & 255))<<40)|(((ulong64)((y)[4] & 255))<<32)| \ | | (((uint64)((y)[5] & 255))<<40)|(((uint64)((y)[4] & 255))<<32)| \ | |
| (((ulong64)((y)[3] & 255))<<24)|(((ulong64)((y)[2] & 255))<<16)| \ | | (((uint64)((y)[3] & 255))<<24)|(((uint64)((y)[2] & 255))<<16)| \ | |
| (((ulong64)((y)[1] & 255))<<8)|(((ulong64)((y)[0] & 255))); \ | | (((uint64)((y)[1] & 255))<<8)|(((uint64)((y)[0] & 255))); \ | |
| } | | } | |
| | | | |
| #define STORE32H(x, y) { \ | | #define STORE32H(x, y) { \ | |
| (y)[0] = (unsigned char)(((x)>>24)&255); \ | | (y)[0] = (unsigned char)(((x)>>24)&255); \ | |
| (y)[1] = (unsigned char)(((x)>>16)&255); \ | | (y)[1] = (unsigned char)(((x)>>16)&255); \ | |
| (y)[2] = (unsigned char)(((x)>>8)&255); \ | | (y)[2] = (unsigned char)(((x)>>8)&255); \ | |
| (y)[3] = (unsigned char)((x)&255); \ | | (y)[3] = (unsigned char)((x)&255); \ | |
| } | | } | |
| | | | |
| #define LOAD32H(x, y) { \ | | #define LOAD32H(x, y) { \ | |
| | | | |
| skipping to change at line 295 | | skipping to change at line 302 | |
| (y)[1] = (unsigned char)(((x)>>48)&255); \ | | (y)[1] = (unsigned char)(((x)>>48)&255); \ | |
| (y)[2] = (unsigned char)(((x)>>40)&255); \ | | (y)[2] = (unsigned char)(((x)>>40)&255); \ | |
| (y)[3] = (unsigned char)(((x)>>32)&255); \ | | (y)[3] = (unsigned char)(((x)>>32)&255); \ | |
| (y)[4] = (unsigned char)(((x)>>24)&255); \ | | (y)[4] = (unsigned char)(((x)>>24)&255); \ | |
| (y)[5] = (unsigned char)(((x)>>16)&255); \ | | (y)[5] = (unsigned char)(((x)>>16)&255); \ | |
| (y)[6] = (unsigned char)(((x)>>8)&255); \ | | (y)[6] = (unsigned char)(((x)>>8)&255); \ | |
| (y)[7] = (unsigned char)((x)&255); \ | | (y)[7] = (unsigned char)((x)&255); \ | |
| } | | } | |
| | | | |
| #define LOAD64H(x, y) { \ | | #define LOAD64H(x, y) { \ | |
|
| x = (((ulong64)((y)[0] & 255))<<56)|(((ulong64)((y)[1] & 255))<<48) | \ | | x = (((uint64)((y)[0] & 255))<<56)|(((uint64)((y)[1] & 255))<<48) | \ | |
| (((ulong64)((y)[2] & 255))<<40)|(((ulong64)((y)[3] & 255))<<32) | \ | | (((uint64)((y)[2] & 255))<<40)|(((uint64)((y)[3] & 255))<<32) | \ | |
| (((ulong64)((y)[4] & 255))<<24)|(((ulong64)((y)[5] & 255))<<16) | \ | | (((uint64)((y)[4] & 255))<<24)|(((uint64)((y)[5] & 255))<<16) | \ | |
| (((ulong64)((y)[6] & 255))<<8)|(((ulong64)((y)[7] & 255))); \ | | (((uint64)((y)[6] & 255))<<8)|(((uint64)((y)[7] & 255))); \ | |
| } | | } | |
| | | | |
| #endif /* ENDIAN_NEUTRAL */ | | #endif /* ENDIAN_NEUTRAL */ | |
| | | | |
| #ifdef ENDIAN_LITTLE | | #ifdef ENDIAN_LITTLE | |
| | | | |
| #define STORE32H(x, y) { \ | | #define STORE32H(x, y) { \ | |
| (y)[0] = (unsigned char)(((x)>>24)&255); \ | | (y)[0] = (unsigned char)(((x)>>24)&255); \ | |
| (y)[1] = (unsigned char)(((x)>>16)&255); \ | | (y)[1] = (unsigned char)(((x)>>16)&255); \ | |
| (y)[2] = (unsigned char)(((x)>>8)&255); \ | | (y)[2] = (unsigned char)(((x)>>8)&255); \ | |
| | | | |
| skipping to change at line 331 | | skipping to change at line 338 | |
| (y)[1] = (unsigned char)(((x)>>48)&255); \ | | (y)[1] = (unsigned char)(((x)>>48)&255); \ | |
| (y)[2] = (unsigned char)(((x)>>40)&255); \ | | (y)[2] = (unsigned char)(((x)>>40)&255); \ | |
| (y)[3] = (unsigned char)(((x)>>32)&255); \ | | (y)[3] = (unsigned char)(((x)>>32)&255); \ | |
| (y)[4] = (unsigned char)(((x)>>24)&255); \ | | (y)[4] = (unsigned char)(((x)>>24)&255); \ | |
| (y)[5] = (unsigned char)(((x)>>16)&255); \ | | (y)[5] = (unsigned char)(((x)>>16)&255); \ | |
| (y)[6] = (unsigned char)(((x)>>8)&255); \ | | (y)[6] = (unsigned char)(((x)>>8)&255); \ | |
| (y)[7] = (unsigned char)((x)&255); \ | | (y)[7] = (unsigned char)((x)&255); \ | |
| } | | } | |
| | | | |
| #define LOAD64H(x, y) { \ | | #define LOAD64H(x, y) { \ | |
|
| x = (((ulong64)((y)[0] & 255))<<56)|(((ulong64)((y)[1] & 255))<<48) | \ | | x = (((uint64)((y)[0] & 255))<<56)|(((uint64)((y)[1] & 255))<<48) | \ | |
| (((ulong64)((y)[2] & 255))<<40)|(((ulong64)((y)[3] & 255))<<32) | \ | | (((uint64)((y)[2] & 255))<<40)|(((uint64)((y)[3] & 255))<<32) | \ | |
| (((ulong64)((y)[4] & 255))<<24)|(((ulong64)((y)[5] & 255))<<16) | \ | | (((uint64)((y)[4] & 255))<<24)|(((uint64)((y)[5] & 255))<<16) | \ | |
| (((ulong64)((y)[6] & 255))<<8)|(((ulong64)((y)[7] & 255))); } | | (((uint64)((y)[6] & 255))<<8)|(((uint64)((y)[7] & 255))); } | |
| | | | |
| #ifdef ENDIAN_32BITWORD | | #ifdef ENDIAN_32BITWORD | |
| | | | |
| #define STORE32L(x, y) { \ | | #define STORE32L(x, y) { \ | |
| unsigned long __t = (x); memcpy(y, &__t, 4); \ | | unsigned long __t = (x); memcpy(y, &__t, 4); \ | |
| } | | } | |
| | | | |
| #define LOAD32L(x, y) memcpy(&(x), y, 4); | | #define LOAD32L(x, y) memcpy(&(x), y, 4); | |
| | | | |
| #define STORE64L(x, y) { \ | | #define STORE64L(x, y) { \ | |
| | | | |
| skipping to change at line 356 | | skipping to change at line 363 | |
| (y)[6] = (unsigned char)(((x)>>48)&255); \ | | (y)[6] = (unsigned char)(((x)>>48)&255); \ | |
| (y)[5] = (unsigned char)(((x)>>40)&255); \ | | (y)[5] = (unsigned char)(((x)>>40)&255); \ | |
| (y)[4] = (unsigned char)(((x)>>32)&255); \ | | (y)[4] = (unsigned char)(((x)>>32)&255); \ | |
| (y)[3] = (unsigned char)(((x)>>24)&255); \ | | (y)[3] = (unsigned char)(((x)>>24)&255); \ | |
| (y)[2] = (unsigned char)(((x)>>16)&255); \ | | (y)[2] = (unsigned char)(((x)>>16)&255); \ | |
| (y)[1] = (unsigned char)(((x)>>8)&255); \ | | (y)[1] = (unsigned char)(((x)>>8)&255); \ | |
| (y)[0] = (unsigned char)((x)&255); \ | | (y)[0] = (unsigned char)((x)&255); \ | |
| } | | } | |
| | | | |
| #define LOAD64L(x, y) { \ | | #define LOAD64L(x, y) { \ | |
|
| x = (((ulong64)((y)[7] & 255))<<56)|(((ulong64)((y)[6] & 255))<<48)| \ | | x = (((uint64)((y)[7] & 255))<<56)|(((uint64)((y)[6] & 255))<<48)| \ | |
| (((ulong64)((y)[5] & 255))<<40)|(((ulong64)((y)[4] & 255))<<32)| \ | | (((uint64)((y)[5] & 255))<<40)|(((uint64)((y)[4] & 255))<<32)| \ | |
| (((ulong64)((y)[3] & 255))<<24)|(((ulong64)((y)[2] & 255))<<16)| \ | | (((uint64)((y)[3] & 255))<<24)|(((uint64)((y)[2] & 255))<<16)| \ | |
| (((ulong64)((y)[1] & 255))<<8)|(((ulong64)((y)[0] & 255))); \ | | (((uint64)((y)[1] & 255))<<8)|(((uint64)((y)[0] & 255))); \ | |
| } | | } | |
| | | | |
| #else /* 64-bit words then */ | | #else /* 64-bit words then */ | |
| | | | |
| #define STORE32L(x, y) \ | | #define STORE32L(x, y) \ | |
| { unsigned long __t = (x); memcpy(y, &__t, 4); } | | { unsigned long __t = (x); memcpy(y, &__t, 4); } | |
| | | | |
| #define LOAD32L(x, y) \ | | #define LOAD32L(x, y) \ | |
| { memcpy(&(x), y, 4); x &= 0xFFFFFFFF; } | | { memcpy(&(x), y, 4); x &= 0xFFFFFFFF; } | |
| | | | |
| #define STORE64L(x, y) \ | | #define STORE64L(x, y) \ | |
|
| { ulong64 __t = (x); memcpy(y, &__t, 8); } | | { uint64 __t = (x); memcpy(y, &__t, 8); } | |
| | | | |
| #define LOAD64L(x, y) \ | | #define LOAD64L(x, y) \ | |
| { memcpy(&(x), y, 8); } | | { memcpy(&(x), y, 8); } | |
| | | | |
| #endif /* ENDIAN_64BITWORD */ | | #endif /* ENDIAN_64BITWORD */ | |
| #endif /* ENDIAN_LITTLE */ | | #endif /* ENDIAN_LITTLE */ | |
| | | | |
| #ifdef ENDIAN_BIG | | #ifdef ENDIAN_BIG | |
| | | | |
| #define STORE32L(x, y) { \ | | #define STORE32L(x, y) { \ | |
| | | | |
| skipping to change at line 407 | | skipping to change at line 414 | |
| (y)[6] = (unsigned char)(((x)>>48)&255); \ | | (y)[6] = (unsigned char)(((x)>>48)&255); \ | |
| (y)[5] = (unsigned char)(((x)>>40)&255); \ | | (y)[5] = (unsigned char)(((x)>>40)&255); \ | |
| (y)[4] = (unsigned char)(((x)>>32)&255); \ | | (y)[4] = (unsigned char)(((x)>>32)&255); \ | |
| (y)[3] = (unsigned char)(((x)>>24)&255); \ | | (y)[3] = (unsigned char)(((x)>>24)&255); \ | |
| (y)[2] = (unsigned char)(((x)>>16)&255); \ | | (y)[2] = (unsigned char)(((x)>>16)&255); \ | |
| (y)[1] = (unsigned char)(((x)>>8)&255); \ | | (y)[1] = (unsigned char)(((x)>>8)&255); \ | |
| (y)[0] = (unsigned char)((x)&255); \ | | (y)[0] = (unsigned char)((x)&255); \ | |
| } | | } | |
| | | | |
| #define LOAD64L(x, y) { \ | | #define LOAD64L(x, y) { \ | |
|
| x = (((ulong64)((y)[7] & 255))<<56)|(((ulong64)((y)[6] & 255))<<48) | \ | | x = (((uint64)((y)[7] & 255))<<56)|(((uint64)((y)[6] & 255))<<48) | \ | |
| (((ulong64)((y)[5] & 255))<<40)|(((ulong64)((y)[4] & 255))<<32) | \ | | (((uint64)((y)[5] & 255))<<40)|(((uint64)((y)[4] & 255))<<32) | \ | |
| (((ulong64)((y)[3] & 255))<<24)|(((ulong64)((y)[2] & 255))<<16) | \ | | (((uint64)((y)[3] & 255))<<24)|(((uint64)((y)[2] & 255))<<16) | \ | |
| (((ulong64)((y)[1] & 255))<<8)|(((ulong64)((y)[0] & 255))); \ | | (((uint64)((y)[1] & 255))<<8)|(((uint64)((y)[0] & 255))); \ | |
| } | | } | |
| | | | |
| #ifdef ENDIAN_32BITWORD | | #ifdef ENDIAN_32BITWORD | |
| | | | |
| #define STORE32H(x, y) \ | | #define STORE32H(x, y) \ | |
| { unsigned long __t = (x); memcpy(y, &__t, 4); } | | { unsigned long __t = (x); memcpy(y, &__t, 4); } | |
| | | | |
| #define LOAD32H(x, y) memcpy(&(x), y, 4); | | #define LOAD32H(x, y) memcpy(&(x), y, 4); | |
| | | | |
| #define STORE64H(x, y) { \ | | #define STORE64H(x, y) { \ | |
| | | | |
| skipping to change at line 432 | | skipping to change at line 439 | |
| (y)[1] = (unsigned char)(((x)>>48)&255); \ | | (y)[1] = (unsigned char)(((x)>>48)&255); \ | |
| (y)[2] = (unsigned char)(((x)>>40)&255); \ | | (y)[2] = (unsigned char)(((x)>>40)&255); \ | |
| (y)[3] = (unsigned char)(((x)>>32)&255); \ | | (y)[3] = (unsigned char)(((x)>>32)&255); \ | |
| (y)[4] = (unsigned char)(((x)>>24)&255); \ | | (y)[4] = (unsigned char)(((x)>>24)&255); \ | |
| (y)[5] = (unsigned char)(((x)>>16)&255); \ | | (y)[5] = (unsigned char)(((x)>>16)&255); \ | |
| (y)[6] = (unsigned char)(((x)>>8)&255); \ | | (y)[6] = (unsigned char)(((x)>>8)&255); \ | |
| (y)[7] = (unsigned char)((x)&255); \ | | (y)[7] = (unsigned char)((x)&255); \ | |
| } | | } | |
| | | | |
| #define LOAD64H(x, y) { \ | | #define LOAD64H(x, y) { \ | |
|
| x = (((ulong64)((y)[0] & 255))<<56)|(((ulong64)((y)[1] & 255))<<48)| \ | | x = (((uint64)((y)[0] & 255))<<56)|(((uint64)((y)[1] & 255))<<48)| \ | |
| (((ulong64)((y)[2] & 255))<<40)|(((ulong64)((y)[3] & 255))<<32)| \ | | (((uint64)((y)[2] & 255))<<40)|(((uint64)((y)[3] & 255))<<32)| \ | |
| (((ulong64)((y)[4] & 255))<<24)|(((ulong64)((y)[5] & 255))<<16)| \ | | (((uint64)((y)[4] & 255))<<24)|(((uint64)((y)[5] & 255))<<16)| \ | |
| (((ulong64)((y)[6] & 255))<<8)| (((ulong64)((y)[7] & 255))); \ | | (((uint64)((y)[6] & 255))<<8)| (((uint64)((y)[7] & 255))); \ | |
| } | | } | |
| | | | |
| #else /* 64-bit words then */ | | #else /* 64-bit words then */ | |
| | | | |
| #define STORE32H(x, y) \ | | #define STORE32H(x, y) \ | |
| { unsigned long __t = (x); memcpy(y, &__t, 4); } | | { unsigned long __t = (x); memcpy(y, &__t, 4); } | |
| | | | |
| #define LOAD32H(x, y) \ | | #define LOAD32H(x, y) \ | |
| { memcpy(&(x), y, 4); x &= 0xFFFFFFFF; } | | { memcpy(&(x), y, 4); x &= 0xFFFFFFFF; } | |
| | | | |
| #define STORE64H(x, y) \ | | #define STORE64H(x, y) \ | |
|
| { ulong64 __t = (x); memcpy(y, &__t, 8); } | | { uint64 __t = (x); memcpy(y, &__t, 8); } | |
| | | | |
| #define LOAD64H(x, y) \ | | #define LOAD64H(x, y) \ | |
| { memcpy(&(x), y, 8); } | | { memcpy(&(x), y, 8); } | |
| | | | |
| #endif /* ENDIAN_64BITWORD */ | | #endif /* ENDIAN_64BITWORD */ | |
| #endif /* ENDIAN_BIG */ | | #endif /* ENDIAN_BIG */ | |
|
| | | | |
| | | #ifdef HAVE_NATIVE_INT64 | |
| | | #define ROL64c(x, y) \ | |
| | | ( (((x)<<((uint64)(y)&63)) | \ | |
| | | (((x)&CONST64(0xFFFFFFFFFFFFFFFF))>>((uint64)64-((y)&63)))) & CONST64(0xFFF | |
| | | FFFFFFFFFFFFF)) | |
| | | | |
| | | #define ROR64c(x, y) \ | |
| | | ( ((((x)&CONST64(0xFFFFFFFFFFFFFFFF))>>((uint64)(y)&CONST64(63))) | \ | |
| | | ((x)<<((uint64)(64-((y)&CONST64(63)))))) & CONST64(0xFFFFFFFFFFFFFFFF)) | |
| | | #endif /* HAVE_NATIVE_INT64 */ | |
| /**************************************************************************
****/ | | /**************************************************************************
****/ | |
| | | | |
| /**************************************************************************
****/ | | /**************************************************************************
****/ | |
| /* | | /* | |
| Return the length of padding bytes required for a record of 'LEN' by
tes | | Return the length of padding bytes required for a record of 'LEN' by
tes | |
| The name Pwr2 indicates that calculations will work with 'BLOCKSIZE' | | The name Pwr2 indicates that calculations will work with 'BLOCKSIZE' | |
| that are powers of 2. | | that are powers of 2. | |
| Because of the trailing pad length byte, a length that is a multiple | | Because of the trailing pad length byte, a length that is a multiple | |
| of the pad bytes | | of the pad bytes | |
| */ | | */ | |
| | | | |
End of changes. 14 change blocks. |
| 27 lines changed or deleted | | 47 lines changed or added | |
|
| matrixsslApi.h | | matrixsslApi.h | |
| /* | | /* | |
| * matrixsslApi.h | | * matrixsslApi.h | |
|
| * Release $Name: MATRIXSSL-3-1-4-OPEN $ | | * Release $Name: MATRIXSSL-3-2-1-OPEN $ | |
| * | | * | |
| * Public header file for MatrixSSL | | * Public header file for MatrixSSL | |
| * Implementations interacting with the matrixssl library should | | * Implementations interacting with the matrixssl library should | |
| * only use the APIs and definitions used in this file. | | * only use the APIs and definitions used in this file. | |
| */ | | */ | |
| /* | | /* | |
| * Copyright (c) PeerSec Networks, 2002-2011. All Rights Reserved. | | * Copyright (c) PeerSec Networks, 2002-2011. All Rights Reserved. | |
| * The latest version of this code is available at http://www.matrixssl
.org | | * The latest version of this code is available at http://www.matrixssl
.org | |
| * | | * | |
| * This software is open source; you can redistribute it and/or modify | | * This software is open source; you can redistribute it and/or modify | |
| | | | |
| skipping to change at line 79 | | skipping to change at line 79 | |
| | | | |
| PSPUBLIC void matrixSslDeleteKeys(sslKeys_t *keys); | | PSPUBLIC void matrixSslDeleteKeys(sslKeys_t *keys); | |
| | | | |
| PSPUBLIC void matrixSslDeleteSession(ssl_t *ssl); | | PSPUBLIC void matrixSslDeleteSession(ssl_t *ssl); | |
| | | | |
| PSPUBLIC int32 matrixSslGetReadbuf(ssl_t *ssl, unsigned char **buf); | | PSPUBLIC int32 matrixSslGetReadbuf(ssl_t *ssl, unsigned char **buf); | |
| PSPUBLIC int32 matrixSslGetOutdata(ssl_t *ssl, unsigned char **buf); | | PSPUBLIC int32 matrixSslGetOutdata(ssl_t *ssl, unsigned char **buf); | |
| PSPUBLIC int32 matrixSslGetWritebuf(ssl_t *ssl, unsigned char **buf, | | PSPUBLIC int32 matrixSslGetWritebuf(ssl_t *ssl, unsigned char **buf, | |
| uint32 reqLen); | | uint32 reqLen); | |
| PSPUBLIC int32 matrixSslEncodeWritebuf(ssl_t *ssl, uint32 len); | | PSPUBLIC int32 matrixSslEncodeWritebuf(ssl_t *ssl, uint32 len); | |
|
| | | PSPUBLIC int32 matrixSslEncodeToOutdata(ssl_t *ssl, unsigned char *buf, | |
| | | uint32 len); | |
| PSPUBLIC int32 matrixSslSentData(ssl_t *ssl, uint32 bytes); | | PSPUBLIC int32 matrixSslSentData(ssl_t *ssl, uint32 bytes); | |
| PSPUBLIC int32 matrixSslReceivedData(ssl_t *ssl, uint32 bytes, | | PSPUBLIC int32 matrixSslReceivedData(ssl_t *ssl, uint32 bytes, | |
| unsigned char **ptbuf, uint32 *ptlen); | | unsigned char **ptbuf, uint32 *ptlen); | |
| PSPUBLIC int32 matrixSslProcessedData(ssl_t *ssl, | | PSPUBLIC int32 matrixSslProcessedData(ssl_t *ssl, | |
| unsigned char **ptbuf, uint32 *ptlen); | | unsigned char **ptbuf, uint32 *ptlen); | |
| PSPUBLIC int32 matrixSslEncodeClosureAlert(ssl_t *ssl); | | PSPUBLIC int32 matrixSslEncodeClosureAlert(ssl_t *ssl); | |
| | | | |
| PSPUBLIC int32 matrixSslLoadRsaKeys(sslKeys_t *keys, const char *certFile, | | PSPUBLIC int32 matrixSslLoadRsaKeys(sslKeys_t *keys, const char *certFile, | |
| const char *privFile, const
char *privPass, | | const char *privFile, const
char *privPass, | |
| const char *trustedCAFile); | | const char *trustedCAFile); | |
| | | | |
| skipping to change at line 136 | | skipping to change at line 138 | |
| Server side APIs | | Server side APIs | |
| */ | | */ | |
| PSPUBLIC int32 matrixSslNewServerSession(ssl_t **ssl, sslKeys_t *keys, | | PSPUBLIC int32 matrixSslNewServerSession(ssl_t **ssl, sslKeys_t *keys, | |
| int32 (*certCb)(ssl_t *ssl, psX509Cert_t *ce
rt, int32 alert)); | | int32 (*certCb)(ssl_t *ssl, psX509Cert_t *ce
rt, int32 alert)); | |
| PSPUBLIC int32 matrixSslSetCipherSuiteEnabledStatus(ssl_t *ssl, uint16 ciph
erId, | | PSPUBLIC int32 matrixSslSetCipherSuiteEnabledStatus(ssl_t *ssl, uint16 ciph
erId, | |
| uint32 status); | | uint32 status); | |
| #endif /* USE_SERVER_SIDE_SSL */ | | #endif /* USE_SERVER_SIDE_SSL */ | |
| | | | |
| /**************************************************************************
****/ | | /**************************************************************************
****/ | |
| | | | |
|
| | | /************************************************************************** | |
| | | ****/ | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| } | | } | |
| #endif | | #endif | |
| | | | |
| #endif /* _h_MATRIXSSL */ | | #endif /* _h_MATRIXSSL */ | |
| | | | |
| /**************************************************************************
****/ | | /**************************************************************************
****/ | |
| | | | |
End of changes. 3 change blocks. |
| 1 lines changed or deleted | | 6 lines changed or added | |
|
| matrixsslConfig.h | | matrixsslConfig.h | |
| /* | | /* | |
| * matrixsslConfig.h | | * matrixsslConfig.h | |
|
| * Release $Name: MATRIXSSL-3-1-4-OPEN $ | | * Release $Name: MATRIXSSL-3-2-1-OPEN $ | |
| * | | * | |
| * Configuration settings for building the MatrixSSL library. | | * Configuration settings for building the MatrixSSL library. | |
| */ | | */ | |
| /* | | /* | |
| * Copyright (c) PeerSec Networks, 2002-2011. All Rights Reserved. | | * Copyright (c) PeerSec Networks, 2002-2011. All Rights Reserved. | |
| * The latest version of this code is available at http://www.matrixssl
.org | | * The latest version of this code is available at http://www.matrixssl
.org | |
| * | | * | |
| * This software is open source; you can redistribute it and/or modify | | * This software is open source; you can redistribute it and/or modify | |
| * it under the terms of the GNU General Public License as published by | | * it under the terms of the GNU General Public License as published by | |
| * the Free Software Foundation; either version 2 of the License, or | | * the Free Software Foundation; either version 2 of the License, or | |
| | | | |
| skipping to change at line 48 | | skipping to change at line 48 | |
| | | | |
| /**************************************************************************
****/ | | /**************************************************************************
****/ | |
| /* | | /* | |
| Recommended cipher suites: | | Recommended cipher suites: | |
| | | | |
| Define the following to enable various cipher suites | | Define the following to enable various cipher suites | |
| At least one of these must be defined. If multiple are defined, | | At least one of these must be defined. If multiple are defined, | |
| the handshake will determine which is best for the connection. | | the handshake will determine which is best for the connection. | |
| */ | | */ | |
| #define USE_TLS_RSA_WITH_AES_128_CBC_SHA | | #define USE_TLS_RSA_WITH_AES_128_CBC_SHA | |
|
| #define USE_SSL_RSA_WITH_3DES_EDE_CBC_SHA | | #define USE_TLS_RSA_WITH_AES_256_CBC_SHA | |
| | | /* #define USE_SSL_RSA_WITH_3DES_EDE_CBC_SHA */ | |
| /* #define USE_SSL_RSA_WITH_RC4_128_SHA */ | | /* #define USE_SSL_RSA_WITH_RC4_128_SHA */ | |
| /* #define USE_SSL_RSA_WITH_RC4_128_MD5 */ | | /* #define USE_SSL_RSA_WITH_RC4_128_MD5 */ | |
| | | | |
| /**************************************************************************
****/ | | /**************************************************************************
****/ | |
| /* | | /* | |
| These cipher suites do not combine authentication and encryption and | | These cipher suites do not combine authentication and encryption and | |
| are not recommended for use-cases that require strong security | | are not recommended for use-cases that require strong security | |
| */ | | */ | |
| /* #define USE_SSL_RSA_WITH_NULL_SHA */ | | /* #define USE_SSL_RSA_WITH_NULL_SHA */ | |
| /* #define USE_SSL_RSA_WITH_NULL_MD5 */ | | /* #define USE_SSL_RSA_WITH_NULL_MD5 */ | |
| | | | |
| /**************************************************************************
****/ | | /**************************************************************************
****/ | |
| /* | | /* | |
| Support for TLS protocols. | | Support for TLS protocols. | |
|
| TLS versions must 'stack' (can't support 1.1 without 1.0) | | | |
| | | - SSLv3 is always on unless disabled | |
| | | - TLS versions must 'stack' (can't support 1.1 without 1.0) | |
| */ | | */ | |
|
| #define USE_TLS /* TLS 1.0 */ | | #define USE_TLS /* TLS 1.0 aka SSL 3.1 */ | |
| | | #define USE_TLS_1_1 | |
| | | | |
| | | /* #define DISABLE_SSLV3 */ /* Disable SSL 3.0 */ | |
| | | | |
| /**************************************************************************
****/ | | /**************************************************************************
****/ | |
| /* | | /* | |
| Compile time support for server or client side SSL | | Compile time support for server or client side SSL | |
| */ | | */ | |
| #define USE_CLIENT_SIDE_SSL | | #define USE_CLIENT_SIDE_SSL | |
| #define USE_SERVER_SIDE_SSL | | #define USE_SERVER_SIDE_SSL | |
| | | | |
| /**************************************************************************
****/ | | /**************************************************************************
****/ | |
| /* | | /* | |
|
| The initial buffer size for send and receive buffers in each ssl_t s
ession. | | The initial buffer sizes for send and receive buffers in each ssl_t
session. | |
| Buffers are internally grown if more incoming or outgoing data stora
ge is | | Buffers are internally grown if more incoming or outgoing data stora
ge is | |
| needed, up to a maximum of SSL_MAX_BUF_SIZE. Once the memory used by
the | | needed, up to a maximum of SSL_MAX_BUF_SIZE. Once the memory used by
the | |
|
| buffer again drops below SSL_DEFAULT_BUF_SIZE, the buffer will be re
duced | | buffer again drops below SSL_DEFAULT_X_BUF_SIZE, the buffer will be
reduced | |
| to this size. Most standard SSL handshakes require on the order of 1
024 B. | | to this size. Most standard SSL handshakes require on the order of 1
024 B. | |
| | | | |
|
| SSL_DEFAULT_BUF_SIZE value in bytes, maximum SSL_MAX_BUF_SIZE | | SSL_DEFAULT_X_BUF_SIZE value in bytes, maximum SSL_MAX_BUF_SIZE | |
| */ | | */ | |
|
| #define SSL_DEFAULT_BUF_SIZE 256 /* Baseline send/recv buf si | | #define SSL_DEFAULT_IN_BUF_SIZE 1500 /* Baseline | |
| ze */ | | recv buf size */ | |
| | | #define SSL_DEFAULT_OUT_BUF_SIZE 1500 /* Baseline | |
| | | send buf size */ | |
| | | | |
| /**************************************************************************
****/ | | /**************************************************************************
****/ | |
| /* | | /* | |
| If SERVER you may define the number of sessions to cache and how | | If SERVER you may define the number of sessions to cache and how | |
| long a session will remain valid in the cache from first access. | | long a session will remain valid in the cache from first access. | |
| | | | |
| Session caching enables very fast "session resumption handshakes". S
ession | | Session caching enables very fast "session resumption handshakes". S
ession | |
| caching can effectively by disabled by setting SSL_SESSION_ENTRY_LIF
E to 0 | | caching can effectively by disabled by setting SSL_SESSION_ENTRY_LIF
E to 0 | |
| | | | |
| SSL_SESSION_TABLE_SIZE minimum value is 1 | | SSL_SESSION_TABLE_SIZE minimum value is 1 | |
| | | | |
End of changes. 8 change blocks. |
| 9 lines changed or deleted | | 17 lines changed or added | |
|
| matrixssllib.h | | matrixssllib.h | |
| /* | | /* | |
| * matrixssllib.h | | * matrixssllib.h | |
|
| * Release $Name: MATRIXSSL-3-1-4-OPEN $ | | * Release $Name: MATRIXSSL-3-2-1-OPEN $ | |
| * | | * | |
| * Internal header file used for the MatrixSSL implementation. | | * Internal header file used for the MatrixSSL implementation. | |
| * Only modifiers of the library should be intersted in this file | | * Only modifiers of the library should be intersted in this file | |
| */ | | */ | |
| /* | | /* | |
| * Copyright (c) PeerSec Networks, 2002-2011. All Rights Reserved. | | * Copyright (c) PeerSec Networks, 2002-2011. All Rights Reserved. | |
| * The latest version of this code is available at http://www.matrixssl
.org | | * The latest version of this code is available at http://www.matrixssl
.org | |
| * | | * | |
| * This software is open source; you can redistribute it and/or modify | | * This software is open source; you can redistribute it and/or modify | |
| * it under the terms of the GNU General Public License as published by | | * it under the terms of the GNU General Public License as published by | |
| | | | |
| skipping to change at line 42 | | skipping to change at line 42 | |
| | | | |
| #ifndef _h_MATRIXSSLLIB | | #ifndef _h_MATRIXSSLLIB | |
| #define _h_MATRIXSSLLIB | | #define _h_MATRIXSSLLIB | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| extern "C" { | | extern "C" { | |
| #endif | | #endif | |
| | | | |
| /**************************************************************************
***/ | | /**************************************************************************
***/ | |
| /* | | /* | |
|
| Start with compile-time checks for the necessary crypto support. | | Start with compile-time checks for the necessary proto and crypto su
pport. | |
| */ | | */ | |
|
| | | #if !defined(USE_TLS) && defined(DISABLE_SSLV3) | |
| | | #error "Must enable a protocol: USE_TLS enabled or DISABLE_SSLV3 disabled" | |
| | | #endif | |
| | | | |
| | | #if defined(USE_TLS_1_1) && !defined(USE_TLS) | |
| | | #error "Must define USE_TLS if defining USE_TLS_1_1" | |
| | | #endif | |
| | | | |
| /**************************************************************************
****/ | | /**************************************************************************
****/ | |
| /* | | /* | |
| SHA1 and MD5 are essential elements for SSL key derivation during pr
otocol | | SHA1 and MD5 are essential elements for SSL key derivation during pr
otocol | |
| */ | | */ | |
| #if !defined USE_MD5 || !defined USE_SHA1 | | #if !defined USE_MD5 || !defined USE_SHA1 | |
| #error "Must enable both USE_MD5 and USE_SHA1 in cryptoConfig.h for MatrixS
SL" | | #error "Must enable both USE_MD5 and USE_SHA1 in cryptoConfig.h for MatrixS
SL" | |
| #endif | | #endif | |
| | | | |
| #if !defined USE_CLIENT_SIDE_SSL && !defined USE_SERVER_SIDE_SSL | | #if !defined USE_CLIENT_SIDE_SSL && !defined USE_SERVER_SIDE_SSL | |
| #error "Must enable either USE_CLIENT_SIDE_SSL or USE_SERVER_SIDE_SSL (or b
oth)" | | #error "Must enable either USE_CLIENT_SIDE_SSL or USE_SERVER_SIDE_SSL (or b
oth)" | |
| | | | |
| skipping to change at line 260 | | skipping to change at line 268 | |
| #define SSL_ALERT_UNSUPPORTED_EXTENSION 110 | | #define SSL_ALERT_UNSUPPORTED_EXTENSION 110 | |
| | | | |
| /* | | /* | |
| Use as return code in user validation callback to allow | | Use as return code in user validation callback to allow | |
| anonymous connections to proceed. | | anonymous connections to proceed. | |
| MUST NOT OVERLAP WITH ANY OF THE ALERT CODES ABOVE | | MUST NOT OVERLAP WITH ANY OF THE ALERT CODES ABOVE | |
| */ | | */ | |
| #define SSL_ALLOW_ANON_CONNECTION 254 | | #define SSL_ALLOW_ANON_CONNECTION 254 | |
| | | | |
| /* | | /* | |
|
| Flags. DO NOT TOUCH | | Internal flags for ssl_t.flags field. | |
| */ | | */ | |
|
| #define SSL_FLAGS_SERVER 0x1 | | #define SSL_FLAGS_SERVER 0x000001 | |
| #define SSL_FLAGS_READ_SECURE 0x2 | | #define SSL_FLAGS_READ_SECURE 0x000002 | |
| #define SSL_FLAGS_WRITE_SECURE 0x4 | | #define SSL_FLAGS_WRITE_SECURE 0x000004 | |
| #define SSL_FLAGS_RESUMED 0x8 | | #define SSL_FLAGS_RESUMED 0x000008 | |
| #define SSL_FLAGS_CLOSED 0x10 | | #define SSL_FLAGS_CLOSED 0x000010 | |
| #define SSL_FLAGS_NEED_ENCODE 0x20 | | #define SSL_FLAGS_NEED_ENCODE 0x000020 | |
| #define SSL_FLAGS_ERROR 0x40 | | #define SSL_FLAGS_ERROR 0x000040 | |
| #define SSL_FLAGS_TLS 0x80 | | #define SSL_FLAGS_TLS 0x000080 | |
| #define SSL_FLAGS_CLIENT_AUTH 0x100 | | #define SSL_FLAGS_CLIENT_AUTH 0x000100 | |
| #define SSL_FLAGS_ANON_CIPHER 0x200 | | #define SSL_FLAGS_ANON_CIPHER 0x000200 | |
| #define SSL_FLAGS_FALSE_START 0x400 | | #define SSL_FLAGS_FALSE_START 0x000400 | |
| | | #define SSL_FLAGS_TLS_1_1 0x000800 | |
| | | | |
| /* | | /* | |
| Buffer flags (ssl->bFlags) | | Buffer flags (ssl->bFlags) | |
| */ | | */ | |
| #define BFLAG_CLOSE_AFTER_SENT 0x01 | | #define BFLAG_CLOSE_AFTER_SENT 0x01 | |
| #define BFLAG_HS_COMPLETE 0x02 | | #define BFLAG_HS_COMPLETE 0x02 | |
| | | | |
| /* | | /* | |
| Cipher types | | Cipher types | |
| */ | | */ | |
| | | | |
| skipping to change at line 465 | | skipping to change at line 474 | |
| #ifdef USE_CLIENT_SIDE_SSL | | #ifdef USE_CLIENT_SIDE_SSL | |
| int32 certMatch; | | int32 certMatch; | |
| #endif /* USE_CLIENT_SIDE_SSL */ | | #endif /* USE_CLIENT_SIDE_SSL */ | |
| | | | |
| psDigestContext_t msgHashMd5; | | psDigestContext_t msgHashMd5; | |
| psDigestContext_t msgHashSha1; | | psDigestContext_t msgHashSha1; | |
| | | | |
| psCipherContext_t encryptCtx; | | psCipherContext_t encryptCtx; | |
| psCipherContext_t decryptCtx; | | psCipherContext_t decryptCtx; | |
| | | | |
|
| | | #ifdef USE_TLS_1_1 | |
| | | int32 explicitIv; | |
| | | #endif /* USE_TLS_1_1 */ | |
| int32 anon; | | int32 anon; | |
| } sslSec_t; | | } sslSec_t; | |
| | | | |
| typedef struct { | | typedef struct { | |
| uint16 ident; /* Official cipher ID */ | | uint16 ident; /* Official cipher ID */ | |
| uint16 type; /* Key exchange method */ | | uint16 type; /* Key exchange method */ | |
| uint32 flags; /* from CRYPTO_FLAGS_* */ | | uint32 flags; /* from CRYPTO_FLAGS_* */ | |
| unsigned char macSize; | | unsigned char macSize; | |
| unsigned char keySize; | | unsigned char keySize; | |
| unsigned char ivSize; | | unsigned char ivSize; | |
| | | | |
| skipping to change at line 602 | | skipping to change at line 614 | |
| Former public APIS in 1.x and 2.x. Now deprecated in 3.x | | Former public APIS in 1.x and 2.x. Now deprecated in 3.x | |
| These functions are still heavily used internally, just no longer pu
blically | | These functions are still heavily used internally, just no longer pu
blically | |
| supported. | | supported. | |
| */ | | */ | |
| extern int32 matrixSslDecode(ssl_t *ssl, unsigned char **buf, uint32 *len, | | extern int32 matrixSslDecode(ssl_t *ssl, unsigned char **buf, uint32 *len, | |
| uint32 size, uint32 *remaini
ng, uint32 *requiredLen, | | uint32 size, uint32 *remaini
ng, uint32 *requiredLen, | |
| int32 *error, unsigned char
*alertLevel, | | int32 *error, unsigned char
*alertLevel, | |
| unsigned char *alertDescript
ion); | | unsigned char *alertDescript
ion); | |
| extern int32 matrixSslEncode(ssl_t *ssl, unsigned char *buf, uint32 size, | | extern int32 matrixSslEncode(ssl_t *ssl, unsigned char *buf, uint32 size, | |
| unsigned char *ptBuf, uint32
*len); | | unsigned char *ptBuf, uint32
*len); | |
|
| extern int32 matrixSslGetEncodedHeaderSize(ssl_t *ssl); | | | |
| extern int32 matrixSslGetEncodedSize(ssl_t *ssl, uint32 len); | | extern int32 matrixSslGetEncodedSize(ssl_t *ssl, uint32 len); | |
| extern void matrixSslSetCertValidator(ssl_t *ssl, | | extern void matrixSslSetCertValidator(ssl_t *ssl, | |
| int32 (*certValidator)(void
*, psX509Cert_t *, int32)); | | int32 (*certValidator)(void
*, psX509Cert_t *, int32)); | |
| extern int32 matrixSslNewSession(ssl_t **ssl, sslKeys_t *keys, | | extern int32 matrixSslNewSession(ssl_t **ssl, sslKeys_t *keys, | |
| sslSessionId_t *session, int
32 flags); | | sslSessionId_t *session, int
32 flags); | |
| extern void matrixSslSetSessionOption(ssl_t *ssl, int32 option,
void *arg); | | extern void matrixSslSetSessionOption(ssl_t *ssl, int32 option,
void *arg); | |
| extern int32 matrixSslHandshakeIsComplete(ssl_t *ssl); | | extern int32 matrixSslHandshakeIsComplete(ssl_t *ssl); | |
| typedef int32 (*sslExtCb_t)(void *, unsigned short, unsigned short, void *
); | | typedef int32 (*sslExtCb_t)(void *, unsigned short, unsigned short, void *
); | |
| | | | |
| /* This used to be prefixed with 'matrix' */ | | /* This used to be prefixed with 'matrix' */ | |
| | | | |
| skipping to change at line 680 | | skipping to change at line 691 | |
| int32 addScsv); | | int32 addScsv); | |
| extern int32 csRsaEncryptPub(psPool_t *pool, psPubKey_t *key, | | extern int32 csRsaEncryptPub(psPool_t *pool, psPubKey_t *key, | |
| unsigned char *in, uint32 inlen, unsigned char *out,
uint32 outlen); | | unsigned char *in, uint32 inlen, unsigned char *out,
uint32 outlen); | |
| extern int32 csRsaDecryptPub(psPool_t *pool, psPubKey_t *key, | | extern int32 csRsaDecryptPub(psPool_t *pool, psPubKey_t *key, | |
| unsigned char *in, uint32 inlen, unsigned char *out,
uint32 outlen); | | unsigned char *in, uint32 inlen, unsigned char *out,
uint32 outlen); | |
| extern int32 csRsaEncryptPriv(psPool_t *pool, psPubKey_t *key, | | extern int32 csRsaEncryptPriv(psPool_t *pool, psPubKey_t *key, | |
| unsigned char *in, uint32 inlen, unsigned char *out,
uint32 outlen); | | unsigned char *in, uint32 inlen, unsigned char *out,
uint32 outlen); | |
| extern int32 csRsaDecryptPriv(psPool_t *pool, psPubKey_t *key, | | extern int32 csRsaDecryptPriv(psPool_t *pool, psPubKey_t *key, | |
| unsigned char *in, uint32 inlen, unsigned char *out,
uint32 outlen); | | unsigned char *in, uint32 inlen, unsigned char *out,
uint32 outlen); | |
| | | | |
|
| | | #ifndef DISABLE_SSLV3 | |
| /**************************************************************************
****/ | | /**************************************************************************
****/ | |
| /* | | /* | |
| sslv3.c | | sslv3.c | |
| */ | | */ | |
| extern int32 sslGenerateFinishedHash(psDigestContext_t *md5, | | extern int32 sslGenerateFinishedHash(psDigestContext_t *md5, | |
| psDigestContext_t *sha1, unsigned char *mast
erSecret, | | psDigestContext_t *sha1, unsigned char *mast
erSecret, | |
| unsigned char *out, int32 sender); | | unsigned char *out, int32 sender); | |
| | | | |
| extern int32 sslDeriveKeys(ssl_t *ssl); | | extern int32 sslDeriveKeys(ssl_t *ssl); | |
| | | | |
| | | | |
| skipping to change at line 701 | | skipping to change at line 713 | |
| extern int32 ssl3HMACSha1(unsigned char *key, unsigned char *seq, | | extern int32 ssl3HMACSha1(unsigned char *key, unsigned char *seq, | |
| unsigned char type, unsigned
char *data, uint32 len, | | unsigned char type, unsigned
char *data, uint32 len, | |
| unsigned char *mac); | | unsigned char *mac); | |
| #endif /* USE_SHA1_MAC */ | | #endif /* USE_SHA1_MAC */ | |
| | | | |
| #ifdef USE_MD5_MAC | | #ifdef USE_MD5_MAC | |
| extern int32 ssl3HMACMd5(unsigned char *key, unsigned char *seq, | | extern int32 ssl3HMACMd5(unsigned char *key, unsigned char *seq, | |
| unsigned char type, unsigned
char *data, uint32 len, | | unsigned char type, unsigned
char *data, uint32 len, | |
| unsigned char *mac); | | unsigned char *mac); | |
| #endif /* USE_MD5_MAC */ | | #endif /* USE_MD5_MAC */ | |
|
| | | #endif /* DISABLE_SSLV3 */ | |
| | | | |
| #ifdef USE_TLS | | #ifdef USE_TLS | |
| /**************************************************************************
****/ | | /**************************************************************************
****/ | |
| /* | | /* | |
| tls.c | | tls.c | |
| */ | | */ | |
| extern int32 tlsDeriveKeys(ssl_t *ssl); | | extern int32 tlsDeriveKeys(ssl_t *ssl); | |
| extern int32 tlsGenerateFinishedHash(psDigestContext_t *md5, | | extern int32 tlsGenerateFinishedHash(psDigestContext_t *md5, | |
| psDigestContext_t *sha1, unsigned char *mast
erSecret, | | psDigestContext_t *sha1, unsigned char *mast
erSecret, | |
| unsigned char *out, int32 sender); | | unsigned char *out, int32 sender); | |
| | | | |
End of changes. 9 change blocks. |
| 15 lines changed or deleted | | 28 lines changed or added | |
|
| osdep.h | | osdep.h | |
| /* | | /* | |
| * osdep.h | | * osdep.h | |
| * Operating System and Hardware Abstraction Layer | | * Operating System and Hardware Abstraction Layer | |
|
| * Release $Name: MATRIXSSL-3-1-4-OPEN $ | | * Release $Name: MATRIXSSL-3-2-1-OPEN $ | |
| */ | | */ | |
| /* | | /* | |
| * Copyright (c) PeerSec Networks, 2002-2011. All Rights Reserved. | | * Copyright (c) PeerSec Networks, 2002-2011. All Rights Reserved. | |
| * The latest version of this code is available at http://www.matrixssl
.org | | * The latest version of this code is available at http://www.matrixssl
.org | |
| * | | * | |
| * This software is open source; you can redistribute it and/or modify | | * This software is open source; you can redistribute it and/or modify | |
| * it under the terms of the GNU General Public License as published by | | * it under the terms of the GNU General Public License as published by | |
| * the Free Software Foundation; either version 2 of the License, or | | * the Free Software Foundation; either version 2 of the License, or | |
| * (at your option) any later version. | | * (at your option) any later version. | |
| * | | * | |
| | | | |
| skipping to change at line 61 | | skipping to change at line 61 | |
| /**************************************************************************
****/ | | /**************************************************************************
****/ | |
| /* | | /* | |
| If the Makefile specifies that PeerSec MatrixSSL does not currently hav
e | | If the Makefile specifies that PeerSec MatrixSSL does not currently hav
e | |
| a layer for the given OS, or the port is to "bare metal" hardware, | | a layer for the given OS, or the port is to "bare metal" hardware, | |
| do basic defines here and include externally provided file "matrixos.h"
. | | do basic defines here and include externally provided file "matrixos.h"
. | |
| In addition, if building for such a platform, a C file defining the abo
ve | | In addition, if building for such a platform, a C file defining the abo
ve | |
| functions must be linked with the final executable. | | functions must be linked with the final executable. | |
| */ | | */ | |
| #ifdef PS_UNSUPPORTED_OS | | #ifdef PS_UNSUPPORTED_OS | |
| #define PSPUBLIC extern | | #define PSPUBLIC extern | |
|
| #define likely(x) x | | | |
| #define unlikely(x) x | | | |
| | | | |
| #include "matrixos.h" | | #include "matrixos.h" | |
| #else | | #else | |
| /**************************************************************************
****/ | | /**************************************************************************
****/ | |
| /* | | /* | |
| Supported Platforms below. The implementations of the apis are in | | Supported Platforms below. The implementations of the apis are in | |
| platform specific directories, such as core/POSIX and core/ECOS | | platform specific directories, such as core/POSIX and core/ECOS | |
| | | | |
| POSIX define is used for Linux and Mac OS X | | POSIX define is used for Linux and Mac OS X | |
| */ | | */ | |
| #include <stdio.h> | | #include <stdio.h> | |
| | | | |
| #ifndef POSIX | | #ifndef POSIX | |
| #if defined(LINUX) || defined(OSX) | | #if defined(LINUX) || defined(OSX) | |
| #define POSIX | | #define POSIX | |
| #endif | | #endif | |
| #endif | | #endif | |
| | | | |
|
| /* Branch hints for GCC. */ | | | |
| #ifdef __GNUC__ | | | |
| #define likely(x) __builtin_expect((x), 1) | | | |
| #define unlikely(x) __builtin_expect((x), 0) | | | |
| #else | | | |
| #define likely(x) x | | | |
| #define unlikely(x) x | | | |
| #endif | | | |
| | | | |
| #ifdef POSIX | | #ifdef POSIX | |
| #include <stdint.h> | | #include <stdint.h> | |
| typedef int32_t int32; | | typedef int32_t int32; | |
| typedef uint32_t uint32; | | typedef uint32_t uint32; | |
| typedef int16_t int16; | | typedef int16_t int16; | |
| typedef uint16_t uint16; | | typedef uint16_t uint16; | |
| #ifdef HAVE_NATIVE_INT64 | | #ifdef HAVE_NATIVE_INT64 | |
| typedef int64_t int64; | | typedef int64_t int64; | |
| typedef uint64_t uint64; | | typedef uint64_t uint64; | |
| #endif | | #endif | |
| | | | |
| skipping to change at line 164 | | skipping to change at line 152 | |
| #endif /* !WIN */ | | #endif /* !WIN */ | |
| | | | |
| /**************************************************************************
****/ | | /**************************************************************************
****/ | |
| /* | | /* | |
| Raw trace and error | | Raw trace and error | |
| */ | | */ | |
| PSPUBLIC void _psTrace(char *msg); | | PSPUBLIC void _psTrace(char *msg); | |
| PSPUBLIC void _psTraceInt(char *msg, int32 val); | | PSPUBLIC void _psTraceInt(char *msg, int32 val); | |
| PSPUBLIC void _psTraceStr(char *msg, char *val); | | PSPUBLIC void _psTraceStr(char *msg, char *val); | |
| PSPUBLIC void _psTracePtr(char *message, void *value); | | PSPUBLIC void _psTracePtr(char *message, void *value); | |
|
| | | PSPUBLIC void psTraceBytes(char *tag, unsigned char *p, int l); | |
| | | | |
| PSPUBLIC void _psError(char *msg); | | PSPUBLIC void _psError(char *msg); | |
| PSPUBLIC void _psErrorInt(char *msg, int32 val); | | PSPUBLIC void _psErrorInt(char *msg, int32 val); | |
| PSPUBLIC void _psErrorStr(char *msg, char *val); | | PSPUBLIC void _psErrorStr(char *msg, char *val); | |
| | | | |
| /**************************************************************************
****/ | | /**************************************************************************
****/ | |
| /* | | /* | |
| Core trace | | Core trace | |
| */ | | */ | |
| #ifndef USE_CORE_TRACE | | #ifndef USE_CORE_TRACE | |
| | | | |
| skipping to change at line 190 | | skipping to change at line 179 | |
| #define psTraceStrCore(x, y) _psTraceStr(x, y) | | #define psTraceStrCore(x, y) _psTraceStr(x, y) | |
| #define psTraceIntCore(x, y) _psTraceInt(x, y) | | #define psTraceIntCore(x, y) _psTraceInt(x, y) | |
| #define psTracePtrCore(x, y) _psTracePtr(x, y) | | #define psTracePtrCore(x, y) _psTracePtr(x, y) | |
| #endif /* USE_CORE_TRACE */ | | #endif /* USE_CORE_TRACE */ | |
| | | | |
| /**************************************************************************
****/ | | /**************************************************************************
****/ | |
| /* | | /* | |
| HALT_ON_PS_ERROR define at compile-time determines whether to halt o
n | | HALT_ON_PS_ERROR define at compile-time determines whether to halt o
n | |
| psAssert and psError calls | | psAssert and psError calls | |
| */ | | */ | |
|
| #define psAssert(C) if (likely(C)) ; else \ | | #define psAssert(C) if (C) ; else \ | |
| {halAlert();_psTraceStr("psAssert %s", __FILE__);_psTraceInt(":%d ", __LINE
__);\ | | {halAlert();_psTraceStr("psAssert %s", __FILE__);_psTraceInt(":%d ", __LINE
__);\ | |
| _psError(#C);} | | _psError(#C);} | |
| | | | |
| #define psError(a) \ | | #define psError(a) \ | |
| halAlert();_psTraceStr("psError %s", __FILE__);_psTraceInt(":%d ", __LINE_
_); \ | | halAlert();_psTraceStr("psError %s", __FILE__);_psTraceInt(":%d ", __LINE_
_); \ | |
| _psError(a); | | _psError(a); | |
| | | | |
| #define psErrorStr(a,b) \ | | #define psErrorStr(a,b) \ | |
| halAlert();_psTraceStr("psError %s", __FILE__);_psTraceInt(":%d ", __LINE_
_); \ | | halAlert();_psTraceStr("psError %s", __FILE__);_psTraceInt(":%d ", __LINE_
_); \ | |
| _psErrorStr(a,b) | | _psErrorStr(a,b) | |
| | | | |
End of changes. 5 change blocks. |
| 14 lines changed or deleted | | 3 lines changed or added | |
|