| bignum.h | | bignum.h | |
| | | | |
| skipping to change at line 35 | | skipping to change at line 35 | |
| * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
| */ | | */ | |
| #ifndef POLARSSL_BIGNUM_H | | #ifndef POLARSSL_BIGNUM_H | |
| #define POLARSSL_BIGNUM_H | | #define POLARSSL_BIGNUM_H | |
| | | | |
| #include <stdio.h> | | #include <stdio.h> | |
| #include <string.h> | | #include <string.h> | |
| | | | |
| #include "config.h" | | #include "config.h" | |
| | | | |
|
| | | #ifdef _MSC_VER | |
| | | #include <basetsd.h> | |
| | | typedef INT16 int16_t; | |
| | | typedef UINT16 uint16_t; | |
| | | typedef INT32 int32_t; | |
| | | typedef UINT32 uint32_t; | |
| | | typedef UINT64 uint64_t; | |
| | | #else | |
| | | #include <inttypes.h> | |
| | | #endif | |
| | | | |
| #define POLARSSL_ERR_MPI_FILE_IO_ERROR -0x0002 /**< An
error occurred while reading from or writing to a file. */ | | #define POLARSSL_ERR_MPI_FILE_IO_ERROR -0x0002 /**< An
error occurred while reading from or writing to a file. */ | |
| #define POLARSSL_ERR_MPI_BAD_INPUT_DATA -0x0004 /**< Ba
d input parameters to function. */ | | #define POLARSSL_ERR_MPI_BAD_INPUT_DATA -0x0004 /**< Ba
d input parameters to function. */ | |
| #define POLARSSL_ERR_MPI_INVALID_CHARACTER -0x0006 /**< Th
ere is an invalid character in the digit string. */ | | #define POLARSSL_ERR_MPI_INVALID_CHARACTER -0x0006 /**< Th
ere is an invalid character in the digit string. */ | |
| #define POLARSSL_ERR_MPI_BUFFER_TOO_SMALL -0x0008 /**< Th
e buffer is too small to write to. */ | | #define POLARSSL_ERR_MPI_BUFFER_TOO_SMALL -0x0008 /**< Th
e buffer is too small to write to. */ | |
| #define POLARSSL_ERR_MPI_NEGATIVE_VALUE -0x000A /**< Th
e input arguments are negative or result in illegal output. */ | | #define POLARSSL_ERR_MPI_NEGATIVE_VALUE -0x000A /**< Th
e input arguments are negative or result in illegal output. */ | |
| #define POLARSSL_ERR_MPI_DIVISION_BY_ZERO -0x000C /**< Th
e input argument for division is zero, which is not allowed. */ | | #define POLARSSL_ERR_MPI_DIVISION_BY_ZERO -0x000C /**< Th
e input argument for division is zero, which is not allowed. */ | |
| #define POLARSSL_ERR_MPI_NOT_ACCEPTABLE -0x000E /**< Th
e input arguments are not acceptable. */ | | #define POLARSSL_ERR_MPI_NOT_ACCEPTABLE -0x000E /**< Th
e input arguments are not acceptable. */ | |
| #define POLARSSL_ERR_MPI_MALLOC_FAILED -0x0010 /**< Me
mory allocation failed. */ | | #define POLARSSL_ERR_MPI_MALLOC_FAILED -0x0010 /**< Me
mory allocation failed. */ | |
| | | | |
| #define MPI_CHK(f) if( ( ret = f ) != 0 ) goto cleanup | | #define MPI_CHK(f) if( ( ret = f ) != 0 ) goto cleanup | |
| | | | |
| skipping to change at line 64 | | skipping to change at line 75 | |
| * | | * | |
| * Result is an array of ( 2 << POLARSSL_MPI_WINDOW_SIZE ) MPIs used | | * Result is an array of ( 2 << POLARSSL_MPI_WINDOW_SIZE ) MPIs used | |
| * for the sliding window calculation. (So 64 by default) | | * for the sliding window calculation. (So 64 by default) | |
| * | | * | |
| * Reduction in size, reduces speed. | | * Reduction in size, reduces speed. | |
| */ | | */ | |
| #define POLARSSL_MPI_WINDOW_SIZE 6 /**< Ma
ximum windows size used. */ | | #define POLARSSL_MPI_WINDOW_SIZE 6 /**< Ma
ximum windows size used. */ | |
| | | | |
| /* | | /* | |
| * Maximum size of MPIs allowed in bits and bytes for user-MPIs. | | * Maximum size of MPIs allowed in bits and bytes for user-MPIs. | |
|
| * ( Default: 512 bytes => 4096 bits ) | | * ( Default: 512 bytes => 4096 bits, Maximum: 1024 bytes => 8192 bits ) | |
| * | | * | |
| * Note: Calculations can results temporarily in larger MPIs. So the number | | * Note: Calculations can results temporarily in larger MPIs. So the number | |
| * of limbs required (POLARSSL_MPI_MAX_LIMBS) is higher. | | * of limbs required (POLARSSL_MPI_MAX_LIMBS) is higher. | |
| */ | | */ | |
| #define POLARSSL_MPI_MAX_SIZE 512 /**< Ma
ximum number of bytes for usable MPIs. */ | | #define POLARSSL_MPI_MAX_SIZE 512 /**< Ma
ximum number of bytes for usable MPIs. */ | |
| #define POLARSSL_MPI_MAX_BITS ( 8 * POLARSSL_M
PI_MAX_SIZE ) /**< Maximum number of bits for usable MPIs. */ | | #define POLARSSL_MPI_MAX_BITS ( 8 * POLARSSL_M
PI_MAX_SIZE ) /**< Maximum number of bits for usable MPIs. */ | |
| | | | |
| /* | | /* | |
|
| * When reading from files with mpi_read_file() the buffer should have spac | | * When reading from files with mpi_read_file() and writing to files with | |
| e | | * mpi_write_file() the buffer should have space | |
| * for a (short) label, the MPI (in the provided radix), the newline | | * for a (short) label, the MPI (in the provided radix), the newline | |
| * characters and the '\0'. | | * characters and the '\0'. | |
| * | | * | |
| * By default we assume at least a 10 char label, a minimum radix of 10 | | * By default we assume at least a 10 char label, a minimum radix of 10 | |
| * (decimal) and a maximum of 4096 bit numbers (1234 decimal chars). | | * (decimal) and a maximum of 4096 bit numbers (1234 decimal chars). | |
|
| */ | | * Autosized at compile time for at least a 10 char label, a minimum radix | |
| #define POLARSSL_MPI_READ_BUFFER_SIZE 1250 | | * of 10 (decimal) for a number of POLARSSL_MPI_MAX_BITS size. | |
| | | * | |
| | | * This used to be statically sized to 1250 for a maximum of 4096 bit | |
| | | * numbers (1234 decimal chars). | |
| | | * | |
| | | * Calculate using the formula: | |
| | | * POLARSSL_MPI_RW_BUFFER_SIZE = ceil(POLARSSL_MPI_MAX_BITS / ln(10) * ln( | |
| | | 2)) + | |
| | | * LabelSize + 6 | |
| | | */ | |
| | | #define POLARSSL_MPI_MAX_BITS_SCALE100 ( 100 * POLARSSL_MPI_MAX_BI | |
| | | TS ) | |
| | | #define LN_2_DIV_LN_10_SCALE100 332 | |
| | | #define POLARSSL_MPI_RW_BUFFER_SIZE ( ((POLARSSL_MPI_MAX_BITS_S | |
| | | CALE100 + LN_2_DIV_LN_10_SCALE100 - 1) / LN_2_DIV_LN_10_SCALE100) + 10 + 6 | |
| | | ) | |
| | | | |
| /* | | /* | |
| * Define the base integer type, architecture-wise | | * Define the base integer type, architecture-wise | |
| */ | | */ | |
| #if defined(POLARSSL_HAVE_INT8) | | #if defined(POLARSSL_HAVE_INT8) | |
| typedef signed char t_sint; | | typedef signed char t_sint; | |
| typedef unsigned char t_uint; | | typedef unsigned char t_uint; | |
|
| typedef unsigned short t_udbl; | | typedef uint16_t t_udbl; | |
| | | #define POLARSSL_HAVE_UDBL | |
| #else | | #else | |
| #if defined(POLARSSL_HAVE_INT16) | | #if defined(POLARSSL_HAVE_INT16) | |
|
| typedef signed short t_sint; | | typedef int16_t t_sint; | |
| typedef unsigned short t_uint; | | typedef uint16_t t_uint; | |
| typedef unsigned long t_udbl; | | typedef uint32_t t_udbl; | |
| | | #define POLARSSL_HAVE_UDBL | |
| #else | | #else | |
|
| typedef signed long t_sint; | | #if ( defined(__MSC_VER) && defined(_M_AMD64) ) | |
| typedef unsigned long t_uint; | | typedef int64_t t_sint; | |
| #if defined(_MSC_VER) && defined(_M_IX86) | | typedef uint64_t t_uint; | |
| typedef unsigned __int64 t_udbl; | | | |
| #else | | #else | |
|
| #if defined(__GNUC__) && ( \ | | #if ( defined(__GNUC__) && ( \ | |
| defined(__amd64__) || defined(__x86_64__) || \ | | defined(__amd64__) || defined(__x86_64__) || \ | |
| defined(__ppc64__) || defined(__powerpc64__) || \ | | defined(__ppc64__) || defined(__powerpc64__) || \ | |
| defined(__ia64__) || defined(__alpha__) || \ | | defined(__ia64__) || defined(__alpha__) || \ | |
| (defined(__sparc__) && defined(__arch64__)) || \ | | (defined(__sparc__) && defined(__arch64__)) || \ | |
| defined(__s390x__) ) | | defined(__s390x__) ) ) | |
| typedef unsigned int t_udbl __attribute__((mode(TI))); | | typedef int64_t t_sint; | |
| #define POLARSSL_HAVE_LONGLONG | | typedef uint64_t t_uint; | |
| | | typedef unsigned int t_udbl __attribute__((mode(TI))); | |
| | | #define POLARSSL_HAVE_UDBL | |
| #else | | #else | |
|
| #if defined(POLARSSL_HAVE_LONGLONG) | | typedef int32_t t_sint; | |
| typedef unsigned long long t_udbl; | | typedef uint32_t t_uint; | |
| #endif | | #if ( defined(_MSC_VER) && defined(_M_IX86) ) | |
| | | typedef uint64_t t_udbl; | |
| | | #define POLARSSL_HAVE_UDBL | |
| | | #else | |
| | | #if defined( POLARSSL_HAVE_LONGLONG ) | |
| | | typedef unsigned long long t_udbl; | |
| | | #define POLARSSL_HAVE_UDBL | |
| | | #endif | |
| | | #endif | |
| #endif | | #endif | |
| #endif | | #endif | |
|
| #endif | | #endif /* POLARSSL_HAVE_INT16 */ | |
| #endif | | #endif /* POLARSSL_HAVE_INT8 */ | |
| | | | |
| /** | | /** | |
| * \brief MPI structure | | * \brief MPI structure | |
| */ | | */ | |
| typedef struct | | typedef struct | |
| { | | { | |
| int s; /*!< integer sign */ | | int s; /*!< integer sign */ | |
| size_t n; /*!< total # of limbs */ | | size_t n; /*!< total # of limbs */ | |
| t_uint *p; /*!< pointer to limbs */ | | t_uint *p; /*!< pointer to limbs */ | |
| } | | } | |
| | | | |
| skipping to change at line 187 | | skipping to change at line 221 | |
| * \brief Set value from integer | | * \brief Set value from integer | |
| * | | * | |
| * \param X MPI to set | | * \param X MPI to set | |
| * \param z Value to use | | * \param z Value to use | |
| * | | * | |
| * \return 0 if successful, | | * \return 0 if successful, | |
| * POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation fail
ed | | * POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation fail
ed | |
| */ | | */ | |
| int mpi_lset( mpi *X, t_sint z ); | | int mpi_lset( mpi *X, t_sint z ); | |
| | | | |
|
| /** | | /* | |
| * \brief Get a specific bit from X | | * \brief Get a specific bit from X | |
| * | | * | |
| * \param X MPI to use | | * \param X MPI to use | |
| * \param pos Zero-based index of the bit in X | | * \param pos Zero-based index of the bit in X | |
| * | | * | |
| * \return Either a 0 or a 1 | | * \return Either a 0 or a 1 | |
| */ | | */ | |
|
| int mpi_get_bit( mpi *X, size_t pos ); | | int mpi_get_bit( const mpi *X, size_t pos ); | |
| | | | |
|
| /** | | /* | |
| * \brief Set a bit of X to a specific value of 0 or 1 | | * \brief Set a bit of X to a specific value of 0 or 1 | |
| * | | * | |
| * \note Will grow X if necessary to set a bit to 1 in a not yet | | * \note Will grow X if necessary to set a bit to 1 in a not yet | |
| * existing limb. Will not grow if bit should be set to 0 | | * existing limb. Will not grow if bit should be set to 0 | |
| * | | * | |
| * \param X MPI to use | | * \param X MPI to use | |
| * \param pos Zero-based index of the bit in X | | * \param pos Zero-based index of the bit in X | |
| * \param val The value to set the bit to (0 or 1) | | * \param val The value to set the bit to (0 or 1) | |
| * | | * | |
| * \return 0 if successful, | | * \return 0 if successful, | |
| * POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation fail
ed, | | * POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation fail
ed, | |
| * POLARSSL_ERR_MPI_BAD_INPUT_DATA if val is not 0 or 1 | | * POLARSSL_ERR_MPI_BAD_INPUT_DATA if val is not 0 or 1 | |
| */ | | */ | |
| int mpi_set_bit( mpi *X, size_t pos, unsigned char val ); | | int mpi_set_bit( mpi *X, size_t pos, unsigned char val ); | |
| | | | |
| /** | | /** | |
|
| * \brief Return the number of least significant bits | | * \brief Return the number of zero-bits before the least signific | |
| | | ant | |
| | | * '1' bit | |
| | | * | |
| | | * Note: Thus also the zero-based index of the least significant '1' bit | |
| * | | * | |
| * \param X MPI to use | | * \param X MPI to use | |
| */ | | */ | |
| size_t mpi_lsb( const mpi *X ); | | size_t mpi_lsb( const mpi *X ); | |
| | | | |
| /** | | /** | |
|
| * \brief Return the number of most significant bits | | * \brief Return the number of bits up to and including the most | |
| | | * significant '1' bit' | |
| | | * | |
| | | * Note: Thus also the one-based index of the most significant '1' bit | |
| * | | * | |
| * \param X MPI to use | | * \param X MPI to use | |
| */ | | */ | |
| size_t mpi_msb( const mpi *X ); | | size_t mpi_msb( const mpi *X ); | |
| | | | |
| /** | | /** | |
| * \brief Return the total size in bytes | | * \brief Return the total size in bytes | |
| * | | * | |
| * \param X MPI to use | | * \param X MPI to use | |
| */ | | */ | |
| | | | |
| skipping to change at line 262 | | skipping to change at line 302 | |
| * | | * | |
| * \return 0 if successful, or a POLARSSL_ERR_MPI_XXX error code. | | * \return 0 if successful, or a POLARSSL_ERR_MPI_XXX error code. | |
| * *slen is always updated to reflect the amount | | * *slen is always updated to reflect the amount | |
| * of data that has (or would have) been written. | | * of data that has (or would have) been written. | |
| * | | * | |
| * \note Call this function with *slen = 0 to obtain the | | * \note Call this function with *slen = 0 to obtain the | |
| * minimum required buffer size in *slen. | | * minimum required buffer size in *slen. | |
| */ | | */ | |
| int mpi_write_string( const mpi *X, int radix, char *s, size_t *slen ); | | int mpi_write_string( const mpi *X, int radix, char *s, size_t *slen ); | |
| | | | |
|
| | | #if defined(POLARSSL_FS_IO) | |
| /** | | /** | |
| * \brief Read X from an opened file | | * \brief Read X from an opened file | |
| * | | * | |
| * \param X Destination MPI | | * \param X Destination MPI | |
| * \param radix Input numeric base | | * \param radix Input numeric base | |
| * \param fin Input file handle | | * \param fin Input file handle | |
| * | | * | |
| * \return 0 if successful, POLARSSL_ERR_MPI_BUFFER_TOO_SMALL if | | * \return 0 if successful, POLARSSL_ERR_MPI_BUFFER_TOO_SMALL if | |
| * the file read buffer is too small or a | | * the file read buffer is too small or a | |
| * POLARSSL_ERR_MPI_XXX error code | | * POLARSSL_ERR_MPI_XXX error code | |
| | | | |
| skipping to change at line 288 | | skipping to change at line 329 | |
| * \param p Prefix, can be NULL | | * \param p Prefix, can be NULL | |
| * \param X Source MPI | | * \param X Source MPI | |
| * \param radix Output numeric base | | * \param radix Output numeric base | |
| * \param fout Output file handle (can be NULL) | | * \param fout Output file handle (can be NULL) | |
| * | | * | |
| * \return 0 if successful, or a POLARSSL_ERR_MPI_XXX error code | | * \return 0 if successful, or a POLARSSL_ERR_MPI_XXX error code | |
| * | | * | |
| * \note Set fout == NULL to print X on the console. | | * \note Set fout == NULL to print X on the console. | |
| */ | | */ | |
| int mpi_write_file( const char *p, const mpi *X, int radix, FILE *fout ); | | int mpi_write_file( const char *p, const mpi *X, int radix, FILE *fout ); | |
|
| | | #endif /* POLARSSL_FS_IO */ | |
| | | | |
| /** | | /** | |
| * \brief Import X from unsigned binary data, big endian | | * \brief Import X from unsigned binary data, big endian | |
| * | | * | |
| * \param X Destination MPI | | * \param X Destination MPI | |
| * \param buf Input buffer | | * \param buf Input buffer | |
| * \param buflen Input buffer size | | * \param buflen Input buffer size | |
| * | | * | |
| * \return 0 if successful, | | * \return 0 if successful, | |
| * POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation fail
ed | | * POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation fail
ed | |
| | | | |
End of changes. 17 change blocks. |
| 31 lines changed or deleted | | 77 lines changed or added | |
|
| config.h | | config.h | |
| /** | | /** | |
| * \file config.h | | * \file config.h | |
| * | | * | |
| * \brief Configuration options (set of defines) | | * \brief Configuration options (set of defines) | |
| * | | * | |
|
| * Copyright (C) 2006-2011, Brainspark B.V. | | * Copyright (C) 2006-2012, Brainspark B.V. | |
| * | | * | |
| * This file is part of PolarSSL (http://www.polarssl.org) | | * This file is part of PolarSSL (http://www.polarssl.org) | |
| * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org> | | * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org> | |
| * | | * | |
| * All rights reserved. | | * All rights reserved. | |
| * | | * | |
| * This program is free software; you can redistribute it and/or modify | | * This program is free software; 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 66 | | skipping to change at line 66 | |
| * | | * | |
| * The system uses 16-bit wide native integers. | | * The system uses 16-bit wide native integers. | |
| * | | * | |
| * Uncomment if native integers are 16-bit wide. | | * Uncomment if native integers are 16-bit wide. | |
| #define POLARSSL_HAVE_INT16 | | #define POLARSSL_HAVE_INT16 | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * \def POLARSSL_HAVE_LONGLONG | | * \def POLARSSL_HAVE_LONGLONG | |
| * | | * | |
|
| * The compiler supports the use of long long. | | * The compiler supports the 'long long' type. | |
| * | | * (Only used on 32-bit platforms) | |
| * Uncomment if the compiler supports long long. | | | |
| #define POLARSSL_HAVE_LONGLONG | | | |
| */ | | */ | |
|
| | | #define POLARSSL_HAVE_LONGLONG | |
| | | | |
| /** | | /** | |
| * \def POLARSSL_HAVE_ASM | | * \def POLARSSL_HAVE_ASM | |
| * | | * | |
| * The compiler has support for asm() | | * The compiler has support for asm() | |
| * | | * | |
| * Uncomment to enable the use of assembly code. | | * Uncomment to enable the use of assembly code. | |
| * | | * | |
| * Requires support for asm() in compiler. | | * Requires support for asm() in compiler. | |
| * | | * | |
| | | | |
| skipping to change at line 92 | | skipping to change at line 91 | |
| * library/timing.c | | * library/timing.c | |
| * library/padlock.c | | * library/padlock.c | |
| * include/polarssl/bn_mul.h | | * include/polarssl/bn_mul.h | |
| * | | * | |
| */ | | */ | |
| #define POLARSSL_HAVE_ASM | | #define POLARSSL_HAVE_ASM | |
| | | | |
| /** | | /** | |
| * \def POLARSSL_HAVE_SSE2 | | * \def POLARSSL_HAVE_SSE2 | |
| * | | * | |
|
| * CPI supports SSE2 instruction set. | | * CPU supports SSE2 instruction set. | |
| * | | * | |
| * Uncomment if the CPU supports SSE2 (IA-32 specific). | | * Uncomment if the CPU supports SSE2 (IA-32 specific). | |
| * | | * | |
| #define POLARSSL_HAVE_SSE2 | | #define POLARSSL_HAVE_SSE2 | |
| */ | | */ | |
| /* \} name */ | | /* \} name */ | |
| | | | |
| /** | | /** | |
| * \name SECTION: PolarSSL feature support | | * \name SECTION: PolarSSL feature support | |
| * | | * | |
| | | | |
| skipping to change at line 133 | | skipping to change at line 132 | |
| #define POLARSSL_CIPHER_MODE_CFB | | #define POLARSSL_CIPHER_MODE_CFB | |
| | | | |
| /** | | /** | |
| * \def POLARSSL_CIPHER_MODE_CTR | | * \def POLARSSL_CIPHER_MODE_CTR | |
| * | | * | |
| * Enable Counter Block Cipher mode (CTR) for symmetric ciphers. | | * Enable Counter Block Cipher mode (CTR) for symmetric ciphers. | |
| */ | | */ | |
| #define POLARSSL_CIPHER_MODE_CTR | | #define POLARSSL_CIPHER_MODE_CTR | |
| | | | |
| /** | | /** | |
|
| * \def POLARSSL_DEBUG_MSG | | * \def POLARSSL_CIPHER_NULL_CIPHER | |
| * | | * | |
|
| * Requires: POLARSSL_DEBUG_C | | * Enable NULL cipher. | |
| | | * Warning: Only do so when you know what you are doing. This allows for | |
| | | * encryption or channels without any security! | |
| * | | * | |
|
| * Enable all SSL/TLS debugging messages. | | * Requires POLARSSL_ENABLE_WEAK_CIPHERSUITES as well to enable | |
| | | * the following ciphersuites: | |
| | | * TLS_RSA_WITH_NULL_MD5 | |
| | | * TLS_RSA_WITH_NULL_SHA | |
| | | * TLS_RSA_WITH_NULL_SHA256 | |
| | | * | |
| | | * Uncomment this macro to enable the NULL cipher and ciphersuites | |
| | | #define POLARSSL_CIPHER_NULL_CIPHER | |
| */ | | */ | |
|
| #define POLARSSL_DEBUG_MSG | | | |
| | | | |
| /** | | /** | |
|
| * \def POLARSSL_ERROR_STRERROR_DUMMY | | * \def POLARSSL_ENABLE_WEAK_CIPHERSUITES | |
| | | * | |
| | | * Enable weak ciphersuites in SSL / TLS | |
| | | * Warning: Only do so when you know what you are doing. This allows for | |
| | | * channels without virtually no security at all! | |
| * | | * | |
|
| * Enable a dummy error function to make use of error_strerror() in | | * This enables the following ciphersuites: | |
| * third party libraries easier. | | * TLS_RSA_WITH_DES_CBC_SHA | |
| | | * TLS_DHE_RSA_WITH_DES_CBC_SHA | |
| * | | * | |
|
| * Disable if you run into name conflicts and want to really remove the | | * Uncomment this macro to enable weak ciphersuites | |
| * error_strerror() | | #define POLARSSL_ENABLE_WEAK_CIPHERSUITES | |
| */ | | */ | |
|
| #define POLARSSL_ERROR_STRERROR_DUMMY | | | |
| | | | |
| /** | | /** | |
| * \def POLARSSL_GENPRIME | | * \def POLARSSL_GENPRIME | |
| * | | * | |
| * Requires: POLARSSL_BIGNUM_C, POLARSSL_RSA_C | | * Requires: POLARSSL_BIGNUM_C, POLARSSL_RSA_C | |
| * | | * | |
| * Enable the RSA prime-number generation code. | | * Enable the RSA prime-number generation code. | |
| */ | | */ | |
| #define POLARSSL_GENPRIME | | #define POLARSSL_GENPRIME | |
| | | | |
| | | | |
| skipping to change at line 220 | | skipping to change at line 231 | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * \def POLARSSL_SELF_TEST | | * \def POLARSSL_SELF_TEST | |
| * | | * | |
| * Enable the checkup functions (*_self_test). | | * Enable the checkup functions (*_self_test). | |
| */ | | */ | |
| #define POLARSSL_SELF_TEST | | #define POLARSSL_SELF_TEST | |
| | | | |
| /** | | /** | |
|
| * \def POLARSSL_SSL_DEBUG_ALL | | * \def POLARSSL_SSL_HW_RECORD_ACCEL | |
| * | | * | |
|
| * Enable the debug messages in SSL module for all issues. | | * Enable hooking functions in SSL module for hardware acceleration of | |
| * Debug messages have been disabled in some places to prevent timing | | * individual records. | |
| * attacks due to (unbalanced) debugging function calls. | | | |
| * | | * | |
|
| * If you need all error reporting you should enable this during debugging, | | * Uncomment this macro to enable hooking functions. | |
| * but remove this for production servers that should log as well. | | #define POLARSSL_SSL_HW_RECORD_ACCEL | |
| * | | | |
| * Uncomment this macro to report all debug messages on errors introducing | | | |
| * a timing side-channel. | | | |
| * | | | |
| #define POLARSSL_SSL_DEBUG_ALL | | | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * \def POLARSSL_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION | | * \def POLARSSL_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION | |
| * | | * | |
| * If set, the X509 parser will not break-off when parsing an X509 certific
ate | | * If set, the X509 parser will not break-off when parsing an X509 certific
ate | |
| * and encountering an unknown critical extension. | | * and encountering an unknown critical extension. | |
| * | | * | |
| * Uncomment to prevent an error. | | * Uncomment to prevent an error. | |
| * | | * | |
| #define POLARSSL_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION | | #define POLARSSL_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION | |
| */ | | */ | |
|
| | | | |
| | | /** | |
| | | * \def POLARSSL_ZLIB_SUPPORT | |
| | | * | |
| | | * If set, the SSL/TLS module uses ZLIB to support compression and | |
| | | * decompression of packet data. | |
| | | * | |
| | | * Used in: library/ssl_tls.c | |
| | | * library/ssl_cli.c | |
| | | * library/ssl_srv.c | |
| | | * | |
| | | * This feature requires zlib library and headers to be present. | |
| | | * | |
| | | * Uncomment to enable use of ZLIB | |
| | | #define POLARSSL_ZLIB_SUPPORT | |
| | | */ | |
| /* \} name */ | | /* \} name */ | |
| | | | |
| /** | | /** | |
| * \name SECTION: PolarSSL modules | | * \name SECTION: PolarSSL modules | |
| * | | * | |
| * This section enables or disables entire modules in PolarSSL | | * This section enables or disables entire modules in PolarSSL | |
| * \{ | | * \{ | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * \def POLARSSL_AES_C | | * \def POLARSSL_AES_C | |
| * | | * | |
| * Enable the AES block cipher. | | * Enable the AES block cipher. | |
| * | | * | |
| * Module: library/aes.c | | * Module: library/aes.c | |
| * Caller: library/ssl_tls.c | | * Caller: library/ssl_tls.c | |
| * library/pem.c | | * library/pem.c | |
| * library/ctr_drbg.c | | * library/ctr_drbg.c | |
| * | | * | |
|
| * This module enables the following ciphersuites: | | * This module enables the following ciphersuites (if other requisites are | |
| * SSL_RSA_AES_128_SHA | | * enabled as well): | |
| * SSL_RSA_AES_256_SHA | | * TLS_RSA_WITH_AES_128_CBC_SHA | |
| * SSL_EDH_RSA_AES_256_SHA | | * TLS_RSA_WITH_AES_256_CBC_SHA | |
| * | | * TLS_DHE_RSA_WITH_AES_128_CBC_SHA | |
| * PEM uses AES for decrypting encrypted keys. | | * TLS_DHE_RSA_WITH_AES_256_CBC_SHA | |
| | | * TLS_RSA_WITH_AES_128_CBC_SHA256 | |
| | | * TLS_RSA_WITH_AES_256_CBC_SHA256 | |
| | | * TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 | |
| | | * TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 | |
| | | * TLS_RSA_WITH_AES_128_GCM_SHA256 | |
| | | * TLS_RSA_WITH_AES_256_GCM_SHA384 | |
| */ | | */ | |
| #define POLARSSL_AES_C | | #define POLARSSL_AES_C | |
| | | | |
| /** | | /** | |
| * \def POLARSSL_ARC4_C | | * \def POLARSSL_ARC4_C | |
| * | | * | |
| * Enable the ARCFOUR stream cipher. | | * Enable the ARCFOUR stream cipher. | |
| * | | * | |
| * Module: library/arc4.c | | * Module: library/arc4.c | |
| * Caller: library/ssl_tls.c | | * Caller: library/ssl_tls.c | |
| * | | * | |
| * This module enables the following ciphersuites: | | * This module enables the following ciphersuites: | |
|
| * SSL_RSA_RC4_128_MD5 | | * TLS_RSA_WITH_RC4_128_MD5 | |
| * SSL_RSA_RC4_128_SHA | | * TLS_RSA_WITH_RC4_128_SHA | |
| */ | | */ | |
| #define POLARSSL_ARC4_C | | #define POLARSSL_ARC4_C | |
| | | | |
| /** | | /** | |
| * \def POLARSSL_ASN1_PARSE_C | | * \def POLARSSL_ASN1_PARSE_C | |
| * | | * | |
| * Enable the generic ASN1 parser. | | * Enable the generic ASN1 parser. | |
| * | | * | |
| * Module: library/asn1.c | | * Module: library/asn1.c | |
| * Caller: library/x509parse.c | | * Caller: library/x509parse.c | |
| */ | | */ | |
| #define POLARSSL_ASN1_PARSE_C | | #define POLARSSL_ASN1_PARSE_C | |
| | | | |
| /** | | /** | |
|
| | | * \def POLARSSL_ASN1_WRITE_C | |
| | | * | |
| | | * Enable the generic ASN1 writer. | |
| | | * | |
| | | * Module: library/asn1write.c | |
| | | */ | |
| | | #define POLARSSL_ASN1_WRITE_C | |
| | | | |
| | | /** | |
| * \def POLARSSL_BASE64_C | | * \def POLARSSL_BASE64_C | |
| * | | * | |
| * Enable the Base64 module. | | * Enable the Base64 module. | |
| * | | * | |
| * Module: library/base64.c | | * Module: library/base64.c | |
| * Caller: library/pem.c | | * Caller: library/pem.c | |
| * | | * | |
| * This module is required for PEM support (required by X.509). | | * This module is required for PEM support (required by X.509). | |
| */ | | */ | |
| #define POLARSSL_BASE64_C | | #define POLARSSL_BASE64_C | |
| | | | |
| /** | | /** | |
| * \def POLARSSL_BIGNUM_C | | * \def POLARSSL_BIGNUM_C | |
| * | | * | |
|
| * Enable the multi-precision integer library. | | * Enable the multo-precision integer library. | |
| * | | * | |
| * Module: library/bignum.c | | * Module: library/bignum.c | |
| * Caller: library/dhm.c | | * Caller: library/dhm.c | |
| * library/rsa.c | | * library/rsa.c | |
| * library/ssl_tls.c | | * library/ssl_tls.c | |
| * library/x509parse.c | | * library/x509parse.c | |
| * | | * | |
| * This module is required for RSA and DHM support. | | * This module is required for RSA and DHM support. | |
| */ | | */ | |
| #define POLARSSL_BIGNUM_C | | #define POLARSSL_BIGNUM_C | |
| | | | |
| /** | | /** | |
|
| | | * \def POLARSSL_BLOWFISH_C | |
| | | * | |
| | | * Enable the Blowfish block cipher. | |
| | | * | |
| | | * Module: library/blowfish.c | |
| | | */ | |
| | | #define POLARSSL_BLOWFISH_C | |
| | | | |
| | | /** | |
| * \def POLARSSL_CAMELLIA_C | | * \def POLARSSL_CAMELLIA_C | |
| * | | * | |
| * Enable the Camellia block cipher. | | * Enable the Camellia block cipher. | |
| * | | * | |
| * Module: library/camellia.c | | * Module: library/camellia.c | |
| * Caller: library/ssl_tls.c | | * Caller: library/ssl_tls.c | |
| * | | * | |
|
| * This module enabled the following cipher suites: | | * This module enables the following ciphersuites (if other requisites are | |
| * SSL_RSA_CAMELLIA_128_SHA | | * enabled as well): | |
| * SSL_RSA_CAMELLIA_256_SHA | | * TLS_RSA_WITH_CAMELLIA_128_CBC_SHA | |
| * SSL_EDH_RSA_CAMELLIA_256_SHA | | * TLS_RSA_WITH_CAMELLIA_256_CBC_SHA | |
| | | * TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA | |
| | | * TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA | |
| | | * TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 | |
| | | * TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 | |
| | | * TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 | |
| | | * TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 | |
| */ | | */ | |
| #define POLARSSL_CAMELLIA_C | | #define POLARSSL_CAMELLIA_C | |
| | | | |
| /** | | /** | |
| * \def POLARSSL_CERTS_C | | * \def POLARSSL_CERTS_C | |
| * | | * | |
| * Enable the test certificates. | | * Enable the test certificates. | |
| * | | * | |
| * Module: library/certs.c | | * Module: library/certs.c | |
| * Caller: | | * Caller: | |
| | | | |
| skipping to change at line 397 | | skipping to change at line 448 | |
| * This module provides debugging functions. | | * This module provides debugging functions. | |
| */ | | */ | |
| #define POLARSSL_DEBUG_C | | #define POLARSSL_DEBUG_C | |
| | | | |
| /** | | /** | |
| * \def POLARSSL_DES_C | | * \def POLARSSL_DES_C | |
| * | | * | |
| * Enable the DES block cipher. | | * Enable the DES block cipher. | |
| * | | * | |
| * Module: library/des.c | | * Module: library/des.c | |
|
| * Caller: library/pem.c | | * Caller: library/ssl_tls.c | |
| * library/ssl_tls.c | | | |
| * | | | |
| * This module enables the following ciphersuites: | | | |
| * SSL_RSA_DES_168_SHA | | | |
| * SSL_EDH_RSA_DES_168_SHA | | | |
| * | | * | |
|
| * PEM uses DES/3DES for decrypting encrypted keys. | | * This module enables the following ciphersuites (if other requisites are | |
| | | * enabled as well): | |
| | | * TLS_RSA_WITH_3DES_EDE_CBC_SHA | |
| | | * TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA | |
| */ | | */ | |
| #define POLARSSL_DES_C | | #define POLARSSL_DES_C | |
| | | | |
| /** | | /** | |
| * \def POLARSSL_DHM_C | | * \def POLARSSL_DHM_C | |
| * | | * | |
| * Enable the Diffie-Hellman-Merkle key exchange. | | * Enable the Diffie-Hellman-Merkle key exchange. | |
| * | | * | |
| * Module: library/dhm.c | | * Module: library/dhm.c | |
| * Caller: library/ssl_cli.c | | * Caller: library/ssl_cli.c | |
| * library/ssl_srv.c | | * library/ssl_srv.c | |
| * | | * | |
|
| * This module enables the following ciphersuites: | | * This module enables the following ciphersuites (if other requisites are | |
| * SSL_EDH_RSA_DES_168_SHA | | * enabled as well): | |
| * SSL_EDH_RSA_AES_256_SHA | | * TLS_DHE_RSA_WITH_DES_CBC_SHA | |
| * SSL_EDH_RSA_CAMELLIA_256_SHA | | * TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA | |
| | | * TLS_DHE_RSA_WITH_AES_128_CBC_SHA | |
| | | * TLS_DHE_RSA_WITH_AES_256_CBC_SHA | |
| | | * TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 | |
| | | * TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 | |
| | | * TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA | |
| | | * TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA | |
| | | * TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 | |
| | | * TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 | |
| | | * TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 | |
| | | * TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 | |
| */ | | */ | |
| #define POLARSSL_DHM_C | | #define POLARSSL_DHM_C | |
| | | | |
| /** | | /** | |
| * \def POLARSSL_ENTROPY_C | | * \def POLARSSL_ENTROPY_C | |
| * | | * | |
| * Enable the platform-specific entropy code. | | * Enable the platform-specific entropy code. | |
| * | | * | |
| * Module: library/entropy.c | | * Module: library/entropy.c | |
| * Caller: | | * Caller: | |
| | | | |
| skipping to change at line 451 | | skipping to change at line 510 | |
| * Enable error code to error string conversion. | | * Enable error code to error string conversion. | |
| * | | * | |
| * Module: library/error.c | | * Module: library/error.c | |
| * Caller: | | * Caller: | |
| * | | * | |
| * This module enables err_strerror(). | | * This module enables err_strerror(). | |
| */ | | */ | |
| #define POLARSSL_ERROR_C | | #define POLARSSL_ERROR_C | |
| | | | |
| /** | | /** | |
|
| * \def POLARSSL_HAVEGE_C | | * \def POLARSSL_GCM_C | |
| * | | * | |
|
| * Enable the HAVEGE random generator. | | * Enable the Galois/Counter Mode (GCM) for AES | |
| * | | * | |
|
| * Warning: the HAVEGE random generator is not suitable for virtualized | | * Module: library/gcm.c | |
| * environments | | | |
| * | | * | |
|
| * Warning: the HAVEGE random generator is dependent on timing and specific | | * Requires: POLARSSL_AES_C | |
| * processor traits. It is therefore not advised to use HAVEGE as | | * | |
| * your applications primary random generator or primary entropy p | | * This module enables the following ciphersuites (if other requisites are | |
| ool | | * enabled as well): | |
| * input. As a secondary input to your entropy pool, it IS able ad | | * TLS_RSA_WITH_AES_128_GCM_SHA256 | |
| d | | * TLS_RSA_WITH_AES_256_GCM_SHA384 | |
| * the (limited) extra entropy it provides. | | */ | |
| | | #define POLARSSL_GCM_C | |
| | | | |
| | | /** | |
| | | * \def POLARSSL_HAVEGE_C | |
| | | * | |
| | | * Enable the HAVEGE random generator. | |
| * | | * | |
| * Module: library/havege.c | | * Module: library/havege.c | |
| * Caller: | | * Caller: | |
| * | | * | |
| * Requires: POLARSSL_TIMING_C | | * Requires: POLARSSL_TIMING_C | |
| * | | * | |
|
| * Uncomment to enable the HAVEGE random generator. | | * This module enables the HAVEGE random number generator. | |
| #define POLARSSL_HAVEGE_C | | | |
| */ | | */ | |
|
| | | #define POLARSSL_HAVEGE_C | |
| | | | |
| /** | | /** | |
| * \def POLARSSL_MD_C | | * \def POLARSSL_MD_C | |
| * | | * | |
| * Enable the generic message digest layer. | | * Enable the generic message digest layer. | |
| * | | * | |
| * Module: library/md.c | | * Module: library/md.c | |
| * Caller: | | * Caller: | |
| * | | * | |
| * Uncomment to enable generic message digest wrappers. | | * Uncomment to enable generic message digest wrappers. | |
| | | | |
| skipping to change at line 517 | | skipping to change at line 583 | |
| * | | * | |
| #define POLARSSL_MD4_C | | #define POLARSSL_MD4_C | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * \def POLARSSL_MD5_C | | * \def POLARSSL_MD5_C | |
| * | | * | |
| * Enable the MD5 hash algorithm | | * Enable the MD5 hash algorithm | |
| * | | * | |
| * Module: library/md5.c | | * Module: library/md5.c | |
|
| * Caller: library/pem.c | | * Caller: library/ssl_tls.c | |
| * library/ssl_tls.c | | | |
| * library/x509parse.c | | * library/x509parse.c | |
| * | | * | |
| * This module is required for SSL/TLS and X.509. | | * This module is required for SSL/TLS and X.509. | |
|
| * PEM uses MD5 for decrypting encrypted keys. | | | |
| */ | | */ | |
| #define POLARSSL_MD5_C | | #define POLARSSL_MD5_C | |
| | | | |
| /** | | /** | |
| * \def POLARSSL_NET_C | | * \def POLARSSL_NET_C | |
| * | | * | |
| * Enable the TCP/IP networking routines. | | * Enable the TCP/IP networking routines. | |
| * | | * | |
| * Module: library/net.c | | * Module: library/net.c | |
| * Caller: | | * Caller: | |
| | | | |
| skipping to change at line 551 | | skipping to change at line 615 | |
| * Enable VIA Padlock support on x86. | | * Enable VIA Padlock support on x86. | |
| * | | * | |
| * Module: library/padlock.c | | * Module: library/padlock.c | |
| * Caller: library/aes.c | | * Caller: library/aes.c | |
| * | | * | |
| * This modules adds support for the VIA PadLock on x86. | | * This modules adds support for the VIA PadLock on x86. | |
| */ | | */ | |
| #define POLARSSL_PADLOCK_C | | #define POLARSSL_PADLOCK_C | |
| | | | |
| /** | | /** | |
|
| | | * \def POLARSSL_PBKDF2_C | |
| | | * | |
| | | * Enable PKCS#5 PBKDF2 key derivation function | |
| | | * | |
| | | * Module: library/pbkdf2.c | |
| | | * | |
| | | * Requires: POLARSSL_MD_C | |
| | | * | |
| | | * This module adds support for the PKCS#5 PBKDF2 key derivation function. | |
| | | #define POLARSSL_PBKDF2_C | |
| | | */ | |
| | | | |
| | | /** | |
| * \def POLARSSL_PEM_C | | * \def POLARSSL_PEM_C | |
| * | | * | |
| * Enable PEM decoding | | * Enable PEM decoding | |
| * | | * | |
| * Module: library/pem.c | | * Module: library/pem.c | |
| * Caller: library/x509parse.c | | * Caller: library/x509parse.c | |
| * | | * | |
| * Requires: POLARSSL_BASE64_C | | * Requires: POLARSSL_BASE64_C | |
| * | | * | |
| * This modules adds support for decoding PEM files. | | * This modules adds support for decoding PEM files. | |
| */ | | */ | |
| #define POLARSSL_PEM_C | | #define POLARSSL_PEM_C | |
| | | | |
| /** | | /** | |
| * \def POLARSSL_PKCS11_C | | * \def POLARSSL_PKCS11_C | |
| * | | * | |
|
| * Enable support for PKCS#11 smartcard support. | | * Enable wrapper for PKCS#11 smartcard support. | |
| * | | * | |
| * Module: library/ssl_srv.c | | * Module: library/ssl_srv.c | |
| * Caller: library/ssl_cli.c | | * Caller: library/ssl_cli.c | |
| * library/ssl_srv.c | | * library/ssl_srv.c | |
| * | | * | |
| * Requires: POLARSSL_SSL_TLS_C | | * Requires: POLARSSL_SSL_TLS_C | |
| * | | * | |
|
| * This module is required for SSL/TLS PKCS #11 smartcard support. | | * This module enables SSL/TLS PKCS #11 smartcard support. | |
| * Requires the presence of the PKCS#11 helper library (libpkcs11-helper) | | * Requires the presence of the PKCS#11 helper library (libpkcs11-helper) | |
| #define POLARSSL_PKCS11_C | | #define POLARSSL_PKCS11_C | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * \def POLARSSL_RSA_C | | * \def POLARSSL_RSA_C | |
| * | | * | |
| * Enable the RSA public-key cryptosystem. | | * Enable the RSA public-key cryptosystem. | |
| * | | * | |
| * Module: library/rsa.c | | * Module: library/rsa.c | |
| | | | |
| skipping to change at line 639 | | skipping to change at line 716 | |
| * | | * | |
| * Module: library/sha4.c | | * Module: library/sha4.c | |
| * Caller: library/md_wrap.c | | * Caller: library/md_wrap.c | |
| * library/x509parse.c | | * library/x509parse.c | |
| * | | * | |
| * This module adds support for SHA-384 and SHA-512. | | * This module adds support for SHA-384 and SHA-512. | |
| */ | | */ | |
| #define POLARSSL_SHA4_C | | #define POLARSSL_SHA4_C | |
| | | | |
| /** | | /** | |
|
| | | * \def POLARSSL_SSL_CACHE_C | |
| | | * | |
| | | * Enable simple SSL cache implementation. | |
| | | * | |
| | | * Module: library/ssl_cache.c | |
| | | * Caller: | |
| | | * | |
| | | * Requires: POLARSSL_SSL_CACHE_C | |
| | | */ | |
| | | #define POLARSSL_SSL_CACHE_C | |
| | | | |
| | | /** | |
| * \def POLARSSL_SSL_CLI_C | | * \def POLARSSL_SSL_CLI_C | |
| * | | * | |
| * Enable the SSL/TLS client code. | | * Enable the SSL/TLS client code. | |
| * | | * | |
| * Module: library/ssl_cli.c | | * Module: library/ssl_cli.c | |
| * Caller: | | * Caller: | |
| * | | * | |
| * Requires: POLARSSL_SSL_TLS_C | | * Requires: POLARSSL_SSL_TLS_C | |
| * | | * | |
| * This module is required for SSL/TLS client support. | | * This module is required for SSL/TLS client support. | |
| */ | | */ | |
| #define POLARSSL_SSL_CLI_C | | #define POLARSSL_SSL_CLI_C | |
| | | | |
|
| /** | | /* | |
| * \def POLARSSL_SSL_SRV_C | | * \def POLARSSL_SSL_SRV_C | |
| * | | * | |
| * Enable the SSL/TLS server code. | | * Enable the SSL/TLS server code. | |
| * | | * | |
| * Module: library/ssl_srv.c | | * Module: library/ssl_srv.c | |
| * Caller: | | * Caller: | |
| * | | * | |
| * Requires: POLARSSL_SSL_TLS_C | | * Requires: POLARSSL_SSL_TLS_C | |
| * | | * | |
| * This module is required for SSL/TLS server support. | | * This module is required for SSL/TLS server support. | |
| | | | |
| skipping to change at line 721 | | skipping to change at line 810 | |
| * library/ssl_srv.c | | * library/ssl_srv.c | |
| * library/ssl_tls.c | | * library/ssl_tls.c | |
| * | | * | |
| * Requires: POLARSSL_ASN1_PARSE_C, POLARSSL_BIGNUM_C, POLARSSL_RSA_C | | * Requires: POLARSSL_ASN1_PARSE_C, POLARSSL_BIGNUM_C, POLARSSL_RSA_C | |
| * | | * | |
| * This module is required for X.509 certificate parsing. | | * This module is required for X.509 certificate parsing. | |
| */ | | */ | |
| #define POLARSSL_X509_PARSE_C | | #define POLARSSL_X509_PARSE_C | |
| | | | |
| /** | | /** | |
|
| | | * \def POLARSSL_X509_WRITE_C | |
| | | * | |
| | | * Enable X.509 buffer writing. | |
| | | * | |
| | | * Module: library/x509write.c | |
| | | * | |
| | | * Requires: POLARSSL_BIGNUM_C, POLARSSL_RSA_C | |
| | | * | |
| | | * This module is required for X.509 certificate request writing. | |
| | | */ | |
| | | #define POLARSSL_X509_WRITE_C | |
| | | | |
| | | /** | |
| * \def POLARSSL_XTEA_C | | * \def POLARSSL_XTEA_C | |
| * | | * | |
| * Enable the XTEA block cipher. | | * Enable the XTEA block cipher. | |
| * | | * | |
| * Module: library/xtea.c | | * Module: library/xtea.c | |
| * Caller: | | * Caller: | |
| */ | | */ | |
| #define POLARSSL_XTEA_C | | #define POLARSSL_XTEA_C | |
| /* \} name */ | | /* \} name */ | |
| | | | |
| | | | |
End of changes. 39 change blocks. |
| 70 lines changed or deleted | | 170 lines changed or added | |
|
| ssl.h | | ssl.h | |
| /** | | /** | |
| * \file ssl.h | | * \file ssl.h | |
| * | | * | |
| * \brief SSL/TLS functions. | | * \brief SSL/TLS functions. | |
| * | | * | |
|
| * Copyright (C) 2006-2010, Brainspark B.V. | | * Copyright (C) 2006-2012, Brainspark B.V. | |
| * | | * | |
| * This file is part of PolarSSL (http://www.polarssl.org) | | * This file is part of PolarSSL (http://www.polarssl.org) | |
| * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org> | | * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org> | |
| * | | * | |
| * All rights reserved. | | * All rights reserved. | |
| * | | * | |
| * This program is free software; you can redistribute it and/or modify | | * This program is free software; 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 33 | | skipping to change at line 33 | |
| * You should have received a copy of the GNU General Public License along | | * You should have received a copy of the GNU General Public License along | |
| * with this program; if not, write to the Free Software Foundation, Inc., | | * with this program; if not, write to the Free Software Foundation, Inc., | |
| * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
| */ | | */ | |
| #ifndef POLARSSL_SSL_H | | #ifndef POLARSSL_SSL_H | |
| #define POLARSSL_SSL_H | | #define POLARSSL_SSL_H | |
| | | | |
| #include <time.h> | | #include <time.h> | |
| | | | |
| #include "net.h" | | #include "net.h" | |
|
| #include "dhm.h" | | | |
| #include "rsa.h" | | #include "rsa.h" | |
| #include "md5.h" | | #include "md5.h" | |
| #include "sha1.h" | | #include "sha1.h" | |
|
| | | #include "sha2.h" | |
| | | #include "sha4.h" | |
| #include "x509.h" | | #include "x509.h" | |
| #include "config.h" | | #include "config.h" | |
| | | | |
|
| #if defined(POLARSSL_PKCS11_C) | | #if defined(POLARSSL_DHM_C) | |
| #include "pkcs11.h" | | #include "dhm.h" | |
| | | #endif | |
| | | | |
| | | #if defined(POLARSSL_ZLIB_SUPPORT) | |
| | | #include "zlib.h" | |
| #endif | | #endif | |
| | | | |
| #if defined(_MSC_VER) && !defined(inline) | | #if defined(_MSC_VER) && !defined(inline) | |
| #define inline _inline | | #define inline _inline | |
| #else | | #else | |
| #if defined(__ARMCC_VERSION) && !defined(inline) | | #if defined(__ARMCC_VERSION) && !defined(inline) | |
| #define inline __inline | | #define inline __inline | |
| #endif /* __ARMCC_VERSION */ | | #endif /* __ARMCC_VERSION */ | |
| #endif /*_MSC_VER */ | | #endif /*_MSC_VER */ | |
| | | | |
| | | | |
| skipping to change at line 85 | | skipping to change at line 90 | |
| #define POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST -0x7A80 /**< Pr
ocessing of the CertificateRequest handshake message failed. */ | | #define POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST -0x7A80 /**< Pr
ocessing of the CertificateRequest handshake message failed. */ | |
| #define POLARSSL_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE -0x7B00 /**< Pr
ocessing of the ServerKeyExchange handshake message failed. */ | | #define POLARSSL_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE -0x7B00 /**< Pr
ocessing of the ServerKeyExchange handshake message failed. */ | |
| #define POLARSSL_ERR_SSL_BAD_HS_SERVER_HELLO_DONE -0x7B80 /**< Pr
ocessing of the ServerHelloDone handshake message failed. */ | | #define POLARSSL_ERR_SSL_BAD_HS_SERVER_HELLO_DONE -0x7B80 /**< Pr
ocessing of the ServerHelloDone handshake message failed. */ | |
| #define POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE -0x7C00 /**< Pr
ocessing of the ClientKeyExchange handshake message failed. */ | | #define POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE -0x7C00 /**< Pr
ocessing of the ClientKeyExchange handshake message failed. */ | |
| #define POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_DHM_RP -0x7C80 /**< Pr
ocessing of the ClientKeyExchange handshake message failed in DHM Read Publ
ic. */ | | #define POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_DHM_RP -0x7C80 /**< Pr
ocessing of the ClientKeyExchange handshake message failed in DHM Read Publ
ic. */ | |
| #define POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_DHM_CS -0x7D00 /**< Pr
ocessing of the ClientKeyExchange handshake message failed in DHM Calculate
Secret. */ | | #define POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_DHM_CS -0x7D00 /**< Pr
ocessing of the ClientKeyExchange handshake message failed in DHM Calculate
Secret. */ | |
| #define POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY -0x7D80 /**< Pr
ocessing of the CertificateVerify handshake message failed. */ | | #define POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY -0x7D80 /**< Pr
ocessing of the CertificateVerify handshake message failed. */ | |
| #define POLARSSL_ERR_SSL_BAD_HS_CHANGE_CIPHER_SPEC -0x7E00 /**< Pr
ocessing of the ChangeCipherSpec handshake message failed. */ | | #define POLARSSL_ERR_SSL_BAD_HS_CHANGE_CIPHER_SPEC -0x7E00 /**< Pr
ocessing of the ChangeCipherSpec handshake message failed. */ | |
| #define POLARSSL_ERR_SSL_BAD_HS_FINISHED -0x7E80 /**< Pr
ocessing of the Finished handshake message failed. */ | | #define POLARSSL_ERR_SSL_BAD_HS_FINISHED -0x7E80 /**< Pr
ocessing of the Finished handshake message failed. */ | |
| #define POLARSSL_ERR_SSL_MALLOC_FAILED -0x7F00 /**< Me
mory allocation failed */ | | #define POLARSSL_ERR_SSL_MALLOC_FAILED -0x7F00 /**< Me
mory allocation failed */ | |
|
| | | #define POLARSSL_ERR_SSL_HW_ACCEL_FAILED -0x7F80 /**< Ha | |
| | | rdware acceleration function returned with error */ | |
| | | #define POLARSSL_ERR_SSL_HW_ACCEL_FALLTHROUGH -0x6F80 /**< Ha | |
| | | rdware acceleration function skipped / left alone data */ | |
| | | #define POLARSSL_ERR_SSL_COMPRESSION_FAILED -0x6F00 /**< Pr | |
| | | ocessing of the compression / decompression failed */ | |
| | | #define POLARSSL_ERR_SSL_BAD_HS_PROTOCOL_VERSION -0x6E80 /**< Ha | |
| | | ndshake protocol not within min/max boundaries */ | |
| | | | |
| /* | | /* | |
| * Various constants | | * Various constants | |
| */ | | */ | |
| #define SSL_MAJOR_VERSION_3 3 | | #define SSL_MAJOR_VERSION_3 3 | |
| #define SSL_MINOR_VERSION_0 0 /*!< SSL v3.0 */ | | #define SSL_MINOR_VERSION_0 0 /*!< SSL v3.0 */ | |
| #define SSL_MINOR_VERSION_1 1 /*!< TLS v1.0 */ | | #define SSL_MINOR_VERSION_1 1 /*!< TLS v1.0 */ | |
| #define SSL_MINOR_VERSION_2 2 /*!< TLS v1.1 */ | | #define SSL_MINOR_VERSION_2 2 /*!< TLS v1.1 */ | |
|
| | | #define SSL_MINOR_VERSION_3 3 /*!< TLS v1.2 */ | |
| | | | |
| #define SSL_IS_CLIENT 0 | | #define SSL_IS_CLIENT 0 | |
| #define SSL_IS_SERVER 1 | | #define SSL_IS_SERVER 1 | |
| #define SSL_COMPRESS_NULL 0 | | #define SSL_COMPRESS_NULL 0 | |
|
| | | #define SSL_COMPRESS_DEFLATE 1 | |
| | | | |
| #define SSL_VERIFY_NONE 0 | | #define SSL_VERIFY_NONE 0 | |
| #define SSL_VERIFY_OPTIONAL 1 | | #define SSL_VERIFY_OPTIONAL 1 | |
| #define SSL_VERIFY_REQUIRED 2 | | #define SSL_VERIFY_REQUIRED 2 | |
| | | | |
|
| | | #define SSL_INITIAL_HANDSHAKE 0 | |
| | | #define SSL_RENEGOTIATION 1 | |
| | | | |
| | | #define SSL_LEGACY_RENEGOTIATION 0 | |
| | | #define SSL_SECURE_RENEGOTIATION 1 | |
| | | | |
| | | #define SSL_RENEGOTIATION_ENABLED 0 | |
| | | #define SSL_RENEGOTIATION_DISABLED 1 | |
| | | | |
| | | #define SSL_LEGACY_NO_RENEGOTIATION 0 | |
| | | #define SSL_LEGACY_ALLOW_RENEGOTIATION 1 | |
| | | #define SSL_LEGACY_BREAK_HANDSHAKE 2 | |
| | | | |
| #define SSL_MAX_CONTENT_LEN 16384 | | #define SSL_MAX_CONTENT_LEN 16384 | |
| | | | |
| /* | | /* | |
| * Allow an extra 512 bytes for the record header | | * Allow an extra 512 bytes for the record header | |
|
| * and encryption overhead (counter + MAC + padding). | | * and encryption overhead (counter + MAC + padding) | |
| | | * and allow for a maximum of 1024 of compression expansion if | |
| | | * enabled. | |
| | | */ | |
| | | #if defined(POLARSSL_ZLIB_SUPPORT) | |
| | | #define SSL_COMPRESSION_ADD 1024 | |
| | | #else | |
| | | #define SSL_COMPRESSION_ADD 0 | |
| | | #endif | |
| | | | |
| | | #define SSL_BUFFER_LEN (SSL_MAX_CONTENT_LEN + SSL_COMPRESSION_ADD + 512) | |
| | | | |
| | | /* | |
| | | * Supported ciphersuites (Official IANA names) | |
| */ | | */ | |
|
| #define SSL_BUFFER_LEN (SSL_MAX_CONTENT_LEN + 512) | | #define TLS_RSA_WITH_NULL_MD5 0x01 /**< Weak! */ | |
| | | #define TLS_RSA_WITH_NULL_SHA 0x02 /**< Weak! */ | |
| | | #define TLS_RSA_WITH_NULL_SHA256 0x3B /**< Weak! */ | |
| | | #define TLS_RSA_WITH_DES_CBC_SHA 0x09 /**< Weak! Not in T | |
| | | LS 1.2 */ | |
| | | #define TLS_DHE_RSA_WITH_DES_CBC_SHA 0x15 /**< Weak! Not in T | |
| | | LS 1.2 */ | |
| | | | |
| | | #define TLS_RSA_WITH_RC4_128_MD5 0x04 | |
| | | #define TLS_RSA_WITH_RC4_128_SHA 0x05 | |
| | | | |
| | | #define TLS_RSA_WITH_3DES_EDE_CBC_SHA 0x0A | |
| | | #define TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA 0x16 | |
| | | | |
| | | #define TLS_RSA_WITH_AES_128_CBC_SHA 0x2F | |
| | | #define TLS_DHE_RSA_WITH_AES_128_CBC_SHA 0x33 | |
| | | #define TLS_RSA_WITH_AES_256_CBC_SHA 0x35 | |
| | | #define TLS_DHE_RSA_WITH_AES_256_CBC_SHA 0x39 | |
| | | #define TLS_RSA_WITH_AES_128_CBC_SHA256 0x3C /**< TLS 1.2 */ | |
| | | #define TLS_RSA_WITH_AES_256_CBC_SHA256 0x3D /**< TLS 1.2 */ | |
| | | #define TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 0x67 /**< TLS 1.2 */ | |
| | | #define TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 0x6B /**< TLS 1.2 */ | |
| | | | |
| | | #define TLS_RSA_WITH_CAMELLIA_128_CBC_SHA 0x41 | |
| | | #define TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA 0x45 | |
| | | #define TLS_RSA_WITH_CAMELLIA_256_CBC_SHA 0x84 | |
| | | #define TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA 0x88 | |
| | | #define TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 0xBA /**< TLS 1.2 */ | |
| | | #define TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 0xBE /**< TLS 1.2 */ | |
| | | #define TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 0xC0 /**< TLS 1.2 */ | |
| | | #define TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 0xC4 /**< TLS 1.2 */ | |
| | | | |
| | | #define TLS_RSA_WITH_AES_128_GCM_SHA256 0x9C | |
| | | #define TLS_RSA_WITH_AES_256_GCM_SHA384 0x9D | |
| | | #define TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 0x9E | |
| | | #define TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 0x9F | |
| | | | |
| | | #define SSL_EMPTY_RENEGOTIATION_INFO 0xFF /**< renegotiation info ext | |
| | | */ | |
| | | | |
| /* | | /* | |
|
| * Supported ciphersuites | | * Supported Signature and Hash algorithms (For TLS 1.2) | |
| */ | | */ | |
|
| #define SSL_RSA_RC4_128_MD5 0x04 | | #define SSL_HASH_NONE 0 | |
| #define SSL_RSA_RC4_128_SHA 0x05 | | #define SSL_HASH_MD5 1 | |
| #define SSL_RSA_DES_168_SHA 0x0A | | #define SSL_HASH_SHA1 2 | |
| #define SSL_EDH_RSA_DES_168_SHA 0x16 | | #define SSL_HASH_SHA224 3 | |
| #define SSL_RSA_AES_128_SHA 0x2F | | #define SSL_HASH_SHA256 4 | |
| #define SSL_EDH_RSA_AES_128_SHA 0x33 | | #define SSL_HASH_SHA384 5 | |
| #define SSL_RSA_AES_256_SHA 0x35 | | #define SSL_HASH_SHA512 6 | |
| #define SSL_EDH_RSA_AES_256_SHA 0x39 | | | |
| | | #define SSL_SIG_RSA 1 | |
| #define SSL_RSA_CAMELLIA_128_SHA 0x41 | | | |
| #define SSL_EDH_RSA_CAMELLIA_128_SHA 0x45 | | | |
| #define SSL_RSA_CAMELLIA_256_SHA 0x84 | | | |
| #define SSL_EDH_RSA_CAMELLIA_256_SHA 0x88 | | | |
| | | | |
| /* | | /* | |
| * Message, alert and handshake types | | * Message, alert and handshake types | |
| */ | | */ | |
| #define SSL_MSG_CHANGE_CIPHER_SPEC 20 | | #define SSL_MSG_CHANGE_CIPHER_SPEC 20 | |
| #define SSL_MSG_ALERT 21 | | #define SSL_MSG_ALERT 21 | |
| #define SSL_MSG_HANDSHAKE 22 | | #define SSL_MSG_HANDSHAKE 22 | |
| #define SSL_MSG_APPLICATION_DATA 23 | | #define SSL_MSG_APPLICATION_DATA 23 | |
| | | | |
| #define SSL_ALERT_LEVEL_WARNING 1 | | #define SSL_ALERT_LEVEL_WARNING 1 | |
| #define SSL_ALERT_LEVEL_FATAL 2 | | #define SSL_ALERT_LEVEL_FATAL 2 | |
| | | | |
|
| #define SSL_ALERT_MSG_CLOSE_NOTIFY 0 | | #define SSL_ALERT_MSG_CLOSE_NOTIFY 0 /* 0x00 */ | |
| #define SSL_ALERT_MSG_UNEXPECTED_MESSAGE 10 | | #define SSL_ALERT_MSG_UNEXPECTED_MESSAGE 10 /* 0x0A */ | |
| #define SSL_ALERT_MSG_BAD_RECORD_MAC 20 | | #define SSL_ALERT_MSG_BAD_RECORD_MAC 20 /* 0x14 */ | |
| #define SSL_ALERT_MSG_DECRYPTION_FAILED 21 | | #define SSL_ALERT_MSG_DECRYPTION_FAILED 21 /* 0x15 */ | |
| #define SSL_ALERT_MSG_RECORD_OVERFLOW 22 | | #define SSL_ALERT_MSG_RECORD_OVERFLOW 22 /* 0x16 */ | |
| #define SSL_ALERT_MSG_DECOMPRESSION_FAILURE 30 | | #define SSL_ALERT_MSG_DECOMPRESSION_FAILURE 30 /* 0x1E */ | |
| #define SSL_ALERT_MSG_HANDSHAKE_FAILURE 40 | | #define SSL_ALERT_MSG_HANDSHAKE_FAILURE 40 /* 0x28 */ | |
| #define SSL_ALERT_MSG_NO_CERT 41 | | #define SSL_ALERT_MSG_NO_CERT 41 /* 0x29 */ | |
| #define SSL_ALERT_MSG_BAD_CERT 42 | | #define SSL_ALERT_MSG_BAD_CERT 42 /* 0x2A */ | |
| #define SSL_ALERT_MSG_UNSUPPORTED_CERT 43 | | #define SSL_ALERT_MSG_UNSUPPORTED_CERT 43 /* 0x2B */ | |
| #define SSL_ALERT_MSG_CERT_REVOKED 44 | | #define SSL_ALERT_MSG_CERT_REVOKED 44 /* 0x2C */ | |
| #define SSL_ALERT_MSG_CERT_EXPIRED 45 | | #define SSL_ALERT_MSG_CERT_EXPIRED 45 /* 0x2D */ | |
| #define SSL_ALERT_MSG_CERT_UNKNOWN 46 | | #define SSL_ALERT_MSG_CERT_UNKNOWN 46 /* 0x2E */ | |
| #define SSL_ALERT_MSG_ILLEGAL_PARAMETER 47 | | #define SSL_ALERT_MSG_ILLEGAL_PARAMETER 47 /* 0x2F */ | |
| #define SSL_ALERT_MSG_UNKNOWN_CA 48 | | #define SSL_ALERT_MSG_UNKNOWN_CA 48 /* 0x30 */ | |
| #define SSL_ALERT_MSG_ACCESS_DENIED 49 | | #define SSL_ALERT_MSG_ACCESS_DENIED 49 /* 0x31 */ | |
| #define SSL_ALERT_MSG_DECODE_ERROR 50 | | #define SSL_ALERT_MSG_DECODE_ERROR 50 /* 0x32 */ | |
| #define SSL_ALERT_MSG_DECRYPT_ERROR 51 | | #define SSL_ALERT_MSG_DECRYPT_ERROR 51 /* 0x33 */ | |
| #define SSL_ALERT_MSG_EXPORT_RESTRICTION 60 | | #define SSL_ALERT_MSG_EXPORT_RESTRICTION 60 /* 0x3C */ | |
| #define SSL_ALERT_MSG_PROTOCOL_VERSION 70 | | #define SSL_ALERT_MSG_PROTOCOL_VERSION 70 /* 0x46 */ | |
| #define SSL_ALERT_MSG_INSUFFICIENT_SECURITY 71 | | #define SSL_ALERT_MSG_INSUFFICIENT_SECURITY 71 /* 0x47 */ | |
| #define SSL_ALERT_MSG_INTERNAL_ERROR 80 | | #define SSL_ALERT_MSG_INTERNAL_ERROR 80 /* 0x50 */ | |
| #define SSL_ALERT_MSG_USER_CANCELED 90 | | #define SSL_ALERT_MSG_USER_CANCELED 90 /* 0x5A */ | |
| #define SSL_ALERT_MSG_NO_RENEGOTIATION 100 | | #define SSL_ALERT_MSG_NO_RENEGOTIATION 100 /* 0x64 */ | |
| | | #define SSL_ALERT_MSG_UNSUPPORTED_EXT 110 /* 0x6E */ | |
| | | #define SSL_ALERT_MSG_UNRECOGNIZED_NAME 112 /* 0x70 */ | |
| | | | |
| #define SSL_HS_HELLO_REQUEST 0 | | #define SSL_HS_HELLO_REQUEST 0 | |
| #define SSL_HS_CLIENT_HELLO 1 | | #define SSL_HS_CLIENT_HELLO 1 | |
| #define SSL_HS_SERVER_HELLO 2 | | #define SSL_HS_SERVER_HELLO 2 | |
| #define SSL_HS_CERTIFICATE 11 | | #define SSL_HS_CERTIFICATE 11 | |
| #define SSL_HS_SERVER_KEY_EXCHANGE 12 | | #define SSL_HS_SERVER_KEY_EXCHANGE 12 | |
| #define SSL_HS_CERTIFICATE_REQUEST 13 | | #define SSL_HS_CERTIFICATE_REQUEST 13 | |
| #define SSL_HS_SERVER_HELLO_DONE 14 | | #define SSL_HS_SERVER_HELLO_DONE 14 | |
| #define SSL_HS_CERTIFICATE_VERIFY 15 | | #define SSL_HS_CERTIFICATE_VERIFY 15 | |
| #define SSL_HS_CLIENT_KEY_EXCHANGE 16 | | #define SSL_HS_CLIENT_KEY_EXCHANGE 16 | |
| #define SSL_HS_FINISHED 20 | | #define SSL_HS_FINISHED 20 | |
| | | | |
| /* | | /* | |
| * TLS extensions | | * TLS extensions | |
| */ | | */ | |
| #define TLS_EXT_SERVERNAME 0 | | #define TLS_EXT_SERVERNAME 0 | |
| #define TLS_EXT_SERVERNAME_HOSTNAME 0 | | #define TLS_EXT_SERVERNAME_HOSTNAME 0 | |
| | | | |
|
| | | #define TLS_EXT_SIG_ALG 13 | |
| | | | |
| | | #define TLS_EXT_RENEGOTIATION_INFO 0xFF01 | |
| | | | |
| | | /* | |
| | | * Generic function pointers for allowing external RSA private key | |
| | | * implementations. | |
| | | */ | |
| | | typedef int (*rsa_decrypt_func)( void *ctx, int mode, size_t *olen, | |
| | | const unsigned char *input, unsigned char *output, | |
| | | size_t output_max_len ); | |
| | | typedef int (*rsa_sign_func)( void *ctx, | |
| | | int (*f_rng)(void *, unsigned char *, size_t), void *p | |
| | | _rng, | |
| | | int mode, int hash_id, unsigned int hashlen, | |
| | | const unsigned char *hash, unsigned char *sig ); | |
| | | typedef size_t (*rsa_key_len_func)( void *ctx ); | |
| | | | |
| /* | | /* | |
| * SSL state machine | | * SSL state machine | |
| */ | | */ | |
| typedef enum | | typedef enum | |
| { | | { | |
| SSL_HELLO_REQUEST, | | SSL_HELLO_REQUEST, | |
| SSL_CLIENT_HELLO, | | SSL_CLIENT_HELLO, | |
| SSL_SERVER_HELLO, | | SSL_SERVER_HELLO, | |
| SSL_SERVER_CERTIFICATE, | | SSL_SERVER_CERTIFICATE, | |
| SSL_SERVER_KEY_EXCHANGE, | | SSL_SERVER_KEY_EXCHANGE, | |
| SSL_CERTIFICATE_REQUEST, | | SSL_CERTIFICATE_REQUEST, | |
| SSL_SERVER_HELLO_DONE, | | SSL_SERVER_HELLO_DONE, | |
| SSL_CLIENT_CERTIFICATE, | | SSL_CLIENT_CERTIFICATE, | |
| SSL_CLIENT_KEY_EXCHANGE, | | SSL_CLIENT_KEY_EXCHANGE, | |
| SSL_CERTIFICATE_VERIFY, | | SSL_CERTIFICATE_VERIFY, | |
| SSL_CLIENT_CHANGE_CIPHER_SPEC, | | SSL_CLIENT_CHANGE_CIPHER_SPEC, | |
| SSL_CLIENT_FINISHED, | | SSL_CLIENT_FINISHED, | |
| SSL_SERVER_CHANGE_CIPHER_SPEC, | | SSL_SERVER_CHANGE_CIPHER_SPEC, | |
| SSL_SERVER_FINISHED, | | SSL_SERVER_FINISHED, | |
| SSL_FLUSH_BUFFERS, | | SSL_FLUSH_BUFFERS, | |
|
| | | SSL_HANDSHAKE_WRAPUP, | |
| SSL_HANDSHAKE_OVER | | SSL_HANDSHAKE_OVER | |
| } | | } | |
| ssl_states; | | ssl_states; | |
| | | | |
| typedef struct _ssl_session ssl_session; | | typedef struct _ssl_session ssl_session; | |
| typedef struct _ssl_context ssl_context; | | typedef struct _ssl_context ssl_context; | |
|
| | | typedef struct _ssl_transform ssl_transform; | |
| | | typedef struct _ssl_handshake_params ssl_handshake_params; | |
| | | | |
| /* | | /* | |
|
| * This structure is used for session resuming. | | * This structure is used for storing current session data. | |
| */ | | */ | |
| struct _ssl_session | | struct _ssl_session | |
| { | | { | |
| time_t start; /*!< starting time */ | | time_t start; /*!< starting time */ | |
| int ciphersuite; /*!< chosen ciphersuite */ | | int ciphersuite; /*!< chosen ciphersuite */ | |
|
| | | int compression; /*!< chosen compression */ | |
| size_t length; /*!< session id length */ | | size_t length; /*!< session id length */ | |
| unsigned char id[32]; /*!< session identifier */ | | unsigned char id[32]; /*!< session identifier */ | |
| unsigned char master[48]; /*!< the master secret */ | | unsigned char master[48]; /*!< the master secret */ | |
|
| ssl_session *next; /*!< next session entry */ | | x509_cert *peer_cert; /*!< peer X.509 cert chain */ | |
| | | }; | |
| | | | |
| | | /* | |
| | | * This structure contains a full set of runtime transform parameters | |
| | | * either in negotiation or active. | |
| | | */ | |
| | | struct _ssl_transform | |
| | | { | |
| | | /* | |
| | | * Session specific crypto layer | |
| | | */ | |
| | | unsigned int keylen; /*!< symmetric key length */ | |
| | | size_t minlen; /*!< min. ciphertext length */ | |
| | | size_t ivlen; /*!< IV length */ | |
| | | size_t fixed_ivlen; /*!< Fixed part of IV (AEAD) */ | |
| | | size_t maclen; /*!< MAC length */ | |
| | | | |
| | | unsigned char iv_enc[16]; /*!< IV (encryption) */ | |
| | | unsigned char iv_dec[16]; /*!< IV (decryption) */ | |
| | | | |
| | | unsigned char mac_enc[32]; /*!< MAC (encryption) */ | |
| | | unsigned char mac_dec[32]; /*!< MAC (decryption) */ | |
| | | | |
| | | uint32_t ctx_enc[136]; /*!< encryption context */ | |
| | | uint32_t ctx_dec[136]; /*!< decryption context */ | |
| | | | |
| | | /* | |
| | | * Session specific compression layer | |
| | | */ | |
| | | #if defined(POLARSSL_ZLIB_SUPPORT) | |
| | | z_stream ctx_deflate; /*!< compression context */ | |
| | | z_stream ctx_inflate; /*!< decompression context */ | |
| | | #endif | |
| | | }; | |
| | | | |
| | | /* | |
| | | * This structure contains the parameters only needed during handshake. | |
| | | */ | |
| | | struct _ssl_handshake_params | |
| | | { | |
| | | /* | |
| | | * Handshake specific crypto variables | |
| | | */ | |
| | | int sig_alg; /*!< Signature algorithm */ | |
| | | #if defined(POLARSSL_DHM_C) | |
| | | dhm_context dhm_ctx; /*!< DHM key exchange */ | |
| | | #endif | |
| | | | |
| | | /* | |
| | | * Checksum contexts | |
| | | */ | |
| | | md5_context fin_md5; | |
| | | sha1_context fin_sha1; | |
| | | sha2_context fin_sha2; | |
| | | sha4_context fin_sha4; | |
| | | | |
| | | void (*update_checksum)(ssl_context *, unsigned char *, size_t); | |
| | | void (*calc_verify)(ssl_context *, unsigned char *); | |
| | | void (*calc_finished)(ssl_context *, unsigned char *, int); | |
| | | int (*tls_prf)(unsigned char *, size_t, char *, | |
| | | unsigned char *, size_t, | |
| | | unsigned char *, size_t); | |
| | | | |
| | | size_t pmslen; /*!< premaster length */ | |
| | | | |
| | | unsigned char randbytes[64]; /*!< random bytes */ | |
| | | unsigned char premaster[POLARSSL_MPI_MAX_SIZE]; | |
| | | /*!< premaster secret */ | |
| | | | |
| | | int resume; /*!< session resume indicator*/ | |
| }; | | }; | |
| | | | |
| struct _ssl_context | | struct _ssl_context | |
| { | | { | |
| /* | | /* | |
| * Miscellaneous | | * Miscellaneous | |
| */ | | */ | |
| int state; /*!< SSL handshake: current state */ | | int state; /*!< SSL handshake: current state */ | |
|
| | | int renegotiation; /*!< Initial or renegotiation */ | |
| | | | |
| int major_ver; /*!< equal to SSL_MAJOR_VERSION_3 */ | | int major_ver; /*!< equal to SSL_MAJOR_VERSION_3 */ | |
| int minor_ver; /*!< either 0 (SSL3) or 1 (TLS1.0) */ | | int minor_ver; /*!< either 0 (SSL3) or 1 (TLS1.0) */ | |
| | | | |
| int max_major_ver; /*!< max. major version from client */ | | int max_major_ver; /*!< max. major version from client */ | |
| int max_minor_ver; /*!< max. minor version from client */ | | int max_minor_ver; /*!< max. minor version from client */ | |
|
| | | int min_major_ver; /*!< min. major version accepted */ | |
| | | int min_minor_ver; /*!< min. minor version accepted */ | |
| | | | |
| /* | | /* | |
| * Callbacks (RNG, debug, I/O, verification) | | * Callbacks (RNG, debug, I/O, verification) | |
| */ | | */ | |
| int (*f_rng)(void *, unsigned char *, size_t); | | int (*f_rng)(void *, unsigned char *, size_t); | |
| void (*f_dbg)(void *, int, const char *); | | void (*f_dbg)(void *, int, const char *); | |
| int (*f_recv)(void *, unsigned char *, size_t); | | int (*f_recv)(void *, unsigned char *, size_t); | |
| int (*f_send)(void *, const unsigned char *, size_t); | | int (*f_send)(void *, const unsigned char *, size_t); | |
|
| int (*f_vrfy)(void *, x509_cert *, int, int); | | int (*f_vrfy)(void *, x509_cert *, int, int *); | |
| | | int (*f_get_cache)(void *, ssl_session *); | |
| | | int (*f_set_cache)(void *, const ssl_session *); | |
| | | int (*f_sni)(void *, ssl_context *, const unsigned char *, size_t); | |
| | | | |
| void *p_rng; /*!< context for the RNG function */ | | void *p_rng; /*!< context for the RNG function */ | |
| void *p_dbg; /*!< context for the debug function */ | | void *p_dbg; /*!< context for the debug function */ | |
| void *p_recv; /*!< context for reading operations */ | | void *p_recv; /*!< context for reading operations */ | |
| void *p_send; /*!< context for writing operations */ | | void *p_send; /*!< context for writing operations */ | |
|
| void *p_vrfy; /*!< context for verification */ | | void *p_vrfy; /*!< context for verification */ | |
| | | void *p_get_cache; /*!< context for cache retrieval */ | |
| | | void *p_set_cache; /*!< context for cache store */ | |
| | | void *p_sni; /*!< context for SNI extension */ | |
| | | | |
| /* | | /* | |
| * Session layer | | * Session layer | |
| */ | | */ | |
|
| int resume; /*!< session resuming flag */ | | ssl_session *session_in; /*!< current session data (in) * | |
| int timeout; /*!< sess. expiration time */ | | / | |
| ssl_session *session; /*!< current session data */ | | ssl_session *session_out; /*!< current session data (out) * | |
| int (*s_get)(ssl_context *); /*!< (server) get callback */ | | / | |
| int (*s_set)(ssl_context *); /*!< (server) set callback */ | | ssl_session *session; /*!< negotiated session data * | |
| | | / | |
| | | ssl_session *session_negotiate; /*!< session data in negotiation * | |
| | | / | |
| | | | |
| | | ssl_handshake_params *handshake; /*!< params required only during | |
| | | the handshake process | |
| | | */ | |
| | | | |
| | | /* | |
| | | * Record layer transformations | |
| | | */ | |
| | | ssl_transform *transform_in; /*!< current transform params (in) | |
| | | */ | |
| | | ssl_transform *transform_out; /*!< current transform params (in) | |
| | | */ | |
| | | ssl_transform *transform; /*!< negotiated transform params | |
| | | */ | |
| | | ssl_transform *transform_negotiate; /*!< transform params in negotiati | |
| | | on */ | |
| | | | |
| /* | | /* | |
| * Record layer (incoming data) | | * Record layer (incoming data) | |
| */ | | */ | |
| unsigned char *in_ctr; /*!< 64-bit incoming message counter */ | | unsigned char *in_ctr; /*!< 64-bit incoming message counter */ | |
| unsigned char *in_hdr; /*!< 5-byte record header (in_ctr+8) */ | | unsigned char *in_hdr; /*!< 5-byte record header (in_ctr+8) */ | |
| unsigned char *in_msg; /*!< the message contents (in_hdr+5) */ | | unsigned char *in_msg; /*!< the message contents (in_hdr+5) */ | |
| unsigned char *in_offt; /*!< read offset in application data */ | | unsigned char *in_offt; /*!< read offset in application data */ | |
| | | | |
| int in_msgtype; /*!< record header: message type */ | | int in_msgtype; /*!< record header: message type */ | |
| | | | |
| skipping to change at line 277 | | skipping to change at line 457 | |
| size_t in_left; /*!< amount of data read so far */ | | size_t in_left; /*!< amount of data read so far */ | |
| | | | |
| size_t in_hslen; /*!< current handshake message length */ | | size_t in_hslen; /*!< current handshake message length */ | |
| int nb_zero; /*!< # of 0-length encrypted messages */ | | int nb_zero; /*!< # of 0-length encrypted messages */ | |
| | | | |
| /* | | /* | |
| * Record layer (outgoing data) | | * Record layer (outgoing data) | |
| */ | | */ | |
| unsigned char *out_ctr; /*!< 64-bit outgoing message counter */ | | unsigned char *out_ctr; /*!< 64-bit outgoing message counter */ | |
| unsigned char *out_hdr; /*!< 5-byte record header (out_ctr+8) */ | | unsigned char *out_hdr; /*!< 5-byte record header (out_ctr+8) */ | |
|
| unsigned char *out_msg; /*!< the message contents (out_hdr+5) */ | | unsigned char *out_msg; /*!< the message contents (out_hdr+32)*/ | |
| | | | |
| int out_msgtype; /*!< record header: message type */ | | int out_msgtype; /*!< record header: message type */ | |
| size_t out_msglen; /*!< record header: message length */ | | size_t out_msglen; /*!< record header: message length */ | |
| size_t out_left; /*!< amount of data not yet written */ | | size_t out_left; /*!< amount of data not yet written */ | |
| | | | |
| /* | | /* | |
| * PKI layer | | * PKI layer | |
| */ | | */ | |
|
| rsa_context *rsa_key; /*!< own RSA private key */ | | void *rsa_key; /*!< own RSA private key */ | |
| #if defined(POLARSSL_PKCS11_C) | | rsa_decrypt_func rsa_decrypt; /*!< function for RSA decrypt*/ | |
| pkcs11_context *pkcs11_key; /*!< own PKCS#11 RSA private key * | | rsa_sign_func rsa_sign; /*!< function for RSA sign */ | |
| / | | rsa_key_len_func rsa_key_len; /*!< function for RSA key len*/ | |
| #endif | | | |
| x509_cert *own_cert; /*!< own X.509 certificate */ | | x509_cert *own_cert; /*!< own X.509 certificate */ | |
| x509_cert *ca_chain; /*!< own trusted CA chain */ | | x509_cert *ca_chain; /*!< own trusted CA chain */ | |
| x509_crl *ca_crl; /*!< trusted CA CRLs */ | | x509_crl *ca_crl; /*!< trusted CA CRLs */ | |
|
| x509_cert *peer_cert; /*!< peer X.509 cert chain */ | | | |
| const char *peer_cn; /*!< expected peer CN */ | | const char *peer_cn; /*!< expected peer CN */ | |
| | | | |
|
| | | /* | |
| | | * User settings | |
| | | */ | |
| int endpoint; /*!< 0: client, 1: server */ | | int endpoint; /*!< 0: client, 1: server */ | |
| int authmode; /*!< verification mode */ | | int authmode; /*!< verification mode */ | |
| int client_auth; /*!< flag for client auth. */ | | int client_auth; /*!< flag for client auth. */ | |
| int verify_result; /*!< verification result */ | | int verify_result; /*!< verification result */ | |
|
| | | int disable_renegotiation; /*!< enable/disable renegotiation | |
| /* | | */ | |
| * Crypto layer | | int allow_legacy_renegotiation; /*!< allow legacy renegotiation | |
| */ | | */ | |
| dhm_context dhm_ctx; /*!< DHM key exchange */ | | const int *ciphersuites; /*!< allowed ciphersuites */ | |
| md5_context fin_md5; /*!< Finished MD5 checksum */ | | | |
| sha1_context fin_sha1; /*!< Finished SHA-1 checksum */ | | #if defined(POLARSSL_DHM_C) | |
| | | mpi dhm_P; /*!< prime modulus for DHM */ | |
| int do_crypt; /*!< en(de)cryption flag */ | | mpi dhm_G; /*!< generator for DHM */ | |
| int *ciphersuites; /*!< allowed ciphersuites */ | | #endif | |
| size_t pmslen; /*!< premaster length */ | | | |
| unsigned int keylen; /*!< symmetric key length */ | | | |
| size_t minlen; /*!< min. ciphertext length */ | | | |
| size_t ivlen; /*!< IV length */ | | | |
| size_t maclen; /*!< MAC length */ | | | |
| | | | |
| unsigned char randbytes[64]; /*!< random bytes */ | | | |
| unsigned char premaster[256]; /*!< premaster secret */ | | | |
| | | | |
| unsigned char iv_enc[16]; /*!< IV (encryption) */ | | | |
| unsigned char iv_dec[16]; /*!< IV (decryption) */ | | | |
| | | | |
| unsigned char mac_enc[32]; /*!< MAC (encryption) */ | | | |
| unsigned char mac_dec[32]; /*!< MAC (decryption) */ | | | |
| | | | |
| unsigned long ctx_enc[128]; /*!< encryption context */ | | | |
| unsigned long ctx_dec[128]; /*!< decryption context */ | | | |
| | | | |
| /* | | /* | |
| * TLS extensions | | * TLS extensions | |
| */ | | */ | |
| unsigned char *hostname; | | unsigned char *hostname; | |
| size_t hostname_len; | | size_t hostname_len; | |
|
| | | | |
| | | /* | |
| | | * Secure renegotiation | |
| | | */ | |
| | | int secure_renegotiation; /*!< does peer support legacy or | |
| | | secure renegotiation | |
| | | */ | |
| | | size_t verify_data_len; /*!< length of verify data stored | |
| | | */ | |
| | | char own_verify_data[36]; /*!< previous handshake verify dat | |
| | | a */ | |
| | | char peer_verify_data[36]; /*!< previous handshake verify dat | |
| | | a */ | |
| }; | | }; | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| extern "C" { | | extern "C" { | |
| #endif | | #endif | |
| | | | |
|
| extern int ssl_default_ciphersuites[]; | | extern const int ssl_default_ciphersuites[]; | |
| | | | |
| | | #if defined(POLARSSL_SSL_HW_RECORD_ACCEL) | |
| | | extern int (*ssl_hw_record_init)(ssl_context *ssl, | |
| | | const unsigned char *key_enc, const unsigned char *key_dec, | |
| | | const unsigned char *iv_enc, const unsigned char *iv_dec, | |
| | | const unsigned char *mac_enc, const unsigned char *mac_dec) | |
| | | ; | |
| | | extern int (*ssl_hw_record_reset)(ssl_context *ssl); | |
| | | extern int (*ssl_hw_record_write)(ssl_context *ssl); | |
| | | extern int (*ssl_hw_record_read)(ssl_context *ssl); | |
| | | extern int (*ssl_hw_record_finish)(ssl_context *ssl); | |
| | | #endif | |
| | | | |
| /** | | /** | |
| * \brief Returns the list of ciphersuites supported by the SSL/TLS module. | | * \brief Returns the list of ciphersuites supported by the SSL/TLS module. | |
| * | | * | |
| * \return a statically allocated array of ciphersuites, the l
ast | | * \return a statically allocated array of ciphersuites, the l
ast | |
| * entry is 0. | | * entry is 0. | |
| */ | | */ | |
| static inline const int *ssl_list_ciphersuites( void ) | | static inline const int *ssl_list_ciphersuites( void ) | |
| { | | { | |
| return ssl_default_ciphersuites; | | return ssl_default_ciphersuites; | |
| | | | |
| skipping to change at line 388 | | skipping to change at line 572 | |
| * memory allocation failed | | * memory allocation failed | |
| */ | | */ | |
| int ssl_init( ssl_context *ssl ); | | int ssl_init( ssl_context *ssl ); | |
| | | | |
| /** | | /** | |
| * \brief Reset an already initialized SSL context for re-use | | * \brief Reset an already initialized SSL context for re-use | |
| * while retaining application-set variables, function | | * while retaining application-set variables, function | |
| * pointers and data. | | * pointers and data. | |
| * | | * | |
| * \param ssl SSL context | | * \param ssl SSL context | |
|
| | | * \return 0 if successful, or POLASSL_ERR_SSL_MALLOC_FAILED, | |
| | | POLARSSL_ERR_SSL_HW_ACCEL_FAILED or | |
| | | * POLARSSL_ERR_SSL_COMPRESSION_FAILED | |
| */ | | */ | |
|
| void ssl_session_reset( ssl_context *ssl ); | | int ssl_session_reset( ssl_context *ssl ); | |
| | | | |
| /** | | /** | |
| * \brief Set the current endpoint type | | * \brief Set the current endpoint type | |
| * | | * | |
| * \param ssl SSL context | | * \param ssl SSL context | |
| * \param endpoint must be SSL_IS_CLIENT or SSL_IS_SERVER | | * \param endpoint must be SSL_IS_CLIENT or SSL_IS_SERVER | |
| */ | | */ | |
| void ssl_set_endpoint( ssl_context *ssl, int endpoint ); | | void ssl_set_endpoint( ssl_context *ssl, int endpoint ); | |
| | | | |
| /** | | /** | |
| | | | |
| skipping to change at line 421 | | skipping to change at line 608 | |
| * handshake is complete. | | * handshake is complete. | |
| * | | * | |
| * SSL_VERIFY_REQUIRED: peer *must* present a valid certificate, | | * SSL_VERIFY_REQUIRED: peer *must* present a valid certificate, | |
| * handshake is aborted if verification failed. | | * handshake is aborted if verification failed. | |
| */ | | */ | |
| void ssl_set_authmode( ssl_context *ssl, int authmode ); | | void ssl_set_authmode( ssl_context *ssl, int authmode ); | |
| | | | |
| /** | | /** | |
| * \brief Set the verification callback (Optional). | | * \brief Set the verification callback (Optional). | |
| * | | * | |
|
| * If set, the verification callback is called once for eve | | * If set, the verify callback is called for each | |
| ry | | * certificate in the chain. For implementation | |
| * certificate in the chain. The verification function has | | * information, please see \c x509parse_verify() | |
| the | | | |
| * following parameter: (void *parameter, x509_cert certifi | | | |
| cate, | | | |
| * int certifcate_depth, int preverify_ok). It should | | | |
| * return 0 on SUCCESS. | | | |
| * | | * | |
| * \param ssl SSL context | | * \param ssl SSL context | |
| * \param f_vrfy verification function | | * \param f_vrfy verification function | |
| * \param p_vrfy verification parameter | | * \param p_vrfy verification parameter | |
| */ | | */ | |
| void ssl_set_verify( ssl_context *ssl, | | void ssl_set_verify( ssl_context *ssl, | |
|
| int (*f_vrfy)(void *, x509_cert *, int, int), | | int (*f_vrfy)(void *, x509_cert *, int, int *), | |
| void *p_vrfy ); | | void *p_vrfy ); | |
| | | | |
| /** | | /** | |
| * \brief Set the random number generator callback | | * \brief Set the random number generator callback | |
| * | | * | |
| * \param ssl SSL context | | * \param ssl SSL context | |
| * \param f_rng RNG function | | * \param f_rng RNG function | |
| * \param p_rng RNG parameter | | * \param p_rng RNG parameter | |
| */ | | */ | |
| void ssl_set_rng( ssl_context *ssl, | | void ssl_set_rng( ssl_context *ssl, | |
| | | | |
| skipping to change at line 471 | | skipping to change at line 656 | |
| * \param f_recv read callback | | * \param f_recv read callback | |
| * \param p_recv read parameter | | * \param p_recv read parameter | |
| * \param f_send write callback | | * \param f_send write callback | |
| * \param p_send write parameter | | * \param p_send write parameter | |
| */ | | */ | |
| void ssl_set_bio( ssl_context *ssl, | | void ssl_set_bio( ssl_context *ssl, | |
| int (*f_recv)(void *, unsigned char *, size_t), void *p_recv, | | int (*f_recv)(void *, unsigned char *, size_t), void *p_recv, | |
| int (*f_send)(void *, const unsigned char *, size_t), void *p_send
); | | int (*f_send)(void *, const unsigned char *, size_t), void *p_send
); | |
| | | | |
| /** | | /** | |
|
| * \brief Set the session callbacks (server-side only) | | * \brief Set the session cache callbacks (server-side only) | |
| | | * If not set, no session resuming is done. | |
| * | | * | |
|
| * \param ssl SSL context | | * The session cache has the responsibility to check for st | |
| * \param s_get session get callback | | ale | |
| * \param s_set session set callback | | * entries based on timeout. See RFC 5246 for recommendatio | |
| */ | | ns. | |
| void ssl_set_scb( ssl_context *ssl, | | * | |
| int (*s_get)(ssl_context *), | | * Warning: session.peer_cert is cleared by the SSL/TLS lay | |
| int (*s_set)(ssl_context *) ); | | er on | |
| | | * connection shutdown, so do not cache the pointer! Either | |
| /** | | set | |
| * \brief Set the session resuming flag, timeout and data | | * it to NULL or make a full copy of the certificate. | |
| | | * | |
| | | * The get callback is called once during the initial hands | |
| | | hake | |
| | | * to enable session resuming. The get function has the | |
| | | * following parameters: (void *parameter, ssl_session *ses | |
| | | sion) | |
| | | * If a valid entry is found, it should fill the master of | |
| | | * the session object with the cached values and return 0, | |
| | | * return 1 otherwise. Optionally peer_cert can be set as w | |
| | | ell | |
| | | * if it is properly present in cache entry. | |
| | | * | |
| | | * The set callback is called once during the initial hands | |
| | | hake | |
| | | * to enable session resuming after the entire handshake ha | |
| | | s | |
| | | * been finished. The set function has the following parame | |
| | | ters: | |
| | | * (void *parameter, const ssl_session *session). The funct | |
| | | ion | |
| | | * should create a cache entry for future retrieval based o | |
| | | n | |
| | | * the data in the session structure and should keep in min | |
| | | d | |
| | | * that the ssl_session object presented (and all its refer | |
| | | enced | |
| | | * data) is cleared by the SSL/TLS layer when the connectio | |
| | | n is | |
| | | * terminated. It is recommended to add metadata to determi | |
| | | ne if | |
| | | * an entry is still valid in the future. Return 0 if | |
| | | * successfully cached, return 0 otherwise. | |
| | | * | |
| | | * \param ssl SSL context | |
| | | * \param f_get_cache session get callback | |
| | | * \param p_get_cache session get parameter | |
| | | * \param f_set_cache session set callback | |
| | | * \param p_set_cache session set parameter | |
| | | */ | |
| | | void ssl_set_session_cache( ssl_context *ssl, | |
| | | int (*f_get_cache)(void *, ssl_session *), void *p_get_cache, | |
| | | int (*f_set_cache)(void *, const ssl_session *), void *p_set_cache | |
| | | ); | |
| | | | |
| | | /** | |
| | | * \brief Request resumption of session (client-side only) | |
| | | * Session data is copied from presented session structure. | |
| | | * | |
| | | * Warning: session.peer_cert is cleared by the SSL/TLS lay | |
| | | er on | |
| | | * connection shutdown, so do not cache the pointer! Either | |
| | | set | |
| | | * it to NULL or make a full copy of the certificate when | |
| | | * storing the session for use in this function. | |
| * | | * | |
| * \param ssl SSL context | | * \param ssl SSL context | |
|
| * \param resume if 0 (default), the session will not be resumed | | | |
| * \param timeout session timeout in seconds, or 0 (no timeout) | | | |
| * \param session session context | | * \param session session context | |
| */ | | */ | |
|
| void ssl_set_session( ssl_context *ssl, int resume, int timeout, | | void ssl_set_session( ssl_context *ssl, const ssl_session *session ); | |
| ssl_session *session ); | | | |
| | | | |
| /** | | /** | |
| * \brief Set the list of allowed ciphersuites | | * \brief Set the list of allowed ciphersuites | |
| * | | * | |
| * \param ssl SSL context | | * \param ssl SSL context | |
| * \param ciphersuites 0-terminated list of allowed ciphersuites | | * \param ciphersuites 0-terminated list of allowed ciphersuites | |
| */ | | */ | |
|
| void ssl_set_ciphersuites( ssl_context *ssl, int *ciphersuites ); | | void ssl_set_ciphersuites( ssl_context *ssl, const int *ciphersuites ); | |
| | | | |
| /** | | /** | |
| * \brief Set the data required to verify peer certificate | | * \brief Set the data required to verify peer certificate | |
| * | | * | |
| * \param ssl SSL context | | * \param ssl SSL context | |
| * \param ca_chain trusted CA chain | | * \param ca_chain trusted CA chain | |
| * \param ca_crl trusted CA CRLs | | * \param ca_crl trusted CA CRLs | |
| * \param peer_cn expected peer CommonName (or NULL) | | * \param peer_cn expected peer CommonName (or NULL) | |
| * | | * | |
| * \note TODO: add two more parameters: depth and crl | | * \note TODO: add two more parameters: depth and crl | |
| | | | |
| skipping to change at line 523 | | skipping to change at line 741 | |
| /** | | /** | |
| * \brief Set own certificate and private key | | * \brief Set own certificate and private key | |
| * | | * | |
| * \param ssl SSL context | | * \param ssl SSL context | |
| * \param own_cert own public certificate | | * \param own_cert own public certificate | |
| * \param rsa_key own private RSA key | | * \param rsa_key own private RSA key | |
| */ | | */ | |
| void ssl_set_own_cert( ssl_context *ssl, x509_cert *own_cert, | | void ssl_set_own_cert( ssl_context *ssl, x509_cert *own_cert, | |
| rsa_context *rsa_key ); | | rsa_context *rsa_key ); | |
| | | | |
|
| #if defined(POLARSSL_PKCS11_C) | | | |
| /** | | /** | |
|
| * \brief Set own certificate and PKCS#11 private key | | * \brief Set own certificate and alternate non-PolarSSL private | |
| | | * key and handling callbacks, such as the PKCS#11 wrappers | |
| | | * or any other external private key handler. | |
| | | * (see the respective RSA functions in rsa.h for documenta | |
| | | tion | |
| | | * of the callback parameters, with the only change being | |
| | | * that the rsa_context * is a void * in the callbacks) | |
| * | | * | |
| * \param ssl SSL context | | * \param ssl SSL context | |
| * \param own_cert own public certificate | | * \param own_cert own public certificate | |
|
| * \param pkcs11_key own PKCS#11 RSA key | | * \param rsa_key alternate implementation private RSA key | |
| */ | | * \param rsa_decrypt_func alternate implementation of \c rsa_pkcs1_decryp | |
| void ssl_set_own_cert_pkcs11( ssl_context *ssl, x509_cert *own_cert, | | t() | |
| pkcs11_context *pkcs11_key ); | | * \param rsa_sign_func alternate implementation of \c rsa_pkcs1_sign() | |
| #endif | | * \param rsa_key_len_func function returning length of RSA key in bytes | |
| | | */ | |
| | | void ssl_set_own_cert_alt( ssl_context *ssl, x509_cert *own_cert, | |
| | | void *rsa_key, | |
| | | rsa_decrypt_func rsa_decrypt, | |
| | | rsa_sign_func rsa_sign, | |
| | | rsa_key_len_func rsa_key_len ); | |
| | | | |
|
| | | #if defined(POLARSSL_DHM_C) | |
| /** | | /** | |
| * \brief Set the Diffie-Hellman public P and G values, | | * \brief Set the Diffie-Hellman public P and G values, | |
| * read as hexadecimal strings (server-side only) | | * read as hexadecimal strings (server-side only) | |
|
| | | * (Default: POLARSSL_DHM_RFC5114_MODP_1024_[PG]) | |
| * | | * | |
| * \param ssl SSL context | | * \param ssl SSL context | |
| * \param dhm_P Diffie-Hellman-Merkle modulus | | * \param dhm_P Diffie-Hellman-Merkle modulus | |
| * \param dhm_G Diffie-Hellman-Merkle generator | | * \param dhm_G Diffie-Hellman-Merkle generator | |
| * | | * | |
| * \return 0 if successful | | * \return 0 if successful | |
| */ | | */ | |
| int ssl_set_dh_param( ssl_context *ssl, const char *dhm_P, const char *dhm_
G ); | | int ssl_set_dh_param( ssl_context *ssl, const char *dhm_P, const char *dhm_
G ); | |
| | | | |
| /** | | /** | |
| * \brief Set the Diffie-Hellman public P and G values, | | * \brief Set the Diffie-Hellman public P and G values, | |
| * read from existing context (server-side only) | | * read from existing context (server-side only) | |
| * | | * | |
| * \param ssl SSL context | | * \param ssl SSL context | |
| * \param dhm_ctx Diffie-Hellman-Merkle context | | * \param dhm_ctx Diffie-Hellman-Merkle context | |
| * | | * | |
| * \return 0 if successful | | * \return 0 if successful | |
| */ | | */ | |
| int ssl_set_dh_param_ctx( ssl_context *ssl, dhm_context *dhm_ctx ); | | int ssl_set_dh_param_ctx( ssl_context *ssl, dhm_context *dhm_ctx ); | |
|
| | | #endif | |
| | | | |
| /** | | /** | |
|
| * \brief Set hostname for ServerName TLS Extension | | * \brief Set hostname for ServerName TLS extension | |
| | | * (client-side only) | |
| * | | * | |
| * | | * | |
| * \param ssl SSL context | | * \param ssl SSL context | |
| * \param hostname the server hostname | | * \param hostname the server hostname | |
| * | | * | |
| * \return 0 if successful or POLARSSL_ERR_SSL_MALLOC_FAILED | | * \return 0 if successful or POLARSSL_ERR_SSL_MALLOC_FAILED | |
| */ | | */ | |
| int ssl_set_hostname( ssl_context *ssl, const char *hostname ); | | int ssl_set_hostname( ssl_context *ssl, const char *hostname ); | |
| | | | |
| /** | | /** | |
|
| | | * \brief Set server side ServerName TLS extension callback | |
| | | * (optional, server-side only). | |
| | | * | |
| | | * If set, the ServerName callback is called whenever the | |
| | | * server receives a ServerName TLS extension from the clie | |
| | | nt | |
| | | * during a handshake. The ServerName callback has the | |
| | | * following parameters: (void *parameter, ssl_context *ssl | |
| | | , | |
| | | * const unsigned char *hostname, size_t len). If a suitabl | |
| | | e | |
| | | * certificate is found, the callback should set the | |
| | | * certificate and key to use with ssl_set_own_cert() (and | |
| | | * possibly adjust the CA chain as well) and return 0. The | |
| | | * callback should return -1 to abort the handshake at this | |
| | | * point. | |
| | | * | |
| | | * \param ssl SSL context | |
| | | * \param f_sni verification function | |
| | | * \param p_sni verification parameter | |
| | | */ | |
| | | void ssl_set_sni( ssl_context *ssl, | |
| | | int (*f_sni)(void *, ssl_context *, const unsigned char * | |
| | | , | |
| | | size_t), | |
| | | void *p_sni ); | |
| | | | |
| | | /** | |
| * \brief Set the maximum supported version sent from the client s
ide | | * \brief Set the maximum supported version sent from the client s
ide | |
| * | | * | |
| * \param ssl SSL context | | * \param ssl SSL context | |
| * \param major Major version number (only SSL_MAJOR_VERSION_3 supported
) | | * \param major Major version number (only SSL_MAJOR_VERSION_3 supported
) | |
| * \param minor Minor version number (SSL_MINOR_VERSION_0, | | * \param minor Minor version number (SSL_MINOR_VERSION_0, | |
|
| * SSL_MINOR_VERSION_1 and SSL_MINOR_VERSION_2 supported) | | * SSL_MINOR_VERSION_1 and SSL_MINOR_VERSION_2, | |
| | | * SSL_MINOR_VERSION_3 supported) | |
| */ | | */ | |
| void ssl_set_max_version( ssl_context *ssl, int major, int minor ); | | void ssl_set_max_version( ssl_context *ssl, int major, int minor ); | |
| | | | |
| /** | | /** | |
|
| | | * \brief Set the minimum accepted SSL/TLS protocol version | |
| | | * (Default: SSL_MAJOR_VERSION_3, SSL_MINOR_VERSION_0) | |
| | | * | |
| | | * \param ssl SSL context | |
| | | * \param major Major version number (only SSL_MAJOR_VERSION_3 supported | |
| | | ) | |
| | | * \param minor Minor version number (SSL_MINOR_VERSION_0, | |
| | | * SSL_MINOR_VERSION_1 and SSL_MINOR_VERSION_2, | |
| | | * SSL_MINOR_VERSION_3 supported) | |
| | | */ | |
| | | void ssl_set_min_version( ssl_context *ssl, int major, int minor ); | |
| | | | |
| | | /** | |
| | | * \brief Enable / Disable renegotiation support for connection wh | |
| | | en | |
| | | * initiated by peer | |
| | | * (Default: SSL_RENEGOTIATION_DISABLED) | |
| | | * | |
| | | * Note: A server with support enabled is more vulnerable f | |
| | | or a | |
| | | * resource DoS by a malicious client. | |
| | | * | |
| | | * \param ssl SSL context | |
| | | * \param renegotiation Enable or disable (SSL_RENEGOTIATION_ENABLED or | |
| | | * SSL_RENEGOTIATION_DISABLED) | |
| | | */ | |
| | | void ssl_set_renegotiation( ssl_context *ssl, int renegotiation ); | |
| | | | |
| | | /** | |
| | | * \brief Prevent or allow legacy renegotiation. | |
| | | * (Default: SSL_LEGACY_NO_RENEGOTIATION) | |
| | | * | |
| | | * SSL_LEGACY_NO_RENEGOTIATION allows connections to | |
| | | * be established even if the peer does not support | |
| | | * secure renegotiation, but does not allow renegotiation | |
| | | * to take place if not secure. | |
| | | * (Interoperable and secure option) | |
| | | * | |
| | | * SSL_LEGACY_ALLOW_RENEGOTIATION allows renegotiations | |
| | | * with non-upgraded peers. Allowing legacy renegotiation | |
| | | * makes the connection vulnerable to specific man in the | |
| | | * middle attacks. (See RFC 5746) | |
| | | * (Most interoperable and least secure option) | |
| | | * | |
| | | * SSL_LEGACY_BREAK_HANDSHAKE breaks off connections | |
| | | * if peer does not support secure renegotiation. Results | |
| | | * in interoperability issues with non-upgraded peers | |
| | | * that do not support renegotiation altogether. | |
| | | * (Most secure option, interoperability issues) | |
| | | * | |
| | | * \param ssl SSL context | |
| | | * \param allow_legacy Prevent or allow (SSL_NO_LEGACY_RENEGOTIATION or | |
| | | * SSL_ALLOW_LEGACY_RENEGOTIATION) | |
| | | */ | |
| | | void ssl_legacy_renegotiation( ssl_context *ssl, int allow_legacy ); | |
| | | | |
| | | /** | |
| * \brief Return the number of data bytes available to read | | * \brief Return the number of data bytes available to read | |
| * | | * | |
| * \param ssl SSL context | | * \param ssl SSL context | |
| * | | * | |
| * \return how many bytes are available in the read buffer | | * \return how many bytes are available in the read buffer | |
| */ | | */ | |
| size_t ssl_get_bytes_avail( const ssl_context *ssl ); | | size_t ssl_get_bytes_avail( const ssl_context *ssl ); | |
| | | | |
| /** | | /** | |
| * \brief Return the result of the certificate verification | | * \brief Return the result of the certificate verification | |
| | | | |
| skipping to change at line 620 | | skipping to change at line 930 | |
| /** | | /** | |
| * \brief Return the current SSL version (SSLv3/TLSv1/etc) | | * \brief Return the current SSL version (SSLv3/TLSv1/etc) | |
| * | | * | |
| * \param ssl SSL context | | * \param ssl SSL context | |
| * | | * | |
| * \return a string containing the SSL version | | * \return a string containing the SSL version | |
| */ | | */ | |
| const char *ssl_get_version( const ssl_context *ssl ); | | const char *ssl_get_version( const ssl_context *ssl ); | |
| | | | |
| /** | | /** | |
|
| | | * \brief Return the peer certificate from the current connection | |
| | | * | |
| | | * Note: Can be NULL in case no certificate was sent during | |
| | | * the handshake. Different calls for the same connection c | |
| | | an | |
| | | * return the same or different pointers for the same | |
| | | * certificate and even a different certificate altogether. | |
| | | * The peer cert CAN change in a single connection if | |
| | | * renegotiation is performed. | |
| | | * | |
| | | * \param ssl SSL context | |
| | | * | |
| | | * \return the current peer certificate | |
| | | */ | |
| | | const x509_cert *ssl_get_peer_cert( const ssl_context *ssl ); | |
| | | | |
| | | /** | |
| * \brief Perform the SSL handshake | | * \brief Perform the SSL handshake | |
| * | | * | |
| * \param ssl SSL context | | * \param ssl SSL context | |
| * | | * | |
| * \return 0 if successful, POLARSSL_ERR_NET_WANT_READ, | | * \return 0 if successful, POLARSSL_ERR_NET_WANT_READ, | |
| * POLARSSL_ERR_NET_WANT_WRITE, or a specific SSL error cod
e. | | * POLARSSL_ERR_NET_WANT_WRITE, or a specific SSL error cod
e. | |
| */ | | */ | |
| int ssl_handshake( ssl_context *ssl ); | | int ssl_handshake( ssl_context *ssl ); | |
| | | | |
| /** | | /** | |
|
| | | * \brief Perform an SSL renegotiation on the running connection | |
| | | * | |
| | | * \param ssl SSL context | |
| | | * | |
| | | * \return 0 if succesful, or any ssl_handshake() return value. | |
| | | */ | |
| | | int ssl_renegotiate( ssl_context *ssl ); | |
| | | | |
| | | /** | |
| * \brief Read at most 'len' application data bytes | | * \brief Read at most 'len' application data bytes | |
| * | | * | |
| * \param ssl SSL context | | * \param ssl SSL context | |
| * \param buf buffer that will hold the data | | * \param buf buffer that will hold the data | |
| * \param len how many bytes must be read | | * \param len how many bytes must be read | |
| * | | * | |
| * \return This function returns the number of bytes read, 0 for EO
F, | | * \return This function returns the number of bytes read, 0 for EO
F, | |
| * or a negative error code. | | * or a negative error code. | |
| */ | | */ | |
| int ssl_read( ssl_context *ssl, unsigned char *buf, size_t len ); | | int ssl_read( ssl_context *ssl, unsigned char *buf, size_t len ); | |
| | | | |
| skipping to change at line 658 | | skipping to change at line 993 | |
| * \return This function returns the number of bytes written, | | * \return This function returns the number of bytes written, | |
| * or a negative error code. | | * or a negative error code. | |
| * | | * | |
| * \note When this function returns POLARSSL_ERR_NET_WANT_WRITE, | | * \note When this function returns POLARSSL_ERR_NET_WANT_WRITE, | |
| * it must be called later with the *same* arguments, | | * it must be called later with the *same* arguments, | |
| * until it returns a positive value. | | * until it returns a positive value. | |
| */ | | */ | |
| int ssl_write( ssl_context *ssl, const unsigned char *buf, size_t len ); | | int ssl_write( ssl_context *ssl, const unsigned char *buf, size_t len ); | |
| | | | |
| /** | | /** | |
|
| | | * \brief Send an alert message | |
| | | * | |
| | | * \param ssl SSL context | |
| | | * \param level The alert level of the message | |
| | | * (SSL_ALERT_LEVEL_WARNING or SSL_ALERT_LEVEL_FATAL) | |
| | | * \param message The alert message (SSL_ALERT_MSG_*) | |
| | | * | |
| | | * \return 1 if successful, or a specific SSL error code. | |
| | | */ | |
| | | int ssl_send_alert_message( ssl_context *ssl, | |
| | | unsigned char level, | |
| | | unsigned char message ); | |
| | | /** | |
| * \brief Notify the peer that the connection is being closed | | * \brief Notify the peer that the connection is being closed | |
| * | | * | |
| * \param ssl SSL context | | * \param ssl SSL context | |
| */ | | */ | |
| int ssl_close_notify( ssl_context *ssl ); | | int ssl_close_notify( ssl_context *ssl ); | |
| | | | |
| /** | | /** | |
|
| * \brief Free an SSL context | | * \brief Free referenced items in an SSL context and clear memory | |
| * | | * | |
| * \param ssl SSL context | | * \param ssl SSL context | |
| */ | | */ | |
| void ssl_free( ssl_context *ssl ); | | void ssl_free( ssl_context *ssl ); | |
| | | | |
|
| | | /** | |
| | | * \brief Free referenced items in an SSL session including the | |
| | | * peer certificate and clear memory | |
| | | * | |
| | | * \param session SSL session | |
| | | */ | |
| | | void ssl_session_free( ssl_session *session ); | |
| | | | |
| | | /** | |
| | | * \brief Free referenced items in an SSL transform context and c | |
| | | lear | |
| | | * memory | |
| | | * | |
| | | * \param transform SSL transform context | |
| | | */ | |
| | | void ssl_transform_free( ssl_transform *transform ); | |
| | | | |
| | | /** | |
| | | * \brief Free referenced items in an SSL handshake context and c | |
| | | lear | |
| | | * memory | |
| | | * | |
| | | * \param handshake SSL handshake context | |
| | | */ | |
| | | void ssl_handshake_free( ssl_handshake_params *handshake ); | |
| | | | |
| /* | | /* | |
| * Internal functions (do not call directly) | | * Internal functions (do not call directly) | |
| */ | | */ | |
| int ssl_handshake_client( ssl_context *ssl ); | | int ssl_handshake_client( ssl_context *ssl ); | |
| int ssl_handshake_server( ssl_context *ssl ); | | int ssl_handshake_server( ssl_context *ssl ); | |
|
| | | void ssl_handshake_wrapup( ssl_context *ssl ); | |
| | | | |
| | | int ssl_send_fatal_handshake_failure( ssl_context *ssl ); | |
| | | | |
| int ssl_derive_keys( ssl_context *ssl ); | | int ssl_derive_keys( ssl_context *ssl ); | |
|
| void ssl_calc_verify( ssl_context *ssl, unsigned char hash[36] ); | | | |
| | | | |
| int ssl_read_record( ssl_context *ssl ); | | int ssl_read_record( ssl_context *ssl ); | |
| /** | | /** | |
| * \return 0 if successful, POLARSSL_ERR_SSL_CONN_EOF on EOF or | | * \return 0 if successful, POLARSSL_ERR_SSL_CONN_EOF on EOF or | |
| * another negative error code. | | * another negative error code. | |
| */ | | */ | |
| int ssl_fetch_input( ssl_context *ssl, size_t nb_want ); | | int ssl_fetch_input( ssl_context *ssl, size_t nb_want ); | |
| | | | |
| int ssl_write_record( ssl_context *ssl ); | | int ssl_write_record( ssl_context *ssl ); | |
| int ssl_flush_output( ssl_context *ssl ); | | int ssl_flush_output( ssl_context *ssl ); | |
| | | | |
| int ssl_parse_certificate( ssl_context *ssl ); | | int ssl_parse_certificate( ssl_context *ssl ); | |
| int ssl_write_certificate( ssl_context *ssl ); | | int ssl_write_certificate( ssl_context *ssl ); | |
| | | | |
| int ssl_parse_change_cipher_spec( ssl_context *ssl ); | | int ssl_parse_change_cipher_spec( ssl_context *ssl ); | |
| int ssl_write_change_cipher_spec( ssl_context *ssl ); | | int ssl_write_change_cipher_spec( ssl_context *ssl ); | |
| | | | |
| int ssl_parse_finished( ssl_context *ssl ); | | int ssl_parse_finished( ssl_context *ssl ); | |
| int ssl_write_finished( ssl_context *ssl ); | | int ssl_write_finished( ssl_context *ssl ); | |
| | | | |
|
| | | void ssl_optimize_checksum( ssl_context *ssl, int ciphersuite ); | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| } | | } | |
| #endif | | #endif | |
| | | | |
| #endif /* ssl.h */ | | #endif /* ssl.h */ | |
| | | | |
End of changes. 58 change blocks. |
| 125 lines changed or deleted | | 552 lines changed or added | |
|
| x509.h | | x509.h | |
| | | | |
| skipping to change at line 79 | | skipping to change at line 79 | |
| * \{ | | * \{ | |
| */ | | */ | |
| #define BADCERT_EXPIRED 0x01 /**< The certificate validity has
expired. */ | | #define BADCERT_EXPIRED 0x01 /**< The certificate validity has
expired. */ | |
| #define BADCERT_REVOKED 0x02 /**< The certificate has been rev
oked (is on a CRL). */ | | #define BADCERT_REVOKED 0x02 /**< The certificate has been rev
oked (is on a CRL). */ | |
| #define BADCERT_CN_MISMATCH 0x04 /**< The certificate Common Name
(CN) does not match with the expected CN. */ | | #define BADCERT_CN_MISMATCH 0x04 /**< The certificate Common Name
(CN) does not match with the expected CN. */ | |
| #define BADCERT_NOT_TRUSTED 0x08 /**< The certificate is not corre
ctly signed by the trusted CA. */ | | #define BADCERT_NOT_TRUSTED 0x08 /**< The certificate is not corre
ctly signed by the trusted CA. */ | |
| #define BADCRL_NOT_TRUSTED 0x10 /**< CRL is not correctly signed
by the trusted CA. */ | | #define BADCRL_NOT_TRUSTED 0x10 /**< CRL is not correctly signed
by the trusted CA. */ | |
| #define BADCRL_EXPIRED 0x20 /**< CRL is expired. */ | | #define BADCRL_EXPIRED 0x20 /**< CRL is expired. */ | |
| #define BADCERT_MISSING 0x40 /**< Certificate was missing. */ | | #define BADCERT_MISSING 0x40 /**< Certificate was missing. */ | |
| #define BADCERT_SKIP_VERIFY 0x80 /**< Certificate verification was
skipped. */ | | #define BADCERT_SKIP_VERIFY 0x80 /**< Certificate verification was
skipped. */ | |
|
| | | #define BADCERT_OTHER 0x0100 /**< Other reason (can be used by
verify callback) */ | |
| /* \} name */ | | /* \} name */ | |
| /* \} addtogroup x509_module */ | | /* \} addtogroup x509_module */ | |
| | | | |
| /* | | /* | |
| * various object identifiers | | * various object identifiers | |
| */ | | */ | |
| #define X520_COMMON_NAME 3 | | #define X520_COMMON_NAME 3 | |
| #define X520_COUNTRY 6 | | #define X520_COUNTRY 6 | |
| #define X520_LOCALITY 7 | | #define X520_LOCALITY 7 | |
| #define X520_STATE 8 | | #define X520_STATE 8 | |
| | | | |
| skipping to change at line 101 | | skipping to change at line 102 | |
| #define PKCS9_EMAIL 1 | | #define PKCS9_EMAIL 1 | |
| | | | |
| #define X509_OUTPUT_DER 0x01 | | #define X509_OUTPUT_DER 0x01 | |
| #define X509_OUTPUT_PEM 0x02 | | #define X509_OUTPUT_PEM 0x02 | |
| #define PEM_LINE_LENGTH 72 | | #define PEM_LINE_LENGTH 72 | |
| #define X509_ISSUER 0x01 | | #define X509_ISSUER 0x01 | |
| #define X509_SUBJECT 0x02 | | #define X509_SUBJECT 0x02 | |
| | | | |
| #define OID_X520 "\x55\x04" | | #define OID_X520 "\x55\x04" | |
| #define OID_CN OID_X520 "\x03" | | #define OID_CN OID_X520 "\x03" | |
|
| | | #define OID_COUNTRY OID_X520 "\x06" | |
| | | #define OID_LOCALITY OID_X520 "\x07" | |
| | | #define OID_STATE OID_X520 "\x08" | |
| | | #define OID_ORGANIZATION OID_X520 "\x0A" | |
| | | #define OID_ORG_UNIT OID_X520 "\x0B" | |
| | | | |
| #define OID_PKCS1 "\x2A\x86\x48\x86\xF7\x0D\x01\x01" | | #define OID_PKCS1 "\x2A\x86\x48\x86\xF7\x0D\x01\x01" | |
| #define OID_PKCS1_RSA OID_PKCS1 "\x01" | | #define OID_PKCS1_RSA OID_PKCS1 "\x01" | |
|
| | | #define OID_PKCS1_SHA1 OID_PKCS1 "\x05" | |
| | | | |
| #define OID_RSA_SHA_OBS "\x2B\x0E\x03\x02\x1D" | | #define OID_RSA_SHA_OBS "\x2B\x0E\x03\x02\x1D" | |
| | | | |
| #define OID_PKCS9 "\x2A\x86\x48\x86\xF7\x0D\x01\x09" | | #define OID_PKCS9 "\x2A\x86\x48\x86\xF7\x0D\x01\x09" | |
| #define OID_PKCS9_EMAIL OID_PKCS9 "\x01" | | #define OID_PKCS9_EMAIL OID_PKCS9 "\x01" | |
| | | | |
| /** ISO arc for standard certificate and CRL extensions */ | | /** ISO arc for standard certificate and CRL extensions */ | |
| #define OID_ID_CE "\x55\x1D" /**< id-ce OBJECT IDENTIFIER ::
= {joint-iso-ccitt(2) ds(5) 29} */ | | #define OID_ID_CE "\x55\x1D" /**< id-ce OBJECT IDENTIFIER ::
= {joint-iso-ccitt(2) ds(5) 29} */ | |
| | | | |
| /** | | /** | |
| | | | |
| skipping to change at line 302 | | skipping to change at line 309 | |
| | | | |
| x509_time valid_from; /**< Start time of certificate validity. */ | | x509_time valid_from; /**< Start time of certificate validity. */ | |
| x509_time valid_to; /**< End time of certificate validity. */ | | x509_time valid_to; /**< End time of certificate validity. */ | |
| | | | |
| x509_buf pk_oid; /**< Subject public key info. Includes the
public key algorithm and the key itself. */ | | x509_buf pk_oid; /**< Subject public key info. Includes the
public key algorithm and the key itself. */ | |
| rsa_context rsa; /**< Container for the RSA context. Only RS
A is supported for public keys at this time. */ | | rsa_context rsa; /**< Container for the RSA context. Only RS
A is supported for public keys at this time. */ | |
| | | | |
| x509_buf issuer_id; /**< Optional X.509 v2/v3 issuer unique ide
ntifier. */ | | x509_buf issuer_id; /**< Optional X.509 v2/v3 issuer unique ide
ntifier. */ | |
| x509_buf subject_id; /**< Optional X.509 v2/v3 subject unique id
entifier. */ | | x509_buf subject_id; /**< Optional X.509 v2/v3 subject unique id
entifier. */ | |
| x509_buf v3_ext; /**< Optional X.509 v3 extensions. Only Bas
ic Contraints are supported at this time. */ | | x509_buf v3_ext; /**< Optional X.509 v3 extensions. Only Bas
ic Contraints are supported at this time. */ | |
|
| | | x509_sequence subject_alt_names; /**< Optional list of Subject Alter
native Names (Only dNSName supported). */ | |
| | | | |
| int ext_types; /**< Bit string containing detected and par
sed extensions */ | | int ext_types; /**< Bit string containing detected and par
sed extensions */ | |
| int ca_istrue; /**< Optional Basic Constraint extension va
lue: 1 if this certificate belongs to a CA, 0 otherwise. */ | | int ca_istrue; /**< Optional Basic Constraint extension va
lue: 1 if this certificate belongs to a CA, 0 otherwise. */ | |
|
| int max_pathlen; /**< Optional Basic Constraint extension va
lue: The maximum path length to the root certificate. */ | | int max_pathlen; /**< Optional Basic Constraint extension va
lue: The maximum path length to the root certificate. Path length is 1 high
er than RFC 5280 'meaning', so 1+ */ | |
| | | | |
| unsigned char key_usage; /**< Optional key usage extension value: Se
e the values below */ | | unsigned char key_usage; /**< Optional key usage extension value: Se
e the values below */ | |
| | | | |
| x509_sequence ext_key_usage; /**< Optional list of extended key usage O
IDs. */ | | x509_sequence ext_key_usage; /**< Optional list of extended key usage O
IDs. */ | |
| | | | |
| unsigned char ns_cert_type; /**< Optional Netscape certificate type ext
ension value: See the values below */ | | unsigned char ns_cert_type; /**< Optional Netscape certificate type ext
ension value: See the values below */ | |
| | | | |
| x509_buf sig_oid2; /**< Signature algorithm. Must match sig_oi
d1. */ | | x509_buf sig_oid2; /**< Signature algorithm. Must match sig_oi
d1. */ | |
| x509_buf sig; /**< Signature: hash of the tbs part signed
with the private key. */ | | x509_buf sig; /**< Signature: hash of the tbs part signed
with the private key. */ | |
| int sig_alg; /**< Internal representation of the signatu
re algorithm, e.g. SIG_RSA_MD2 */ | | int sig_alg; /**< Internal representation of the signatu
re algorithm, e.g. SIG_RSA_MD2 */ | |
| | | | |
| skipping to change at line 419 | | skipping to change at line 427 | |
| extern "C" { | | extern "C" { | |
| #endif | | #endif | |
| | | | |
| /** | | /** | |
| * \name Functions to read in DHM parameters, a certificate, CRL or private
RSA key | | * \name Functions to read in DHM parameters, a certificate, CRL or private
RSA key | |
| * \{ | | * \{ | |
| */ | | */ | |
| | | | |
| /** \ingroup x509_module */ | | /** \ingroup x509_module */ | |
| /** | | /** | |
|
| * \brief Parse a single DER formatted certificate and add it | | | |
| * to the chained list. | | | |
| * | | | |
| * \param chain points to the start of the chain | | | |
| * \param buf buffer holding the certificate DER data | | | |
| * \param buflen size of the buffer | | | |
| * | | | |
| * \return 0 if successful, or a specific X509 or PEM error code | | | |
| */ | | | |
| int x509parse_crt_der( x509_cert *chain, const unsigned char *buf, size_t b | | | |
| uflen ); | | | |
| | | | |
| /** | | | |
| * \brief Parse one or more certificates and add them | | * \brief Parse one or more certificates and add them | |
| * to the chained list. Parses permissively. If some | | * to the chained list. Parses permissively. If some | |
| * certificates can be parsed, the result is the number | | * certificates can be parsed, the result is the number | |
| * of failed certificates it encountered. If none complete | | * of failed certificates it encountered. If none complete | |
| * correctly, the first error is returned. | | * correctly, the first error is returned. | |
| * | | * | |
| * \param chain points to the start of the chain | | * \param chain points to the start of the chain | |
| * \param buf buffer holding the certificate data | | * \param buf buffer holding the certificate data | |
| * \param buflen size of the buffer | | * \param buflen size of the buffer | |
| * | | * | |
| | | | |
| skipping to change at line 464 | | skipping to change at line 460 | |
| * \param chain points to the start of the chain | | * \param chain points to the start of the chain | |
| * \param path filename to read the certificates from | | * \param path filename to read the certificates from | |
| * | | * | |
| * \return 0 if all certificates parsed successfully, a positive nu
mber | | * \return 0 if all certificates parsed successfully, a positive nu
mber | |
| * if partly successful or a specific X509 or PEM error cod
e | | * if partly successful or a specific X509 or PEM error cod
e | |
| */ | | */ | |
| int x509parse_crtfile( x509_cert *chain, const char *path ); | | int x509parse_crtfile( x509_cert *chain, const char *path ); | |
| | | | |
| /** \ingroup x509_module */ | | /** \ingroup x509_module */ | |
| /** | | /** | |
|
| | | * \brief Load one or more certificate files from a path and add t | |
| | | hem | |
| | | * to the chained list. Parses permissively. If some | |
| | | * certificates can be parsed, the result is the number | |
| | | * of failed certificates it encountered. If none complete | |
| | | * correctly, the first error is returned. | |
| | | * | |
| | | * \param chain points to the start of the chain | |
| | | * \param path directory / folder to read the certificate files from | |
| | | * | |
| | | * \return 0 if all certificates parsed successfully, a positive nu | |
| | | mber | |
| | | * if partly successful or a specific X509 or PEM error cod | |
| | | e | |
| | | */ | |
| | | int x509parse_crtpath( x509_cert *chain, const char *path ); | |
| | | | |
| | | /** \ingroup x509_module */ | |
| | | /** | |
| * \brief Parse one or more CRLs and add them | | * \brief Parse one or more CRLs and add them | |
| * to the chained list | | * to the chained list | |
| * | | * | |
| * \param chain points to the start of the chain | | * \param chain points to the start of the chain | |
| * \param buf buffer holding the CRL data | | * \param buf buffer holding the CRL data | |
| * \param buflen size of the buffer | | * \param buflen size of the buffer | |
| * | | * | |
| * \return 0 if successful, or a specific X509 or PEM error code | | * \return 0 if successful, or a specific X509 or PEM error code | |
| */ | | */ | |
| int x509parse_crl( x509_crl *chain, const unsigned char *buf, size_t buflen
); | | int x509parse_crl( x509_crl *chain, const unsigned char *buf, size_t buflen
); | |
| | | | |
| skipping to change at line 631 | | skipping to change at line 643 | |
| /** | | /** | |
| * \brief Give an known OID, return its descriptive string. | | * \brief Give an known OID, return its descriptive string. | |
| * | | * | |
| * \param oid buffer containing the oid | | * \param oid buffer containing the oid | |
| * | | * | |
| * \return Return a string if the OID is known, | | * \return Return a string if the OID is known, | |
| * or NULL otherwise. | | * or NULL otherwise. | |
| */ | | */ | |
| const char *x509_oid_get_description( x509_buf *oid ); | | const char *x509_oid_get_description( x509_buf *oid ); | |
| | | | |
|
| /** | | /* | |
| * \brief Give an OID, return a string version of its OID number. | | * \brief Give an OID, return a string version of its OID number. | |
| * | | * | |
| * \param buf Buffer to write to | | * \param buf Buffer to write to | |
| * \param size Maximum size of buffer | | * \param size Maximum size of buffer | |
| * \param oid Buffer containing the OID | | * \param oid Buffer containing the OID | |
| * | | * | |
| * \return The amount of data written to the buffer, or -1 in | | * \return The amount of data written to the buffer, or -1 in | |
| * case of an error. | | * case of an error. | |
| */ | | */ | |
| int x509_oid_get_numeric_string( char *buf, size_t size, x509_buf *oid ); | | int x509_oid_get_numeric_string( char *buf, size_t size, x509_buf *oid ); | |
| | | | |
| skipping to change at line 662 | | skipping to change at line 674 | |
| int x509parse_time_expired( const x509_time *time ); | | int x509parse_time_expired( const x509_time *time ); | |
| | | | |
| /** | | /** | |
| * \name Functions to verify a certificate | | * \name Functions to verify a certificate | |
| * \{ | | * \{ | |
| */ | | */ | |
| /** \ingroup x509_module */ | | /** \ingroup x509_module */ | |
| /** | | /** | |
| * \brief Verify the certificate signature | | * \brief Verify the certificate signature | |
| * | | * | |
|
| | | * The verify callback is a user-supplied callback that | |
| | | * can clear / modify / add flags for a certificate. If set | |
| | | , | |
| | | * the verification callback is called for each | |
| | | * certificate in the chain (from the trust-ca down to the | |
| | | * presented crt). The parameters for the callback are: | |
| | | * (void *parameter, x509_cert *crt, int certificate_depth, | |
| | | * int *flags). With the flags representing current flags f | |
| | | or | |
| | | * that specific certificate and the certificate depth from | |
| | | * the top (Trust CA depth = 0). | |
| | | * | |
| | | * All flags left after returning from the callback | |
| | | * are also returned to the application. The function shoul | |
| | | d | |
| | | * return 0 for anything but a fatal error. | |
| | | * | |
| * \param crt a certificate to be verified | | * \param crt a certificate to be verified | |
| * \param trust_ca the trusted CA chain | | * \param trust_ca the trusted CA chain | |
| * \param ca_crl the CRL chain for trusted CA's | | * \param ca_crl the CRL chain for trusted CA's | |
| * \param cn expected Common Name (can be set to | | * \param cn expected Common Name (can be set to | |
| * NULL if the CN must not be verified) | | * NULL if the CN must not be verified) | |
| * \param flags result of the verification | | * \param flags result of the verification | |
| * \param f_vrfy verification function | | * \param f_vrfy verification function | |
| * \param p_vrfy verification parameter | | * \param p_vrfy verification parameter | |
| * | | * | |
| * \return 0 if successful or POLARSSL_ERR_X509_SIG_VERIFY_FAILED, | | * \return 0 if successful or POLARSSL_ERR_X509_SIG_VERIFY_FAILED, | |
| * in which case *flags will have one or more of | | * in which case *flags will have one or more of | |
| * the following values set: | | * the following values set: | |
| * BADCERT_EXPIRED -- | | * BADCERT_EXPIRED -- | |
| * BADCERT_REVOKED -- | | * BADCERT_REVOKED -- | |
| * BADCERT_CN_MISMATCH -- | | * BADCERT_CN_MISMATCH -- | |
| * BADCERT_NOT_TRUSTED | | * BADCERT_NOT_TRUSTED | |
|
| * | | * or another error in case of a fatal error encountered | |
| * \note TODO: add two arguments, depth and crl | | * during the verification process. | |
| */ | | */ | |
| int x509parse_verify( x509_cert *crt, | | int x509parse_verify( x509_cert *crt, | |
| x509_cert *trust_ca, | | x509_cert *trust_ca, | |
| x509_crl *ca_crl, | | x509_crl *ca_crl, | |
| const char *cn, int *flags, | | const char *cn, int *flags, | |
|
| int (*f_vrfy)(void *, x509_cert *, int, int), | | int (*f_vrfy)(void *, x509_cert *, int, int *), | |
| void *p_vrfy ); | | void *p_vrfy ); | |
| | | | |
| /** | | /** | |
| * \brief Verify the certificate signature | | * \brief Verify the certificate signature | |
| * | | * | |
| * \param crt a certificate to be verified | | * \param crt a certificate to be verified | |
| * \param crl the CRL to verify against | | * \param crl the CRL to verify against | |
| * | | * | |
| * \return 1 if the certificate is revoked, 0 otherwise | | * \return 1 if the certificate is revoked, 0 otherwise | |
| * | | * | |
| | | | |
End of changes. 11 change blocks. |
| 18 lines changed or deleted | | 49 lines changed or added | |
|