Changeset 1159


Ignore:
Timestamp:
12/10/11 22:55:01 (5 months ago)
Author:
paul
Message:
  • Changed the behaviour of x509parse_parse_crt for permissive parsing. Now returns the number of 'failed certificates' instead of having a switch to enable it.
  • As a consequence all error code that were positive were changed. A lot of MALLOC_FAILED and FILE_IO_ERROR error codes added for different modules.
  • Programs and tests were adapted accordingly
Location:
trunk
Files:
38 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r1154 r1159  
    3939   * Added permissive certificate parsing to x509parse_crt() and 
    4040     x509parse_crtfile(). With permissive parsing the parsing does not stop on 
    41          encountering a parse-error 
     41         encountering a parse-error. Beware that the meaning of return values has 
     42         changed! 
     43   * All error codes are now negative. Even on mermory failures and IO errors. 
    4244 
    4345Bugfix 
  • trunk/include/polarssl/asn1.h

    r1110 r1159  
    5353#define POLARSSL_ERR_ASN1_LENGTH_MISMATCH                  -0x001A  /**< Actual length differs from expected length. */ 
    5454#define POLARSSL_ERR_ASN1_INVALID_DATA                     -0x001C  /**< Data is invalid. (not used) */ 
     55#define POLARSSL_ERR_ASN1_MALLOC_FAILED                    -0x001E  /**< Memory allocation failed */ 
    5556/* \} name */ 
    5657 
  • trunk/include/polarssl/base64.h

    r1027 r1159  
    3030#include <string.h> 
    3131 
    32 #define POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL               -0x0010  /**< Output buffer too small. */ 
    33 #define POLARSSL_ERR_BASE64_INVALID_CHARACTER              -0x0012  /**< Invalid character in input. */ 
     32#define POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL               -0x002A  /**< Output buffer too small. */ 
     33#define POLARSSL_ERR_BASE64_INVALID_CHARACTER              -0x002C  /**< Invalid character in input. */ 
    3434 
    3535#ifdef __cplusplus 
  • trunk/include/polarssl/bignum.h

    r1136 r1159  
    3434#define POLARSSL_ERR_MPI_BAD_INPUT_DATA                    -0x0004  /**< Bad input parameters to function. */ 
    3535#define POLARSSL_ERR_MPI_INVALID_CHARACTER                 -0x0006  /**< There is an invalid character in the digit string. */ 
    36 #define POLARSSL_ERR_MPI_BUFFER_TOO_SMALL                  -0x0008  /**< The buffer is too small to write too. */ 
     36#define POLARSSL_ERR_MPI_BUFFER_TOO_SMALL                  -0x0008  /**< The buffer is too small to write to. */ 
    3737#define POLARSSL_ERR_MPI_NEGATIVE_VALUE                    -0x000A  /**< The input arguments are negative or result in illegal output. */ 
    3838#define POLARSSL_ERR_MPI_DIVISION_BY_ZERO                  -0x000C  /**< The input argument for division is zero, which is not allowed. */ 
    3939#define POLARSSL_ERR_MPI_NOT_ACCEPTABLE                    -0x000E  /**< The input arguments are not acceptable. */ 
     40#define POLARSSL_ERR_MPI_MALLOC_FAILED                     -0x0010  /**< Memory allocation failed. */ 
    4041 
    4142#define MPI_CHK(f) if( ( ret = f ) != 0 ) goto cleanup 
     
    146147 * 
    147148 * \return         0 if successful, 
    148  *                 1 if memory allocation failed 
     149 *                 POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed 
    149150 */ 
    150151int mpi_grow( mpi *X, size_t nblimbs ); 
     
    157158 * 
    158159 * \return         0 if successful, 
    159  *                 1 if memory allocation failed 
     160 *                 POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed 
    160161 */ 
    161162int mpi_copy( mpi *X, const mpi *Y ); 
     
    176177 * 
    177178 * \return         0 if successful, 
    178  *                 1 if memory allocation failed 
     179 *                 POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed 
    179180 */ 
    180181int mpi_lset( mpi *X, t_sint z ); 
     
    201202 * 
    202203 * \return         0 if successful, 
    203  *                 1 if memory allocation failed, 
     204 *                 POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed, 
    204205 *                 POLARSSL_ERR_MPI_BAD_INPUT_DATA if val is not 0 or 1 
    205206 */ 
     
    290291 * 
    291292 * \return         0 if successful, 
    292  *                 1 if memory allocation failed 
     293 *                 POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed 
    293294 */ 
    294295int mpi_read_binary( mpi *X, const unsigned char *buf, size_t buflen ); 
     
    313314 * 
    314315 * \return         0 if successful, 
    315  *                 1 if memory allocation failed 
     316 *                 POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed 
    316317 */ 
    317318int mpi_shift_l( mpi *X, size_t count ); 
     
    324325 * 
    325326 * \return         0 if successful, 
    326  *                 1 if memory allocation failed 
     327 *                 POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed 
    327328 */ 
    328329int mpi_shift_r( mpi *X, size_t count ); 
     
    372373 * 
    373374 * \return         0 if successful, 
    374  *                 1 if memory allocation failed 
     375 *                 POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed 
    375376 */ 
    376377int mpi_add_abs( mpi *X, const mpi *A, const mpi *B ); 
     
    396397 * 
    397398 * \return         0 if successful, 
    398  *                 1 if memory allocation failed 
     399 *                 POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed 
    399400 */ 
    400401int mpi_add_mpi( mpi *X, const mpi *A, const mpi *B ); 
     
    408409 * 
    409410 * \return         0 if successful, 
    410  *                 1 if memory allocation failed 
     411 *                 POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed 
    411412 */ 
    412413int mpi_sub_mpi( mpi *X, const mpi *A, const mpi *B ); 
     
    420421 * 
    421422 * \return         0 if successful, 
    422  *                 1 if memory allocation failed 
     423 *                 POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed 
    423424 */ 
    424425int mpi_add_int( mpi *X, const mpi *A, t_sint b ); 
     
    432433 * 
    433434 * \return         0 if successful, 
    434  *                 1 if memory allocation failed 
     435 *                 POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed 
    435436 */ 
    436437int mpi_sub_int( mpi *X, const mpi *A, t_sint b ); 
     
    444445 * 
    445446 * \return         0 if successful, 
    446  *                 1 if memory allocation failed 
     447 *                 POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed 
    447448 */ 
    448449int mpi_mul_mpi( mpi *X, const mpi *A, const mpi *B ); 
     
    458459 * 
    459460 * \return         0 if successful, 
    460  *                 1 if memory allocation failed 
     461 *                 POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed 
    461462 */ 
    462463int mpi_mul_int( mpi *X, const mpi *A, t_sint b ); 
     
    471472 * 
    472473 * \return         0 if successful, 
    473  *                 1 if memory allocation failed, 
     474 *                 POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed, 
    474475 *                 POLARSSL_ERR_MPI_DIVISION_BY_ZERO if B == 0 
    475476 * 
     
    487488 * 
    488489 * \return         0 if successful, 
    489  *                 1 if memory allocation failed, 
     490 *                 POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed, 
    490491 *                 POLARSSL_ERR_MPI_DIVISION_BY_ZERO if b == 0 
    491492 * 
     
    502503 * 
    503504 * \return         0 if successful, 
    504  *                 1 if memory allocation failed, 
     505 *                 POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed, 
    505506 *                 POLARSSL_ERR_MPI_DIVISION_BY_ZERO if B == 0, 
    506507 *                 POLARSSL_ERR_MPI_NEGATIVE_VALUE if B < 0 
     
    516517 * 
    517518 * \return         0 if successful, 
    518  *                 1 if memory allocation failed, 
     519 *                 POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed, 
    519520 *                 POLARSSL_ERR_MPI_DIVISION_BY_ZERO if b == 0, 
    520521 *                 POLARSSL_ERR_MPI_NEGATIVE_VALUE if b < 0 
     
    532533 * 
    533534 * \return         0 if successful, 
    534  *                 1 if memory allocation failed, 
     535 *                 POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed, 
    535536 *                 POLARSSL_ERR_MPI_BAD_INPUT_DATA if N is negative or even 
    536537 * 
     
    550551 * 
    551552 * \return         0 if successful, 
    552  *                 1 if memory allocation failed 
     553 *                 POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed 
    553554 */ 
    554555int mpi_fill_random( mpi *X, size_t size, 
     
    564565 * 
    565566 * \return         0 if successful, 
    566  *                 1 if memory allocation failed 
     567 *                 POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed 
    567568 */ 
    568569int mpi_gcd( mpi *G, const mpi *A, const mpi *B ); 
     
    576577 * 
    577578 * \return         0 if successful, 
    578  *                 1 if memory allocation failed, 
     579 *                 POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed, 
    579580 *                 POLARSSL_ERR_MPI_BAD_INPUT_DATA if N is negative or nil 
    580581                   POLARSSL_ERR_MPI_NOT_ACCEPTABLE if A has no inverse mod N 
     
    590591 * 
    591592 * \return         0 if successful (probably prime), 
    592  *                 1 if memory allocation failed, 
     593 *                 POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed, 
    593594 *                 POLARSSL_ERR_MPI_NOT_ACCEPTABLE if X is not prime 
    594595 */ 
     
    607608 * 
    608609 * \return         0 if successful (probably prime), 
    609  *                 1 if memory allocation failed, 
     610 *                 POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed, 
    610611 *                 POLARSSL_ERR_MPI_BAD_INPUT_DATA if nbits is < 3 
    611612 */ 
  • trunk/include/polarssl/ctr_drbg.h

    r1156 r1159  
    3535#define POLARSSL_ERR_CTR_DRBG_REQUEST_TOO_BIG              -0x0036  /**< Too many random requested in single call. */ 
    3636#define POLARSSL_ERR_CTR_DRBG_INPUT_TOO_BIG                -0x0038  /**< Input too large (Entropy + additional). */ 
     37#define POLARSSL_ERR_CTR_DRBG_FILE_IO_ERROR                -0x003A  /**< Read/write error in file. */ 
    3738 
    3839#define CTR_DRBG_BLOCKSIZE          16      /**< Block size used by the cipher                  */ 
  • trunk/include/polarssl/entropy.h

    r1157 r1159  
    3232#include "sha4.h" 
    3333 
    34 #define POLARSSL_ERR_ENTROPY_SOURCE_FAILED                 -0x003A  /**< Critical entropy source failure. */ 
    35 #define POLARSSL_ERR_ENTROPY_MAX_SOURCES                   -0x003C  /**< No more sources can be added. */ 
     34#define POLARSSL_ERR_ENTROPY_SOURCE_FAILED                 -0x003C  /**< Critical entropy source failure. */ 
     35#define POLARSSL_ERR_ENTROPY_MAX_SOURCES                   -0x003E  /**< No more sources can be added. */ 
    3636 
    3737#define ENTROPY_MAX_SOURCES     20      /**< Maximum number of sources supported */ 
  • trunk/include/polarssl/error.h

    r1138 r1159  
    4949 * 
    5050 * Module   Nr  Codes assigned  
    51  * MPI       7  0x0002-0x000E 
    52  * BASE64    2  0x0010-0x0012 
    53  * ASN1      5  0x0014-0x001C 
     51 * MPI       7  0x0002-0x0010 
     52 * ASN1      6  0x0014-0x001E 
    5453 * AES       2  0x0020-0x0022 
    5554 * CAMELLIA  2  0x0024-0x0026 
    5655 * XTEA      1  0x0028-0x0028 
     56 * BASE64    2  0x002A-0x002C 
    5757 * PADLOCK   1  0x0030-0x0030 
    5858 * DES       1  0x0032-0x0032 
    5959 * NET      11  0x0040-0x0054 
    60  * CTR_DBRG  3  0x0034-0x0038 
    61  * ENTROPY   2  0x003A-0x003C 
     60 * CTR_DBRG  3  0x0034-0x003A 
     61 * ENTROPY   2  0x003C-0x003E 
     62 * MD2       1  0x0070-0x0070 
     63 * MD4       1  0x0072-0x0072 
     64 * MD5       1  0x0074-0x0074 
     65 * SHA1      1  0x0076-0x0076 
     66 * SHA2      1  0x0078-0x0078 
     67 * SHA4      1  0x007A-0x007A 
    6268 * 
    6369 * High-level module nr (3 bits - 0x1...-0x8...) 
    6470 * Name     ID  Nr of Errors 
    6571 * PEM      1   8 
    66  * X509     2   20 
     72 * X509     2   21 
    6773 * DHM      3   6 
    6874 * RSA      4   9 
    6975 * MD       5   1 
    7076 * CIPER    6   1 
    71  * SSL      7   27 
     77 * SSL      7   30 
    7278 * 
    7379 * Module dependent error code (5 bits 0x.08.-0x.F8.) 
  • trunk/include/polarssl/md2.h

    r1097 r1159  
    2929 
    3030#include <string.h> 
     31 
     32#define POLARSSL_ERR_MD2_FILE_IO_ERROR                 -0x0070  /**< Read/write error in file. */ 
    3133 
    3234/** 
     
    8890 * \param output   MD2 checksum result 
    8991 * 
    90  * \return         0 if successful, 1 if fopen failed, 
    91  *                 or 2 if fread failed 
     92 * \return         0 if successful, or POLARSSL_ERR_MD2_FILE_IO_ERROR 
    9293 */ 
    9394int md2_file( const char *path, unsigned char output[16] ); 
  • trunk/include/polarssl/md4.h

    r1014 r1159  
    2929 
    3030#include <string.h> 
     31 
     32#define POLARSSL_ERR_MD4_FILE_IO_ERROR                 -0x0072  /**< Read/write error in file. */ 
    3133 
    3234/** 
     
    8789 * \param output   MD4 checksum result 
    8890 * 
    89  * \return         0 if successful, 1 if fopen failed, 
    90  *                 or 2 if fread failed 
     91 * \return         0 if successful, or POLARSSL_ERR_MD4_FILE_IO_ERROR 
    9192 */ 
    9293int md4_file( const char *path, unsigned char output[16] ); 
  • trunk/include/polarssl/md5.h

    r1014 r1159  
    2929 
    3030#include <string.h> 
     31 
     32#define POLARSSL_ERR_MD5_FILE_IO_ERROR                 -0x0074  /**< Read/write error in file. */ 
    3133 
    3234/** 
     
    8789 * \param output   MD5 checksum result 
    8890 * 
    89  * \return         0 if successful, 1 if fopen failed, 
    90  *                 or 2 if fread failed 
     91 * \return         0 if successful, or POLARSSL_ERR_MD5_FILE_IO_ERROR 
    9192 */ 
    9293int md5_file( const char *path, unsigned char output[16] ); 
  • trunk/include/polarssl/sha1.h

    r1014 r1159  
    2929 
    3030#include <string.h> 
     31 
     32#define POLARSSL_ERR_SHA1_FILE_IO_ERROR                -0x0076  /**< Read/write error in file. */ 
    3133 
    3234/** 
     
    8789 * \param output   SHA-1 checksum result 
    8890 * 
    89  * \return         0 if successful, 1 if fopen failed, 
    90  *                 or 2 if fread failed 
     91 * \return         0 if successful, or POLARSSL_ERR_SHA1_FILE_IO_ERROR 
    9192 */ 
    9293int sha1_file( const char *path, unsigned char output[20] ); 
  • trunk/include/polarssl/sha2.h

    r1014 r1159  
    2929 
    3030#include <string.h> 
     31 
     32#define POLARSSL_ERR_SHA2_FILE_IO_ERROR                -0x0078  /**< Read/write error in file. */ 
    3133 
    3234/** 
     
    9294 * \param is224    0 = use SHA256, 1 = use SHA224 
    9395 * 
    94  * \return         0 if successful, 1 if fopen failed, 
    95  *                 or 2 if fread failed 
     96 * \return         0 if successful, or POLARSSL_ERR_SHA2_FILE_IO_ERROR 
    9697 */ 
    9798int sha2_file( const char *path, unsigned char output[32], int is224 ); 
  • trunk/include/polarssl/sha4.h

    r1145 r1159  
    2929 
    3030#include <string.h> 
     31 
     32#define POLARSSL_ERR_SHA4_FILE_IO_ERROR                -0x007A  /**< Read/write error in file. */ 
    3133 
    3234#if defined(_MSC_VER) || defined(__WATCOMC__) 
     
    100102 * \param is384    0 = use SHA512, 1 = use SHA384 
    101103 * 
    102  * \return         0 if successful, 1 if fopen failed, 
    103  *                 or 2 if fread failed 
     104 * \return         0 if successful, or POLARSSL_ERR_SHA4_FILE_IO_ERROR 
    104105 */ 
    105106int sha4_file( const char *path, unsigned char output[64], int is384 ); 
  • trunk/include/polarssl/ssl.h

    r1132 r1159  
    8282#define POLARSSL_ERR_SSL_BAD_HS_CHANGE_CIPHER_SPEC         -0x7E00  /**< Processing of the ChangeCipherSpec handshake message failed. */ 
    8383#define POLARSSL_ERR_SSL_BAD_HS_FINISHED                   -0x7E80  /**< Processing of the Finished handshake message failed. */ 
     84#define POLARSSL_ERR_SSL_MALLOC_FAILED                     -0x7F00  /**< Memory allocation failed */ 
    8485 
    8586/* 
     
    374375 * \param ssl      SSL context 
    375376 * 
    376  * \return         0 if successful, or 1 if memory allocation failed 
     377 * \return         0 if successful, or POLARSSL_ERR_SSL_MALLOC_FAILED if 
     378 *                 memory allocation failed 
    377379 */ 
    378380int ssl_init( ssl_context *ssl ); 
  • trunk/include/polarssl/x509.h

    r1140 r1159  
    6060#define POLARSSL_ERR_X509_KEY_INVALID_FORMAT               -0x2900  /**< Invalid RSA key tag or value. */ 
    6161#define POLARSSL_ERR_X509_CERT_UNKNOWN_FORMAT              -0x2980  /**< Format not recognized as DER or PEM. */ 
    62 #define POLARSSL_ERR_X509_VALUE_TO_LENGTH                  -0x2A00  /**< Not used. */ 
     62#define POLARSSL_ERR_X509_INVALID_INPUT                    -0x2A00  /**< Input invalid. */ 
     63#define POLARSSL_ERR_X509_MALLOC_FAILED                    -0x2A80  /**< Allocation of memory failed. */ 
     64#define POLARSSL_ERR_X509_FILE_IO_ERROR                    -0x2B00  /**< Read/write of file failed. */ 
    6365/* \} name */ 
    6466 
     
    228230#define X509_FORMAT_PEM                 2 
    229231 
    230 #define X509_NON_PERMISSIVE             0 
    231 #define X509_PERMISSIVE                 1 
    232  
    233  
    234232/**  
    235233 * \addtogroup x509_module 
     
    421419/** 
    422420 * \brief          Parse one or more certificates and add them 
    423  *                 to the chained list. With permissive parsing enabled 
    424  *                 all certificates that cannot be parsed are ignored. 
    425  *                 If none complete correctly, the first error is returned. 
     421 *                 to the chained list. Parses permissively. If some 
     422 *                 certificates can be parsed, the result is the number 
     423 *                 of failed certificates it encountered. If none complete 
     424 *                 correctly, the first error is returned. 
    426425 * 
    427426 * \param chain    points to the start of the chain 
    428427 * \param buf      buffer holding the certificate data 
    429428 * \param buflen   size of the buffer 
    430  * \param permissive    X509_PERMISSIVE or X509_NON_PERMISSIVE 
    431  * 
    432  * \return         0 if successful, or a specific X509 or PEM error code 
    433  */ 
    434 int x509parse_crt( x509_cert *chain, const unsigned char *buf, size_t buflen, 
    435                    int permissive ); 
     429 * 
     430 * \return         0 if all certificates parsed successfully, a positive number 
     431 *                 if partly successful or a specific X509 or PEM error code 
     432 */ 
     433int x509parse_crt( x509_cert *chain, const unsigned char *buf, size_t buflen ); 
    436434 
    437435/** \ingroup x509_module */ 
    438436/** 
    439437 * \brief          Load one or more certificates and add them 
    440  *                 to the chained list. With permissive parsing enabled 
    441  *                 all certificates that cannot be parsed are ignored. 
    442  *                 If none complete correctly, the first error is returned. 
     438 *                 to the chained list. Parses permissively. If some 
     439 *                 certificates can be parsed, the result is the number 
     440 *                 of failed certificates it encountered. If none complete 
     441 *                 correctly, the first error is returned. 
    443442 * 
    444443 * \param chain    points to the start of the chain 
    445444 * \param path     filename to read the certificates from 
    446  * \param permissive    X509_PERMISSIVE or X509_NON_PERMISSIVE 
    447  * 
    448  * \return         0 if successful, or a specific X509 or PEM error code 
    449  */ 
    450 int x509parse_crtfile( x509_cert *chain, const char *path, int permissive ); 
     445 * 
     446 * \return         0 if all certificates parsed successfully, a positive number 
     447 *                 if partly successful or a specific X509 or PEM error code 
     448 */ 
     449int x509parse_crtfile( x509_cert *chain, const char *path ); 
    451450 
    452451/** \ingroup x509_module */ 
     
    552551 
    553552/** \} name Functions to read in DHM parameters, a certificate, CRL or private RSA key */ 
    554  
    555  
    556553 
    557554/** 
  • trunk/library/asn1parse.c

    r1110 r1159  
    243243 
    244244            if( cur->next == NULL ) 
    245                 return( 1 ); 
     245                return( POLARSSL_ERR_ASN1_MALLOC_FAILED ); 
    246246 
    247247            cur = cur->next; 
  • trunk/library/bignum.c

    r1136 r1159  
    9090 
    9191    if( nblimbs > POLARSSL_MPI_MAX_LIMBS ) 
    92         return( 1 ); 
     92        return( POLARSSL_ERR_MPI_MALLOC_FAILED ); 
    9393 
    9494    if( X->n < nblimbs ) 
    9595    { 
    9696        if( ( p = (t_uint *) malloc( nblimbs * ciL ) ) == NULL ) 
    97             return( 1 ); 
     97            return( POLARSSL_ERR_MPI_MALLOC_FAILED ); 
    9898 
    9999        memset( p, 0, nblimbs * ciL ); 
  • trunk/library/ctr_drbg.c

    r1158 r1159  
    245245 
    246246    /* 
    247      * Gather POLARSSL_CTR_DRBG_ENTROPYLEN bytes of entropy to seed state 
     247     * Gather enropy_len bytes of entropy to seed state 
    248248     */ 
    249249    if( 0 != ctx->f_entropy( ctx->p_entropy, seed, 
     
    358358 
    359359    if( ( f = fopen( path, "wb" ) ) == NULL ) 
    360         return( 1 ); 
     360        return( POLARSSL_ERR_CTR_DRBG_FILE_IO_ERROR ); 
    361361 
    362362    if( ( ret = ctr_drbg_random( ctx, buf, CTR_DRBG_MAX_INPUT ) ) != 0 ) 
     
    366366    { 
    367367        fclose( f ); 
    368         return( 1 ); 
     368        return( POLARSSL_ERR_CTR_DRBG_FILE_IO_ERROR ); 
    369369    } 
    370370 
     
    380380 
    381381    if( ( f = fopen( path, "rb" ) ) == NULL ) 
    382         return( 1 ); 
     382        return( POLARSSL_ERR_CTR_DRBG_FILE_IO_ERROR ); 
    383383 
    384384    fseek( f, 0, SEEK_END ); 
     
    392392    { 
    393393        fclose( f ); 
    394         return( 1 ); 
     394        return( POLARSSL_ERR_CTR_DRBG_FILE_IO_ERROR ); 
    395395    } 
    396396 
  • trunk/library/error.c

    r1140 r1159  
    6868#endif 
    6969 
     70#if defined(POLARSSL_MD2_C) 
     71#include "polarssl/md2.h" 
     72#endif 
     73 
     74#if defined(POLARSSL_MD4_C) 
     75#include "polarssl/md4.h" 
     76#endif 
     77 
     78#if defined(POLARSSL_MD5_C) 
     79#include "polarssl/md5.h" 
     80#endif 
     81 
    7082#if defined(POLARSSL_NET_C) 
    7183#include "polarssl/net.h" 
     
    8294#if defined(POLARSSL_RSA_C) 
    8395#include "polarssl/rsa.h" 
     96#endif 
     97 
     98#if defined(POLARSSL_SHA1_C) 
     99#include "polarssl/sha1.h" 
     100#endif 
     101 
     102#if defined(POLARSSL_SHA2_C) 
     103#include "polarssl/sha2.h" 
     104#endif 
     105 
     106#if defined(POLARSSL_SHA4_C) 
     107#include "polarssl/sha4.h" 
    84108#endif 
    85109 
     
    259283        if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_FINISHED) ) 
    260284            snprintf( buf, buflen, "SSL - Processing of the Finished handshake message failed" ); 
     285        if( use_ret == -(POLARSSL_ERR_SSL_MALLOC_FAILED) ) 
     286            snprintf( buf, buflen, "SSL - Memory allocation failed" ); 
    261287#endif /* POLARSSL_SSL_TLS_C */ 
    262288 
     
    300326        if( use_ret == -(POLARSSL_ERR_X509_CERT_UNKNOWN_FORMAT) ) 
    301327            snprintf( buf, buflen, "X509 - Format not recognized as DER or PEM" ); 
    302         if( use_ret == -(POLARSSL_ERR_X509_VALUE_TO_LENGTH) ) 
    303             snprintf( buf, buflen, "X509 - Not used" ); 
     328        if( use_ret == -(POLARSSL_ERR_X509_INVALID_INPUT) ) 
     329            snprintf( buf, buflen, "X509 - Input invalid" ); 
     330        if( use_ret == -(POLARSSL_ERR_X509_MALLOC_FAILED) ) 
     331            snprintf( buf, buflen, "X509 - Allocation of memory failed" ); 
     332        if( use_ret == -(POLARSSL_ERR_X509_FILE_IO_ERROR) ) 
     333            snprintf( buf, buflen, "X509 - Read/write of file failed" ); 
    304334#endif /* POLARSSL_X509_PARSE_C */ 
    305335 
     
    349379    if( use_ret == -(POLARSSL_ERR_ASN1_INVALID_DATA) ) 
    350380        snprintf( buf, buflen, "ASN1 - Data is invalid. (not used)" ); 
     381    if( use_ret == -(POLARSSL_ERR_ASN1_MALLOC_FAILED) ) 
     382        snprintf( buf, buflen, "ASN1 - Memory allocation failed" ); 
    351383#endif /* POLARSSL_ASN1_PARSE_C */ 
    352384 
     
    366398        snprintf( buf, buflen, "BIGNUM - There is an invalid character in the digit string" ); 
    367399    if( use_ret == -(POLARSSL_ERR_MPI_BUFFER_TOO_SMALL) ) 
    368         snprintf( buf, buflen, "BIGNUM - The output buffer is too small to write too" ); 
     400        snprintf( buf, buflen, "BIGNUM - The buffer is too small to write to" ); 
    369401    if( use_ret == -(POLARSSL_ERR_MPI_NEGATIVE_VALUE) ) 
    370402        snprintf( buf, buflen, "BIGNUM - The input arguments are negative or result in illegal output" ); 
     
    373405    if( use_ret == -(POLARSSL_ERR_MPI_NOT_ACCEPTABLE) ) 
    374406        snprintf( buf, buflen, "BIGNUM - The input arguments are not acceptable" ); 
     407    if( use_ret == -(POLARSSL_ERR_MPI_MALLOC_FAILED) ) 
     408        snprintf( buf, buflen, "BIGNUM - Memory allocation failed" ); 
    375409#endif /* POLARSSL_BIGNUM_C */ 
    376410 
     
    389423    if( use_ret == -(POLARSSL_ERR_CTR_DRBG_INPUT_TOO_BIG) ) 
    390424        snprintf( buf, buflen, "CTR_DRBG - Input too large (Entropy + additional)" ); 
     425    if( use_ret == -(POLARSSL_ERR_CTR_DRBG_FILE_IO_ERROR) ) 
     426        snprintf( buf, buflen, "CTR_DRBG - Read/write error in file" ); 
    391427#endif /* POLARSSL_CTR_DRBG_C */ 
    392428 
     
    402438        snprintf( buf, buflen, "ENTROPY - No more sources can be added" ); 
    403439#endif /* POLARSSL_ENTROPY_C */ 
     440 
     441#if defined(POLARSSL_MD2_C) 
     442    if( use_ret == -(POLARSSL_ERR_MD2_FILE_IO_ERROR) ) 
     443        snprintf( buf, buflen, "MD2 - Read/write error in file" ); 
     444#endif /* POLARSSL_MD2_C */ 
     445 
     446#if defined(POLARSSL_MD4_C) 
     447    if( use_ret == -(POLARSSL_ERR_MD4_FILE_IO_ERROR) ) 
     448        snprintf( buf, buflen, "MD4 - Read/write error in file" ); 
     449#endif /* POLARSSL_MD4_C */ 
     450 
     451#if defined(POLARSSL_MD5_C) 
     452    if( use_ret == -(POLARSSL_ERR_MD5_FILE_IO_ERROR) ) 
     453        snprintf( buf, buflen, "MD5 - Read/write error in file" ); 
     454#endif /* POLARSSL_MD5_C */ 
    404455 
    405456#if defined(POLARSSL_NET_C) 
     
    433484#endif /* POLARSSL_PADLOCK_C */ 
    434485 
     486#if defined(POLARSSL_SHA1_C) 
     487    if( use_ret == -(POLARSSL_ERR_SHA1_FILE_IO_ERROR) ) 
     488        snprintf( buf, buflen, "SHA1 - Read/write error in file" ); 
     489#endif /* POLARSSL_SHA1_C */ 
     490 
     491#if defined(POLARSSL_SHA2_C) 
     492    if( use_ret == -(POLARSSL_ERR_SHA2_FILE_IO_ERROR) ) 
     493        snprintf( buf, buflen, "SHA2 - Read/write error in file" ); 
     494#endif /* POLARSSL_SHA2_C */ 
     495 
     496#if defined(POLARSSL_SHA4_C) 
     497    if( use_ret == -(POLARSSL_ERR_SHA4_FILE_IO_ERROR) ) 
     498        snprintf( buf, buflen, "SHA4 - Read/write error in file" ); 
     499#endif /* POLARSSL_SHA4_C */ 
     500 
    435501#if defined(POLARSSL_XTEA_C) 
    436502    if( use_ret == -(POLARSSL_ERR_XTEA_INVALID_INPUT_LENGTH) ) 
  • trunk/library/md2.c

    r1097 r1159  
    190190 
    191191    if( ( f = fopen( path, "rb" ) ) == NULL ) 
    192         return( 1 ); 
     192        return( POLARSSL_ERR_MD2_FILE_IO_ERROR ); 
    193193 
    194194    md2_starts( &ctx ); 
     
    204204    { 
    205205        fclose( f ); 
    206         return( 2 ); 
     206        return( POLARSSL_ERR_MD2_FILE_IO_ERROR ); 
    207207    } 
    208208 
  • trunk/library/md4.c

    r1052 r1159  
    286286 
    287287    if( ( f = fopen( path, "rb" ) ) == NULL ) 
    288         return( 1 ); 
     288        return( POLARSSL_ERR_MD4_FILE_IO_ERROR ); 
    289289 
    290290    md4_starts( &ctx ); 
     
    300300    { 
    301301        fclose( f ); 
    302         return( 2 ); 
     302        return( POLARSSL_ERR_MD4_FILE_IO_ERROR ); 
    303303    } 
    304304 
  • trunk/library/md5.c

    r1052 r1159  
    305305 
    306306    if( ( f = fopen( path, "rb" ) ) == NULL ) 
    307         return( 1 ); 
     307        return( POLARSSL_ERR_MD5_FILE_IO_ERROR ); 
    308308 
    309309    md5_starts( &ctx ); 
     
    319319    { 
    320320        fclose( f ); 
    321         return( 2 ); 
     321        return( POLARSSL_ERR_MD5_FILE_IO_ERROR ); 
    322322    } 
    323323 
  • trunk/library/sha1.c

    r1052 r1159  
    340340 
    341341    if( ( f = fopen( path, "rb" ) ) == NULL ) 
    342         return( 1 ); 
     342        return( POLARSSL_ERR_SHA1_FILE_IO_ERROR ); 
    343343 
    344344    sha1_starts( &ctx ); 
     
    354354    { 
    355355        fclose( f ); 
    356         return( 2 ); 
     356        return( POLARSSL_ERR_SHA1_FILE_IO_ERROR ); 
    357357    } 
    358358 
  • trunk/library/sha2.c

    r1052 r1159  
    342342 
    343343    if( ( f = fopen( path, "rb" ) ) == NULL ) 
    344         return( 1 ); 
     344        return( POLARSSL_ERR_SHA2_FILE_IO_ERROR ); 
    345345 
    346346    sha2_starts( &ctx, is224 ); 
     
    356356    { 
    357357        fclose( f ); 
    358         return( 2 ); 
     358        return( POLARSSL_ERR_SHA2_FILE_IO_ERROR ); 
    359359    } 
    360360 
  • trunk/library/sha4.c

    r1145 r1159  
    340340 
    341341    if( ( f = fopen( path, "rb" ) ) == NULL ) 
    342         return( 1 ); 
     342        return( POLARSSL_ERR_SHA4_FILE_IO_ERROR ); 
    343343 
    344344    sha4_starts( &ctx, is384 ); 
     
    354354    { 
    355355        fclose( f ); 
    356         return( 2 ); 
     356        return( POLARSSL_ERR_SHA4_FILE_IO_ERROR ); 
    357357    } 
    358358 
  • trunk/library/ssl_tls.c

    r1140 r1159  
    13771377        SSL_DEBUG_MSG( 1, ( "malloc(%d bytes) failed", 
    13781378                       sizeof( x509_cert ) ) ); 
    1379         return( 1 ); 
     1379        return( POLARSSL_ERR_SSL_MALLOC_FAILED ); 
    13801380    } 
    13811381 
     
    14021402        } 
    14031403 
    1404         ret = x509parse_crt( ssl->peer_cert, ssl->in_msg + i, n, 
    1405                              X509_NON_PERMISSIVE ); 
     1404        ret = x509parse_crt( ssl->peer_cert, ssl->in_msg + i, n ); 
    14061405        if( ret != 0 ) 
    14071406        { 
     
    17081707    { 
    17091708        SSL_DEBUG_MSG( 1, ( "malloc(%d bytes) failed", len ) ); 
    1710         return( 1 ); 
     1709        return( POLARSSL_ERR_SSL_MALLOC_FAILED ); 
    17111710    } 
    17121711 
     
    17191718        SSL_DEBUG_MSG( 1, ( "malloc(%d bytes) failed", len ) ); 
    17201719        free( ssl-> in_ctr ); 
    1721         return( 1 ); 
     1720        return( POLARSSL_ERR_SSL_MALLOC_FAILED ); 
    17221721    } 
    17231722 
  • trunk/library/x509parse.c

    r1153 r1159  
    285285 
    286286            if( use->next == NULL ) 
    287                 return( 1 ); 
     287                return( POLARSSL_ERR_X509_MALLOC_FAILED ); 
    288288             
    289289            memset( use->next, 0, sizeof( x509_name ) ); 
     
    304304 
    305305    if( cur->next == NULL ) 
    306         return( 1 ); 
     306        return( POLARSSL_ERR_X509_MALLOC_FAILED ); 
    307307 
    308308    return( x509_get_name( p, end2, cur->next ) ); 
     
    10191019     */ 
    10201020    if( crt == NULL || buf == NULL ) 
    1021         return( 1 ); 
     1021        return( POLARSSL_ERR_X509_INVALID_INPUT ); 
    10221022 
    10231023    p = (unsigned char *) malloc( len = buflen ); 
    10241024 
    10251025    if( p == NULL ) 
    1026         return( 1 ); 
     1026        return( POLARSSL_ERR_X509_MALLOC_FAILED ); 
    10271027 
    10281028    memcpy( p, buf, buflen ); 
     
    12601260 * Parse one or more PEM certificates from a buffer and add them to the chained list 
    12611261 */ 
    1262 int x509parse_crt( x509_cert *chain, const unsigned char *buf, size_t buflen, 
    1263                    int permissive ) 
    1264 { 
    1265     int ret, success = 0, first_error = 0; 
     1262int x509parse_crt( x509_cert *chain, const unsigned char *buf, size_t buflen ) 
     1263{ 
     1264    int ret, success = 0, first_error = 0, total_failed = 0; 
    12661265    x509_cert *crt, *prev = NULL; 
    12671266    int buf_format = X509_FORMAT_DER; 
     
    12731272     */ 
    12741273    if( crt == NULL || buf == NULL ) 
    1275         return( 1 ); 
     1274        return( POLARSSL_ERR_X509_INVALID_INPUT ); 
    12761275 
    12771276    while( crt->version != 0 && crt->next != NULL ) 
     
    12891288 
    12901289        if( crt->next == NULL ) 
    1291             return( 1 ); 
     1290            return( POLARSSL_ERR_X509_MALLOC_FAILED ); 
    12921291 
    12931292        prev = crt; 
     
    13501349            { 
    13511350                /* 
    1352                  * quit parsing on a memory error or if in non-permissive parsing mode 
     1351                 * quit parsing on a memory error 
    13531352                 */ 
    1354                 if( ret == 1 || permissive != 1 ) 
     1353                if( ret == POLARSSL_ERR_X509_MALLOC_FAILED ) 
    13551354                { 
    13561355                    if( prev ) 
     
    13651364                if( first_error == 0 ) 
    13661365                    first_error = ret; 
     1366                 
     1367                total_failed++; 
    13671368 
    13681369                memset( crt, 0, sizeof( x509_cert ) ); 
     
    13781379 
    13791380            if( crt->next == NULL ) 
    1380                 return( 1 ); 
     1381                return( POLARSSL_ERR_X509_MALLOC_FAILED ); 
    13811382 
    13821383            prev = crt; 
     
    13971398 
    13981399    if( success ) 
    1399         return( 0 ); 
     1400        return( total_failed ); 
    14001401    else if( first_error ) 
    14011402        return( first_error ); 
     
    14241425     */ 
    14251426    if( crl == NULL || buf == NULL ) 
    1426         return( 1 ); 
     1427        return( POLARSSL_ERR_X509_INVALID_INPUT ); 
    14271428 
    14281429    while( crl->version != 0 && crl->next != NULL ) 
     
    14391440        { 
    14401441            x509_crl_free( crl ); 
    1441             return( 1 ); 
     1442            return( POLARSSL_ERR_X509_MALLOC_FAILED ); 
    14421443        } 
    14431444 
     
    14821483 
    14831484        if( p == NULL ) 
    1484             return( 1 ); 
     1485            return( POLARSSL_ERR_X509_MALLOC_FAILED ); 
    14851486 
    14861487        memcpy( p, buf, buflen ); 
     
    14921493 
    14931494    if( p == NULL ) 
    1494         return( 1 ); 
     1495        return( POLARSSL_ERR_X509_MALLOC_FAILED ); 
    14951496 
    14961497    memcpy( p, buf, buflen ); 
     
    16811682        { 
    16821683            x509_crl_free( crl ); 
    1683             return( 1 ); 
     1684            return( POLARSSL_ERR_X509_MALLOC_FAILED ); 
    16841685        } 
    16851686 
     
    17021703 
    17031704    if( ( f = fopen( path, "rb" ) ) == NULL ) 
    1704         return( 1 ); 
     1705        return( POLARSSL_ERR_X509_FILE_IO_ERROR ); 
    17051706 
    17061707    fseek( f, 0, SEEK_END ); 
     
    17091710 
    17101711    if( ( *buf = (unsigned char *) malloc( *n + 1 ) ) == NULL ) 
    1711         return( 1 ); 
     1712        return( POLARSSL_ERR_X509_MALLOC_FAILED ); 
    17121713 
    17131714    if( fread( *buf, 1, *n, f ) != *n ) 
     
    17151716        fclose( f ); 
    17161717        free( *buf ); 
    1717         return( 1 ); 
     1718        return( POLARSSL_ERR_X509_FILE_IO_ERROR ); 
    17181719    } 
    17191720 
     
    17281729 * Load one or more certificates and add them to the chained list 
    17291730 */ 
    1730 int x509parse_crtfile( x509_cert *chain, const char *path, int permissive ) 
     1731int x509parse_crtfile( x509_cert *chain, const char *path ) 
    17311732{ 
    17321733    int ret; 
     
    17341735    unsigned char *buf; 
    17351736 
    1736     if ( load_file( path, &buf, &n ) ) 
    1737         return( 1 ); 
    1738  
    1739     ret = x509parse_crt( chain, buf, n, permissive ); 
     1737    if ( (ret = load_file( path, &buf, &n ) ) != 0 ) 
     1738        return( ret ); 
     1739 
     1740    ret = x509parse_crt( chain, buf, n ); 
    17401741 
    17411742    memset( buf, 0, n + 1 ); 
     
    17541755    unsigned char *buf; 
    17551756 
    1756     if ( load_file( path, &buf, &n ) ) 
    1757         return( 1 ); 
     1757    if ( (ret = load_file( path, &buf, &n ) ) != 0 ) 
     1758        return( ret ); 
    17581759 
    17591760    ret = x509parse_crl( chain, buf, n ); 
     
    17741775    unsigned char *buf; 
    17751776 
    1776     if ( load_file( path, &buf, &n ) ) 
    1777         return( 1 ); 
     1777    if ( (ret = load_file( path, &buf, &n ) ) != 0 ) 
     1778        return( ret ); 
    17781779 
    17791780    if( pwd == NULL ) 
     
    17981799    unsigned char *buf; 
    17991800 
    1800     if ( load_file( path, &buf, &n ) ) 
    1801         return( 1 ); 
     1801    if ( (ret = load_file( path, &buf, &n ) ) != 0 ) 
     1802        return( ret ); 
    18021803 
    18031804    ret = x509parse_public_key( rsa, buf, n ); 
     
    22512252    unsigned char *buf; 
    22522253 
    2253     if ( load_file( path, &buf, &n ) ) 
    2254         return( 1 ); 
     2254    if ( ( ret = load_file( path, &buf, &n ) ) != 0 ) 
     2255        return( ret ); 
    22552256 
    22562257    ret = x509parse_dhm( dhm, buf, n ); 
     
    31563157 
    31573158    ret = x509parse_crt( &clicert, (unsigned char *) test_cli_crt, 
    3158                          strlen( test_cli_crt ), X509_NON_PERMISSIVE ); 
     3159                         strlen( test_cli_crt ) ); 
    31593160    if( ret != 0 ) 
    31603161    { 
     
    31683169 
    31693170    ret = x509parse_crt( &cacert, (unsigned char *) test_ca_crt, 
    3170                          strlen( test_ca_crt ), X509_NON_PERMISSIVE ); 
     3171                         strlen( test_ca_crt ) ); 
    31713172    if( ret != 0 ) 
    31723173    { 
  • trunk/programs/ssl/ssl_client2.c

    r1143 r1159  
    242242#if defined(POLARSSL_FS_IO) 
    243243    if( strlen( opt.ca_file ) ) 
    244         ret = x509parse_crtfile( &cacert, opt.ca_file, X509_NON_PERMISSIVE ); 
     244        ret = x509parse_crtfile( &cacert, opt.ca_file ); 
    245245    else  
    246246#endif 
    247247#if defined(POLARSSL_CERTS_C) 
    248248        ret = x509parse_crt( &cacert, (unsigned char *) test_ca_crt, 
    249                 strlen( test_ca_crt ), X509_NON_PERMISSIVE ); 
     249                strlen( test_ca_crt ) ); 
    250250#else 
    251251    { 
     
    272272#if defined(POLARSSL_FS_IO) 
    273273    if( strlen( opt.crt_file ) ) 
    274         ret = x509parse_crtfile( &clicert, opt.crt_file, X509_NON_PERMISSIVE ); 
     274        ret = x509parse_crtfile( &clicert, opt.crt_file ); 
    275275    else  
    276276#endif 
    277277#if defined(POLARSSL_CERTS_C) 
    278278        ret = x509parse_crt( &clicert, (unsigned char *) test_cli_crt, 
    279                 strlen( test_cli_crt ), X509_NON_PERMISSIVE ); 
     279                strlen( test_cli_crt ) ); 
    280280#else 
    281281    { 
  • trunk/programs/ssl/ssl_fork_server.c

    r1143 r1159  
    251251     */ 
    252252    ret = x509parse_crt( &srvcert, (unsigned char *) test_srv_crt, 
    253                          strlen( test_srv_crt ), X509_NON_PERMISSIVE ); 
     253                         strlen( test_srv_crt ) ); 
    254254    if( ret != 0 ) 
    255255    { 
     
    259259 
    260260    ret = x509parse_crt( &srvcert, (unsigned char *) test_ca_crt, 
    261                          strlen( test_ca_crt ), X509_NON_PERMISSIVE ); 
     261                         strlen( test_ca_crt ) ); 
    262262    if( ret != 0 ) 
    263263    { 
  • trunk/programs/ssl/ssl_mail_client.c

    r1143 r1159  
    494494#if defined(POLARSSL_FS_IO) 
    495495    if( strlen( opt.ca_file ) ) 
    496         ret = x509parse_crtfile( &cacert, opt.ca_file, X509_NON_PERMISSIVE ); 
     496        ret = x509parse_crtfile( &cacert, opt.ca_file ); 
    497497    else 
    498498#endif 
    499499#if defined(POLARSSL_CERTS_C) 
    500500        ret = x509parse_crt( &cacert, (unsigned char *) test_ca_crt, 
    501                 strlen( test_ca_crt ), X509_NON_PERMISSIVE ); 
     501                strlen( test_ca_crt ) ); 
    502502#else 
    503503    { 
     
    524524#if defined(POLARSSL_FS_IO) 
    525525    if( strlen( opt.crt_file ) ) 
    526         ret = x509parse_crtfile( &clicert, opt.crt_file, X509_NON_PERMISSIVE ); 
     526        ret = x509parse_crtfile( &clicert, opt.crt_file ); 
    527527    else  
    528528#endif 
    529529#if defined(POLARSSL_CERTS_C) 
    530530        ret = x509parse_crt( &clicert, (unsigned char *) test_cli_crt, 
    531                 strlen( test_cli_crt ), X509_NON_PERMISSIVE ); 
     531                strlen( test_cli_crt ) ); 
    532532#else 
    533533    { 
    534         ret = 1; 
     534        ret = -1; 
    535535        printf("POLARSSL_CERTS_C not defined."); 
    536536    } 
     
    552552#else 
    553553    { 
    554         ret = 1; 
     554        ret = -1; 
    555555        printf("POLARSSL_CERTS_C not defined."); 
    556556    } 
  • trunk/programs/ssl/ssl_server.c

    r1143 r1159  
    221221     */ 
    222222    ret = x509parse_crt( &srvcert, (unsigned char *) test_srv_crt, 
    223                          strlen( test_srv_crt ), X509_NON_PERMISSIVE ); 
     223                         strlen( test_srv_crt ) ); 
    224224    if( ret != 0 ) 
    225225    { 
     
    229229 
    230230    ret = x509parse_crt( &srvcert, (unsigned char *) test_ca_crt, 
    231                          strlen( test_ca_crt ), X509_NON_PERMISSIVE ); 
     231                         strlen( test_ca_crt ) ); 
    232232    if( ret != 0 ) 
    233233    { 
  • trunk/programs/test/ssl_cert_test.c

    r1140 r1159  
    101101     * .crt file by calling x509parse_crtfile( &cacert, "myca.crt" ). 
    102102     */ 
    103     ret = x509parse_crtfile( &cacert, "ssl/test-ca/test-ca.crt", X509_NON_PERMISSIVE ); 
     103    ret = x509parse_crtfile( &cacert, "ssl/test-ca/test-ca.crt" ); 
    104104    if( ret != 0 ) 
    105105    { 
     
    149149        fflush( stdout ); 
    150150 
    151         ret = x509parse_crtfile( &clicert, name, X509_NON_PERMISSIVE ); 
     151        ret = x509parse_crtfile( &clicert, name ); 
    152152        if( ret != 0 ) 
    153153        { 
  • trunk/programs/test/ssl_test.c

    r1143 r1159  
    215215#else 
    216216        ret =  x509parse_crt( &srvcert, (unsigned char *) test_srv_crt, 
    217                               strlen( test_srv_crt ), X509_NON_PERMISSIVE ); 
     217                              strlen( test_srv_crt ) ); 
    218218        if( ret != 0 ) 
    219219        { 
     
    223223 
    224224        ret =  x509parse_crt( &srvcert, (unsigned char *) test_ca_crt, 
    225                               strlen( test_ca_crt ), X509_NON_PERMISSIVE ); 
     225                              strlen( test_ca_crt ) ); 
    226226        if( ret != 0 ) 
    227227        { 
  • trunk/programs/x509/cert_app.c

    r1143 r1159  
    201201        fflush( stdout ); 
    202202 
    203         ret = x509parse_crtfile( &crt, opt.filename, opt.permissive ); 
    204  
    205         if( ret != 0 ) 
     203        ret = x509parse_crtfile( &crt, opt.filename ); 
     204 
     205        if( ret < 0 ) 
    206206        { 
    207207            printf( " failed\n  !  x509parse_crt returned %d\n\n", ret ); 
     
    210210        } 
    211211 
     212        if( opt.permissive == 0 && ret > 0 ) 
     213        { 
     214            printf( " failed\n  !  x509parse_crt failed to parse %d certificates\n\n", ret ); 
     215            x509_free( &crt ); 
     216            goto exit; 
     217        } 
     218 
    212219        printf( " ok\n" ); 
    213220 
     221     
    214222        /* 
    215223         * 1.2 Print the certificate(s) 
  • trunk/scripts/generate_errors.pl

    r1138 r1159  
    1010 
    1111my @low_level_modules = ( "AES", "ASN1", "CAMELLIA", "BIGNUM", "BASE64", "XTEA", 
    12                           "PADLOCK", "DES", "NET", "CTR_DRBG", "ENTROPY" ); 
     12                          "PADLOCK", "DES", "NET", "CTR_DRBG", "ENTROPY", 
     13                          "MD2", "MD4", "MD5", "SHA1", "SHA2", "SHA4" ); 
    1314my @high_level_modules = ( "PEM", "X509", "DHM", "RSA", "MD", "CIPHER", "SSL" ); 
    1415 
  • trunk/tests/suites/test_suite_ctr_drbg.function

    r1158 r1159  
    33 
    44int test_offset; 
    5 int entropy_func( void *p, unsigned char *buf, size_t len ) 
     5int entropy_func( void *data, unsigned char *buf, size_t len ) 
    66{ 
     7    unsigned char *p = (unsigned char *) data; 
    78    memcpy( buf, p + test_offset, len ); 
    89    test_offset += 32; 
  • trunk/tests/suites/test_suite_debug.function

    r1140 r1159  
    3636    ssl_set_dbg(&ssl, string_debug, &buffer); 
    3737 
    38     TEST_ASSERT( x509parse_crtfile( &crt, {crt_file}, X509_NON_PERMISSIVE ) == 0 ); 
     38    TEST_ASSERT( x509parse_crtfile( &crt, {crt_file} ) == 0 ); 
    3939    debug_print_crt( &ssl, 0, {file}, {line}, {prefix}, &crt); 
    4040 
  • trunk/tests/suites/test_suite_x509parse.function

    r1140 r1159  
    3939    memset( buf, 0, 2000 ); 
    4040 
    41     TEST_ASSERT( x509parse_crtfile( &crt, {crt_file}, X509_NON_PERMISSIVE ) == 0 ); 
     41    TEST_ASSERT( x509parse_crtfile( &crt, {crt_file} ) == 0 ); 
    4242    res = x509parse_cert_info( buf, 2000, "", &crt ); 
    4343 
     
    8282    memset( &crl, 0, sizeof( x509_crl ) ); 
    8383 
    84     TEST_ASSERT( x509parse_crtfile( &crt, {crt_file}, X509_NON_PERMISSIVE ) == 0 ); 
    85     TEST_ASSERT( x509parse_crtfile( &ca, {ca_file}, X509_NON_PERMISSIVE ) == 0 ); 
     84    TEST_ASSERT( x509parse_crtfile( &crt, {crt_file} ) == 0 ); 
     85    TEST_ASSERT( x509parse_crtfile( &ca, {ca_file} ) == 0 ); 
    8686    TEST_ASSERT( x509parse_crlfile( &crl, {crl_file} ) == 0 ); 
    8787 
     
    103103    memset( buf, 0, 2000 ); 
    104104 
    105     TEST_ASSERT( x509parse_crtfile( &crt, {crt_file}, X509_NON_PERMISSIVE ) == 0 ); 
     105    TEST_ASSERT( x509parse_crtfile( &crt, {crt_file} ) == 0 ); 
    106106    res =  x509parse_dn_gets( buf, 2000, &crt.{entity} ); 
    107107 
     
    120120    memset( &crt, 0, sizeof( x509_cert ) ); 
    121121 
    122     TEST_ASSERT( x509parse_crtfile( &crt, {crt_file}, X509_NON_PERMISSIVE ) == 0 ); 
     122    TEST_ASSERT( x509parse_crtfile( &crt, {crt_file} ) == 0 ); 
    123123    TEST_ASSERT( x509parse_time_expired( &crt.{entity} ) == {result} ); 
    124124} 
     
    177177    data_len = unhexify( buf, {crt_data} ); 
    178178 
    179     TEST_ASSERT( x509parse_crt( &crt, buf, data_len, X509_NON_PERMISSIVE ) == ( {result} ) ); 
     179    TEST_ASSERT( x509parse_crt( &crt, buf, data_len ) == ( {result} ) ); 
    180180    if( ( {result} ) == 0 ) 
    181181    { 
Note: See TracChangeset for help on using the changeset viewer.

What are you looking for?