mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-12-23 00:45:39 +00:00
Merge branch 'development' into dtls
* development: (100 commits) Update Changelog for the mem-measure branch Fix issues introduced when rebasing Fix compile error in memory_buffer_alloc_selftest Code cosmetics Add curve25519 to ecc-heap.sh Add curve25519 to the benchmark program Fix compile issue when buffer_alloc not available New script ecc-heap.sh Fix unused variable issue in some configs Rm usunused member in private struct Add heap usage for PK in benchmark Use memory_buffer_alloc() in benchmark if available Only define mode_func if mode is enabled (CBC etc) PKCS8 encrypted key depend on PKCS5 or PKCS12 Disable SRV_C for client measurement Output stack+heap usage with massif Enable NIST_OPTIM by default for config-suite-b Refactor memory.sh Adapt memory.sh to config-suite-b Adapt mini-client for config-suite-b.h ... Conflicts: ChangeLog include/polarssl/net.h library/Makefile library/error.c library/ssl_tls.c programs/Makefile programs/ssl/ssl_client2.c programs/ssl/ssl_server2.c tests/Makefile
This commit is contained in:
commit
d901d17817
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -7,6 +7,9 @@ Coverage
|
|||
*.gcno
|
||||
*.gcda
|
||||
|
||||
# generated by scripts/memory.sh
|
||||
massif-*
|
||||
|
||||
# MSVC files generated by CMake:
|
||||
/*.sln
|
||||
/*.vcxproj
|
||||
|
|
|
@ -3,7 +3,7 @@ compiler:
|
|||
- clang
|
||||
- gcc
|
||||
before_install: sudo apt-get update
|
||||
install: sudo apt-get install gnutls-bin valgrind perl
|
||||
install: sudo apt-get install valgrind perl
|
||||
script:
|
||||
- cmake -D CMAKE_BUILD_TYPE:String="Check" .
|
||||
- make
|
||||
|
|
33
ChangeLog
33
ChangeLog
|
@ -10,6 +10,39 @@ API Changes
|
|||
* ssl_set_bio() now requires that p_send == p_recv.
|
||||
* ssl_set_bio() is deprecated in favor of ssl_set_bio_timeout().
|
||||
|
||||
= mbed TLS 1.3 branch
|
||||
|
||||
Security
|
||||
|
||||
Features
|
||||
* Add support for overriding snprintf() (except on Windows) and exit() in
|
||||
the platform layer.
|
||||
* Add an option to use macros instead of function pointers in the platform
|
||||
layer (helps get rid of unwanted references).
|
||||
* Improved Makefiles for Windows targets by fixing library targets and making
|
||||
cross-compilation easier (thanks to Alon Bar-Lev).
|
||||
* The benchmark program also prints heap usage for public-key primitives
|
||||
if POLARSSL_MEMORY_BUFFER_ALLOC_C and POLARSSL_MEMORY_DEBUG are defined.
|
||||
* New script ecc-heap.sh helps measuring the impact of ECC parameters on
|
||||
speed and RAM (heap only for now) usage.
|
||||
* New script memory.sh helps measuring the ROM and RAM requirements of two
|
||||
reduced configurations (PSK-CCM and NSA suite B).
|
||||
|
||||
Bugfix
|
||||
* Fix hardclock() (only used in the benchmarking program) with some
|
||||
versions of mingw64 (found by kxjhlele).
|
||||
* Fix warnings from mingw64 in timing.c (found by kxjklele).
|
||||
* Fix potential unintended sign extension in asn1_get_len() on 64-bit
|
||||
platforms.
|
||||
|
||||
Changes
|
||||
* Move from SHA-1 to SHA-256 in example programs using signatures
|
||||
(suggested by Thorsten Mühlfelder).
|
||||
* Remove some unneeded inclusions of header files from the standard library
|
||||
"minimize" others (eg use stddef.h if only size_t is needed).
|
||||
* Change #include lines in test files to use double quotes instead of angle
|
||||
brackets for uniformity with the rest of the code.
|
||||
* Remove dependency on sscanf() in X.509 parsing modules.
|
||||
|
||||
= mbed TLS 1.3.10 released 2015-02-09
|
||||
Security
|
||||
|
|
|
@ -35,6 +35,8 @@ In order to run the tests, enter::
|
|||
|
||||
make check
|
||||
|
||||
In order to build for a Windows platform, you should use WINDOWS_BUILD=1 if the target is Windows but the build environment is Unix-like (eg when cross-compiling, or compiling from an MSYS shell), and WINDOWS=1 if the build environment is a Windows shell.
|
||||
|
||||
Depending on your platform, you might run into some issues. Please check the Makefiles in *library/*, *programs/* and *tests/* for options to manually add or remove for specific platforms. You can also check `the mbed TLS Knowledge Base <https://polarssl.org/kb>`_ for articles on your platform or issue.
|
||||
|
||||
In case you find that you need to do something else as well, please let us know what, so we can add it to the KB.
|
||||
|
@ -59,7 +61,7 @@ There are many different build modes available within the CMake buildsystem. Mos
|
|||
- ASan.
|
||||
This instruments the code with AddressSanitizer to check for memory errors.
|
||||
(This includes LeakSanitizer, with recent version of gcc and clang.)
|
||||
(With recent version of clang, this mode also intruments the code with
|
||||
(With recent version of clang, this mode also instruments the code with
|
||||
UndefinedSanitizer to check for undefined behaviour.)
|
||||
- ASanDbg.
|
||||
Same as ASan but slower, with debug information and better stack traces.
|
||||
|
@ -70,7 +72,7 @@ There are many different build modes available within the CMake buildsystem. Mos
|
|||
Same as ASan but slower, with debug information, better stack traces and
|
||||
origin tracking.
|
||||
- Check.
|
||||
This activates the compiler warnings that depend on optimisation and treats
|
||||
This activates the compiler warnings that depend on optimization and treats
|
||||
all warnings as errors.
|
||||
|
||||
Switching build modes in CMake is simple. For debug mode, enter at the command line:
|
||||
|
@ -103,7 +105,7 @@ Tests
|
|||
|
||||
mbed TLS includes an elaborate test suite in *tests/* that initially requires Perl to generate the tests files (e.g. *test_suite_mpi.c*). These files are generates from a **function file** (e.g. *suites/test_suite_mpi.function*) and a **data file** (e.g. *suites/test_suite_mpi.data*). The **function file** contains the template for each test function. The **data file** contains the test cases, specified as parameters that should be pushed into a template function.
|
||||
|
||||
For machines with a Unix shell and OpenSSL (and optionnally GnuTLS) installed, additional test scripts are available:
|
||||
For machines with a Unix shell and OpenSSL (and optionally GnuTLS) installed, additional test scripts are available:
|
||||
|
||||
- *tests/ssl-opt.sh* runs integration tests for various TLS options (renegotiation, resumption, etc.) and tests interoperability of these options with other implementations.
|
||||
- *tests/compat.sh* tests interoperability of every ciphersuite with other implementations.
|
||||
|
|
|
@ -68,8 +68,8 @@
|
|||
#define POLARSSL_ECP_WINDOW_SIZE 2
|
||||
#define POLARSSL_ECP_FIXED_POINT_OPTIM 0
|
||||
|
||||
/* Uncomment for a significant speed benefit at the expense of some ROM */
|
||||
//#define POLARSSL_ECP_NIST_OPTIM
|
||||
/* Significant speed benefit at the expense of some ROM */
|
||||
#define POLARSSL_ECP_NIST_OPTIM
|
||||
|
||||
/*
|
||||
* You should adjust this to the exact number of sources you're using: default
|
||||
|
|
1
include/.gitignore
vendored
1
include/.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
Makefile
|
||||
*.sln
|
||||
*.vcxproj
|
||||
polarssl/check_config
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include POLARSSL_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
|
||||
#include <basetsd.h>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include POLARSSL_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#if !defined(POLARSSL_ARC4_ALT)
|
||||
// Regular implementation
|
||||
|
|
|
@ -30,12 +30,12 @@
|
|||
#include POLARSSL_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(POLARSSL_BIGNUM_C)
|
||||
#include "bignum.h"
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/**
|
||||
* \addtogroup asn1_module
|
||||
* \{
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#ifndef POLARSSL_BASE64_H
|
||||
#define POLARSSL_BASE64_H
|
||||
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#define POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL -0x002A /**< Output buffer too small. */
|
||||
#define POLARSSL_ERR_BASE64_INVALID_CHARACTER -0x002C /**< Invalid character in input. */
|
||||
|
|
|
@ -24,14 +24,14 @@
|
|||
#ifndef POLARSSL_BIGNUM_H
|
||||
#define POLARSSL_BIGNUM_H
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if !defined(POLARSSL_CONFIG_FILE)
|
||||
#include "config.h"
|
||||
#else
|
||||
#include POLARSSL_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(POLARSSL_FS_IO)
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include POLARSSL_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
|
||||
#include <basetsd.h>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include POLARSSL_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
|
||||
#include <basetsd.h>
|
||||
|
|
|
@ -145,13 +145,13 @@
|
|||
#endif
|
||||
|
||||
#if defined(POLARSSL_KEY_EXCHANGE_RSA_PSK_ENABLED) && \
|
||||
( !defined(POLARSSL_RSA_C) || !defined(POLARSSL_X509_CRT_PARSE_C) ||\
|
||||
( !defined(POLARSSL_RSA_C) || !defined(POLARSSL_X509_CRT_PARSE_C) || \
|
||||
!defined(POLARSSL_PKCS1_V15) )
|
||||
#error "POLARSSL_KEY_EXCHANGE_RSA_PSK_ENABLED defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_KEY_EXCHANGE_RSA_ENABLED) && \
|
||||
( !defined(POLARSSL_RSA_C) || !defined(POLARSSL_X509_CRT_PARSE_C) ||\
|
||||
( !defined(POLARSSL_RSA_C) || !defined(POLARSSL_X509_CRT_PARSE_C) || \
|
||||
!defined(POLARSSL_PKCS1_V15) )
|
||||
#error "POLARSSL_KEY_EXCHANGE_RSA_ENABLED defined, but not all prerequisites"
|
||||
#endif
|
||||
|
@ -198,6 +198,136 @@
|
|||
#error "POLARSSL_PKCS11_C defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_EXIT_ALT) && !defined(POLARSSL_PLATFORM_C)
|
||||
#error "POLARSSL_PLATFORM_EXIT_ALT defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_EXIT_MACRO) && !defined(POLARSSL_PLATFORM_C)
|
||||
#error "POLARSSL_PLATFORM_EXIT_MACRO defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_EXIT_MACRO) &&\
|
||||
( defined(POLARSSL_PLATFORM_STD_EXIT) ||\
|
||||
defined(POLARSSL_PLATFORM_EXIT_ALT) )
|
||||
#error "POLARSSL_PLATFORM_EXIT_MACRO and POLARSSL_PLATFORM_STD_EXIT/POLARSSL_PLATFORM_EXIT_ALT cannot be defined simultaneously"
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_FPRINTF_ALT) && !defined(POLARSSL_PLATFORM_C)
|
||||
#error "POLARSSL_PLATFORM_FPRINTF_ALT defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_FPRINTF_MACRO) && !defined(POLARSSL_PLATFORM_C)
|
||||
#error "POLARSSL_PLATFORM_FPRINTF_MACRO defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_FPRINTF_MACRO) &&\
|
||||
( defined(POLARSSL_PLATFORM_STD_FPRINTF) ||\
|
||||
defined(POLARSSL_PLATFORM_FPRINTF_ALT) )
|
||||
#error "POLARSSL_PLATFORM_FPRINTF_MACRO and POLARSSL_PLATFORM_STD_FPRINTF/POLARSSL_PLATFORM_FPRINTF_ALT cannot be defined simultaneously"
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_FREE_MACRO) &&\
|
||||
( !defined(POLARSSL_PLATFORM_C) || !defined(POLARSSL_PLATFORM_MEMORY) )
|
||||
#error "POLARSSL_PLATFORM_FREE_MACRO defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_FREE_MACRO) &&\
|
||||
defined(POLARSSL_PLATFORM_STD_FREE)
|
||||
#error "POLARSSL_PLATFORM_FREE_MACRO and POLARSSL_PLATFORM_STD_FREE cannot be defined simultaneously"
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_FREE_MACRO) && !defined(POLARSSL_PLATFORM_MALLOC_MACRO)
|
||||
#error "POLARSSL_PLATFORM_MALLOC_MACRO must be defined if POLARSSL_PLATFORM_FREE_MACRO is"
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_MALLOC_MACRO) &&\
|
||||
( !defined(POLARSSL_PLATFORM_C) || !defined(POLARSSL_PLATFORM_MEMORY) )
|
||||
#error "POLARSSL_PLATFORM_MALLOC_MACRO defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_MALLOC_MACRO) &&\
|
||||
defined(POLARSSL_PLATFORM_STD_MALLOC)
|
||||
#error "POLARSSL_PLATFORM_MALLOC_MACRO and POLARSSL_PLATFORM_STD_MALLOC cannot be defined simultaneously"
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_MALLOC_MACRO) && !defined(POLARSSL_PLATFORM_FREE_MACRO)
|
||||
#error "POLARSSL_PLATFORM_FREE_MACRO must be defined if POLARSSL_PLATFORM_MALLOC_MACRO is"
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_MEMORY) && !defined(POLARSSL_PLATFORM_C)
|
||||
#error "POLARSSL_PLATFORM_MEMORY defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_PRINTF_ALT) && !defined(POLARSSL_PLATFORM_C)
|
||||
#error "POLARSSL_PLATFORM_PRINTF_ALT defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_PRINTF_MACRO) && !defined(POLARSSL_PLATFORM_C)
|
||||
#error "POLARSSL_PLATFORM_PRINTF_MACRO defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_PRINTF_MACRO) &&\
|
||||
( defined(POLARSSL_PLATFORM_STD_PRINTF) ||\
|
||||
defined(POLARSSL_PLATFORM_PRINTF_ALT) )
|
||||
#error "POLARSSL_PLATFORM_PRINTF_MACRO and POLARSSL_PLATFORM_STD_PRINTF/POLARSSL_PLATFORM_PRINTF_ALT cannot be defined simultaneously"
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_SNPRINTF_ALT) && !defined(POLARSSL_PLATFORM_C)
|
||||
#error "POLARSSL_PLATFORM_SNPRINTF_ALT defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_SNPRINTF_ALT) && ( defined(_WIN32)\
|
||||
&& !defined(EFIX64) && !defined(EFI32) )
|
||||
#error "POLARSSL_PLATFORM_SNPRINTF_ALT defined but not available on Windows"
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_SNPRINTF_MACRO) && !defined(POLARSSL_PLATFORM_C)
|
||||
#error "POLARSSL_PLATFORM_SNPRINTF_MACRO defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_SNPRINTF_MACRO) &&\
|
||||
( defined(POLARSSL_PLATFORM_STD_SNPRINTF) ||\
|
||||
defined(POLARSSL_PLATFORM_SNPRINTF_ALT) )
|
||||
#error "POLARSSL_PLATFORM_SNPRINTF_MACRO and POLARSSL_PLATFORM_STD_SNPRINTF/POLARSSL_PLATFORM_SNPRINTF_ALT cannot be defined simultaneously"
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_STD_MEM_HDR) &&\
|
||||
!defined(POLARSSL_PLATFORM_NO_STD_FUNCTIONS)
|
||||
#error "POLARSSL_PLATFORM_STD_MEM_HDR defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_STD_MALLOC) && !defined(POLARSSL_PLATFORM_MEMORY)
|
||||
#error "POLARSSL_PLATFORM_STD_MALLOC defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_STD_MALLOC) && !defined(POLARSSL_PLATFORM_MEMORY)
|
||||
#error "POLARSSL_PLATFORM_STD_MALLOC defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_STD_FREE) && !defined(POLARSSL_PLATFORM_MEMORY)
|
||||
#error "POLARSSL_PLATFORM_STD_FREE defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_STD_EXIT) &&\
|
||||
!defined(POLARSSL_PLATFORM_EXIT_ALT)
|
||||
#error "POLARSSL_PLATFORM_STD_EXIT defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_STD_FPRINTF) &&\
|
||||
!defined(POLARSSL_PLATFORM_FPRINTF_ALT)
|
||||
#error "POLARSSL_PLATFORM_STD_FPRINTF defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_STD_PRINTF) &&\
|
||||
!defined(POLARSSL_PLATFORM_PRINTF_ALT)
|
||||
#error "POLARSSL_PLATFORM_STD_PRINTF defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_STD_SNPRINTF) &&\
|
||||
!defined(POLARSSL_PLATFORM_SNPRINTF_ALT)
|
||||
#error "POLARSSL_PLATFORM_STD_SNPRINTF defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_RSA_C) && ( !defined(POLARSSL_BIGNUM_C) || \
|
||||
!defined(POLARSSL_OID_C) )
|
||||
#error "POLARSSL_RSA_C defined, but not all prerequisites"
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#include POLARSSL_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(POLARSSL_GCM_C) || defined(POLARSSL_CCM_C)
|
||||
#define POLARSSL_CIPHER_MODE_AEAD
|
||||
#endif
|
||||
|
@ -41,7 +43,9 @@
|
|||
#define POLARSSL_CIPHER_MODE_WITH_PADDING
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#if defined(POLARSSL_ARC4_C)
|
||||
#define POLARSSL_CIPHER_MODE_STREAM
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && !defined(inline)
|
||||
#define inline _inline
|
||||
|
@ -182,24 +186,32 @@ typedef struct {
|
|||
int (*ecb_func)( void *ctx, operation_t mode,
|
||||
const unsigned char *input, unsigned char *output );
|
||||
|
||||
#if defined(POLARSSL_CIPHER_MODE_CBC)
|
||||
/** Encrypt using CBC */
|
||||
int (*cbc_func)( void *ctx, operation_t mode, size_t length,
|
||||
unsigned char *iv, const unsigned char *input,
|
||||
unsigned char *output );
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_CIPHER_MODE_CFB)
|
||||
/** Encrypt using CFB (Full length) */
|
||||
int (*cfb_func)( void *ctx, operation_t mode, size_t length, size_t *iv_off,
|
||||
unsigned char *iv, const unsigned char *input,
|
||||
unsigned char *output );
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_CIPHER_MODE_CTR)
|
||||
/** Encrypt using CTR */
|
||||
int (*ctr_func)( void *ctx, size_t length, size_t *nc_off,
|
||||
unsigned char *nonce_counter, unsigned char *stream_block,
|
||||
const unsigned char *input, unsigned char *output );
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_CIPHER_MODE_STREAM)
|
||||
/** Encrypt using STREAM */
|
||||
int (*stream_func)( void *ctx, size_t length,
|
||||
const unsigned char *input, unsigned char *output );
|
||||
#endif
|
||||
|
||||
/** Set key for encryption purposes */
|
||||
int (*setkey_enc_func)( void *ctx, const unsigned char *key,
|
||||
|
@ -262,9 +274,11 @@ typedef struct {
|
|||
/** Operation that the context's key has been initialised for */
|
||||
operation_t operation;
|
||||
|
||||
#if defined(POLARSSL_CIPHER_MODE_WITH_PADDING)
|
||||
/** Padding functions to use, if relevant for cipher mode */
|
||||
void (*add_padding)( unsigned char *output, size_t olen, size_t data_len );
|
||||
int (*get_padding)( unsigned char *input, size_t ilen, size_t *data_len );
|
||||
#endif
|
||||
|
||||
/** Buffer for data that hasn't been encrypted yet */
|
||||
unsigned char unprocessed_data[POLARSSL_MAX_BLOCK_LENGTH];
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#else
|
||||
#include POLARSSL_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#include "cipher.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -120,8 +120,14 @@
|
|||
* This allows different allocators (self-implemented or provided) to be
|
||||
* provided to the platform abstraction layer.
|
||||
*
|
||||
* Enabling POLARSSL_PLATFORM_MEMORY will provide "platform_set_malloc_free()"
|
||||
* to allow you to set an alternative malloc() and free() function pointer.
|
||||
* Enabling POLARSSL_PLATFORM_MEMORY without the
|
||||
* POLARSSL_PLATFORM_{FREE,MALLOC}_MACROs will provide
|
||||
* "platform_set_malloc_free()" allowing you to set an alternative malloc() and
|
||||
* free() function pointer at runtime.
|
||||
*
|
||||
* Enabling POLARSSL_PLATFORM_MEMORY and specifying
|
||||
* POLARSSL_PLATFORM_{MALLOC,FREE}_MACROs will allow you to specify the
|
||||
* alternate function at compile time.
|
||||
*
|
||||
* Requires: POLARSSL_PLATFORM_C
|
||||
*
|
||||
|
@ -138,7 +144,8 @@
|
|||
* This makes sure there are no linking errors on platforms that do not support
|
||||
* these functions. You will HAVE to provide alternatives, either at runtime
|
||||
* via the platform_set_xxx() functions or at compile time by setting
|
||||
* the POLARSSL_PLATFORM_STD_XXX defines.
|
||||
* the POLARSSL_PLATFORM_STD_XXX defines, or enabling a
|
||||
* POLARSSL_PLATFORM_XXX_MACRO.
|
||||
*
|
||||
* Requires: POLARSSL_PLATFORM_C
|
||||
*
|
||||
|
@ -159,11 +166,19 @@
|
|||
*
|
||||
* All these define require POLARSSL_PLATFORM_C to be defined!
|
||||
*
|
||||
* WARNING: POLARSSL_PLATFORM_SNPRINTF_ALT is not available on Windows
|
||||
* for compatibility reasons.
|
||||
*
|
||||
* WARNING: POLARSSL_PLATFORM_XXX_ALT cannot be defined at the same time as
|
||||
* POLARSSL_PLATFORM_XXX_MACRO!
|
||||
*
|
||||
* Uncomment a macro to enable alternate implementation of specific base
|
||||
* platform function
|
||||
*/
|
||||
//#define POLARSSL_PLATFORM_PRINTF_ALT
|
||||
//#define POLARSSL_PLATFORM_EXIT_ALT
|
||||
//#define POLARSSL_PLATFORM_FPRINTF_ALT
|
||||
//#define POLARSSL_PLATFORM_PRINTF_ALT
|
||||
//#define POLARSSL_PLATFORM_SNPRINTF_ALT
|
||||
/* \} name SECTION: System support */
|
||||
|
||||
/**
|
||||
|
@ -1957,7 +1972,11 @@
|
|||
* \def POLARSSL_PLATFORM_C
|
||||
*
|
||||
* Enable the platform abstraction layer that allows you to re-assign
|
||||
* functions like malloc(), free(), printf(), fprintf()
|
||||
* functions like malloc(), free(), snprintf(), printf(), fprintf(), exit()
|
||||
*
|
||||
* Enabling POLARSSL_PLATFORM_C enables to use of POLARSSL_PLATFORM_XXX_ALT
|
||||
* or POLARSSL_PLATFORM_XXX_MACRO directives, allowing the functions mentioned
|
||||
* above to be specified at runtime or compile time respectively.
|
||||
*
|
||||
* Module: library/platform.c
|
||||
* Caller: Most other .c files
|
||||
|
@ -2314,11 +2333,22 @@
|
|||
//#define POLARSSL_MEMORY_ALIGN_MULTIPLE 4 /**< Align on multiples of this value */
|
||||
|
||||
/* Platform options */
|
||||
//#define POLARSSL_PLATFORM_STD_MEM_HDR <stdlib.h> /**< Header to include if POLARSSL_PLATFORM_NO_STD_FUNCTIONS is defined. Don't define if no header is needed. */
|
||||
//#define POLARSSL_PLATFORM_STD_MALLOC malloc /**< Default allocator to use, can be undefined */
|
||||
//#define POLARSSL_PLATFORM_STD_FREE free /**< Default free to use, can be undefined */
|
||||
//#define POLARSSL_PLATFORM_STD_PRINTF printf /**< Default printf to use, can be undefined */
|
||||
//#define POLARSSL_PLATFORM_STD_FPRINTF fprintf /**< Default fprintf to use, can be undefined */
|
||||
//#define POLARSSL_PLATFORM_STD_MEM_HDR <stdlib.h> /**< Header to include if POLARSSL_PLATFORM_NO_STD_FUNCTIONS is defined. Don't define if no header is needed. */
|
||||
//#define POLARSSL_PLATFORM_STD_MALLOC malloc /**< Default allocator to use, can be undefined */
|
||||
//#define POLARSSL_PLATFORM_STD_FREE free /**< Default free to use, can be undefined */
|
||||
//#define POLARSSL_PLATFORM_STD_EXIT exit /**< Default exit to use, can be undefined */
|
||||
//#define POLARSSL_PLATFORM_STD_FPRINTF fprintf /**< Default fprintf to use, can be undefined */
|
||||
//#define POLARSSL_PLATFORM_STD_PRINTF printf /**< Default printf to use, can be undefined */
|
||||
//#define POLARSSL_PLATFORM_STD_SNPRINTF snprintf /**< Default snprintf to use, can be undefined */
|
||||
|
||||
/* To Use Function Macros POLARSSL_PLATFORM_C must be enabled */
|
||||
/* POLARSSL_PLATFORM_XXX_MACRO and POLARSSL_PLATFORM_XXX_ALT cannot both be defined */
|
||||
//#define POLARSSL_PLATFORM_MALLOC_MACRO malloc /**< Default allocator macro to use, can be undefined */
|
||||
//#define POLARSSL_PLATFORM_FREE_MACRO free /**< Default free macro to use, can be undefined */
|
||||
//#define POLARSSL_PLATFORM_EXIT_MACRO exit /**< Default exit macro to use, can be undefined */
|
||||
//#define POLARSSL_PLATFORM_FPRINTF_MACRO fprintf /**< Default fprintf macro to use, can be undefined */
|
||||
//#define POLARSSL_PLATFORM_PRINTF_MACRO printf /**< Default printf macro to use, can be undefined */
|
||||
//#define POLARSSL_PLATFORM_SNPRINTF_MACRO snprintf /**< Default snprintf macro to use, can be undefined */
|
||||
|
||||
/* SSL Cache options */
|
||||
//#define SSL_CACHE_DEFAULT_TIMEOUT 86400 /**< 1 day */
|
||||
|
|
|
@ -24,8 +24,6 @@
|
|||
#ifndef POLARSSL_CTR_DRBG_H
|
||||
#define POLARSSL_CTR_DRBG_H
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "aes.h"
|
||||
|
||||
#define POLARSSL_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED -0x0034 /**< The entropy source failed. */
|
||||
|
|
|
@ -29,7 +29,9 @@
|
|||
#else
|
||||
#include POLARSSL_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#include "ssl.h"
|
||||
|
||||
#if defined(POLARSSL_ECP_C)
|
||||
#include "ecp.h"
|
||||
#endif
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include POLARSSL_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
|
||||
#include <basetsd.h>
|
||||
|
|
|
@ -24,14 +24,14 @@
|
|||
#ifndef POLARSSL_ENTROPY_H
|
||||
#define POLARSSL_ENTROPY_H
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if !defined(POLARSSL_CONFIG_FILE)
|
||||
#include "config.h"
|
||||
#else
|
||||
#include POLARSSL_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(POLARSSL_SHA512_C) && !defined(POLARSSL_ENTROPY_FORCE_SHA256)
|
||||
#include "sha512.h"
|
||||
#define POLARSSL_ENTROPY_SHA512_ACCUMULATOR
|
||||
|
|
|
@ -24,14 +24,14 @@
|
|||
#ifndef POLARSSL_ENTROPY_POLL_H
|
||||
#define POLARSSL_ENTROPY_POLL_H
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if !defined(POLARSSL_CONFIG_FILE)
|
||||
#include "config.h"
|
||||
#else
|
||||
#include POLARSSL_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#ifndef POLARSSL_ERROR_H
|
||||
#define POLARSSL_ERROR_H
|
||||
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
|
||||
/**
|
||||
* Error code layout.
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#ifndef POLARSSL_HAVEGE_H
|
||||
#define POLARSSL_HAVEGE_H
|
||||
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#define COLLECT_SIZE 1024
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#ifndef POLARSSL_MD_H
|
||||
#define POLARSSL_MD_H
|
||||
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(_MSC_VER) && !defined(inline)
|
||||
#define inline _inline
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include POLARSSL_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#define POLARSSL_ERR_MD2_FILE_IO_ERROR -0x0070 /**< Read/write error in file. */
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include POLARSSL_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
|
||||
#include <basetsd.h>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include POLARSSL_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
|
||||
#include <basetsd.h>
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#else
|
||||
#include POLARSSL_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#include "md.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include POLARSSL_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
|
||||
/**
|
||||
* \name SECTION: Module settings
|
||||
|
@ -97,6 +97,27 @@ void memory_buffer_set_verify( int verify );
|
|||
* trace if POLARSSL_MEMORY_BACKTRACE is defined.
|
||||
*/
|
||||
void memory_buffer_alloc_status( void );
|
||||
|
||||
/**
|
||||
* \brief Get the peak heap usage so far
|
||||
*
|
||||
* \param max_used Peak number of bytes reauested by the application
|
||||
* \param max_blocks Peak number of blocks reauested by the application
|
||||
*/
|
||||
void memory_buffer_alloc_max_get( size_t *max_used, size_t *max_blocks );
|
||||
|
||||
/**
|
||||
* \brief Reset peak statistics
|
||||
*/
|
||||
void memory_buffer_alloc_max_reset( void );
|
||||
|
||||
/**
|
||||
* \brief Get the current heap usage
|
||||
*
|
||||
* \param cur_used Number of bytes reauested by the application
|
||||
* \param cur_blocks Number of blocks reauested by the application
|
||||
*/
|
||||
void memory_buffer_alloc_cur_get( size_t *cur_used, size_t *cur_blocks );
|
||||
#endif /* POLARSSL_MEMORY_DEBUG */
|
||||
|
||||
/**
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include POLARSSL_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(POLARSSL_HAVE_TIME)
|
||||
#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
|
||||
|
|
|
@ -24,14 +24,17 @@
|
|||
#ifndef POLARSSL_OID_H
|
||||
#define POLARSSL_OID_H
|
||||
|
||||
#include <string.h>
|
||||
#if !defined(POLARSSL_CONFIG_FILE)
|
||||
#include "config.h"
|
||||
#else
|
||||
#include POLARSSL_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#include "asn1.h"
|
||||
#include "pk.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(POLARSSL_CIPHER_C)
|
||||
#include "cipher.h"
|
||||
#endif
|
||||
|
|
|
@ -42,7 +42,6 @@ typedef INT32 int32_t;
|
|||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
|
||||
#define PADLOCK_RNG 0x000C
|
||||
#define PADLOCK_ACE 0x00C0
|
||||
#define PADLOCK_PHE 0x0C00
|
||||
|
|
|
@ -27,10 +27,10 @@
|
|||
#ifndef POLARSSL_PBKDF2_H
|
||||
#define POLARSSL_PBKDF2_H
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "md.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
|
||||
#include <basetsd.h>
|
||||
typedef UINT32 uint32_t;
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#ifndef POLARSSL_PEM_H
|
||||
#define POLARSSL_PEM_H
|
||||
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
|
||||
/**
|
||||
* \name PEM Error codes
|
||||
|
|
|
@ -24,12 +24,12 @@
|
|||
#ifndef POLARSSL_PKCS12_H
|
||||
#define POLARSSL_PKCS12_H
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "md.h"
|
||||
#include "cipher.h"
|
||||
#include "asn1.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#define POLARSSL_ERR_PKCS12_BAD_INPUT_DATA -0x1F80 /**< Bad input parameters to function. */
|
||||
#define POLARSSL_ERR_PKCS12_FEATURE_UNAVAILABLE -0x1F00 /**< Feature not available, e.g. unsupported encryption scheme. */
|
||||
#define POLARSSL_ERR_PKCS12_PBE_INVALID_FORMAT -0x1E80 /**< PBE ASN.1 data not as expected. */
|
||||
|
|
|
@ -26,11 +26,11 @@
|
|||
#ifndef POLARSSL_PKCS5_H
|
||||
#define POLARSSL_PKCS5_H
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "asn1.h"
|
||||
#include "md.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
|
||||
#include <basetsd.h>
|
||||
typedef UINT32 uint32_t;
|
||||
|
|
|
@ -35,8 +35,6 @@
|
|||
#define POLARSSL_PLATFORM_MEMORY
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -50,7 +48,11 @@ extern "C" {
|
|||
*/
|
||||
|
||||
#if !defined(POLARSSL_PLATFORM_NO_STD_FUNCTIONS)
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#if !defined(POLARSSL_PLATFORM_STD_SNPRINTF)
|
||||
#define POLARSSL_PLATFORM_STD_SNPRINTF snprintf /**< Default snprintf to use */
|
||||
#endif
|
||||
#if !defined(POLARSSL_PLATFORM_STD_PRINTF)
|
||||
#define POLARSSL_PLATFORM_STD_PRINTF printf /**< Default printf to use */
|
||||
#endif
|
||||
|
@ -63,6 +65,9 @@ extern "C" {
|
|||
#if !defined(POLARSSL_PLATFORM_STD_FREE)
|
||||
#define POLARSSL_PLATFORM_STD_FREE free /**< Default free to use */
|
||||
#endif
|
||||
#if !defined(POLARSSL_PLATFORM_STD_EXIT)
|
||||
#define POLARSSL_PLATFORM_STD_EXIT exit /**< Default free to use */
|
||||
#endif
|
||||
#else /* POLARSSL_PLATFORM_NO_STD_FUNCTIONS */
|
||||
#if defined(POLARSSL_PLATFORM_STD_MEM_HDR)
|
||||
#include POLARSSL_PLATFORM_STD_MEM_HDR
|
||||
|
@ -75,6 +80,11 @@ extern "C" {
|
|||
* The function pointers for malloc and free
|
||||
*/
|
||||
#if defined(POLARSSL_PLATFORM_MEMORY)
|
||||
#if defined(POLARSSL_PLATFORM_FREE_MACRO) &&\
|
||||
defined(POLARSSL_PLATFORM_MALLOC_MACRO)
|
||||
#define polarssl_free POLARSSL_PLATFORM_FREE_MACRO
|
||||
#define polarssl_malloc POLARSSL_PLATFORM_MALLOC_MACRO
|
||||
#else
|
||||
extern void * (*polarssl_malloc)( size_t len );
|
||||
extern void (*polarssl_free)( void *ptr );
|
||||
|
||||
|
@ -88,10 +98,34 @@ extern void (*polarssl_free)( void *ptr );
|
|||
*/
|
||||
int platform_set_malloc_free( void * (*malloc_func)( size_t ),
|
||||
void (*free_func)( void * ) );
|
||||
#else /* POLARSSL_PLATFORM_ENTROPY */
|
||||
#define polarssl_malloc malloc
|
||||
#define polarssl_free free
|
||||
#endif /* POLARSSL_PLATFORM_ENTROPY */
|
||||
#endif /* POLARSSL_PLATFORM_FREE_MACRO && POLARSSL_PLATFORM_MALLOC_MACRO */
|
||||
#else /* !POLARSSL_PLATFORM_MEMORY */
|
||||
#define polarssl_free free
|
||||
#define polarssl_malloc malloc
|
||||
#endif /* POLARSSL_PLATFORM_MEMORY && !POLARSSL_PLATFORM_{FREE,MALLOC}_MACRO */
|
||||
|
||||
/*
|
||||
* The function pointers for fprintf
|
||||
*/
|
||||
#if defined(POLARSSL_PLATFORM_FPRINTF_ALT)
|
||||
extern int (*polarssl_fprintf)( FILE *stream, const char *format, ... );
|
||||
|
||||
/**
|
||||
* \brief Set your own fprintf function pointer
|
||||
*
|
||||
* \param fprintf_func the fprintf function implementation
|
||||
*
|
||||
* \return 0
|
||||
*/
|
||||
int platform_set_fprintf( int (*fprintf_func)( FILE *stream, const char *,
|
||||
... ) );
|
||||
#else
|
||||
#if defined(POLARSSL_PLATFORM_FPRINTF_MACRO)
|
||||
#define polarssl_fprintf POLARSSL_PLATFORM_FPRINTF_MACRO
|
||||
#else
|
||||
#define polarssl_fprintf fprintf
|
||||
#endif /* POLARSSL_PLATFORM_FPRINTF_MACRO */
|
||||
#endif /* POLARSSL_PLATFORM_FPRINTF_ALT */
|
||||
|
||||
/*
|
||||
* The function pointers for printf
|
||||
|
@ -107,21 +141,58 @@ extern int (*polarssl_printf)( const char *format, ... );
|
|||
* \return 0
|
||||
*/
|
||||
int platform_set_printf( int (*printf_func)( const char *, ... ) );
|
||||
#else /* POLARSSL_PLATFORM_PRINTF_ALT */
|
||||
#else /* !POLARSSL_PLATFORM_PRINTF_ALT */
|
||||
#if defined(POLARSSL_PLATFORM_PRINTF_MACRO)
|
||||
#define polarssl_printf POLARSSL_PLATFORM_PRINTF_MACRO
|
||||
#else
|
||||
#define polarssl_printf printf
|
||||
#endif /* POLARSSL_PLATFORM_PRINTF_MACRO */
|
||||
#endif /* POLARSSL_PLATFORM_PRINTF_ALT */
|
||||
|
||||
/*
|
||||
* The function pointers for fprintf
|
||||
* The function pointers for snprintf
|
||||
*/
|
||||
#if defined(POLARSSL_PLATFORM_FPRINTF_ALT)
|
||||
extern int (*polarssl_fprintf)( FILE *stream, const char *format, ... );
|
||||
#if defined(POLARSSL_PLATFORM_SNPRINTF_ALT)
|
||||
extern int (*polarssl_snprintf)( char * s, size_t n, const char * format, ... );
|
||||
|
||||
int platform_set_fprintf( int (*fprintf_func)( FILE *stream, const char *,
|
||||
... ) );
|
||||
/**
|
||||
* \brief Set your own snprintf function pointer
|
||||
*
|
||||
* \param snprintf_func the snprintf function implementation
|
||||
*
|
||||
* \return 0
|
||||
*/
|
||||
int platform_set_snprintf( int (*snprintf_func)( char * s, size_t n,
|
||||
const char * format, ... ) );
|
||||
#else /* POLARSSL_PLATFORM_SNPRINTF_ALT */
|
||||
#if defined(POLARSSL_PLATFORM_SNPRINTF_MACRO)
|
||||
#define polarssl_snprintf POLARSSL_PLATFORM_SNPRINTF_MACRO
|
||||
#else
|
||||
#define polarssl_fprintf fprintf
|
||||
#endif
|
||||
#define polarssl_snprintf snprintf
|
||||
#endif /* POLARSSL_PLATFORM_SNPRINTF_MACRO */
|
||||
#endif /* POLARSSL_PLATFORM_SNPRINTF_ALT */
|
||||
|
||||
/*
|
||||
* The function pointers for exit
|
||||
*/
|
||||
#if defined(POLARSSL_PLATFORM_EXIT_ALT)
|
||||
extern void (*polarssl_exit)( int status );
|
||||
|
||||
/**
|
||||
* \brief Set your own exit function pointer
|
||||
*
|
||||
* \param exit_func the exit function implementation
|
||||
*
|
||||
* \return 0
|
||||
*/
|
||||
int platform_set_exit( void (*exit_func)( int status ) );
|
||||
#else
|
||||
#if defined(POLARSSL_PLATFORM_EXIT_MACRO)
|
||||
#define polarssl_exit POLARSSL_PLATFORM_EXIT_MACRO
|
||||
#else
|
||||
#define polarssl_exit exit
|
||||
#endif /* POLARSSL_PLATFORM_EXIT_MACRO */
|
||||
#endif /* POLARSSL_PLATFORM_EXIT_ALT */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include POLARSSL_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
|
||||
#include <basetsd.h>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include POLARSSL_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
|
||||
#include <basetsd.h>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include POLARSSL_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
|
||||
#include <basetsd.h>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include POLARSSL_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(_MSC_VER) || defined(__WATCOMC__)
|
||||
#define UL64(x) x##ui64
|
||||
|
|
|
@ -65,6 +65,10 @@ unsigned long get_timer( struct hr_time *val, int reset );
|
|||
* \brief Setup an alarm clock
|
||||
*
|
||||
* \param seconds delay before the "alarmed" flag is set
|
||||
*
|
||||
* \warning Only one alarm at a time is supported. In a threaded
|
||||
* context, this means one for the whole process, not one per
|
||||
* thread.
|
||||
*/
|
||||
void set_alarm( int seconds );
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
#endif
|
||||
|
||||
#include "x509.h"
|
||||
|
||||
#include "x509_crl.h"
|
||||
|
||||
/**
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include POLARSSL_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
|
||||
#include <basetsd.h>
|
||||
|
|
|
@ -19,17 +19,28 @@ endif
|
|||
|
||||
# To compile as a shared library:
|
||||
ifdef SHARED
|
||||
# all code is position-indep with mingw, avoid warning about useless flag
|
||||
ifndef WINDOWS
|
||||
CFLAGS += -fPIC
|
||||
endif
|
||||
endif
|
||||
|
||||
SONAME=libmbedtls.so.8
|
||||
SOEXT=so.8
|
||||
|
||||
DLEXT=so.8
|
||||
DLEXT=so
|
||||
# OSX shared library extension:
|
||||
# DLEXT=dylib
|
||||
|
||||
# Windows shared library extension:
|
||||
#
|
||||
# if we running on Windows build
|
||||
# for Windows
|
||||
#
|
||||
ifdef WINDOWS
|
||||
WINDOWS_BUILD=1
|
||||
endif
|
||||
|
||||
# Windows shared library extension:
|
||||
ifdef WINDOWS_BUILD
|
||||
DLEXT=dll
|
||||
LDFLAGS += -lws2_32
|
||||
endif
|
||||
|
@ -74,7 +85,7 @@ endif
|
|||
|
||||
static: libpolarssl.a
|
||||
|
||||
shared: libpolarssl.so
|
||||
shared: libpolarssl.$(DLEXT)
|
||||
|
||||
libpolarssl.a: libmbedtls.a
|
||||
echo " LN $@ -> $?"
|
||||
|
@ -86,25 +97,32 @@ endif
|
|||
|
||||
libmbedtls.a: $(OBJS)
|
||||
echo " AR $@"
|
||||
$(AR) r $@ $(OBJS)
|
||||
$(AR) rc $@ $(OBJS)
|
||||
echo " RL $@"
|
||||
$(AR) s $@
|
||||
|
||||
libpolarssl.so: libmbedtls.so
|
||||
libpolarssl.$(DLEXT): libmbedtls.$(DLEXT)
|
||||
echo " LN $@ -> $?"
|
||||
ifndef WINDOWS
|
||||
ln -sf $? $@
|
||||
else
|
||||
copy /y /b $? $@
|
||||
endif
|
||||
ifdef WINDOWS_BUILD
|
||||
ifndef WINDOWS
|
||||
ln -sf $?.a $@.a
|
||||
else
|
||||
copy /y /b $?.a $@.a
|
||||
endif
|
||||
endif
|
||||
|
||||
libmbedtls.${DLEXT}: $(OBJS)
|
||||
libmbedtls.$(SOEXT): $(OBJS)
|
||||
echo " LD $@"
|
||||
$(CC) ${LDFLAGS} -shared -Wl,-soname,$(SONAME) -o $@ $(OBJS)
|
||||
$(CC) ${LDFLAGS} -shared -Wl,-soname,$@ -o $@ $(OBJS)
|
||||
|
||||
libmbedtls.so: libmbedtls.${DLEXT}
|
||||
echo " LN $@ -> libmbedtls.${DLEXT}"
|
||||
ln -sf libmbedtls.${DLEXT} $@
|
||||
libmbedtls.so: libmbedtls.$(SOEXT)
|
||||
echo " LN $@ -> libmbedtls.$(SOEXT)"
|
||||
ln -sf libmbedtls.$(SOEXT) $@
|
||||
|
||||
libmbedtls.dylib: $(OBJS)
|
||||
echo " LD $@"
|
||||
|
@ -112,7 +130,7 @@ libmbedtls.dylib: $(OBJS)
|
|||
|
||||
libmbedtls.dll: $(OBJS)
|
||||
echo " LD $@"
|
||||
$(CC) -shared -Wl,-soname,$@ -o $@ $(OBJS) -lws2_32 -lwinmm -lgdi32
|
||||
$(CC) -shared -Wl,-soname,$@ -Wl,--out-implib,$@.a -o $@ $(OBJS) -lws2_32 -lwinmm -lgdi32
|
||||
|
||||
.c.o:
|
||||
echo " CC $<"
|
||||
|
|
|
@ -34,6 +34,8 @@
|
|||
|
||||
#if defined(POLARSSL_AES_C)
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "polarssl/aes.h"
|
||||
#if defined(POLARSSL_PADLOCK_C)
|
||||
#include "polarssl/padlock.h"
|
||||
|
@ -42,11 +44,14 @@
|
|||
#include "polarssl/aesni.h"
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_SELF_TEST)
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#define polarssl_printf printf
|
||||
#endif
|
||||
#endif /* POLARSSL_PLATFORM_C */
|
||||
#endif /* POLARSSL_SELF_TEST */
|
||||
|
||||
#if !defined(POLARSSL_AES_ALT)
|
||||
|
||||
|
@ -926,7 +931,6 @@ int aes_crypt_cfb128( aes_context *ctx,
|
|||
/*
|
||||
* AES-CFB8 buffer encryption/decryption
|
||||
*/
|
||||
#include <stdio.h>
|
||||
int aes_crypt_cfb8( aes_context *ctx,
|
||||
int mode,
|
||||
size_t length,
|
||||
|
@ -996,9 +1000,6 @@ int aes_crypt_ctr( aes_context *ctx,
|
|||
#endif /* !POLARSSL_AES_ALT */
|
||||
|
||||
#if defined(POLARSSL_SELF_TEST)
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
* AES test vectors from:
|
||||
*
|
||||
|
|
|
@ -34,7 +34,8 @@
|
|||
#if defined(POLARSSL_AESNI_C)
|
||||
|
||||
#include "polarssl/aesni.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(POLARSSL_HAVE_X86_64)
|
||||
|
||||
|
|
|
@ -35,11 +35,16 @@
|
|||
|
||||
#include "polarssl/arc4.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(POLARSSL_SELF_TEST)
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#define polarssl_printf printf
|
||||
#endif
|
||||
#endif /* POLARSSL_PLATFORM_C */
|
||||
#endif /* POLARSSL_SELF_TEST */
|
||||
|
||||
#if !defined(POLARSSL_ARC4_ALT)
|
||||
|
||||
|
@ -126,10 +131,6 @@ int arc4_crypt( arc4_context *ctx, size_t length, const unsigned char *input,
|
|||
#endif /* !POLARSSL_ARC4_ALT */
|
||||
|
||||
#if defined(POLARSSL_SELF_TEST)
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
* ARC4 tests vectors as posted by Eric Rescorla in sep. 1994:
|
||||
*
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
|
||||
#include "polarssl/asn1.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(POLARSSL_BIGNUM_C)
|
||||
#include "polarssl/bignum.h"
|
||||
#endif
|
||||
|
@ -37,13 +39,11 @@
|
|||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#define polarssl_malloc malloc
|
||||
#define polarssl_free free
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Implementation that should never be optimized out by the compiler */
|
||||
static void polarssl_zeroize( void *v, size_t n ) {
|
||||
volatile unsigned char *p = v; while( n-- ) *p++ = 0;
|
||||
|
@ -77,7 +77,7 @@ int asn1_get_len( unsigned char **p,
|
|||
if( ( end - *p ) < 3 )
|
||||
return( POLARSSL_ERR_ASN1_OUT_OF_DATA );
|
||||
|
||||
*len = ( (*p)[1] << 8 ) | (*p)[2];
|
||||
*len = ( (size_t)(*p)[1] << 8 ) | (*p)[2];
|
||||
(*p) += 3;
|
||||
break;
|
||||
|
||||
|
@ -85,7 +85,8 @@ int asn1_get_len( unsigned char **p,
|
|||
if( ( end - *p ) < 4 )
|
||||
return( POLARSSL_ERR_ASN1_OUT_OF_DATA );
|
||||
|
||||
*len = ( (*p)[1] << 16 ) | ( (*p)[2] << 8 ) | (*p)[3];
|
||||
*len = ( (size_t)(*p)[1] << 16 ) |
|
||||
( (size_t)(*p)[2] << 8 ) | (*p)[3];
|
||||
(*p) += 4;
|
||||
break;
|
||||
|
||||
|
@ -93,8 +94,8 @@ int asn1_get_len( unsigned char **p,
|
|||
if( ( end - *p ) < 5 )
|
||||
return( POLARSSL_ERR_ASN1_OUT_OF_DATA );
|
||||
|
||||
*len = ( (*p)[1] << 24 ) | ( (*p)[2] << 16 ) | ( (*p)[3] << 8 ) |
|
||||
(*p)[4];
|
||||
*len = ( (size_t)(*p)[1] << 24 ) | ( (size_t)(*p)[2] << 16 ) |
|
||||
( (size_t)(*p)[3] << 8 ) | (*p)[4];
|
||||
(*p) += 5;
|
||||
break;
|
||||
|
||||
|
@ -269,8 +270,7 @@ int asn1_get_sequence_of( unsigned char **p,
|
|||
/* Allocate and assign next pointer */
|
||||
if( *p < end )
|
||||
{
|
||||
cur->next = (asn1_sequence *) polarssl_malloc(
|
||||
sizeof( asn1_sequence ) );
|
||||
cur->next = polarssl_malloc( sizeof( asn1_sequence ) );
|
||||
|
||||
if( cur->next == NULL )
|
||||
return( POLARSSL_ERR_ASN1_MALLOC_FAILED );
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
|
||||
#include "polarssl/asn1write.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
|
|
|
@ -37,11 +37,15 @@ typedef UINT32 uint32_t;
|
|||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_SELF_TEST)
|
||||
#include <string.h>
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#define polarssl_printf printf
|
||||
#endif
|
||||
#endif /* POLARSSL_PLATFORM_C */
|
||||
#endif /* POLARSSL_SELF_TEST */
|
||||
|
||||
static const unsigned char base64_enc_map[64] =
|
||||
{
|
||||
|
@ -221,9 +225,6 @@ int base64_decode( unsigned char *dst, size_t *dlen,
|
|||
|
||||
#if defined(POLARSSL_SELF_TEST)
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
static const unsigned char base64_test_dec[64] =
|
||||
{
|
||||
0x24, 0x48, 0x6E, 0x56, 0x87, 0x62, 0x5A, 0xBD,
|
||||
|
|
|
@ -38,16 +38,18 @@
|
|||
#include "polarssl/bignum.h"
|
||||
#include "polarssl/bn_mul.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#define polarssl_printf printf
|
||||
#define polarssl_malloc malloc
|
||||
#define polarssl_free free
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Implementation that should never be optimized out by the compiler */
|
||||
static void polarssl_zeroize( void *v, size_t n ) {
|
||||
volatile unsigned char *p = v; while( n-- ) *p++ = 0;
|
||||
|
@ -107,7 +109,7 @@ int mpi_grow( mpi *X, size_t nblimbs )
|
|||
|
||||
if( X->n < nblimbs )
|
||||
{
|
||||
if( ( p = (t_uint *) polarssl_malloc( nblimbs * ciL ) ) == NULL )
|
||||
if( ( p = polarssl_malloc( nblimbs * ciL ) ) == NULL )
|
||||
return( POLARSSL_ERR_MPI_MALLOC_FAILED );
|
||||
|
||||
memset( p, 0, nblimbs * ciL );
|
||||
|
@ -147,7 +149,7 @@ int mpi_shrink( mpi *X, size_t nblimbs )
|
|||
if( i < nblimbs )
|
||||
i = nblimbs;
|
||||
|
||||
if( ( p = (t_uint *) polarssl_malloc( i * ciL ) ) == NULL )
|
||||
if( ( p = polarssl_malloc( i * ciL ) ) == NULL )
|
||||
return( POLARSSL_ERR_MPI_MALLOC_FAILED );
|
||||
|
||||
memset( p, 0, i * ciL );
|
||||
|
@ -1238,17 +1240,7 @@ int mpi_div_mpi( mpi *Q, mpi *R, const mpi *A, const mpi *B )
|
|||
Z.p[i - t - 1] = ~0;
|
||||
else
|
||||
{
|
||||
/*
|
||||
* The version of Clang shipped by Apple with Mavericks around
|
||||
* 2014-03 can't handle 128-bit division properly. Disable
|
||||
* 128-bits division for this version. Let's be optimistic and
|
||||
* assume it'll be fixed in the next minor version (next
|
||||
* patchlevel is probably a bit too optimistic).
|
||||
*/
|
||||
#if defined(POLARSSL_HAVE_UDBL) && \
|
||||
! ( defined(__x86_64__) && defined(__APPLE__) && \
|
||||
defined(__clang_major__) && __clang_major__ == 5 && \
|
||||
defined(__clang_minor__) && __clang_minor__ == 0 )
|
||||
#if defined(POLARSSL_HAVE_UDBL)
|
||||
t_udbl r;
|
||||
|
||||
r = (t_udbl) X.p[i] << biL;
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
|
||||
#include "polarssl/blowfish.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if !defined(POLARSSL_BLOWFISH_ALT)
|
||||
|
||||
/* Implementation that should never be optimized out by the compiler */
|
||||
|
|
|
@ -36,11 +36,15 @@
|
|||
|
||||
#include "polarssl/camellia.h"
|
||||
|
||||
#if defined(POLARSSL_SELF_TEST)
|
||||
#include <string.h>
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#define polarssl_printf printf
|
||||
#endif
|
||||
#endif /* POLARSSL_PLATFORM_C */
|
||||
#endif /* POLARSSL_SELF_TEST */
|
||||
|
||||
#if !defined(POLARSSL_CAMELLIA_ALT)
|
||||
|
||||
|
@ -452,7 +456,7 @@ int camellia_setkey_dec( camellia_context *ctx, const unsigned char *key,
|
|||
camellia_init( &cty );
|
||||
|
||||
/* Also checks keysize */
|
||||
if( ( ret = camellia_setkey_enc( &cty, key, keysize ) ) )
|
||||
if( ( ret = camellia_setkey_enc( &cty, key, keysize ) ) != 0 )
|
||||
goto exit;
|
||||
|
||||
ctx->nr = cty.nr;
|
||||
|
@ -689,8 +693,6 @@ int camellia_crypt_ctr( camellia_context *ctx,
|
|||
|
||||
#if defined(POLARSSL_SELF_TEST)
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
* Camellia test vectors from:
|
||||
*
|
||||
|
|
|
@ -39,6 +39,17 @@
|
|||
|
||||
#include "polarssl/ccm.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(POLARSSL_SELF_TEST) && defined(POLARSSL_AES_C)
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#define polarssl_printf printf
|
||||
#endif /* POLARSSL_PLATFORM_C */
|
||||
#endif /* POLARSSL_SELF_TEST && POLARSSL_AES_C */
|
||||
|
||||
/* Implementation that should never be optimized out by the compiler */
|
||||
static void polarssl_zeroize( void *v, size_t n ) {
|
||||
volatile unsigned char *p = v; while( n-- ) *p++ = 0;
|
||||
|
@ -333,14 +344,6 @@ int ccm_auth_decrypt( ccm_context *ctx, size_t length,
|
|||
|
||||
|
||||
#if defined(POLARSSL_SELF_TEST) && defined(POLARSSL_AES_C)
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#define polarssl_printf printf
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Examples 1 to 3 from SP800-38C Appendix C
|
||||
*/
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
#include "polarssl/cipher.h"
|
||||
#include "polarssl/cipher_wrap.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(POLARSSL_GCM_C)
|
||||
#include "polarssl/gcm.h"
|
||||
#endif
|
||||
|
@ -43,8 +46,6 @@
|
|||
#include "polarssl/ccm.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#if defined(POLARSSL_ARC4_C) || defined(POLARSSL_CIPHER_NULL_CIPHER)
|
||||
#define POLARSSL_CIPHER_MODE_STREAM
|
||||
#endif
|
||||
|
|
|
@ -62,15 +62,18 @@
|
|||
#include "polarssl/ccm.h"
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_CIPHER_NULL_CIPHER)
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#define polarssl_malloc malloc
|
||||
#define polarssl_free free
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#if defined(POLARSSL_GCM_C)
|
||||
/* shared by all GCM ciphers */
|
||||
static void *gcm_ctx_alloc( void )
|
||||
|
@ -107,63 +110,34 @@ static int aes_crypt_ecb_wrap( void *ctx, operation_t operation,
|
|||
return aes_crypt_ecb( (aes_context *) ctx, operation, input, output );
|
||||
}
|
||||
|
||||
#if defined(POLARSSL_CIPHER_MODE_CBC)
|
||||
static int aes_crypt_cbc_wrap( void *ctx, operation_t operation, size_t length,
|
||||
unsigned char *iv, const unsigned char *input, unsigned char *output )
|
||||
{
|
||||
#if defined(POLARSSL_CIPHER_MODE_CBC)
|
||||
return aes_crypt_cbc( (aes_context *) ctx, operation, length, iv, input,
|
||||
output );
|
||||
#else
|
||||
((void) ctx);
|
||||
((void) operation);
|
||||
((void) length);
|
||||
((void) iv);
|
||||
((void) input);
|
||||
((void) output);
|
||||
|
||||
return( POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE );
|
||||
#endif /* POLARSSL_CIPHER_MODE_CBC */
|
||||
}
|
||||
#endif /* POLARSSL_CIPHER_MODE_CBC */
|
||||
|
||||
#if defined(POLARSSL_CIPHER_MODE_CFB)
|
||||
static int aes_crypt_cfb128_wrap( void *ctx, operation_t operation,
|
||||
size_t length, size_t *iv_off, unsigned char *iv,
|
||||
const unsigned char *input, unsigned char *output )
|
||||
{
|
||||
#if defined(POLARSSL_CIPHER_MODE_CFB)
|
||||
return aes_crypt_cfb128( (aes_context *) ctx, operation, length, iv_off, iv,
|
||||
input, output );
|
||||
#else
|
||||
((void) ctx);
|
||||
((void) operation);
|
||||
((void) length);
|
||||
((void) iv_off);
|
||||
((void) iv);
|
||||
((void) input);
|
||||
((void) output);
|
||||
|
||||
return( POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE );
|
||||
#endif /* POLARSSL_CIPHER_MODE_CFB */
|
||||
}
|
||||
#endif /* POLARSSL_CIPHER_MODE_CFB */
|
||||
|
||||
#if defined(POLARSSL_CIPHER_MODE_CTR)
|
||||
static int aes_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off,
|
||||
unsigned char *nonce_counter, unsigned char *stream_block,
|
||||
const unsigned char *input, unsigned char *output )
|
||||
{
|
||||
#if defined(POLARSSL_CIPHER_MODE_CTR)
|
||||
return aes_crypt_ctr( (aes_context *) ctx, length, nc_off, nonce_counter,
|
||||
stream_block, input, output );
|
||||
#else
|
||||
((void) ctx);
|
||||
((void) length);
|
||||
((void) nc_off);
|
||||
((void) nonce_counter);
|
||||
((void) stream_block);
|
||||
((void) input);
|
||||
((void) output);
|
||||
|
||||
return( POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE );
|
||||
#endif /* POLARSSL_CIPHER_MODE_CTR */
|
||||
}
|
||||
#endif /* POLARSSL_CIPHER_MODE_CTR */
|
||||
|
||||
static int aes_setkey_dec_wrap( void *ctx, const unsigned char *key,
|
||||
unsigned int key_length )
|
||||
|
@ -179,7 +153,7 @@ static int aes_setkey_enc_wrap( void *ctx, const unsigned char *key,
|
|||
|
||||
static void * aes_ctx_alloc( void )
|
||||
{
|
||||
aes_context *aes = (aes_context *) polarssl_malloc( sizeof( aes_context ) );
|
||||
aes_context *aes = polarssl_malloc( sizeof( aes_context ) );
|
||||
|
||||
if( aes == NULL )
|
||||
return( NULL );
|
||||
|
@ -198,10 +172,18 @@ static void aes_ctx_free( void *ctx )
|
|||
const cipher_base_t aes_info = {
|
||||
POLARSSL_CIPHER_ID_AES,
|
||||
aes_crypt_ecb_wrap,
|
||||
#if defined(POLARSSL_CIPHER_MODE_CBC)
|
||||
aes_crypt_cbc_wrap,
|
||||
#endif
|
||||
#if defined(POLARSSL_CIPHER_MODE_CFB)
|
||||
aes_crypt_cfb128_wrap,
|
||||
#endif
|
||||
#if defined(POLARSSL_CIPHER_MODE_CTR)
|
||||
aes_crypt_ctr_wrap,
|
||||
#endif
|
||||
#if defined(POLARSSL_CIPHER_MODE_STREAM)
|
||||
NULL,
|
||||
#endif
|
||||
aes_setkey_enc_wrap,
|
||||
aes_setkey_dec_wrap,
|
||||
aes_ctx_alloc,
|
||||
|
@ -357,10 +339,18 @@ static int gcm_aes_setkey_wrap( void *ctx, const unsigned char *key,
|
|||
const cipher_base_t gcm_aes_info = {
|
||||
POLARSSL_CIPHER_ID_AES,
|
||||
NULL,
|
||||
#if defined(POLARSSL_CIPHER_MODE_CBC)
|
||||
NULL,
|
||||
#endif
|
||||
#if defined(POLARSSL_CIPHER_MODE_CFB)
|
||||
NULL,
|
||||
#endif
|
||||
#if defined(POLARSSL_CIPHER_MODE_CTR)
|
||||
NULL,
|
||||
#endif
|
||||
#if defined(POLARSSL_CIPHER_MODE_STREAM)
|
||||
NULL,
|
||||
#endif
|
||||
gcm_aes_setkey_wrap,
|
||||
gcm_aes_setkey_wrap,
|
||||
gcm_ctx_alloc,
|
||||
|
@ -412,10 +402,18 @@ static int ccm_aes_setkey_wrap( void *ctx, const unsigned char *key,
|
|||
const cipher_base_t ccm_aes_info = {
|
||||
POLARSSL_CIPHER_ID_AES,
|
||||
NULL,
|
||||
#if defined(POLARSSL_CIPHER_MODE_CBC)
|
||||
NULL,
|
||||
#endif
|
||||
#if defined(POLARSSL_CIPHER_MODE_CFB)
|
||||
NULL,
|
||||
#endif
|
||||
#if defined(POLARSSL_CIPHER_MODE_CTR)
|
||||
NULL,
|
||||
#endif
|
||||
#if defined(POLARSSL_CIPHER_MODE_STREAM)
|
||||
NULL,
|
||||
#endif
|
||||
ccm_aes_setkey_wrap,
|
||||
ccm_aes_setkey_wrap,
|
||||
ccm_ctx_alloc,
|
||||
|
@ -467,64 +465,35 @@ static int camellia_crypt_ecb_wrap( void *ctx, operation_t operation,
|
|||
output );
|
||||
}
|
||||
|
||||
#if defined(POLARSSL_CIPHER_MODE_CBC)
|
||||
static int camellia_crypt_cbc_wrap( void *ctx, operation_t operation,
|
||||
size_t length, unsigned char *iv,
|
||||
const unsigned char *input, unsigned char *output )
|
||||
{
|
||||
#if defined(POLARSSL_CIPHER_MODE_CBC)
|
||||
return camellia_crypt_cbc( (camellia_context *) ctx, operation, length, iv,
|
||||
input, output );
|
||||
#else
|
||||
((void) ctx);
|
||||
((void) operation);
|
||||
((void) length);
|
||||
((void) iv);
|
||||
((void) input);
|
||||
((void) output);
|
||||
|
||||
return( POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE );
|
||||
#endif /* POLARSSL_CIPHER_MODE_CBC */
|
||||
}
|
||||
#endif /* POLARSSL_CIPHER_MODE_CBC */
|
||||
|
||||
#if defined(POLARSSL_CIPHER_MODE_CFB)
|
||||
static int camellia_crypt_cfb128_wrap( void *ctx, operation_t operation,
|
||||
size_t length, size_t *iv_off, unsigned char *iv,
|
||||
const unsigned char *input, unsigned char *output )
|
||||
{
|
||||
#if defined(POLARSSL_CIPHER_MODE_CFB)
|
||||
return camellia_crypt_cfb128( (camellia_context *) ctx, operation, length,
|
||||
iv_off, iv, input, output );
|
||||
#else
|
||||
((void) ctx);
|
||||
((void) operation);
|
||||
((void) length);
|
||||
((void) iv_off);
|
||||
((void) iv);
|
||||
((void) input);
|
||||
((void) output);
|
||||
|
||||
return( POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE );
|
||||
#endif /* POLARSSL_CIPHER_MODE_CFB */
|
||||
}
|
||||
#endif /* POLARSSL_CIPHER_MODE_CFB */
|
||||
|
||||
#if defined(POLARSSL_CIPHER_MODE_CTR)
|
||||
static int camellia_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off,
|
||||
unsigned char *nonce_counter, unsigned char *stream_block,
|
||||
const unsigned char *input, unsigned char *output )
|
||||
{
|
||||
#if defined(POLARSSL_CIPHER_MODE_CTR)
|
||||
return camellia_crypt_ctr( (camellia_context *) ctx, length, nc_off,
|
||||
nonce_counter, stream_block, input, output );
|
||||
#else
|
||||
((void) ctx);
|
||||
((void) length);
|
||||
((void) nc_off);
|
||||
((void) nonce_counter);
|
||||
((void) stream_block);
|
||||
((void) input);
|
||||
((void) output);
|
||||
|
||||
return( POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE );
|
||||
#endif /* POLARSSL_CIPHER_MODE_CTR */
|
||||
}
|
||||
#endif /* POLARSSL_CIPHER_MODE_CTR */
|
||||
|
||||
static int camellia_setkey_dec_wrap( void *ctx, const unsigned char *key,
|
||||
unsigned int key_length )
|
||||
|
@ -541,7 +510,7 @@ static int camellia_setkey_enc_wrap( void *ctx, const unsigned char *key,
|
|||
static void * camellia_ctx_alloc( void )
|
||||
{
|
||||
camellia_context *ctx;
|
||||
ctx = (camellia_context *) polarssl_malloc( sizeof( camellia_context ) );
|
||||
ctx = polarssl_malloc( sizeof( camellia_context ) );
|
||||
|
||||
if( ctx == NULL )
|
||||
return( NULL );
|
||||
|
@ -560,10 +529,18 @@ static void camellia_ctx_free( void *ctx )
|
|||
const cipher_base_t camellia_info = {
|
||||
POLARSSL_CIPHER_ID_CAMELLIA,
|
||||
camellia_crypt_ecb_wrap,
|
||||
#if defined(POLARSSL_CIPHER_MODE_CBC)
|
||||
camellia_crypt_cbc_wrap,
|
||||
#endif
|
||||
#if defined(POLARSSL_CIPHER_MODE_CFB)
|
||||
camellia_crypt_cfb128_wrap,
|
||||
#endif
|
||||
#if defined(POLARSSL_CIPHER_MODE_CTR)
|
||||
camellia_crypt_ctr_wrap,
|
||||
#endif
|
||||
#if defined(POLARSSL_CIPHER_MODE_STREAM)
|
||||
NULL,
|
||||
#endif
|
||||
camellia_setkey_enc_wrap,
|
||||
camellia_setkey_dec_wrap,
|
||||
camellia_ctx_alloc,
|
||||
|
@ -719,10 +696,18 @@ static int gcm_camellia_setkey_wrap( void *ctx, const unsigned char *key,
|
|||
const cipher_base_t gcm_camellia_info = {
|
||||
POLARSSL_CIPHER_ID_CAMELLIA,
|
||||
NULL,
|
||||
#if defined(POLARSSL_CIPHER_MODE_CBC)
|
||||
NULL,
|
||||
#endif
|
||||
#if defined(POLARSSL_CIPHER_MODE_CFB)
|
||||
NULL,
|
||||
#endif
|
||||
#if defined(POLARSSL_CIPHER_MODE_CTR)
|
||||
NULL,
|
||||
#endif
|
||||
#if defined(POLARSSL_CIPHER_MODE_STREAM)
|
||||
NULL,
|
||||
#endif
|
||||
gcm_camellia_setkey_wrap,
|
||||
gcm_camellia_setkey_wrap,
|
||||
gcm_ctx_alloc,
|
||||
|
@ -774,10 +759,18 @@ static int ccm_camellia_setkey_wrap( void *ctx, const unsigned char *key,
|
|||
const cipher_base_t ccm_camellia_info = {
|
||||
POLARSSL_CIPHER_ID_CAMELLIA,
|
||||
NULL,
|
||||
#if defined(POLARSSL_CIPHER_MODE_CBC)
|
||||
NULL,
|
||||
#endif
|
||||
#if defined(POLARSSL_CIPHER_MODE_CFB)
|
||||
NULL,
|
||||
#endif
|
||||
#if defined(POLARSSL_CIPHER_MODE_CTR)
|
||||
NULL,
|
||||
#endif
|
||||
#if defined(POLARSSL_CIPHER_MODE_STREAM)
|
||||
NULL,
|
||||
#endif
|
||||
ccm_camellia_setkey_wrap,
|
||||
ccm_camellia_setkey_wrap,
|
||||
ccm_ctx_alloc,
|
||||
|
@ -836,41 +829,23 @@ static int des3_crypt_ecb_wrap( void *ctx, operation_t operation,
|
|||
return des3_crypt_ecb( (des3_context *) ctx, input, output );
|
||||
}
|
||||
|
||||
#if defined(POLARSSL_CIPHER_MODE_CBC)
|
||||
static int des_crypt_cbc_wrap( void *ctx, operation_t operation, size_t length,
|
||||
unsigned char *iv, const unsigned char *input, unsigned char *output )
|
||||
{
|
||||
#if defined(POLARSSL_CIPHER_MODE_CBC)
|
||||
return des_crypt_cbc( (des_context *) ctx, operation, length, iv, input,
|
||||
output );
|
||||
#else
|
||||
((void) ctx);
|
||||
((void) operation);
|
||||
((void) length);
|
||||
((void) iv);
|
||||
((void) input);
|
||||
((void) output);
|
||||
|
||||
return( POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE );
|
||||
#endif /* POLARSSL_CIPHER_MODE_CBC */
|
||||
}
|
||||
#endif /* POLARSSL_CIPHER_MODE_CBC */
|
||||
|
||||
#if defined(POLARSSL_CIPHER_MODE_CBC)
|
||||
static int des3_crypt_cbc_wrap( void *ctx, operation_t operation, size_t length,
|
||||
unsigned char *iv, const unsigned char *input, unsigned char *output )
|
||||
{
|
||||
#if defined(POLARSSL_CIPHER_MODE_CBC)
|
||||
return des3_crypt_cbc( (des3_context *) ctx, operation, length, iv, input,
|
||||
output );
|
||||
#else
|
||||
((void) ctx);
|
||||
((void) operation);
|
||||
((void) length);
|
||||
((void) iv);
|
||||
((void) input);
|
||||
((void) output);
|
||||
|
||||
return( POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE );
|
||||
#endif /* POLARSSL_CIPHER_MODE_CBC */
|
||||
}
|
||||
#endif /* POLARSSL_CIPHER_MODE_CBC */
|
||||
|
||||
static int des_setkey_dec_wrap( void *ctx, const unsigned char *key,
|
||||
unsigned int key_length )
|
||||
|
@ -922,7 +897,7 @@ static int des3_set3key_enc_wrap( void *ctx, const unsigned char *key,
|
|||
|
||||
static void * des_ctx_alloc( void )
|
||||
{
|
||||
des_context *des = (des_context *) polarssl_malloc( sizeof( des_context ) );
|
||||
des_context *des = polarssl_malloc( sizeof( des_context ) );
|
||||
|
||||
if( des == NULL )
|
||||
return( NULL );
|
||||
|
@ -941,7 +916,7 @@ static void des_ctx_free( void *ctx )
|
|||
static void * des3_ctx_alloc( void )
|
||||
{
|
||||
des3_context *des3;
|
||||
des3 = (des3_context *) polarssl_malloc( sizeof( des3_context ) );
|
||||
des3 = polarssl_malloc( sizeof( des3_context ) );
|
||||
|
||||
if( des3 == NULL )
|
||||
return( NULL );
|
||||
|
@ -960,10 +935,18 @@ static void des3_ctx_free( void *ctx )
|
|||
const cipher_base_t des_info = {
|
||||
POLARSSL_CIPHER_ID_DES,
|
||||
des_crypt_ecb_wrap,
|
||||
#if defined(POLARSSL_CIPHER_MODE_CBC)
|
||||
des_crypt_cbc_wrap,
|
||||
#endif
|
||||
#if defined(POLARSSL_CIPHER_MODE_CFB)
|
||||
NULL,
|
||||
#endif
|
||||
#if defined(POLARSSL_CIPHER_MODE_CTR)
|
||||
NULL,
|
||||
#endif
|
||||
#if defined(POLARSSL_CIPHER_MODE_STREAM)
|
||||
NULL,
|
||||
#endif
|
||||
des_setkey_enc_wrap,
|
||||
des_setkey_dec_wrap,
|
||||
des_ctx_alloc,
|
||||
|
@ -997,10 +980,18 @@ const cipher_info_t des_cbc_info = {
|
|||
const cipher_base_t des_ede_info = {
|
||||
POLARSSL_CIPHER_ID_DES,
|
||||
des3_crypt_ecb_wrap,
|
||||
#if defined(POLARSSL_CIPHER_MODE_CBC)
|
||||
des3_crypt_cbc_wrap,
|
||||
#endif
|
||||
#if defined(POLARSSL_CIPHER_MODE_CFB)
|
||||
NULL,
|
||||
#endif
|
||||
#if defined(POLARSSL_CIPHER_MODE_CTR)
|
||||
NULL,
|
||||
#endif
|
||||
#if defined(POLARSSL_CIPHER_MODE_STREAM)
|
||||
NULL,
|
||||
#endif
|
||||
des3_set2key_enc_wrap,
|
||||
des3_set2key_dec_wrap,
|
||||
des3_ctx_alloc,
|
||||
|
@ -1034,10 +1025,18 @@ const cipher_info_t des_ede_cbc_info = {
|
|||
const cipher_base_t des_ede3_info = {
|
||||
POLARSSL_CIPHER_ID_DES,
|
||||
des3_crypt_ecb_wrap,
|
||||
#if defined(POLARSSL_CIPHER_MODE_CBC)
|
||||
des3_crypt_cbc_wrap,
|
||||
#endif
|
||||
#if defined(POLARSSL_CIPHER_MODE_CFB)
|
||||
NULL,
|
||||
#endif
|
||||
#if defined(POLARSSL_CIPHER_MODE_CTR)
|
||||
NULL,
|
||||
#endif
|
||||
#if defined(POLARSSL_CIPHER_MODE_STREAM)
|
||||
NULL,
|
||||
#endif
|
||||
des3_set3key_enc_wrap,
|
||||
des3_set3key_dec_wrap,
|
||||
des3_ctx_alloc,
|
||||
|
@ -1077,64 +1076,35 @@ static int blowfish_crypt_ecb_wrap( void *ctx, operation_t operation,
|
|||
output );
|
||||
}
|
||||
|
||||
#if defined(POLARSSL_CIPHER_MODE_CBC)
|
||||
static int blowfish_crypt_cbc_wrap( void *ctx, operation_t operation,
|
||||
size_t length, unsigned char *iv, const unsigned char *input,
|
||||
unsigned char *output )
|
||||
{
|
||||
#if defined(POLARSSL_CIPHER_MODE_CBC)
|
||||
return blowfish_crypt_cbc( (blowfish_context *) ctx, operation, length, iv,
|
||||
input, output );
|
||||
#else
|
||||
((void) ctx);
|
||||
((void) operation);
|
||||
((void) length);
|
||||
((void) iv);
|
||||
((void) input);
|
||||
((void) output);
|
||||
|
||||
return( POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE );
|
||||
#endif /* POLARSSL_CIPHER_MODE_CBC */
|
||||
}
|
||||
#endif /* POLARSSL_CIPHER_MODE_CBC */
|
||||
|
||||
#if defined(POLARSSL_CIPHER_MODE_CFB)
|
||||
static int blowfish_crypt_cfb64_wrap( void *ctx, operation_t operation,
|
||||
size_t length, size_t *iv_off, unsigned char *iv,
|
||||
const unsigned char *input, unsigned char *output )
|
||||
{
|
||||
#if defined(POLARSSL_CIPHER_MODE_CFB)
|
||||
return blowfish_crypt_cfb64( (blowfish_context *) ctx, operation, length,
|
||||
iv_off, iv, input, output );
|
||||
#else
|
||||
((void) ctx);
|
||||
((void) operation);
|
||||
((void) length);
|
||||
((void) iv_off);
|
||||
((void) iv);
|
||||
((void) input);
|
||||
((void) output);
|
||||
|
||||
return( POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE );
|
||||
#endif /* POLARSSL_CIPHER_MODE_CFB */
|
||||
}
|
||||
#endif /* POLARSSL_CIPHER_MODE_CFB */
|
||||
|
||||
#if defined(POLARSSL_CIPHER_MODE_CTR)
|
||||
static int blowfish_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off,
|
||||
unsigned char *nonce_counter, unsigned char *stream_block,
|
||||
const unsigned char *input, unsigned char *output )
|
||||
{
|
||||
#if defined(POLARSSL_CIPHER_MODE_CTR)
|
||||
return blowfish_crypt_ctr( (blowfish_context *) ctx, length, nc_off,
|
||||
nonce_counter, stream_block, input, output );
|
||||
#else
|
||||
((void) ctx);
|
||||
((void) length);
|
||||
((void) nc_off);
|
||||
((void) nonce_counter);
|
||||
((void) stream_block);
|
||||
((void) input);
|
||||
((void) output);
|
||||
|
||||
return( POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE );
|
||||
#endif /* POLARSSL_CIPHER_MODE_CTR */
|
||||
}
|
||||
#endif /* POLARSSL_CIPHER_MODE_CTR */
|
||||
|
||||
static int blowfish_setkey_wrap( void *ctx, const unsigned char *key,
|
||||
unsigned int key_length )
|
||||
|
@ -1145,7 +1115,7 @@ static int blowfish_setkey_wrap( void *ctx, const unsigned char *key,
|
|||
static void * blowfish_ctx_alloc( void )
|
||||
{
|
||||
blowfish_context *ctx;
|
||||
ctx = (blowfish_context *) polarssl_malloc( sizeof( blowfish_context ) );
|
||||
ctx = polarssl_malloc( sizeof( blowfish_context ) );
|
||||
|
||||
if( ctx == NULL )
|
||||
return( NULL );
|
||||
|
@ -1164,10 +1134,18 @@ static void blowfish_ctx_free( void *ctx )
|
|||
const cipher_base_t blowfish_info = {
|
||||
POLARSSL_CIPHER_ID_BLOWFISH,
|
||||
blowfish_crypt_ecb_wrap,
|
||||
#if defined(POLARSSL_CIPHER_MODE_CBC)
|
||||
blowfish_crypt_cbc_wrap,
|
||||
#endif
|
||||
#if defined(POLARSSL_CIPHER_MODE_CFB)
|
||||
blowfish_crypt_cfb64_wrap,
|
||||
#endif
|
||||
#if defined(POLARSSL_CIPHER_MODE_CTR)
|
||||
blowfish_crypt_ctr_wrap,
|
||||
#endif
|
||||
#if defined(POLARSSL_CIPHER_MODE_STREAM)
|
||||
NULL,
|
||||
#endif
|
||||
blowfish_setkey_wrap,
|
||||
blowfish_setkey_wrap,
|
||||
blowfish_ctx_alloc,
|
||||
|
@ -1247,7 +1225,7 @@ static int arc4_setkey_wrap( void *ctx, const unsigned char *key,
|
|||
static void * arc4_ctx_alloc( void )
|
||||
{
|
||||
arc4_context *ctx;
|
||||
ctx = (arc4_context *) polarssl_malloc( sizeof( arc4_context ) );
|
||||
ctx = polarssl_malloc( sizeof( arc4_context ) );
|
||||
|
||||
if( ctx == NULL )
|
||||
return( NULL );
|
||||
|
@ -1266,10 +1244,18 @@ static void arc4_ctx_free( void *ctx )
|
|||
const cipher_base_t arc4_base_info = {
|
||||
POLARSSL_CIPHER_ID_ARC4,
|
||||
NULL,
|
||||
#if defined(POLARSSL_CIPHER_MODE_CBC)
|
||||
NULL,
|
||||
#endif
|
||||
#if defined(POLARSSL_CIPHER_MODE_CFB)
|
||||
NULL,
|
||||
#endif
|
||||
#if defined(POLARSSL_CIPHER_MODE_CTR)
|
||||
NULL,
|
||||
#endif
|
||||
#if defined(POLARSSL_CIPHER_MODE_STREAM)
|
||||
arc4_crypt_stream_wrap,
|
||||
#endif
|
||||
arc4_setkey_wrap,
|
||||
arc4_setkey_wrap,
|
||||
arc4_ctx_alloc,
|
||||
|
@ -1321,10 +1307,18 @@ static void null_ctx_free( void *ctx )
|
|||
const cipher_base_t null_base_info = {
|
||||
POLARSSL_CIPHER_ID_NULL,
|
||||
NULL,
|
||||
#if defined(POLARSSL_CIPHER_MODE_CBC)
|
||||
NULL,
|
||||
#endif
|
||||
#if defined(POLARSSL_CIPHER_MODE_CFB)
|
||||
NULL,
|
||||
#endif
|
||||
#if defined(POLARSSL_CIPHER_MODE_CTR)
|
||||
NULL,
|
||||
#endif
|
||||
#if defined(POLARSSL_CIPHER_MODE_STREAM)
|
||||
null_crypt_stream,
|
||||
#endif
|
||||
null_setkey,
|
||||
null_setkey,
|
||||
null_ctx_alloc,
|
||||
|
@ -1439,7 +1433,7 @@ const cipher_definition_t cipher_definitions[] =
|
|||
{ POLARSSL_CIPHER_NULL, &null_cipher_info },
|
||||
#endif /* POLARSSL_CIPHER_NULL_CIPHER */
|
||||
|
||||
{ 0, NULL }
|
||||
{ POLARSSL_CIPHER_NONE, NULL }
|
||||
};
|
||||
|
||||
#define NUM_CIPHERS sizeof cipher_definitions / sizeof cipher_definitions[0]
|
||||
|
|
|
@ -35,15 +35,20 @@
|
|||
|
||||
#include "polarssl/ctr_drbg.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(POLARSSL_FS_IO)
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_SELF_TEST)
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#define polarssl_printf printf
|
||||
#endif
|
||||
#endif /* POLARSSL_PLATFORM_C */
|
||||
#endif /* POLARSSL_SELF_TEST */
|
||||
|
||||
/* Implementation that should never be optimized out by the compiler */
|
||||
static void polarssl_zeroize( void *v, size_t n ) {
|
||||
|
@ -443,8 +448,6 @@ int ctr_drbg_update_seed_file( ctr_drbg_context *ctx, const char *path )
|
|||
|
||||
#if defined(POLARSSL_SELF_TEST)
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
static unsigned char entropy_source_pr[96] =
|
||||
{ 0xc1, 0x80, 0x81, 0xa6, 0x5d, 0x44, 0x02, 0x16,
|
||||
0x19, 0xb3, 0xf1, 0x80, 0xb1, 0xc9, 0x20, 0x02,
|
||||
|
|
|
@ -31,8 +31,8 @@
|
|||
#include "polarssl/debug.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
|
||||
#if !defined snprintf
|
||||
|
@ -44,6 +44,12 @@
|
|||
#endif
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#define polarssl_snprintf snprintf
|
||||
#endif
|
||||
|
||||
static int debug_log_mode = POLARSSL_DEBUG_DFL_MODE;
|
||||
static int debug_threshold = 0;
|
||||
|
||||
|
@ -86,7 +92,7 @@ void debug_print_msg( const ssl_context *ssl, int level,
|
|||
return;
|
||||
}
|
||||
|
||||
snprintf( str, maxlen, "%s(%04d): %s\n", file, line, text );
|
||||
polarssl_snprintf( str, maxlen, "%s(%04d): %s\n", file, line, text );
|
||||
str[maxlen] = '\0';
|
||||
ssl->f_dbg( ssl->p_dbg, level, str );
|
||||
}
|
||||
|
@ -103,9 +109,9 @@ void debug_print_ret( const ssl_context *ssl, int level,
|
|||
return;
|
||||
|
||||
if( debug_log_mode == POLARSSL_DEBUG_LOG_FULL )
|
||||
idx = snprintf( str, maxlen, "%s(%04d): ", file, line );
|
||||
idx = polarssl_snprintf( str, maxlen, "%s(%04d): ", file, line );
|
||||
|
||||
snprintf( str + idx, maxlen - idx, "%s() returned %d (-0x%04x)\n",
|
||||
polarssl_snprintf( str + idx, maxlen - idx, "%s() returned %d (-0x%04x)\n",
|
||||
text, ret, -ret );
|
||||
|
||||
str[maxlen] = '\0';
|
||||
|
@ -124,9 +130,9 @@ void debug_print_buf( const ssl_context *ssl, int level,
|
|||
return;
|
||||
|
||||
if( debug_log_mode == POLARSSL_DEBUG_LOG_FULL )
|
||||
idx = snprintf( str, maxlen, "%s(%04d): ", file, line );
|
||||
idx = polarssl_snprintf( str, maxlen, "%s(%04d): ", file, line );
|
||||
|
||||
snprintf( str + idx, maxlen - idx, "dumping '%s' (%u bytes)\n",
|
||||
polarssl_snprintf( str + idx, maxlen - idx, "dumping '%s' (%u bytes)\n",
|
||||
text, (unsigned int) len );
|
||||
|
||||
str[maxlen] = '\0';
|
||||
|
@ -143,7 +149,7 @@ void debug_print_buf( const ssl_context *ssl, int level,
|
|||
{
|
||||
if( i > 0 )
|
||||
{
|
||||
snprintf( str + idx, maxlen - idx, " %s\n", txt );
|
||||
polarssl_snprintf( str + idx, maxlen - idx, " %s\n", txt );
|
||||
ssl->f_dbg( ssl->p_dbg, level, str );
|
||||
|
||||
idx = 0;
|
||||
|
@ -151,14 +157,14 @@ void debug_print_buf( const ssl_context *ssl, int level,
|
|||
}
|
||||
|
||||
if( debug_log_mode == POLARSSL_DEBUG_LOG_FULL )
|
||||
idx = snprintf( str, maxlen, "%s(%04d): ", file, line );
|
||||
idx = polarssl_snprintf( str, maxlen, "%s(%04d): ", file, line );
|
||||
|
||||
idx += snprintf( str + idx, maxlen - idx, "%04x: ",
|
||||
idx += polarssl_snprintf( str + idx, maxlen - idx, "%04x: ",
|
||||
(unsigned int) i );
|
||||
|
||||
}
|
||||
|
||||
idx += snprintf( str + idx, maxlen - idx, " %02x",
|
||||
idx += polarssl_snprintf( str + idx, maxlen - idx, " %02x",
|
||||
(unsigned int) buf[i] );
|
||||
txt[i % 16] = ( buf[i] > 31 && buf[i] < 127 ) ? buf[i] : '.' ;
|
||||
}
|
||||
|
@ -166,9 +172,9 @@ void debug_print_buf( const ssl_context *ssl, int level,
|
|||
if( len > 0 )
|
||||
{
|
||||
for( /* i = i */; i % 16 != 0; i++ )
|
||||
idx += snprintf( str + idx, maxlen - idx, " " );
|
||||
idx += polarssl_snprintf( str + idx, maxlen - idx, " " );
|
||||
|
||||
snprintf( str + idx, maxlen - idx, " %s\n", txt );
|
||||
polarssl_snprintf( str + idx, maxlen - idx, " %s\n", txt );
|
||||
ssl->f_dbg( ssl->p_dbg, level, str );
|
||||
}
|
||||
}
|
||||
|
@ -184,11 +190,11 @@ void debug_print_ecp( const ssl_context *ssl, int level,
|
|||
if( ssl->f_dbg == NULL || level > debug_threshold )
|
||||
return;
|
||||
|
||||
snprintf( str, maxlen, "%s(X)", text );
|
||||
polarssl_snprintf( str, maxlen, "%s(X)", text );
|
||||
str[maxlen] = '\0';
|
||||
debug_print_mpi( ssl, level, file, line, str, &X->X );
|
||||
|
||||
snprintf( str, maxlen, "%s(Y)", text );
|
||||
polarssl_snprintf( str, maxlen, "%s(Y)", text );
|
||||
str[maxlen] = '\0';
|
||||
debug_print_mpi( ssl, level, file, line, str, &X->Y );
|
||||
}
|
||||
|
@ -215,9 +221,9 @@ void debug_print_mpi( const ssl_context *ssl, int level,
|
|||
break;
|
||||
|
||||
if( debug_log_mode == POLARSSL_DEBUG_LOG_FULL )
|
||||
idx = snprintf( str, maxlen, "%s(%04d): ", file, line );
|
||||
idx = polarssl_snprintf( str, maxlen, "%s(%04d): ", file, line );
|
||||
|
||||
snprintf( str + idx, maxlen - idx, "value of '%s' (%d bits) is:\n",
|
||||
polarssl_snprintf( str + idx, maxlen - idx, "value of '%s' (%d bits) is:\n",
|
||||
text, (int) ( ( n * ( sizeof(t_uint) << 3 ) ) + j + 1 ) );
|
||||
|
||||
str[maxlen] = '\0';
|
||||
|
@ -240,16 +246,16 @@ void debug_print_mpi( const ssl_context *ssl, int level,
|
|||
{
|
||||
if( j > 0 )
|
||||
{
|
||||
snprintf( str + idx, maxlen - idx, "\n" );
|
||||
polarssl_snprintf( str + idx, maxlen - idx, "\n" );
|
||||
ssl->f_dbg( ssl->p_dbg, level, str );
|
||||
idx = 0;
|
||||
}
|
||||
|
||||
if( debug_log_mode == POLARSSL_DEBUG_LOG_FULL )
|
||||
idx = snprintf( str, maxlen, "%s(%04d): ", file, line );
|
||||
idx = polarssl_snprintf( str, maxlen, "%s(%04d): ", file, line );
|
||||
}
|
||||
|
||||
idx += snprintf( str + idx, maxlen - idx, " %02x", (unsigned int)
|
||||
idx += polarssl_snprintf( str + idx, maxlen - idx, " %02x", (unsigned int)
|
||||
( X->p[i - 1] >> ( k << 3 ) ) & 0xFF );
|
||||
|
||||
j++;
|
||||
|
@ -261,13 +267,13 @@ void debug_print_mpi( const ssl_context *ssl, int level,
|
|||
{
|
||||
if( debug_log_mode == POLARSSL_DEBUG_LOG_FULL )
|
||||
{
|
||||
idx = snprintf( str, maxlen, "%s(%04d): ", file, line );
|
||||
idx = polarssl_snprintf( str, maxlen, "%s(%04d): ", file, line );
|
||||
|
||||
}
|
||||
idx += snprintf( str + idx, maxlen - idx, " 00" );
|
||||
idx += polarssl_snprintf( str + idx, maxlen - idx, " 00" );
|
||||
}
|
||||
|
||||
snprintf( str + idx, maxlen - idx, "\n" );
|
||||
polarssl_snprintf( str + idx, maxlen - idx, "\n" );
|
||||
ssl->f_dbg( ssl->p_dbg, level, str );
|
||||
}
|
||||
#endif /* POLARSSL_BIGNUM_C */
|
||||
|
@ -294,7 +300,7 @@ static void debug_print_pk( const ssl_context *ssl, int level,
|
|||
if( items[i].type == POLARSSL_PK_DEBUG_NONE )
|
||||
return;
|
||||
|
||||
snprintf( name, sizeof( name ), "%s%s", text, items[i].name );
|
||||
polarssl_snprintf( name, sizeof( name ), "%s%s", text, items[i].name );
|
||||
name[sizeof( name ) - 1] = '\0';
|
||||
|
||||
if( items[i].type == POLARSSL_PK_DEBUG_MPI )
|
||||
|
@ -321,7 +327,7 @@ void debug_print_crt( const ssl_context *ssl, int level,
|
|||
|
||||
if( debug_log_mode == POLARSSL_DEBUG_LOG_FULL )
|
||||
{
|
||||
snprintf( prefix, maxlen, "%s(%04d): ", file, line );
|
||||
polarssl_snprintf( prefix, maxlen, "%s(%04d): ", file, line );
|
||||
prefix[maxlen] = '\0';
|
||||
}
|
||||
else
|
||||
|
@ -335,9 +341,9 @@ void debug_print_crt( const ssl_context *ssl, int level,
|
|||
x509_crt_info( buf, sizeof( buf ) - 1, prefix, crt );
|
||||
|
||||
if( debug_log_mode == POLARSSL_DEBUG_LOG_FULL )
|
||||
idx = snprintf( str, maxlen, "%s(%04d): ", file, line );
|
||||
idx = polarssl_snprintf( str, maxlen, "%s(%04d): ", file, line );
|
||||
|
||||
snprintf( str + idx, maxlen - idx, "%s #%d:\n%s",
|
||||
polarssl_snprintf( str + idx, maxlen - idx, "%s #%d:\n%s",
|
||||
text, ++i, buf );
|
||||
|
||||
str[maxlen] = '\0';
|
||||
|
|
|
@ -36,11 +36,16 @@
|
|||
|
||||
#include "polarssl/des.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(POLARSSL_SELF_TEST)
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#define polarssl_printf printf
|
||||
#endif
|
||||
#endif /* POLARSSL_PLATFORM_C */
|
||||
#endif /* POLARSSL_SELF_TEST */
|
||||
|
||||
#if !defined(POLARSSL_DES_ALT)
|
||||
|
||||
|
@ -802,9 +807,6 @@ int des3_crypt_cbc( des3_context *ctx,
|
|||
#endif /* !POLARSSL_DES_ALT */
|
||||
|
||||
#if defined(POLARSSL_SELF_TEST)
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
* DES and 3DES test vectors from:
|
||||
*
|
||||
|
|
|
@ -35,6 +35,8 @@
|
|||
|
||||
#include "polarssl/dhm.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(POLARSSL_PEM_PARSE_C)
|
||||
#include "polarssl/pem.h"
|
||||
#endif
|
||||
|
@ -505,7 +507,7 @@ static int load_file( const char *path, unsigned char **buf, size_t *n )
|
|||
*n = (size_t) size;
|
||||
|
||||
if( *n + 1 == 0 ||
|
||||
( *buf = (unsigned char *) polarssl_malloc( *n + 1 ) ) == NULL )
|
||||
( *buf = polarssl_malloc( *n + 1 ) ) == NULL )
|
||||
{
|
||||
fclose( f );
|
||||
return( POLARSSL_ERR_DHM_MALLOC_FAILED );
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
|
||||
#include "polarssl/ecdh.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
* Generate public key: simple wrapper around ecp_gen_keypair
|
||||
*/
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
#include "polarssl/ecdsa.h"
|
||||
#include "polarssl/asn1write.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(POLARSSL_ECDSA_DETERMINISTIC)
|
||||
#include "polarssl/hmac_drbg.h"
|
||||
#endif
|
||||
|
@ -57,7 +59,7 @@ static const md_info_t *md_info_by_size( size_t min_size )
|
|||
|
||||
for( md_alg = md_list(); *md_alg != 0; md_alg++ )
|
||||
{
|
||||
if( ( md_cur = md_info_from_type( *md_alg ) ) == NULL ||
|
||||
if( ( md_cur = md_info_from_type( (md_type_t) *md_alg ) ) == NULL ||
|
||||
(size_t) md_cur->size < min_size ||
|
||||
( md_picked != NULL && md_cur->size > md_picked->size ) )
|
||||
continue;
|
||||
|
|
|
@ -51,16 +51,17 @@
|
|||
|
||||
#include "polarssl/ecp.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#define polarssl_printf printf
|
||||
#define polarssl_malloc malloc
|
||||
#define polarssl_free free
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#if defined(_MSC_VER) && !defined strcasecmp && !defined(EFIX64) && \
|
||||
!defined(EFI32)
|
||||
#define strcasecmp _stricmp
|
||||
|
@ -812,7 +813,7 @@ static int ecp_normalize_jac_many( const ecp_group *grp,
|
|||
if( t_len < 2 )
|
||||
return( ecp_normalize_jac( grp, *T ) );
|
||||
|
||||
if( ( c = (mpi *) polarssl_malloc( t_len * sizeof( mpi ) ) ) == NULL )
|
||||
if( ( c = polarssl_malloc( t_len * sizeof( mpi ) ) ) == NULL )
|
||||
return( POLARSSL_ERR_ECP_MALLOC_FAILED );
|
||||
|
||||
mpi_init( &u ); mpi_init( &Zi ); mpi_init( &ZZi );
|
||||
|
@ -1415,7 +1416,7 @@ static int ecp_mul_comb( ecp_group *grp, ecp_point *R,
|
|||
|
||||
if( T == NULL )
|
||||
{
|
||||
T = (ecp_point *) polarssl_malloc( pre_len * sizeof( ecp_point ) );
|
||||
T = polarssl_malloc( pre_len * sizeof( ecp_point ) );
|
||||
if( T == NULL )
|
||||
{
|
||||
ret = POLARSSL_ERR_ECP_MALLOC_FAILED;
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
|
||||
#include "polarssl/ecp.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(_MSC_VER) && !defined(inline)
|
||||
#define inline _inline
|
||||
#else
|
||||
|
|
|
@ -31,10 +31,21 @@
|
|||
#include "polarssl/entropy.h"
|
||||
#include "polarssl/entropy_poll.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(POLARSSL_FS_IO)
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_SELF_TEST)
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#define polarssl_printf printf
|
||||
#endif /* POLARSSL_PLATFORM_C */
|
||||
#endif /* POLARSSL_SELF_TEST */
|
||||
|
||||
#if defined(POLARSSL_HAVEGE_C)
|
||||
#include "polarssl/havege.h"
|
||||
#endif
|
||||
|
@ -378,14 +389,6 @@ int entropy_update_seed_file( entropy_context *ctx, const char *path )
|
|||
#endif /* POLARSSL_FS_IO */
|
||||
|
||||
#if defined(POLARSSL_SELF_TEST)
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#define polarssl_printf printf
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Dummy source function
|
||||
*/
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "polarssl/entropy_poll.h"
|
||||
|
||||
#if defined(POLARSSL_TIMING_C)
|
||||
#include <string.h>
|
||||
#include "polarssl/timing.h"
|
||||
#endif
|
||||
#if defined(POLARSSL_HAVEGE_C)
|
||||
|
|
412
library/error.c
412
library/error.c
|
@ -28,10 +28,19 @@
|
|||
|
||||
#if defined(POLARSSL_ERROR_C) || defined(POLARSSL_ERROR_STRERROR_DUMMY)
|
||||
#include "polarssl/error.h"
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#define polarssl_snprintf snprintf
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_ERROR_C)
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined(POLARSSL_AES_C)
|
||||
#include "polarssl/aes.h"
|
||||
#endif
|
||||
|
@ -172,9 +181,6 @@
|
|||
#include "polarssl/xtea.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(_MSC_VER) && !defined snprintf && !defined(EFIX64) && \
|
||||
!defined(EFI32)
|
||||
#define snprintf _snprintf
|
||||
|
@ -204,301 +210,301 @@ void polarssl_strerror( int ret, char *buf, size_t buflen )
|
|||
// BEGIN generated code
|
||||
#if defined(POLARSSL_CIPHER_C)
|
||||
if( use_ret == -(POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE) )
|
||||
snprintf( buf, buflen, "CIPHER - The selected feature is not available" );
|
||||
polarssl_snprintf( buf, buflen, "CIPHER - The selected feature is not available" );
|
||||
if( use_ret == -(POLARSSL_ERR_CIPHER_BAD_INPUT_DATA) )
|
||||
snprintf( buf, buflen, "CIPHER - Bad input parameters to function" );
|
||||
polarssl_snprintf( buf, buflen, "CIPHER - Bad input parameters to function" );
|
||||
if( use_ret == -(POLARSSL_ERR_CIPHER_ALLOC_FAILED) )
|
||||
snprintf( buf, buflen, "CIPHER - Failed to allocate memory" );
|
||||
polarssl_snprintf( buf, buflen, "CIPHER - Failed to allocate memory" );
|
||||
if( use_ret == -(POLARSSL_ERR_CIPHER_INVALID_PADDING) )
|
||||
snprintf( buf, buflen, "CIPHER - Input data contains invalid padding and is rejected" );
|
||||
polarssl_snprintf( buf, buflen, "CIPHER - Input data contains invalid padding and is rejected" );
|
||||
if( use_ret == -(POLARSSL_ERR_CIPHER_FULL_BLOCK_EXPECTED) )
|
||||
snprintf( buf, buflen, "CIPHER - Decryption of block requires a full block" );
|
||||
polarssl_snprintf( buf, buflen, "CIPHER - Decryption of block requires a full block" );
|
||||
if( use_ret == -(POLARSSL_ERR_CIPHER_AUTH_FAILED) )
|
||||
snprintf( buf, buflen, "CIPHER - Authentication failed (for AEAD modes)" );
|
||||
polarssl_snprintf( buf, buflen, "CIPHER - Authentication failed (for AEAD modes)" );
|
||||
#endif /* POLARSSL_CIPHER_C */
|
||||
|
||||
#if defined(POLARSSL_DHM_C)
|
||||
if( use_ret == -(POLARSSL_ERR_DHM_BAD_INPUT_DATA) )
|
||||
snprintf( buf, buflen, "DHM - Bad input parameters to function" );
|
||||
polarssl_snprintf( buf, buflen, "DHM - Bad input parameters to function" );
|
||||
if( use_ret == -(POLARSSL_ERR_DHM_READ_PARAMS_FAILED) )
|
||||
snprintf( buf, buflen, "DHM - Reading of the DHM parameters failed" );
|
||||
polarssl_snprintf( buf, buflen, "DHM - Reading of the DHM parameters failed" );
|
||||
if( use_ret == -(POLARSSL_ERR_DHM_MAKE_PARAMS_FAILED) )
|
||||
snprintf( buf, buflen, "DHM - Making of the DHM parameters failed" );
|
||||
polarssl_snprintf( buf, buflen, "DHM - Making of the DHM parameters failed" );
|
||||
if( use_ret == -(POLARSSL_ERR_DHM_READ_PUBLIC_FAILED) )
|
||||
snprintf( buf, buflen, "DHM - Reading of the public values failed" );
|
||||
polarssl_snprintf( buf, buflen, "DHM - Reading of the public values failed" );
|
||||
if( use_ret == -(POLARSSL_ERR_DHM_MAKE_PUBLIC_FAILED) )
|
||||
snprintf( buf, buflen, "DHM - Making of the public value failed" );
|
||||
polarssl_snprintf( buf, buflen, "DHM - Making of the public value failed" );
|
||||
if( use_ret == -(POLARSSL_ERR_DHM_CALC_SECRET_FAILED) )
|
||||
snprintf( buf, buflen, "DHM - Calculation of the DHM secret failed" );
|
||||
polarssl_snprintf( buf, buflen, "DHM - Calculation of the DHM secret failed" );
|
||||
if( use_ret == -(POLARSSL_ERR_DHM_INVALID_FORMAT) )
|
||||
snprintf( buf, buflen, "DHM - The ASN.1 data is not formatted correctly" );
|
||||
polarssl_snprintf( buf, buflen, "DHM - The ASN.1 data is not formatted correctly" );
|
||||
if( use_ret == -(POLARSSL_ERR_DHM_MALLOC_FAILED) )
|
||||
snprintf( buf, buflen, "DHM - Allocation of memory failed" );
|
||||
polarssl_snprintf( buf, buflen, "DHM - Allocation of memory failed" );
|
||||
if( use_ret == -(POLARSSL_ERR_DHM_FILE_IO_ERROR) )
|
||||
snprintf( buf, buflen, "DHM - Read/write of file failed" );
|
||||
polarssl_snprintf( buf, buflen, "DHM - Read/write of file failed" );
|
||||
#endif /* POLARSSL_DHM_C */
|
||||
|
||||
#if defined(POLARSSL_ECP_C)
|
||||
if( use_ret == -(POLARSSL_ERR_ECP_BAD_INPUT_DATA) )
|
||||
snprintf( buf, buflen, "ECP - Bad input parameters to function" );
|
||||
polarssl_snprintf( buf, buflen, "ECP - Bad input parameters to function" );
|
||||
if( use_ret == -(POLARSSL_ERR_ECP_BUFFER_TOO_SMALL) )
|
||||
snprintf( buf, buflen, "ECP - The buffer is too small to write to" );
|
||||
polarssl_snprintf( buf, buflen, "ECP - The buffer is too small to write to" );
|
||||
if( use_ret == -(POLARSSL_ERR_ECP_FEATURE_UNAVAILABLE) )
|
||||
snprintf( buf, buflen, "ECP - Requested curve not available" );
|
||||
polarssl_snprintf( buf, buflen, "ECP - Requested curve not available" );
|
||||
if( use_ret == -(POLARSSL_ERR_ECP_VERIFY_FAILED) )
|
||||
snprintf( buf, buflen, "ECP - The signature is not valid" );
|
||||
polarssl_snprintf( buf, buflen, "ECP - The signature is not valid" );
|
||||
if( use_ret == -(POLARSSL_ERR_ECP_MALLOC_FAILED) )
|
||||
snprintf( buf, buflen, "ECP - Memory allocation failed" );
|
||||
polarssl_snprintf( buf, buflen, "ECP - Memory allocation failed" );
|
||||
if( use_ret == -(POLARSSL_ERR_ECP_RANDOM_FAILED) )
|
||||
snprintf( buf, buflen, "ECP - Generation of random value, such as (ephemeral) key, failed" );
|
||||
polarssl_snprintf( buf, buflen, "ECP - Generation of random value, such as (ephemeral) key, failed" );
|
||||
if( use_ret == -(POLARSSL_ERR_ECP_INVALID_KEY) )
|
||||
snprintf( buf, buflen, "ECP - Invalid private or public key" );
|
||||
polarssl_snprintf( buf, buflen, "ECP - Invalid private or public key" );
|
||||
if( use_ret == -(POLARSSL_ERR_ECP_SIG_LEN_MISMATCH) )
|
||||
snprintf( buf, buflen, "ECP - Signature is valid but shorter than the user-supplied length" );
|
||||
polarssl_snprintf( buf, buflen, "ECP - Signature is valid but shorter than the user-supplied length" );
|
||||
#endif /* POLARSSL_ECP_C */
|
||||
|
||||
#if defined(POLARSSL_MD_C)
|
||||
if( use_ret == -(POLARSSL_ERR_MD_FEATURE_UNAVAILABLE) )
|
||||
snprintf( buf, buflen, "MD - The selected feature is not available" );
|
||||
polarssl_snprintf( buf, buflen, "MD - The selected feature is not available" );
|
||||
if( use_ret == -(POLARSSL_ERR_MD_BAD_INPUT_DATA) )
|
||||
snprintf( buf, buflen, "MD - Bad input parameters to function" );
|
||||
polarssl_snprintf( buf, buflen, "MD - Bad input parameters to function" );
|
||||
if( use_ret == -(POLARSSL_ERR_MD_ALLOC_FAILED) )
|
||||
snprintf( buf, buflen, "MD - Failed to allocate memory" );
|
||||
polarssl_snprintf( buf, buflen, "MD - Failed to allocate memory" );
|
||||
if( use_ret == -(POLARSSL_ERR_MD_FILE_IO_ERROR) )
|
||||
snprintf( buf, buflen, "MD - Opening or reading of file failed" );
|
||||
polarssl_snprintf( buf, buflen, "MD - Opening or reading of file failed" );
|
||||
#endif /* POLARSSL_MD_C */
|
||||
|
||||
#if defined(POLARSSL_PEM_PARSE_C) || defined(POLARSSL_PEM_WRITE_C)
|
||||
if( use_ret == -(POLARSSL_ERR_PEM_NO_HEADER_FOOTER_PRESENT) )
|
||||
snprintf( buf, buflen, "PEM - No PEM header or footer found" );
|
||||
polarssl_snprintf( buf, buflen, "PEM - No PEM header or footer found" );
|
||||
if( use_ret == -(POLARSSL_ERR_PEM_INVALID_DATA) )
|
||||
snprintf( buf, buflen, "PEM - PEM string is not as expected" );
|
||||
polarssl_snprintf( buf, buflen, "PEM - PEM string is not as expected" );
|
||||
if( use_ret == -(POLARSSL_ERR_PEM_MALLOC_FAILED) )
|
||||
snprintf( buf, buflen, "PEM - Failed to allocate memory" );
|
||||
polarssl_snprintf( buf, buflen, "PEM - Failed to allocate memory" );
|
||||
if( use_ret == -(POLARSSL_ERR_PEM_INVALID_ENC_IV) )
|
||||
snprintf( buf, buflen, "PEM - RSA IV is not in hex-format" );
|
||||
polarssl_snprintf( buf, buflen, "PEM - RSA IV is not in hex-format" );
|
||||
if( use_ret == -(POLARSSL_ERR_PEM_UNKNOWN_ENC_ALG) )
|
||||
snprintf( buf, buflen, "PEM - Unsupported key encryption algorithm" );
|
||||
polarssl_snprintf( buf, buflen, "PEM - Unsupported key encryption algorithm" );
|
||||
if( use_ret == -(POLARSSL_ERR_PEM_PASSWORD_REQUIRED) )
|
||||
snprintf( buf, buflen, "PEM - Private key password can't be empty" );
|
||||
polarssl_snprintf( buf, buflen, "PEM - Private key password can't be empty" );
|
||||
if( use_ret == -(POLARSSL_ERR_PEM_PASSWORD_MISMATCH) )
|
||||
snprintf( buf, buflen, "PEM - Given private key password does not allow for correct decryption" );
|
||||
polarssl_snprintf( buf, buflen, "PEM - Given private key password does not allow for correct decryption" );
|
||||
if( use_ret == -(POLARSSL_ERR_PEM_FEATURE_UNAVAILABLE) )
|
||||
snprintf( buf, buflen, "PEM - Unavailable feature, e.g. hashing/encryption combination" );
|
||||
polarssl_snprintf( buf, buflen, "PEM - Unavailable feature, e.g. hashing/encryption combination" );
|
||||
if( use_ret == -(POLARSSL_ERR_PEM_BAD_INPUT_DATA) )
|
||||
snprintf( buf, buflen, "PEM - Bad input parameters to function" );
|
||||
polarssl_snprintf( buf, buflen, "PEM - Bad input parameters to function" );
|
||||
#endif /* POLARSSL_PEM_PARSE_C || POLARSSL_PEM_WRITE_C */
|
||||
|
||||
#if defined(POLARSSL_PK_C)
|
||||
if( use_ret == -(POLARSSL_ERR_PK_MALLOC_FAILED) )
|
||||
snprintf( buf, buflen, "PK - Memory alloation failed" );
|
||||
polarssl_snprintf( buf, buflen, "PK - Memory alloation failed" );
|
||||
if( use_ret == -(POLARSSL_ERR_PK_TYPE_MISMATCH) )
|
||||
snprintf( buf, buflen, "PK - Type mismatch, eg attempt to encrypt with an ECDSA key" );
|
||||
polarssl_snprintf( buf, buflen, "PK - Type mismatch, eg attempt to encrypt with an ECDSA key" );
|
||||
if( use_ret == -(POLARSSL_ERR_PK_BAD_INPUT_DATA) )
|
||||
snprintf( buf, buflen, "PK - Bad input parameters to function" );
|
||||
polarssl_snprintf( buf, buflen, "PK - Bad input parameters to function" );
|
||||
if( use_ret == -(POLARSSL_ERR_PK_FILE_IO_ERROR) )
|
||||
snprintf( buf, buflen, "PK - Read/write of file failed" );
|
||||
polarssl_snprintf( buf, buflen, "PK - Read/write of file failed" );
|
||||
if( use_ret == -(POLARSSL_ERR_PK_KEY_INVALID_VERSION) )
|
||||
snprintf( buf, buflen, "PK - Unsupported key version" );
|
||||
polarssl_snprintf( buf, buflen, "PK - Unsupported key version" );
|
||||
if( use_ret == -(POLARSSL_ERR_PK_KEY_INVALID_FORMAT) )
|
||||
snprintf( buf, buflen, "PK - Invalid key tag or value" );
|
||||
polarssl_snprintf( buf, buflen, "PK - Invalid key tag or value" );
|
||||
if( use_ret == -(POLARSSL_ERR_PK_UNKNOWN_PK_ALG) )
|
||||
snprintf( buf, buflen, "PK - Key algorithm is unsupported (only RSA and EC are supported)" );
|
||||
polarssl_snprintf( buf, buflen, "PK - Key algorithm is unsupported (only RSA and EC are supported)" );
|
||||
if( use_ret == -(POLARSSL_ERR_PK_PASSWORD_REQUIRED) )
|
||||
snprintf( buf, buflen, "PK - Private key password can't be empty" );
|
||||
polarssl_snprintf( buf, buflen, "PK - Private key password can't be empty" );
|
||||
if( use_ret == -(POLARSSL_ERR_PK_PASSWORD_MISMATCH) )
|
||||
snprintf( buf, buflen, "PK - Given private key password does not allow for correct decryption" );
|
||||
polarssl_snprintf( buf, buflen, "PK - Given private key password does not allow for correct decryption" );
|
||||
if( use_ret == -(POLARSSL_ERR_PK_INVALID_PUBKEY) )
|
||||
snprintf( buf, buflen, "PK - The pubkey tag or value is invalid (only RSA and EC are supported)" );
|
||||
polarssl_snprintf( buf, buflen, "PK - The pubkey tag or value is invalid (only RSA and EC are supported)" );
|
||||
if( use_ret == -(POLARSSL_ERR_PK_INVALID_ALG) )
|
||||
snprintf( buf, buflen, "PK - The algorithm tag or value is invalid" );
|
||||
polarssl_snprintf( buf, buflen, "PK - The algorithm tag or value is invalid" );
|
||||
if( use_ret == -(POLARSSL_ERR_PK_UNKNOWN_NAMED_CURVE) )
|
||||
snprintf( buf, buflen, "PK - Elliptic curve is unsupported (only NIST curves are supported)" );
|
||||
polarssl_snprintf( buf, buflen, "PK - Elliptic curve is unsupported (only NIST curves are supported)" );
|
||||
if( use_ret == -(POLARSSL_ERR_PK_FEATURE_UNAVAILABLE) )
|
||||
snprintf( buf, buflen, "PK - Unavailable feature, e.g. RSA disabled for RSA key" );
|
||||
polarssl_snprintf( buf, buflen, "PK - Unavailable feature, e.g. RSA disabled for RSA key" );
|
||||
if( use_ret == -(POLARSSL_ERR_PK_SIG_LEN_MISMATCH) )
|
||||
snprintf( buf, buflen, "PK - The signature is valid but its length is less than expected" );
|
||||
polarssl_snprintf( buf, buflen, "PK - The signature is valid but its length is less than expected" );
|
||||
#endif /* POLARSSL_PK_C */
|
||||
|
||||
#if defined(POLARSSL_PKCS12_C)
|
||||
if( use_ret == -(POLARSSL_ERR_PKCS12_BAD_INPUT_DATA) )
|
||||
snprintf( buf, buflen, "PKCS12 - Bad input parameters to function" );
|
||||
polarssl_snprintf( buf, buflen, "PKCS12 - Bad input parameters to function" );
|
||||
if( use_ret == -(POLARSSL_ERR_PKCS12_FEATURE_UNAVAILABLE) )
|
||||
snprintf( buf, buflen, "PKCS12 - Feature not available, e.g. unsupported encryption scheme" );
|
||||
polarssl_snprintf( buf, buflen, "PKCS12 - Feature not available, e.g. unsupported encryption scheme" );
|
||||
if( use_ret == -(POLARSSL_ERR_PKCS12_PBE_INVALID_FORMAT) )
|
||||
snprintf( buf, buflen, "PKCS12 - PBE ASN.1 data not as expected" );
|
||||
polarssl_snprintf( buf, buflen, "PKCS12 - PBE ASN.1 data not as expected" );
|
||||
if( use_ret == -(POLARSSL_ERR_PKCS12_PASSWORD_MISMATCH) )
|
||||
snprintf( buf, buflen, "PKCS12 - Given private key password does not allow for correct decryption" );
|
||||
polarssl_snprintf( buf, buflen, "PKCS12 - Given private key password does not allow for correct decryption" );
|
||||
#endif /* POLARSSL_PKCS12_C */
|
||||
|
||||
#if defined(POLARSSL_PKCS5_C)
|
||||
if( use_ret == -(POLARSSL_ERR_PKCS5_BAD_INPUT_DATA) )
|
||||
snprintf( buf, buflen, "PKCS5 - Bad input parameters to function" );
|
||||
polarssl_snprintf( buf, buflen, "PKCS5 - Bad input parameters to function" );
|
||||
if( use_ret == -(POLARSSL_ERR_PKCS5_INVALID_FORMAT) )
|
||||
snprintf( buf, buflen, "PKCS5 - Unexpected ASN.1 data" );
|
||||
polarssl_snprintf( buf, buflen, "PKCS5 - Unexpected ASN.1 data" );
|
||||
if( use_ret == -(POLARSSL_ERR_PKCS5_FEATURE_UNAVAILABLE) )
|
||||
snprintf( buf, buflen, "PKCS5 - Requested encryption or digest alg not available" );
|
||||
polarssl_snprintf( buf, buflen, "PKCS5 - Requested encryption or digest alg not available" );
|
||||
if( use_ret == -(POLARSSL_ERR_PKCS5_PASSWORD_MISMATCH) )
|
||||
snprintf( buf, buflen, "PKCS5 - Given private key password does not allow for correct decryption" );
|
||||
polarssl_snprintf( buf, buflen, "PKCS5 - Given private key password does not allow for correct decryption" );
|
||||
#endif /* POLARSSL_PKCS5_C */
|
||||
|
||||
#if defined(POLARSSL_RSA_C)
|
||||
if( use_ret == -(POLARSSL_ERR_RSA_BAD_INPUT_DATA) )
|
||||
snprintf( buf, buflen, "RSA - Bad input parameters to function" );
|
||||
polarssl_snprintf( buf, buflen, "RSA - Bad input parameters to function" );
|
||||
if( use_ret == -(POLARSSL_ERR_RSA_INVALID_PADDING) )
|
||||
snprintf( buf, buflen, "RSA - Input data contains invalid padding and is rejected" );
|
||||
polarssl_snprintf( buf, buflen, "RSA - Input data contains invalid padding and is rejected" );
|
||||
if( use_ret == -(POLARSSL_ERR_RSA_KEY_GEN_FAILED) )
|
||||
snprintf( buf, buflen, "RSA - Something failed during generation of a key" );
|
||||
polarssl_snprintf( buf, buflen, "RSA - Something failed during generation of a key" );
|
||||
if( use_ret == -(POLARSSL_ERR_RSA_KEY_CHECK_FAILED) )
|
||||
snprintf( buf, buflen, "RSA - Key failed to pass the libraries validity check" );
|
||||
polarssl_snprintf( buf, buflen, "RSA - Key failed to pass the libraries validity check" );
|
||||
if( use_ret == -(POLARSSL_ERR_RSA_PUBLIC_FAILED) )
|
||||
snprintf( buf, buflen, "RSA - The public key operation failed" );
|
||||
polarssl_snprintf( buf, buflen, "RSA - The public key operation failed" );
|
||||
if( use_ret == -(POLARSSL_ERR_RSA_PRIVATE_FAILED) )
|
||||
snprintf( buf, buflen, "RSA - The private key operation failed" );
|
||||
polarssl_snprintf( buf, buflen, "RSA - The private key operation failed" );
|
||||
if( use_ret == -(POLARSSL_ERR_RSA_VERIFY_FAILED) )
|
||||
snprintf( buf, buflen, "RSA - The PKCS#1 verification failed" );
|
||||
polarssl_snprintf( buf, buflen, "RSA - The PKCS#1 verification failed" );
|
||||
if( use_ret == -(POLARSSL_ERR_RSA_OUTPUT_TOO_LARGE) )
|
||||
snprintf( buf, buflen, "RSA - The output buffer for decryption is not large enough" );
|
||||
polarssl_snprintf( buf, buflen, "RSA - The output buffer for decryption is not large enough" );
|
||||
if( use_ret == -(POLARSSL_ERR_RSA_RNG_FAILED) )
|
||||
snprintf( buf, buflen, "RSA - The random generator failed to generate non-zeros" );
|
||||
polarssl_snprintf( buf, buflen, "RSA - The random generator failed to generate non-zeros" );
|
||||
#endif /* POLARSSL_RSA_C */
|
||||
|
||||
#if defined(POLARSSL_SSL_TLS_C)
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE) )
|
||||
snprintf( buf, buflen, "SSL - The requested feature is not available" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - The requested feature is not available" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_BAD_INPUT_DATA) )
|
||||
snprintf( buf, buflen, "SSL - Bad input parameters to function" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - Bad input parameters to function" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_INVALID_MAC) )
|
||||
snprintf( buf, buflen, "SSL - Verification of the message MAC failed" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - Verification of the message MAC failed" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_INVALID_RECORD) )
|
||||
snprintf( buf, buflen, "SSL - An invalid SSL record was received" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - An invalid SSL record was received" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_CONN_EOF) )
|
||||
snprintf( buf, buflen, "SSL - The connection indicated an EOF" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - The connection indicated an EOF" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_UNKNOWN_CIPHER) )
|
||||
snprintf( buf, buflen, "SSL - An unknown cipher was received" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - An unknown cipher was received" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_NO_CIPHER_CHOSEN) )
|
||||
snprintf( buf, buflen, "SSL - The server has no ciphersuites in common with the client" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - The server has no ciphersuites in common with the client" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_NO_RNG) )
|
||||
snprintf( buf, buflen, "SSL - No RNG was provided to the SSL module" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - No RNG was provided to the SSL module" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_NO_CLIENT_CERTIFICATE) )
|
||||
snprintf( buf, buflen, "SSL - No client certification received from the client, but required by the authentication mode" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - No client certification received from the client, but required by the authentication mode" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_CERTIFICATE_TOO_LARGE) )
|
||||
snprintf( buf, buflen, "SSL - Our own certificate(s) is/are too large to send in an SSL message" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - Our own certificate(s) is/are too large to send in an SSL message" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_CERTIFICATE_REQUIRED) )
|
||||
snprintf( buf, buflen, "SSL - The own certificate is not set, but needed by the server" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - The own certificate is not set, but needed by the server" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_PRIVATE_KEY_REQUIRED) )
|
||||
snprintf( buf, buflen, "SSL - The own private key or pre-shared key is not set, but needed" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - The own private key or pre-shared key is not set, but needed" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_CA_CHAIN_REQUIRED) )
|
||||
snprintf( buf, buflen, "SSL - No CA Chain is set, but required to operate" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - No CA Chain is set, but required to operate" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_UNEXPECTED_MESSAGE) )
|
||||
snprintf( buf, buflen, "SSL - An unexpected message was received from our peer" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - An unexpected message was received from our peer" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_FATAL_ALERT_MESSAGE) )
|
||||
{
|
||||
snprintf( buf, buflen, "SSL - A fatal alert message was received from our peer" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - A fatal alert message was received from our peer" );
|
||||
return;
|
||||
}
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_PEER_VERIFY_FAILED) )
|
||||
snprintf( buf, buflen, "SSL - Verification of our peer failed" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - Verification of our peer failed" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_PEER_CLOSE_NOTIFY) )
|
||||
snprintf( buf, buflen, "SSL - The peer notified us that the connection is going to be closed" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - The peer notified us that the connection is going to be closed" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CLIENT_HELLO) )
|
||||
snprintf( buf, buflen, "SSL - Processing of the ClientHello handshake message failed" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - Processing of the ClientHello handshake message failed" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_SERVER_HELLO) )
|
||||
snprintf( buf, buflen, "SSL - Processing of the ServerHello handshake message failed" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - Processing of the ServerHello handshake message failed" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE) )
|
||||
snprintf( buf, buflen, "SSL - Processing of the Certificate handshake message failed" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - Processing of the Certificate handshake message failed" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST) )
|
||||
snprintf( buf, buflen, "SSL - Processing of the CertificateRequest handshake message failed" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - Processing of the CertificateRequest handshake message failed" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE) )
|
||||
snprintf( buf, buflen, "SSL - Processing of the ServerKeyExchange handshake message failed" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - Processing of the ServerKeyExchange handshake message failed" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_SERVER_HELLO_DONE) )
|
||||
snprintf( buf, buflen, "SSL - Processing of the ServerHelloDone handshake message failed" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - Processing of the ServerHelloDone handshake message failed" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE) )
|
||||
snprintf( buf, buflen, "SSL - Processing of the ClientKeyExchange handshake message failed" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - Processing of the ClientKeyExchange handshake message failed" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_RP) )
|
||||
snprintf( buf, buflen, "SSL - Processing of the ClientKeyExchange handshake message failed in DHM / ECDH Read Public" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - Processing of the ClientKeyExchange handshake message failed in DHM / ECDH Read Public" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_CS) )
|
||||
snprintf( buf, buflen, "SSL - Processing of the ClientKeyExchange handshake message failed in DHM / ECDH Calculate Secret" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - Processing of the ClientKeyExchange handshake message failed in DHM / ECDH Calculate Secret" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY) )
|
||||
snprintf( buf, buflen, "SSL - Processing of the CertificateVerify handshake message failed" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - Processing of the CertificateVerify handshake message failed" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CHANGE_CIPHER_SPEC) )
|
||||
snprintf( buf, buflen, "SSL - Processing of the ChangeCipherSpec handshake message failed" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - Processing of the ChangeCipherSpec handshake message failed" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_FINISHED) )
|
||||
snprintf( buf, buflen, "SSL - Processing of the Finished handshake message failed" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - Processing of the Finished handshake message failed" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_MALLOC_FAILED) )
|
||||
snprintf( buf, buflen, "SSL - Memory allocation failed" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - Memory allocation failed" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_HW_ACCEL_FAILED) )
|
||||
snprintf( buf, buflen, "SSL - Hardware acceleration function returned with error" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - Hardware acceleration function returned with error" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_HW_ACCEL_FALLTHROUGH) )
|
||||
snprintf( buf, buflen, "SSL - Hardware acceleration function skipped / left alone data" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - Hardware acceleration function skipped / left alone data" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_COMPRESSION_FAILED) )
|
||||
snprintf( buf, buflen, "SSL - Processing of the compression / decompression failed" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - Processing of the compression / decompression failed" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_PROTOCOL_VERSION) )
|
||||
snprintf( buf, buflen, "SSL - Handshake protocol not within min/max boundaries" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - Handshake protocol not within min/max boundaries" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_NEW_SESSION_TICKET) )
|
||||
snprintf( buf, buflen, "SSL - Processing of the NewSessionTicket handshake message failed" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - Processing of the NewSessionTicket handshake message failed" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_SESSION_TICKET_EXPIRED) )
|
||||
snprintf( buf, buflen, "SSL - Session ticket has expired" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - Session ticket has expired" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_PK_TYPE_MISMATCH) )
|
||||
snprintf( buf, buflen, "SSL - Public key type mismatch (eg, asked for RSA key exchange and presented EC key)" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - Public key type mismatch (eg, asked for RSA key exchange and presented EC key)" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_UNKNOWN_IDENTITY) )
|
||||
snprintf( buf, buflen, "SSL - Unknown identity received (eg, PSK identity)" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - Unknown identity received (eg, PSK identity)" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_INTERNAL_ERROR) )
|
||||
snprintf( buf, buflen, "SSL - Internal error (eg, unexpected failure in lower-level module)" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - Internal error (eg, unexpected failure in lower-level module)" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_COUNTER_WRAPPING) )
|
||||
snprintf( buf, buflen, "SSL - A counter would wrap (eg, too many messages exchanged)" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - A counter would wrap (eg, too many messages exchanged)" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_WAITING_SERVER_HELLO_RENEGO) )
|
||||
snprintf( buf, buflen, "SSL - Unexpected message at ServerHello in renegotiation" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - Unexpected message at ServerHello in renegotiation" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_HELLO_VERIFY_REQUIRED) )
|
||||
snprintf( buf, buflen, "SSL - DTLS client must retry for hello verification" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - DTLS client must retry for hello verification" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_BUFFER_TOO_SMALL) )
|
||||
snprintf( buf, buflen, "SSL - A buffer is too small to receive or write a message" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - A buffer is too small to receive or write a message" );
|
||||
if( use_ret == -(POLARSSL_ERR_SSL_NO_USABLE_CIPHERSUITE) )
|
||||
snprintf( buf, buflen, "SSL - None of the common ciphersuites is usable (eg, no suitable certificate, see debug messages)" );
|
||||
polarssl_snprintf( buf, buflen, "SSL - None of the common ciphersuites is usable (eg, no suitable certificate, see debug messages)" );
|
||||
#endif /* POLARSSL_SSL_TLS_C */
|
||||
|
||||
#if defined(POLARSSL_X509_USE_C) || defined(POLARSSL_X509_CREATE_C)
|
||||
if( use_ret == -(POLARSSL_ERR_X509_FEATURE_UNAVAILABLE) )
|
||||
snprintf( buf, buflen, "X509 - Unavailable feature, e.g. RSA hashing/encryption combination" );
|
||||
polarssl_snprintf( buf, buflen, "X509 - Unavailable feature, e.g. RSA hashing/encryption combination" );
|
||||
if( use_ret == -(POLARSSL_ERR_X509_UNKNOWN_OID) )
|
||||
snprintf( buf, buflen, "X509 - Requested OID is unknown" );
|
||||
polarssl_snprintf( buf, buflen, "X509 - Requested OID is unknown" );
|
||||
if( use_ret == -(POLARSSL_ERR_X509_INVALID_FORMAT) )
|
||||
snprintf( buf, buflen, "X509 - The CRT/CRL/CSR format is invalid, e.g. different type expected" );
|
||||
polarssl_snprintf( buf, buflen, "X509 - The CRT/CRL/CSR format is invalid, e.g. different type expected" );
|
||||
if( use_ret == -(POLARSSL_ERR_X509_INVALID_VERSION) )
|
||||
snprintf( buf, buflen, "X509 - The CRT/CRL/CSR version element is invalid" );
|
||||
polarssl_snprintf( buf, buflen, "X509 - The CRT/CRL/CSR version element is invalid" );
|
||||
if( use_ret == -(POLARSSL_ERR_X509_INVALID_SERIAL) )
|
||||
snprintf( buf, buflen, "X509 - The serial tag or value is invalid" );
|
||||
polarssl_snprintf( buf, buflen, "X509 - The serial tag or value is invalid" );
|
||||
if( use_ret == -(POLARSSL_ERR_X509_INVALID_ALG) )
|
||||
snprintf( buf, buflen, "X509 - The algorithm tag or value is invalid" );
|
||||
polarssl_snprintf( buf, buflen, "X509 - The algorithm tag or value is invalid" );
|
||||
if( use_ret == -(POLARSSL_ERR_X509_INVALID_NAME) )
|
||||
snprintf( buf, buflen, "X509 - The name tag or value is invalid" );
|
||||
polarssl_snprintf( buf, buflen, "X509 - The name tag or value is invalid" );
|
||||
if( use_ret == -(POLARSSL_ERR_X509_INVALID_DATE) )
|
||||
snprintf( buf, buflen, "X509 - The date tag or value is invalid" );
|
||||
polarssl_snprintf( buf, buflen, "X509 - The date tag or value is invalid" );
|
||||
if( use_ret == -(POLARSSL_ERR_X509_INVALID_SIGNATURE) )
|
||||
snprintf( buf, buflen, "X509 - The signature tag or value invalid" );
|
||||
polarssl_snprintf( buf, buflen, "X509 - The signature tag or value invalid" );
|
||||
if( use_ret == -(POLARSSL_ERR_X509_INVALID_EXTENSIONS) )
|
||||
snprintf( buf, buflen, "X509 - The extension tag or value is invalid" );
|
||||
polarssl_snprintf( buf, buflen, "X509 - The extension tag or value is invalid" );
|
||||
if( use_ret == -(POLARSSL_ERR_X509_UNKNOWN_VERSION) )
|
||||
snprintf( buf, buflen, "X509 - CRT/CRL/CSR has an unsupported version number" );
|
||||
polarssl_snprintf( buf, buflen, "X509 - CRT/CRL/CSR has an unsupported version number" );
|
||||
if( use_ret == -(POLARSSL_ERR_X509_UNKNOWN_SIG_ALG) )
|
||||
snprintf( buf, buflen, "X509 - Signature algorithm (oid) is unsupported" );
|
||||
polarssl_snprintf( buf, buflen, "X509 - Signature algorithm (oid) is unsupported" );
|
||||
if( use_ret == -(POLARSSL_ERR_X509_SIG_MISMATCH) )
|
||||
snprintf( buf, buflen, "X509 - Signature algorithms do not match. (see \\c ::x509_crt sig_oid)" );
|
||||
polarssl_snprintf( buf, buflen, "X509 - Signature algorithms do not match. (see \\c ::x509_crt sig_oid)" );
|
||||
if( use_ret == -(POLARSSL_ERR_X509_CERT_VERIFY_FAILED) )
|
||||
snprintf( buf, buflen, "X509 - Certificate verification failed, e.g. CRL, CA or signature check failed" );
|
||||
polarssl_snprintf( buf, buflen, "X509 - Certificate verification failed, e.g. CRL, CA or signature check failed" );
|
||||
if( use_ret == -(POLARSSL_ERR_X509_CERT_UNKNOWN_FORMAT) )
|
||||
snprintf( buf, buflen, "X509 - Format not recognized as DER or PEM" );
|
||||
polarssl_snprintf( buf, buflen, "X509 - Format not recognized as DER or PEM" );
|
||||
if( use_ret == -(POLARSSL_ERR_X509_BAD_INPUT_DATA) )
|
||||
snprintf( buf, buflen, "X509 - Input invalid" );
|
||||
polarssl_snprintf( buf, buflen, "X509 - Input invalid" );
|
||||
if( use_ret == -(POLARSSL_ERR_X509_MALLOC_FAILED) )
|
||||
snprintf( buf, buflen, "X509 - Allocation of memory failed" );
|
||||
polarssl_snprintf( buf, buflen, "X509 - Allocation of memory failed" );
|
||||
if( use_ret == -(POLARSSL_ERR_X509_FILE_IO_ERROR) )
|
||||
snprintf( buf, buflen, "X509 - Read/write of file failed" );
|
||||
polarssl_snprintf( buf, buflen, "X509 - Read/write of file failed" );
|
||||
#endif /* POLARSSL_X509_USE,X509_CREATE_C */
|
||||
// END generated code
|
||||
|
||||
if( strlen( buf ) == 0 )
|
||||
snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret );
|
||||
polarssl_snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret );
|
||||
}
|
||||
|
||||
use_ret = ret & ~0xFF80;
|
||||
|
@ -516,7 +522,7 @@ void polarssl_strerror( int ret, char *buf, size_t buflen )
|
|||
if( buflen - len < 5 )
|
||||
return;
|
||||
|
||||
snprintf( buf + len, buflen - len, " : " );
|
||||
polarssl_snprintf( buf + len, buflen - len, " : " );
|
||||
|
||||
buf += len + 3;
|
||||
buflen -= len + 3;
|
||||
|
@ -527,218 +533,218 @@ void polarssl_strerror( int ret, char *buf, size_t buflen )
|
|||
// BEGIN generated code
|
||||
#if defined(POLARSSL_AES_C)
|
||||
if( use_ret == -(POLARSSL_ERR_AES_INVALID_KEY_LENGTH) )
|
||||
snprintf( buf, buflen, "AES - Invalid key length" );
|
||||
polarssl_snprintf( buf, buflen, "AES - Invalid key length" );
|
||||
if( use_ret == -(POLARSSL_ERR_AES_INVALID_INPUT_LENGTH) )
|
||||
snprintf( buf, buflen, "AES - Invalid data input length" );
|
||||
polarssl_snprintf( buf, buflen, "AES - Invalid data input length" );
|
||||
#endif /* POLARSSL_AES_C */
|
||||
|
||||
#if defined(POLARSSL_ASN1_PARSE_C)
|
||||
if( use_ret == -(POLARSSL_ERR_ASN1_OUT_OF_DATA) )
|
||||
snprintf( buf, buflen, "ASN1 - Out of data when parsing an ASN1 data structure" );
|
||||
polarssl_snprintf( buf, buflen, "ASN1 - Out of data when parsing an ASN1 data structure" );
|
||||
if( use_ret == -(POLARSSL_ERR_ASN1_UNEXPECTED_TAG) )
|
||||
snprintf( buf, buflen, "ASN1 - ASN1 tag was of an unexpected value" );
|
||||
polarssl_snprintf( buf, buflen, "ASN1 - ASN1 tag was of an unexpected value" );
|
||||
if( use_ret == -(POLARSSL_ERR_ASN1_INVALID_LENGTH) )
|
||||
snprintf( buf, buflen, "ASN1 - Error when trying to determine the length or invalid length" );
|
||||
polarssl_snprintf( buf, buflen, "ASN1 - Error when trying to determine the length or invalid length" );
|
||||
if( use_ret == -(POLARSSL_ERR_ASN1_LENGTH_MISMATCH) )
|
||||
snprintf( buf, buflen, "ASN1 - Actual length differs from expected length" );
|
||||
polarssl_snprintf( buf, buflen, "ASN1 - Actual length differs from expected length" );
|
||||
if( use_ret == -(POLARSSL_ERR_ASN1_INVALID_DATA) )
|
||||
snprintf( buf, buflen, "ASN1 - Data is invalid. (not used)" );
|
||||
polarssl_snprintf( buf, buflen, "ASN1 - Data is invalid. (not used)" );
|
||||
if( use_ret == -(POLARSSL_ERR_ASN1_MALLOC_FAILED) )
|
||||
snprintf( buf, buflen, "ASN1 - Memory allocation failed" );
|
||||
polarssl_snprintf( buf, buflen, "ASN1 - Memory allocation failed" );
|
||||
if( use_ret == -(POLARSSL_ERR_ASN1_BUF_TOO_SMALL) )
|
||||
snprintf( buf, buflen, "ASN1 - Buffer too small when writing ASN.1 data structure" );
|
||||
polarssl_snprintf( buf, buflen, "ASN1 - Buffer too small when writing ASN.1 data structure" );
|
||||
#endif /* POLARSSL_ASN1_PARSE_C */
|
||||
|
||||
#if defined(POLARSSL_BASE64_C)
|
||||
if( use_ret == -(POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL) )
|
||||
snprintf( buf, buflen, "BASE64 - Output buffer too small" );
|
||||
polarssl_snprintf( buf, buflen, "BASE64 - Output buffer too small" );
|
||||
if( use_ret == -(POLARSSL_ERR_BASE64_INVALID_CHARACTER) )
|
||||
snprintf( buf, buflen, "BASE64 - Invalid character in input" );
|
||||
polarssl_snprintf( buf, buflen, "BASE64 - Invalid character in input" );
|
||||
#endif /* POLARSSL_BASE64_C */
|
||||
|
||||
#if defined(POLARSSL_BIGNUM_C)
|
||||
if( use_ret == -(POLARSSL_ERR_MPI_FILE_IO_ERROR) )
|
||||
snprintf( buf, buflen, "BIGNUM - An error occurred while reading from or writing to a file" );
|
||||
polarssl_snprintf( buf, buflen, "BIGNUM - An error occurred while reading from or writing to a file" );
|
||||
if( use_ret == -(POLARSSL_ERR_MPI_BAD_INPUT_DATA) )
|
||||
snprintf( buf, buflen, "BIGNUM - Bad input parameters to function" );
|
||||
polarssl_snprintf( buf, buflen, "BIGNUM - Bad input parameters to function" );
|
||||
if( use_ret == -(POLARSSL_ERR_MPI_INVALID_CHARACTER) )
|
||||
snprintf( buf, buflen, "BIGNUM - There is an invalid character in the digit string" );
|
||||
polarssl_snprintf( buf, buflen, "BIGNUM - There is an invalid character in the digit string" );
|
||||
if( use_ret == -(POLARSSL_ERR_MPI_BUFFER_TOO_SMALL) )
|
||||
snprintf( buf, buflen, "BIGNUM - The buffer is too small to write to" );
|
||||
polarssl_snprintf( buf, buflen, "BIGNUM - The buffer is too small to write to" );
|
||||
if( use_ret == -(POLARSSL_ERR_MPI_NEGATIVE_VALUE) )
|
||||
snprintf( buf, buflen, "BIGNUM - The input arguments are negative or result in illegal output" );
|
||||
polarssl_snprintf( buf, buflen, "BIGNUM - The input arguments are negative or result in illegal output" );
|
||||
if( use_ret == -(POLARSSL_ERR_MPI_DIVISION_BY_ZERO) )
|
||||
snprintf( buf, buflen, "BIGNUM - The input argument for division is zero, which is not allowed" );
|
||||
polarssl_snprintf( buf, buflen, "BIGNUM - The input argument for division is zero, which is not allowed" );
|
||||
if( use_ret == -(POLARSSL_ERR_MPI_NOT_ACCEPTABLE) )
|
||||
snprintf( buf, buflen, "BIGNUM - The input arguments are not acceptable" );
|
||||
polarssl_snprintf( buf, buflen, "BIGNUM - The input arguments are not acceptable" );
|
||||
if( use_ret == -(POLARSSL_ERR_MPI_MALLOC_FAILED) )
|
||||
snprintf( buf, buflen, "BIGNUM - Memory allocation failed" );
|
||||
polarssl_snprintf( buf, buflen, "BIGNUM - Memory allocation failed" );
|
||||
#endif /* POLARSSL_BIGNUM_C */
|
||||
|
||||
#if defined(POLARSSL_BLOWFISH_C)
|
||||
if( use_ret == -(POLARSSL_ERR_BLOWFISH_INVALID_KEY_LENGTH) )
|
||||
snprintf( buf, buflen, "BLOWFISH - Invalid key length" );
|
||||
polarssl_snprintf( buf, buflen, "BLOWFISH - Invalid key length" );
|
||||
if( use_ret == -(POLARSSL_ERR_BLOWFISH_INVALID_INPUT_LENGTH) )
|
||||
snprintf( buf, buflen, "BLOWFISH - Invalid data input length" );
|
||||
polarssl_snprintf( buf, buflen, "BLOWFISH - Invalid data input length" );
|
||||
#endif /* POLARSSL_BLOWFISH_C */
|
||||
|
||||
#if defined(POLARSSL_CAMELLIA_C)
|
||||
if( use_ret == -(POLARSSL_ERR_CAMELLIA_INVALID_KEY_LENGTH) )
|
||||
snprintf( buf, buflen, "CAMELLIA - Invalid key length" );
|
||||
polarssl_snprintf( buf, buflen, "CAMELLIA - Invalid key length" );
|
||||
if( use_ret == -(POLARSSL_ERR_CAMELLIA_INVALID_INPUT_LENGTH) )
|
||||
snprintf( buf, buflen, "CAMELLIA - Invalid data input length" );
|
||||
polarssl_snprintf( buf, buflen, "CAMELLIA - Invalid data input length" );
|
||||
#endif /* POLARSSL_CAMELLIA_C */
|
||||
|
||||
#if defined(POLARSSL_CCM_C)
|
||||
if( use_ret == -(POLARSSL_ERR_CCM_BAD_INPUT) )
|
||||
snprintf( buf, buflen, "CCM - Bad input parameters to function" );
|
||||
polarssl_snprintf( buf, buflen, "CCM - Bad input parameters to function" );
|
||||
if( use_ret == -(POLARSSL_ERR_CCM_AUTH_FAILED) )
|
||||
snprintf( buf, buflen, "CCM - Authenticated decryption failed" );
|
||||
polarssl_snprintf( buf, buflen, "CCM - Authenticated decryption failed" );
|
||||
#endif /* POLARSSL_CCM_C */
|
||||
|
||||
#if defined(POLARSSL_CTR_DRBG_C)
|
||||
if( use_ret == -(POLARSSL_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED) )
|
||||
snprintf( buf, buflen, "CTR_DRBG - The entropy source failed" );
|
||||
polarssl_snprintf( buf, buflen, "CTR_DRBG - The entropy source failed" );
|
||||
if( use_ret == -(POLARSSL_ERR_CTR_DRBG_REQUEST_TOO_BIG) )
|
||||
snprintf( buf, buflen, "CTR_DRBG - Too many random requested in single call" );
|
||||
polarssl_snprintf( buf, buflen, "CTR_DRBG - Too many random requested in single call" );
|
||||
if( use_ret == -(POLARSSL_ERR_CTR_DRBG_INPUT_TOO_BIG) )
|
||||
snprintf( buf, buflen, "CTR_DRBG - Input too large (Entropy + additional)" );
|
||||
polarssl_snprintf( buf, buflen, "CTR_DRBG - Input too large (Entropy + additional)" );
|
||||
if( use_ret == -(POLARSSL_ERR_CTR_DRBG_FILE_IO_ERROR) )
|
||||
snprintf( buf, buflen, "CTR_DRBG - Read/write error in file" );
|
||||
polarssl_snprintf( buf, buflen, "CTR_DRBG - Read/write error in file" );
|
||||
#endif /* POLARSSL_CTR_DRBG_C */
|
||||
|
||||
#if defined(POLARSSL_DES_C)
|
||||
if( use_ret == -(POLARSSL_ERR_DES_INVALID_INPUT_LENGTH) )
|
||||
snprintf( buf, buflen, "DES - The data input has an invalid length" );
|
||||
polarssl_snprintf( buf, buflen, "DES - The data input has an invalid length" );
|
||||
#endif /* POLARSSL_DES_C */
|
||||
|
||||
#if defined(POLARSSL_ENTROPY_C)
|
||||
if( use_ret == -(POLARSSL_ERR_ENTROPY_SOURCE_FAILED) )
|
||||
snprintf( buf, buflen, "ENTROPY - Critical entropy source failure" );
|
||||
polarssl_snprintf( buf, buflen, "ENTROPY - Critical entropy source failure" );
|
||||
if( use_ret == -(POLARSSL_ERR_ENTROPY_MAX_SOURCES) )
|
||||
snprintf( buf, buflen, "ENTROPY - No more sources can be added" );
|
||||
polarssl_snprintf( buf, buflen, "ENTROPY - No more sources can be added" );
|
||||
if( use_ret == -(POLARSSL_ERR_ENTROPY_NO_SOURCES_DEFINED) )
|
||||
snprintf( buf, buflen, "ENTROPY - No sources have been added to poll" );
|
||||
polarssl_snprintf( buf, buflen, "ENTROPY - No sources have been added to poll" );
|
||||
if( use_ret == -(POLARSSL_ERR_ENTROPY_FILE_IO_ERROR) )
|
||||
snprintf( buf, buflen, "ENTROPY - Read/write error in file" );
|
||||
polarssl_snprintf( buf, buflen, "ENTROPY - Read/write error in file" );
|
||||
#endif /* POLARSSL_ENTROPY_C */
|
||||
|
||||
#if defined(POLARSSL_GCM_C)
|
||||
if( use_ret == -(POLARSSL_ERR_GCM_AUTH_FAILED) )
|
||||
snprintf( buf, buflen, "GCM - Authenticated decryption failed" );
|
||||
polarssl_snprintf( buf, buflen, "GCM - Authenticated decryption failed" );
|
||||
if( use_ret == -(POLARSSL_ERR_GCM_BAD_INPUT) )
|
||||
snprintf( buf, buflen, "GCM - Bad input parameters to function" );
|
||||
polarssl_snprintf( buf, buflen, "GCM - Bad input parameters to function" );
|
||||
#endif /* POLARSSL_GCM_C */
|
||||
|
||||
#if defined(POLARSSL_HMAC_DRBG_C)
|
||||
if( use_ret == -(POLARSSL_ERR_HMAC_DRBG_REQUEST_TOO_BIG) )
|
||||
snprintf( buf, buflen, "HMAC_DRBG - Too many random requested in single call" );
|
||||
polarssl_snprintf( buf, buflen, "HMAC_DRBG - Too many random requested in single call" );
|
||||
if( use_ret == -(POLARSSL_ERR_HMAC_DRBG_INPUT_TOO_BIG) )
|
||||
snprintf( buf, buflen, "HMAC_DRBG - Input too large (Entropy + additional)" );
|
||||
polarssl_snprintf( buf, buflen, "HMAC_DRBG - Input too large (Entropy + additional)" );
|
||||
if( use_ret == -(POLARSSL_ERR_HMAC_DRBG_FILE_IO_ERROR) )
|
||||
snprintf( buf, buflen, "HMAC_DRBG - Read/write error in file" );
|
||||
polarssl_snprintf( buf, buflen, "HMAC_DRBG - Read/write error in file" );
|
||||
if( use_ret == -(POLARSSL_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED) )
|
||||
snprintf( buf, buflen, "HMAC_DRBG - The entropy source failed" );
|
||||
polarssl_snprintf( buf, buflen, "HMAC_DRBG - The entropy source failed" );
|
||||
#endif /* POLARSSL_HMAC_DRBG_C */
|
||||
|
||||
#if defined(POLARSSL_MD2_C)
|
||||
if( use_ret == -(POLARSSL_ERR_MD2_FILE_IO_ERROR) )
|
||||
snprintf( buf, buflen, "MD2 - Read/write error in file" );
|
||||
polarssl_snprintf( buf, buflen, "MD2 - Read/write error in file" );
|
||||
#endif /* POLARSSL_MD2_C */
|
||||
|
||||
#if defined(POLARSSL_MD4_C)
|
||||
if( use_ret == -(POLARSSL_ERR_MD4_FILE_IO_ERROR) )
|
||||
snprintf( buf, buflen, "MD4 - Read/write error in file" );
|
||||
polarssl_snprintf( buf, buflen, "MD4 - Read/write error in file" );
|
||||
#endif /* POLARSSL_MD4_C */
|
||||
|
||||
#if defined(POLARSSL_MD5_C)
|
||||
if( use_ret == -(POLARSSL_ERR_MD5_FILE_IO_ERROR) )
|
||||
snprintf( buf, buflen, "MD5 - Read/write error in file" );
|
||||
polarssl_snprintf( buf, buflen, "MD5 - Read/write error in file" );
|
||||
#endif /* POLARSSL_MD5_C */
|
||||
|
||||
#if defined(POLARSSL_NET_C)
|
||||
if( use_ret == -(POLARSSL_ERR_NET_SOCKET_FAILED) )
|
||||
snprintf( buf, buflen, "NET - Failed to open a socket" );
|
||||
polarssl_snprintf( buf, buflen, "NET - Failed to open a socket" );
|
||||
if( use_ret == -(POLARSSL_ERR_NET_CONNECT_FAILED) )
|
||||
snprintf( buf, buflen, "NET - The connection to the given server / port failed" );
|
||||
polarssl_snprintf( buf, buflen, "NET - The connection to the given server / port failed" );
|
||||
if( use_ret == -(POLARSSL_ERR_NET_BIND_FAILED) )
|
||||
snprintf( buf, buflen, "NET - Binding of the socket failed" );
|
||||
polarssl_snprintf( buf, buflen, "NET - Binding of the socket failed" );
|
||||
if( use_ret == -(POLARSSL_ERR_NET_LISTEN_FAILED) )
|
||||
snprintf( buf, buflen, "NET - Could not listen on the socket" );
|
||||
polarssl_snprintf( buf, buflen, "NET - Could not listen on the socket" );
|
||||
if( use_ret == -(POLARSSL_ERR_NET_ACCEPT_FAILED) )
|
||||
snprintf( buf, buflen, "NET - Could not accept the incoming connection" );
|
||||
polarssl_snprintf( buf, buflen, "NET - Could not accept the incoming connection" );
|
||||
if( use_ret == -(POLARSSL_ERR_NET_RECV_FAILED) )
|
||||
snprintf( buf, buflen, "NET - Reading information from the socket failed" );
|
||||
polarssl_snprintf( buf, buflen, "NET - Reading information from the socket failed" );
|
||||
if( use_ret == -(POLARSSL_ERR_NET_SEND_FAILED) )
|
||||
snprintf( buf, buflen, "NET - Sending information through the socket failed" );
|
||||
polarssl_snprintf( buf, buflen, "NET - Sending information through the socket failed" );
|
||||
if( use_ret == -(POLARSSL_ERR_NET_CONN_RESET) )
|
||||
snprintf( buf, buflen, "NET - Connection was reset by peer" );
|
||||
polarssl_snprintf( buf, buflen, "NET - Connection was reset by peer" );
|
||||
if( use_ret == -(POLARSSL_ERR_NET_WANT_READ) )
|
||||
snprintf( buf, buflen, "NET - Connection requires a read call" );
|
||||
polarssl_snprintf( buf, buflen, "NET - Connection requires a read call" );
|
||||
if( use_ret == -(POLARSSL_ERR_NET_WANT_WRITE) )
|
||||
snprintf( buf, buflen, "NET - Connection requires a write call" );
|
||||
polarssl_snprintf( buf, buflen, "NET - Connection requires a write call" );
|
||||
if( use_ret == -(POLARSSL_ERR_NET_UNKNOWN_HOST) )
|
||||
snprintf( buf, buflen, "NET - Failed to get an IP address for the given hostname" );
|
||||
polarssl_snprintf( buf, buflen, "NET - Failed to get an IP address for the given hostname" );
|
||||
if( use_ret == -(POLARSSL_ERR_NET_TIMEOUT) )
|
||||
snprintf( buf, buflen, "NET - The operation timed out" );
|
||||
polarssl_snprintf( buf, buflen, "NET - The operation timed out" );
|
||||
#endif /* POLARSSL_NET_C */
|
||||
|
||||
#if defined(POLARSSL_OID_C)
|
||||
if( use_ret == -(POLARSSL_ERR_OID_NOT_FOUND) )
|
||||
snprintf( buf, buflen, "OID - OID is not found" );
|
||||
polarssl_snprintf( buf, buflen, "OID - OID is not found" );
|
||||
if( use_ret == -(POLARSSL_ERR_OID_BUF_TOO_SMALL) )
|
||||
snprintf( buf, buflen, "OID - output buffer is too small" );
|
||||
polarssl_snprintf( buf, buflen, "OID - output buffer is too small" );
|
||||
#endif /* POLARSSL_OID_C */
|
||||
|
||||
#if defined(POLARSSL_PADLOCK_C)
|
||||
if( use_ret == -(POLARSSL_ERR_PADLOCK_DATA_MISALIGNED) )
|
||||
snprintf( buf, buflen, "PADLOCK - Input data should be aligned" );
|
||||
polarssl_snprintf( buf, buflen, "PADLOCK - Input data should be aligned" );
|
||||
#endif /* POLARSSL_PADLOCK_C */
|
||||
|
||||
#if defined(POLARSSL_PBKDF2_C)
|
||||
if( use_ret == -(POLARSSL_ERR_PBKDF2_BAD_INPUT_DATA) )
|
||||
snprintf( buf, buflen, "PBKDF2 - Bad input parameters to function" );
|
||||
polarssl_snprintf( buf, buflen, "PBKDF2 - Bad input parameters to function" );
|
||||
#endif /* POLARSSL_PBKDF2_C */
|
||||
|
||||
#if defined(POLARSSL_RIPEMD160_C)
|
||||
if( use_ret == -(POLARSSL_ERR_RIPEMD160_FILE_IO_ERROR) )
|
||||
snprintf( buf, buflen, "RIPEMD160 - Read/write error in file" );
|
||||
polarssl_snprintf( buf, buflen, "RIPEMD160 - Read/write error in file" );
|
||||
#endif /* POLARSSL_RIPEMD160_C */
|
||||
|
||||
#if defined(POLARSSL_SHA1_C)
|
||||
if( use_ret == -(POLARSSL_ERR_SHA1_FILE_IO_ERROR) )
|
||||
snprintf( buf, buflen, "SHA1 - Read/write error in file" );
|
||||
polarssl_snprintf( buf, buflen, "SHA1 - Read/write error in file" );
|
||||
#endif /* POLARSSL_SHA1_C */
|
||||
|
||||
#if defined(POLARSSL_SHA256_C)
|
||||
if( use_ret == -(POLARSSL_ERR_SHA256_FILE_IO_ERROR) )
|
||||
snprintf( buf, buflen, "SHA256 - Read/write error in file" );
|
||||
polarssl_snprintf( buf, buflen, "SHA256 - Read/write error in file" );
|
||||
#endif /* POLARSSL_SHA256_C */
|
||||
|
||||
#if defined(POLARSSL_SHA512_C)
|
||||
if( use_ret == -(POLARSSL_ERR_SHA512_FILE_IO_ERROR) )
|
||||
snprintf( buf, buflen, "SHA512 - Read/write error in file" );
|
||||
polarssl_snprintf( buf, buflen, "SHA512 - Read/write error in file" );
|
||||
#endif /* POLARSSL_SHA512_C */
|
||||
|
||||
#if defined(POLARSSL_THREADING_C)
|
||||
if( use_ret == -(POLARSSL_ERR_THREADING_FEATURE_UNAVAILABLE) )
|
||||
snprintf( buf, buflen, "THREADING - The selected feature is not available" );
|
||||
polarssl_snprintf( buf, buflen, "THREADING - The selected feature is not available" );
|
||||
if( use_ret == -(POLARSSL_ERR_THREADING_BAD_INPUT_DATA) )
|
||||
snprintf( buf, buflen, "THREADING - Bad input parameters to function" );
|
||||
polarssl_snprintf( buf, buflen, "THREADING - Bad input parameters to function" );
|
||||
if( use_ret == -(POLARSSL_ERR_THREADING_MUTEX_ERROR) )
|
||||
snprintf( buf, buflen, "THREADING - Locking / unlocking / free failed with error code" );
|
||||
polarssl_snprintf( buf, buflen, "THREADING - Locking / unlocking / free failed with error code" );
|
||||
#endif /* POLARSSL_THREADING_C */
|
||||
|
||||
#if defined(POLARSSL_XTEA_C)
|
||||
if( use_ret == -(POLARSSL_ERR_XTEA_INVALID_INPUT_LENGTH) )
|
||||
snprintf( buf, buflen, "XTEA - The data input has an invalid length" );
|
||||
polarssl_snprintf( buf, buflen, "XTEA - The data input has an invalid length" );
|
||||
#endif /* POLARSSL_XTEA_C */
|
||||
// END generated code
|
||||
|
||||
if( strlen( buf ) != 0 )
|
||||
return;
|
||||
|
||||
snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret );
|
||||
polarssl_snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret );
|
||||
}
|
||||
|
||||
#if defined(POLARSSL_ERROR_STRERROR_BC)
|
||||
|
@ -752,8 +758,6 @@ void error_strerror( int ret, char *buf, size_t buflen )
|
|||
|
||||
#if defined(POLARSSL_ERROR_STRERROR_DUMMY)
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
* Provide an non-function in case POLARSSL_ERROR_C is not defined
|
||||
*/
|
||||
|
|
|
@ -40,15 +40,20 @@
|
|||
|
||||
#include "polarssl/gcm.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(POLARSSL_AESNI_C)
|
||||
#include "polarssl/aesni.h"
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_SELF_TEST) && defined(POLARSSL_AES_C)
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#define polarssl_printf printf
|
||||
#endif
|
||||
#endif /* POLARSSL_PLATFORM_C */
|
||||
#endif /* POLARSSL_SELF_TEST && POLARSSL_AES_C */
|
||||
|
||||
/*
|
||||
* 32-bit integer manipulation macros (big endian)
|
||||
|
@ -131,7 +136,7 @@ static int gcm_gen_table( gcm_context *ctx )
|
|||
ctx->HH[i] = vh;
|
||||
}
|
||||
|
||||
for( i = 2; i < 16; i <<= 1 )
|
||||
for( i = 2; i <= 8; i *= 2 )
|
||||
{
|
||||
uint64_t *HiL = ctx->HL + i, *HiH = ctx->HH + i;
|
||||
vh = *HiH;
|
||||
|
@ -496,9 +501,6 @@ void gcm_free( gcm_context *ctx )
|
|||
}
|
||||
|
||||
#if defined(POLARSSL_SELF_TEST) && defined(POLARSSL_AES_C)
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
* AES-GCM test vectors from:
|
||||
*
|
||||
|
|
|
@ -36,15 +36,20 @@
|
|||
|
||||
#include "polarssl/hmac_drbg.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(POLARSSL_FS_IO)
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_SELF_TEST)
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#define polarssl_printf printf
|
||||
#endif
|
||||
#endif /* POLARSSL_SELF_TEST */
|
||||
#endif /* POLARSSL_PLATFORM_C */
|
||||
|
||||
/* Implementation that should never be optimized out by the compiler */
|
||||
static void polarssl_zeroize( void *v, size_t n ) {
|
||||
|
@ -376,8 +381,6 @@ int hmac_drbg_update_seed_file( hmac_drbg_context *ctx, const char *path )
|
|||
|
||||
#if defined(POLARSSL_SELF_TEST)
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if !defined(POLARSSL_SHA1_C)
|
||||
/* Dummy checkup routine */
|
||||
int hmac_drbg_self_test( int verbose )
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "polarssl/md_wrap.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(_MSC_VER) && !defined strcasecmp && !defined(EFIX64) && \
|
||||
!defined(EFI32)
|
||||
|
|
|
@ -36,15 +36,20 @@
|
|||
|
||||
#include "polarssl/md2.h"
|
||||
|
||||
#if defined(POLARSSL_FS_IO) || defined(POLARSSL_SELF_TEST)
|
||||
#include <string.h>
|
||||
|
||||
#if defined(POLARSSL_FS_IO)
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_SELF_TEST)
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#define polarssl_printf printf
|
||||
#endif
|
||||
#endif /* POLARSSL_PLATFORM_C */
|
||||
#endif /* POLARSSL_SELF_TEST */
|
||||
|
||||
/* Implementation that should never be optimized out by the compiler */
|
||||
static void polarssl_zeroize( void *v, size_t n ) {
|
||||
|
|
|
@ -36,15 +36,20 @@
|
|||
|
||||
#include "polarssl/md4.h"
|
||||
|
||||
#if defined(POLARSSL_FS_IO) || defined(POLARSSL_SELF_TEST)
|
||||
#include <string.h>
|
||||
|
||||
#if defined(POLARSSL_FS_IO)
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_SELF_TEST)
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#define polarssl_printf printf
|
||||
#endif
|
||||
#endif /* POLARSSL_PLATFORM_C */
|
||||
#endif /* POLARSSL_SELF_TEST */
|
||||
|
||||
/* Implementation that should never be optimized out by the compiler */
|
||||
static void polarssl_zeroize( void *v, size_t n ) {
|
||||
|
|
|
@ -35,15 +35,20 @@
|
|||
|
||||
#include "polarssl/md5.h"
|
||||
|
||||
#if defined(POLARSSL_FS_IO) || defined(POLARSSL_SELF_TEST)
|
||||
#include <string.h>
|
||||
|
||||
#if defined(POLARSSL_FS_IO)
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_SELF_TEST)
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#define polarssl_printf printf
|
||||
#endif
|
||||
#endif /* POLARSSL_PLATFORM_C */
|
||||
#endif /* POLARSSL_SELF_TEST */
|
||||
|
||||
/* Implementation that should never be optimized out by the compiler */
|
||||
static void polarssl_zeroize( void *v, size_t n ) {
|
||||
|
@ -575,7 +580,7 @@ int md5_self_test( int verbose )
|
|||
|
||||
if( i == 5 || i == 6 )
|
||||
{
|
||||
memset( buf, '\xAA', buflen = 80 );
|
||||
memset( buf, 0xAA, buflen = 80 );
|
||||
md5_hmac_starts( &ctx, buf, buflen );
|
||||
}
|
||||
else
|
||||
|
|
|
@ -65,12 +65,11 @@
|
|||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#define polarssl_malloc malloc
|
||||
#define polarssl_free free
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Implementation that should never be optimized out by the compiler */
|
||||
static void polarssl_zeroize( void *v, size_t n ) {
|
||||
volatile unsigned char *p = v; while( n-- ) *p++ = 0;
|
||||
|
@ -396,7 +395,7 @@ static void ripemd160_hmac_reset_wrap( void *ctx )
|
|||
static void * ripemd160_ctx_alloc( void )
|
||||
{
|
||||
ripemd160_context *ctx;
|
||||
ctx = (ripemd160_context *) polarssl_malloc( sizeof( ripemd160_context ) );
|
||||
ctx = polarssl_malloc( sizeof( ripemd160_context ) );
|
||||
|
||||
if( ctx == NULL )
|
||||
return( NULL );
|
||||
|
@ -492,7 +491,7 @@ static void sha1_hmac_reset_wrap( void *ctx )
|
|||
static void * sha1_ctx_alloc( void )
|
||||
{
|
||||
sha1_context *ctx;
|
||||
ctx = (sha1_context *) polarssl_malloc( sizeof( sha1_context ) );
|
||||
ctx = polarssl_malloc( sizeof( sha1_context ) );
|
||||
|
||||
if( ctx == NULL )
|
||||
return( NULL );
|
||||
|
@ -701,7 +700,7 @@ static void sha256_hmac_wrap( const unsigned char *key, size_t keylen,
|
|||
static void * sha256_ctx_alloc( void )
|
||||
{
|
||||
sha256_context *ctx;
|
||||
ctx = (sha256_context *) polarssl_malloc( sizeof( sha256_context ) );
|
||||
ctx = polarssl_malloc( sizeof( sha256_context ) );
|
||||
|
||||
if( ctx == NULL )
|
||||
return( NULL );
|
||||
|
@ -907,7 +906,7 @@ static void sha512_hmac_wrap( const unsigned char *key, size_t keylen,
|
|||
static void * sha512_ctx_alloc( void )
|
||||
{
|
||||
sha512_context *ctx;
|
||||
ctx = (sha512_context *) polarssl_malloc( sizeof( sha512_context ) );
|
||||
ctx = polarssl_malloc( sizeof( sha512_context ) );
|
||||
|
||||
if( ctx == NULL )
|
||||
return( NULL );
|
||||
|
|
|
@ -27,14 +27,14 @@
|
|||
#endif
|
||||
|
||||
#if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C)
|
||||
|
||||
#include "polarssl/memory_buffer_alloc.h"
|
||||
|
||||
/* No need for the header guard as POLARSSL_MEMORY_BUFFER_ALLOC_C
|
||||
is dependent upon POLARSSL_PLATFORM_C */
|
||||
#include "polarssl/platform.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(POLARSSL_MEMORY_DEBUG)
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
#if defined(POLARSSL_MEMORY_BACKTRACE)
|
||||
#include <execinfo.h>
|
||||
#endif
|
||||
|
@ -43,12 +43,6 @@
|
|||
#include "polarssl/threading.h"
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#define polarssl_fprintf fprintf
|
||||
#endif
|
||||
|
||||
/* Implementation that should never be optimized out by the compiler */
|
||||
static void polarssl_zeroize( void *v, size_t n ) {
|
||||
volatile unsigned char *p = v; while( n-- ) *p++ = 0;
|
||||
|
@ -81,7 +75,6 @@ typedef struct
|
|||
size_t len;
|
||||
memory_header *first;
|
||||
memory_header *first_free;
|
||||
size_t current_alloc_size;
|
||||
int verify;
|
||||
#if defined(POLARSSL_MEMORY_DEBUG)
|
||||
size_t malloc_count;
|
||||
|
@ -274,7 +267,7 @@ static void *buffer_alloc_malloc( size_t len )
|
|||
polarssl_fprintf( stderr, "FATAL: block in free_list but allocated "
|
||||
"data\n" );
|
||||
#endif
|
||||
exit( 1 );
|
||||
polarssl_exit( 1 );
|
||||
}
|
||||
|
||||
#if defined(POLARSSL_MEMORY_DEBUG)
|
||||
|
@ -313,7 +306,7 @@ static void *buffer_alloc_malloc( size_t len )
|
|||
#endif
|
||||
|
||||
if( ( heap.verify & MEMORY_VERIFY_ALLOC ) && verify_chain() != 0 )
|
||||
exit( 1 );
|
||||
polarssl_exit( 1 );
|
||||
|
||||
return( ( (unsigned char *) cur ) + sizeof(memory_header) );
|
||||
}
|
||||
|
@ -368,7 +361,7 @@ static void *buffer_alloc_malloc( size_t len )
|
|||
#endif
|
||||
|
||||
if( ( heap.verify & MEMORY_VERIFY_ALLOC ) && verify_chain() != 0 )
|
||||
exit( 1 );
|
||||
polarssl_exit( 1 );
|
||||
|
||||
return( ( (unsigned char *) cur ) + sizeof(memory_header) );
|
||||
}
|
||||
|
@ -387,14 +380,14 @@ static void buffer_alloc_free( void *ptr )
|
|||
polarssl_fprintf( stderr, "FATAL: polarssl_free() outside of managed "
|
||||
"space\n" );
|
||||
#endif
|
||||
exit( 1 );
|
||||
polarssl_exit( 1 );
|
||||
}
|
||||
|
||||
p -= sizeof(memory_header);
|
||||
hdr = (memory_header *) p;
|
||||
|
||||
if( verify_header( hdr ) != 0 )
|
||||
exit( 1 );
|
||||
polarssl_exit( 1 );
|
||||
|
||||
if( hdr->alloc != 1 )
|
||||
{
|
||||
|
@ -402,7 +395,7 @@ static void buffer_alloc_free( void *ptr )
|
|||
polarssl_fprintf( stderr, "FATAL: polarssl_free() on unallocated "
|
||||
"data\n" );
|
||||
#endif
|
||||
exit( 1 );
|
||||
polarssl_exit( 1 );
|
||||
}
|
||||
|
||||
hdr->alloc = 0;
|
||||
|
@ -492,7 +485,7 @@ static void buffer_alloc_free( void *ptr )
|
|||
#endif
|
||||
|
||||
if( ( heap.verify & MEMORY_VERIFY_FREE ) && verify_chain() != 0 )
|
||||
exit( 1 );
|
||||
polarssl_exit( 1 );
|
||||
}
|
||||
|
||||
void memory_buffer_set_verify( int verify )
|
||||
|
@ -525,6 +518,24 @@ void memory_buffer_alloc_status()
|
|||
debug_chain();
|
||||
}
|
||||
}
|
||||
|
||||
void memory_buffer_alloc_max_get( size_t *max_used, size_t *max_blocks )
|
||||
{
|
||||
*max_used = heap.maximum_used;
|
||||
*max_blocks = heap.maximum_header_count;
|
||||
}
|
||||
|
||||
void memory_buffer_alloc_max_reset( void )
|
||||
{
|
||||
heap.maximum_used = 0;
|
||||
heap.maximum_header_count = 0;
|
||||
}
|
||||
|
||||
void memory_buffer_alloc_cur_get( size_t *cur_used, size_t *cur_blocks )
|
||||
{
|
||||
*cur_used = heap.total_used;
|
||||
*cur_blocks = heap.header_count;
|
||||
}
|
||||
#endif /* POLARSSL_MEMORY_DEBUG */
|
||||
|
||||
#if defined(POLARSSL_THREADING_C)
|
||||
|
@ -600,7 +611,10 @@ static int check_pointer( void *p )
|
|||
|
||||
static int check_all_free( )
|
||||
{
|
||||
if( heap.current_alloc_size != 0 ||
|
||||
if(
|
||||
#if defined(POLARSSL_MEMORY_DEBUG)
|
||||
heap.total_used != 0 ||
|
||||
#endif
|
||||
heap.first != heap.first_free ||
|
||||
(void *) heap.first != (void *) heap.buf )
|
||||
{
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
|
||||
#include "polarssl/net.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if (defined(_WIN32) || defined(_WIN32_WCE)) && !defined(EFIX64) && \
|
||||
!defined(EFI32)
|
||||
|
||||
|
@ -127,6 +129,12 @@ typedef UINT32 uint32_t;
|
|||
(((unsigned long )(n) & 0xFF000000) >> 24))
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#define polarssl_snprintf snprintf
|
||||
#endif
|
||||
|
||||
unsigned short net_htons( unsigned short n );
|
||||
unsigned long net_htonl( unsigned long n );
|
||||
#define net_htons(n) POLARSSL_HTONS(n)
|
||||
|
@ -171,7 +179,7 @@ int net_connect( int *fd, const char *host, int port, int proto )
|
|||
|
||||
/* getaddrinfo expects port as a string */
|
||||
memset( port_str, 0, sizeof( port_str ) );
|
||||
snprintf( port_str, sizeof( port_str ), "%d", port );
|
||||
polarssl_snprintf( port_str, sizeof( port_str ), "%d", port );
|
||||
|
||||
/* Do name resolution with both IPv6 and IPv4 */
|
||||
memset( &hints, 0, sizeof( hints ) );
|
||||
|
@ -259,7 +267,7 @@ int net_bind( int *fd, const char *bind_ip, int port, int proto )
|
|||
|
||||
/* getaddrinfo expects port as a string */
|
||||
memset( port_str, 0, sizeof( port_str ) );
|
||||
snprintf( port_str, sizeof( port_str ), "%d", port );
|
||||
polarssl_snprintf( port_str, sizeof( port_str ), "%d", port );
|
||||
|
||||
/* Bind to IPv6 and/or IPv4, but only in TCP */
|
||||
memset( &hints, 0, sizeof( hints ) );
|
||||
|
|
|
@ -33,12 +33,19 @@
|
|||
#include "polarssl/oid.h"
|
||||
#include "polarssl/rsa.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#define polarssl_snprintf snprintf
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_X509_USE_C) || defined(POLARSSL_X509_CREATE_C)
|
||||
#include "polarssl/x509.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
* Macro to automatically add the size of #define'd OIDs
|
||||
*/
|
||||
|
@ -366,7 +373,7 @@ static const oid_sig_alg_t oid_sig_alg[] =
|
|||
},
|
||||
{
|
||||
{ NULL, 0, NULL, NULL },
|
||||
0, 0,
|
||||
POLARSSL_MD_NONE, POLARSSL_PK_NONE,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -400,7 +407,7 @@ static const oid_pk_alg_t oid_pk_alg[] =
|
|||
},
|
||||
{
|
||||
{ NULL, 0, NULL, NULL },
|
||||
0,
|
||||
POLARSSL_PK_NONE,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -465,7 +472,7 @@ static const oid_ecp_grp_t oid_ecp_grp[] =
|
|||
},
|
||||
{
|
||||
{ NULL, 0, NULL, NULL },
|
||||
0,
|
||||
POLARSSL_ECP_DP_NONE,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -495,7 +502,7 @@ static const oid_cipher_alg_t oid_cipher_alg[] =
|
|||
},
|
||||
{
|
||||
{ NULL, 0, NULL, NULL },
|
||||
0,
|
||||
POLARSSL_CIPHER_NONE,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -548,7 +555,7 @@ static const oid_md_alg_t oid_md_alg[] =
|
|||
},
|
||||
{
|
||||
{ NULL, 0, NULL, NULL },
|
||||
0,
|
||||
POLARSSL_MD_NONE,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -579,7 +586,7 @@ static const oid_pkcs12_pbe_alg_t oid_pkcs12_pbe_alg[] =
|
|||
},
|
||||
{
|
||||
{ NULL, 0, NULL, NULL },
|
||||
0, 0,
|
||||
POLARSSL_MD_NONE, POLARSSL_CIPHER_NONE,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -652,7 +659,7 @@ int oid_get_numeric_string( char *buf, size_t size,
|
|||
/* First byte contains first two dots */
|
||||
if( oid->len > 0 )
|
||||
{
|
||||
ret = snprintf( p, n, "%d.%d", oid->p[0] / 40, oid->p[0] % 40 );
|
||||
ret = polarssl_snprintf( p, n, "%d.%d", oid->p[0] / 40, oid->p[0] % 40 );
|
||||
SAFE_SNPRINTF();
|
||||
}
|
||||
|
||||
|
@ -669,7 +676,7 @@ int oid_get_numeric_string( char *buf, size_t size,
|
|||
if( !( oid->p[i] & 0x80 ) )
|
||||
{
|
||||
/* Last byte */
|
||||
ret = snprintf( p, n, ".%d", value );
|
||||
ret = polarssl_snprintf( p, n, ".%d", value );
|
||||
SAFE_SNPRINTF();
|
||||
value = 0;
|
||||
}
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
|
||||
#include "polarssl/padlock.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(POLARSSL_HAVE_X86)
|
||||
|
||||
/*
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#endif
|
||||
|
||||
#if defined(POLARSSL_PEM_PARSE_C) || defined(POLARSSL_PEM_WRITE_C)
|
||||
|
||||
#include "polarssl/pem.h"
|
||||
#include "polarssl/base64.h"
|
||||
#include "polarssl/des.h"
|
||||
|
@ -34,15 +35,16 @@
|
|||
#include "polarssl/md5.h"
|
||||
#include "polarssl/cipher.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#define polarssl_malloc malloc
|
||||
#define polarssl_free free
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Implementation that should never be optimized out by the compiler */
|
||||
static void polarssl_zeroize( void *v, size_t n ) {
|
||||
volatile unsigned char *p = v; while( n-- ) *p++ = 0;
|
||||
|
@ -319,7 +321,7 @@ int pem_read_buffer( pem_context *ctx, const char *header, const char *footer,
|
|||
if( ret == POLARSSL_ERR_BASE64_INVALID_CHARACTER )
|
||||
return( POLARSSL_ERR_PEM_INVALID_DATA + ret );
|
||||
|
||||
if( ( buf = (unsigned char *) polarssl_malloc( len ) ) == NULL )
|
||||
if( ( buf = polarssl_malloc( len ) ) == NULL )
|
||||
return( POLARSSL_ERR_PEM_MALLOC_FAILED );
|
||||
|
||||
if( ( ret = base64_decode( buf, &len, s1, s2 - s1 ) ) != 0 )
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#endif
|
||||
|
||||
#if defined(POLARSSL_PK_C)
|
||||
|
||||
#include "polarssl/pk.h"
|
||||
#include "polarssl/pk_wrap.h"
|
||||
|
||||
|
|
|
@ -27,12 +27,13 @@
|
|||
#endif
|
||||
|
||||
#if defined(POLARSSL_PK_C)
|
||||
|
||||
#include "polarssl/pk_wrap.h"
|
||||
|
||||
/* Even if RSA not activated, for the sake of RSA-alt */
|
||||
#include "polarssl/rsa.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(POLARSSL_ECP_C)
|
||||
#include "polarssl/ecp.h"
|
||||
#endif
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "polarssl/pkcs11.h"
|
||||
|
||||
#if defined(POLARSSL_PKCS11_C)
|
||||
|
||||
#include "polarssl/md.h"
|
||||
#include "polarssl/oid.h"
|
||||
#include "polarssl/x509_crt.h"
|
||||
|
|
|
@ -38,6 +38,8 @@
|
|||
#include "polarssl/asn1.h"
|
||||
#include "polarssl/cipher.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(POLARSSL_ARC4_C)
|
||||
#include "polarssl/arc4.h"
|
||||
#endif
|
||||
|
@ -196,7 +198,7 @@ int pkcs12_pbe( asn1_buf *pbe_params, int mode,
|
|||
if( ( ret = cipher_init_ctx( &cipher_ctx, cipher_info ) ) != 0 )
|
||||
goto exit;
|
||||
|
||||
if( ( ret = cipher_setkey( &cipher_ctx, key, 8 * keylen, mode ) ) != 0 )
|
||||
if( ( ret = cipher_setkey( &cipher_ctx, key, 8 * keylen, (operation_t) mode ) ) != 0 )
|
||||
goto exit;
|
||||
|
||||
if( ( ret = cipher_set_iv( &cipher_ctx, iv, cipher_info->iv_size ) ) != 0 )
|
||||
|
|
|
@ -43,9 +43,12 @@
|
|||
#include "polarssl/cipher.h"
|
||||
#include "polarssl/oid.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#define polarssl_printf printf
|
||||
#endif
|
||||
|
||||
|
@ -198,7 +201,7 @@ int pkcs5_pbes2( asn1_buf *pbe_params, int mode,
|
|||
if( ( ret = cipher_init_ctx( &cipher_ctx, cipher_info ) ) != 0 )
|
||||
goto exit;
|
||||
|
||||
if( ( ret = cipher_setkey( &cipher_ctx, key, 8 * keylen, mode ) ) != 0 )
|
||||
if( ( ret = cipher_setkey( &cipher_ctx, key, 8 * keylen, (operation_t) mode ) ) != 0 )
|
||||
goto exit;
|
||||
|
||||
if( ( ret = cipher_crypt( &cipher_ctx, iv, enc_scheme_params.len,
|
||||
|
@ -295,8 +298,6 @@ int pkcs5_self_test( int verbose )
|
|||
}
|
||||
#else
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define MAX_TESTS 6
|
||||
|
||||
size_t plen[MAX_TESTS] =
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
#include "polarssl/asn1.h"
|
||||
#include "polarssl/oid.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(POLARSSL_RSA_C)
|
||||
#include "polarssl/rsa.h"
|
||||
#endif
|
||||
|
@ -87,7 +89,7 @@ int pk_load_file( const char *path, unsigned char **buf, size_t *n )
|
|||
*n = (size_t) size;
|
||||
|
||||
if( *n + 1 == 0 ||
|
||||
( *buf = (unsigned char *) polarssl_malloc( *n + 1 ) ) == NULL )
|
||||
( *buf = polarssl_malloc( *n + 1 ) ) == NULL )
|
||||
{
|
||||
fclose( f );
|
||||
return( POLARSSL_ERR_PK_MALLOC_FAILED );
|
||||
|
@ -343,7 +345,7 @@ static int pk_group_from_specified( const asn1_buf *params, ecp_group *grp )
|
|||
/*
|
||||
* order INTEGER
|
||||
*/
|
||||
if( ( ret = asn1_get_mpi( &p, end, &grp->N ) ) )
|
||||
if( ( ret = asn1_get_mpi( &p, end, &grp->N ) ) != 0 )
|
||||
return( POLARSSL_ERR_PK_KEY_INVALID_FORMAT + ret );
|
||||
|
||||
grp->nbits = mpi_msb( &grp->N );
|
||||
|
@ -922,6 +924,7 @@ static int pk_parse_key_pkcs8_unencrypted_der(
|
|||
/*
|
||||
* Parse an encrypted PKCS#8 encoded private key
|
||||
*/
|
||||
#if defined(POLARSSL_PKCS12_C) || defined(POLARSSL_PKCS5_C)
|
||||
static int pk_parse_key_pkcs8_encrypted_der(
|
||||
pk_context *pk,
|
||||
const unsigned char *key, size_t keylen,
|
||||
|
@ -1039,6 +1042,7 @@ static int pk_parse_key_pkcs8_encrypted_der(
|
|||
|
||||
return( pk_parse_key_pkcs8_unencrypted_der( pk, buf, len ) );
|
||||
}
|
||||
#endif /* POLARSSL_PKCS12_C || POLARSSL_PKCS5_C */
|
||||
|
||||
/*
|
||||
* Parse a private key
|
||||
|
@ -1130,6 +1134,7 @@ int pk_parse_key( pk_context *pk,
|
|||
else if( ret != POLARSSL_ERR_PEM_NO_HEADER_FOOTER_PRESENT )
|
||||
return( ret );
|
||||
|
||||
#if defined(POLARSSL_PKCS12_C) || defined(POLARSSL_PKCS5_C)
|
||||
ret = pem_read_buffer( &pem,
|
||||
"-----BEGIN ENCRYPTED PRIVATE KEY-----",
|
||||
"-----END ENCRYPTED PRIVATE KEY-----",
|
||||
|
@ -1148,6 +1153,7 @@ int pk_parse_key( pk_context *pk,
|
|||
}
|
||||
else if( ret != POLARSSL_ERR_PEM_NO_HEADER_FOOTER_PRESENT )
|
||||
return( ret );
|
||||
#endif /* POLARSSL_PKCS12_C || POLARSSL_PKCS5_C */
|
||||
#else
|
||||
((void) pwd);
|
||||
((void) pwdlen);
|
||||
|
@ -1160,6 +1166,7 @@ int pk_parse_key( pk_context *pk,
|
|||
* We try the different DER format parsers to see if one passes without
|
||||
* error
|
||||
*/
|
||||
#if defined(POLARSSL_PKCS12_C) || defined(POLARSSL_PKCS5_C)
|
||||
if( ( ret = pk_parse_key_pkcs8_encrypted_der( pk, key, keylen,
|
||||
pwd, pwdlen ) ) == 0 )
|
||||
{
|
||||
|
@ -1172,6 +1179,7 @@ int pk_parse_key( pk_context *pk,
|
|||
{
|
||||
return( ret );
|
||||
}
|
||||
#endif /* POLARSSL_PKCS12_C || POLARSSL_PKCS5_C */
|
||||
|
||||
if( ( ret = pk_parse_key_pkcs8_unencrypted_der( pk, key, keylen ) ) == 0 )
|
||||
return( 0 );
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
#include "polarssl/asn1write.h"
|
||||
#include "polarssl/oid.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(POLARSSL_RSA_C)
|
||||
#include "polarssl/rsa.h"
|
||||
#endif
|
||||
|
|
|
@ -62,6 +62,36 @@ int platform_set_malloc_free( void * (*malloc_func)( size_t ),
|
|||
}
|
||||
#endif /* POLARSSL_PLATFORM_MEMORY */
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_SNPRINTF_ALT)
|
||||
#if !defined(POLARSSL_PLATFORM_STD_SNPRINTF)
|
||||
/*
|
||||
* Make dummy function to prevent NULL pointer dereferences
|
||||
*/
|
||||
static int platform_snprintf_uninit( char * s, size_t n,
|
||||
const char * format, ... )
|
||||
{
|
||||
((void) s);
|
||||
((void) n);
|
||||
((void) format)
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
#define POLARSSL_PLATFORM_STD_SNPRINTF platform_snprintf_uninit
|
||||
#endif /* !POLARSSL_PLATFORM_STD_SNPRINTF */
|
||||
|
||||
int (*polarssl_snprintf)( char * s, size_t n,
|
||||
const char * format,
|
||||
... ) = POLARSSL_PLATFORM_STD_SNPRINTF;
|
||||
|
||||
int platform_set_snprintf( int (*snprintf_func)( char * s, size_t n,
|
||||
const char * format,
|
||||
... ) )
|
||||
{
|
||||
polarssl_snprintf = snprintf_func;
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* POLARSSL_PLATFORM_SNPRINTF_ALT */
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_PRINTF_ALT)
|
||||
#if !defined(POLARSSL_PLATFORM_STD_PRINTF)
|
||||
/*
|
||||
|
@ -110,4 +140,27 @@ int platform_set_fprintf( int (*fprintf_func)( FILE *, const char *, ... ) )
|
|||
}
|
||||
#endif /* POLARSSL_PLATFORM_FPRINTF_ALT */
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_EXIT_ALT)
|
||||
#if !defined(POLARSSL_STD_EXIT)
|
||||
/*
|
||||
* Make dummy function to prevent NULL pointer dereferences
|
||||
*/
|
||||
static void platform_exit_uninit( int status )
|
||||
{
|
||||
((void) status);
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
#define POLARSSL_STD_EXIT platform_exit_uninit
|
||||
#endif /* !POLARSSL_STD_EXIT */
|
||||
|
||||
int (*polarssl_exit)( int status ) = POLARSSL_STD_EXIT;
|
||||
|
||||
int platform_set_exit( void (*exit_func)( int status ) )
|
||||
{
|
||||
polarssl_exit = exit_func;
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* POLARSSL_PLATFORM_EXIT_ALT */
|
||||
|
||||
#endif /* POLARSSL_PLATFORM_C */
|
||||
|
|
|
@ -36,19 +36,20 @@
|
|||
|
||||
#include "polarssl/ripemd160.h"
|
||||
|
||||
#if defined(POLARSSL_FS_IO) || defined(POLARSSL_SELF_TEST)
|
||||
#include <string.h>
|
||||
|
||||
#if defined(POLARSSL_FS_IO)
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_SELF_TEST)
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#define polarssl_printf printf
|
||||
#endif
|
||||
#endif /* POLARSSL_PLATFORM_C */
|
||||
#endif /* POLARSSL_SELF_TEST */
|
||||
|
||||
/*
|
||||
* 32-bit integer manipulation macros (little endian)
|
||||
|
|
|
@ -37,16 +37,20 @@
|
|||
#include "polarssl/rsa.h"
|
||||
#include "polarssl/oid.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(POLARSSL_PKCS1_V21)
|
||||
#include "polarssl/md.h"
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_PKCS1_V15) && !defined(__OpenBSD__)
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#define polarssl_printf printf
|
||||
#endif
|
||||
|
||||
|
@ -522,7 +526,7 @@ int rsa_rsaes_oaep_encrypt( rsa_context *ctx,
|
|||
if( f_rng == NULL )
|
||||
return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
|
||||
|
||||
md_info = md_info_from_type( ctx->hash_id );
|
||||
md_info = md_info_from_type( (md_type_t) ctx->hash_id );
|
||||
if( md_info == NULL )
|
||||
return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
|
||||
|
||||
|
@ -701,7 +705,7 @@ int rsa_rsaes_oaep_decrypt( rsa_context *ctx,
|
|||
if( ilen < 16 || ilen > sizeof( buf ) )
|
||||
return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
|
||||
|
||||
md_info = md_info_from_type( ctx->hash_id );
|
||||
md_info = md_info_from_type( (md_type_t) ctx->hash_id );
|
||||
if( md_info == NULL )
|
||||
return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
|
||||
|
||||
|
@ -939,7 +943,7 @@ int rsa_rsassa_pss_sign( rsa_context *ctx,
|
|||
hashlen = md_get_size( md_info );
|
||||
}
|
||||
|
||||
md_info = md_info_from_type( ctx->hash_id );
|
||||
md_info = md_info_from_type( (md_type_t) ctx->hash_id );
|
||||
if( md_info == NULL )
|
||||
return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );
|
||||
|
||||
|
|
|
@ -35,15 +35,20 @@
|
|||
|
||||
#include "polarssl/sha1.h"
|
||||
|
||||
#if defined(POLARSSL_FS_IO) || defined(POLARSSL_SELF_TEST)
|
||||
#include <string.h>
|
||||
|
||||
#if defined(POLARSSL_FS_IO)
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_SELF_TEST)
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#define polarssl_printf printf
|
||||
#endif
|
||||
#endif /* POLARSSL_PLATFORM_C */
|
||||
#endif /* POLARSSL_SELF_TEST */
|
||||
|
||||
/* Implementation that should never be optimized out by the compiler */
|
||||
static void polarssl_zeroize( void *v, size_t n ) {
|
||||
|
@ -617,7 +622,7 @@ int sha1_self_test( int verbose )
|
|||
|
||||
if( i == 5 || i == 6 )
|
||||
{
|
||||
memset( buf, '\xAA', buflen = 80 );
|
||||
memset( buf, 0xAA, buflen = 80 );
|
||||
sha1_hmac_starts( &ctx, buf, buflen );
|
||||
}
|
||||
else
|
||||
|
|
|
@ -35,15 +35,20 @@
|
|||
|
||||
#include "polarssl/sha256.h"
|
||||
|
||||
#if defined(POLARSSL_FS_IO) || defined(POLARSSL_SELF_TEST)
|
||||
#include <string.h>
|
||||
|
||||
#if defined(POLARSSL_FS_IO)
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_SELF_TEST)
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#define polarssl_printf printf
|
||||
#endif
|
||||
#endif /* POLARSSL_PLATFORM_C */
|
||||
#endif /* POLARSSL_SELF_TEST */
|
||||
|
||||
/* Implementation that should never be optimized out by the compiler */
|
||||
static void polarssl_zeroize( void *v, size_t n ) {
|
||||
|
@ -698,7 +703,7 @@ int sha256_self_test( int verbose )
|
|||
|
||||
if( j == 5 || j == 6 )
|
||||
{
|
||||
memset( buf, '\xAA', buflen = 131 );
|
||||
memset( buf, 0xAA, buflen = 131 );
|
||||
sha256_hmac_starts( &ctx, buf, buflen, k );
|
||||
}
|
||||
else
|
||||
|
|
|
@ -35,15 +35,20 @@
|
|||
|
||||
#include "polarssl/sha512.h"
|
||||
|
||||
#if defined(POLARSSL_FS_IO) || defined(POLARSSL_SELF_TEST)
|
||||
#include <string.h>
|
||||
|
||||
#if defined(POLARSSL_FS_IO)
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_SELF_TEST)
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#define polarssl_printf printf
|
||||
#endif
|
||||
#endif /* POLARSSL_PLATFORM_C */
|
||||
#endif /* POLARSSL_SELF_TEST */
|
||||
|
||||
/* Implementation that should never be optimized out by the compiler */
|
||||
static void polarssl_zeroize( void *v, size_t n ) {
|
||||
|
@ -752,7 +757,7 @@ int sha512_self_test( int verbose )
|
|||
|
||||
if( j == 5 || j == 6 )
|
||||
{
|
||||
memset( buf, '\xAA', buflen = 131 );
|
||||
memset( buf, 0xAA, buflen = 131 );
|
||||
sha512_hmac_starts( &ctx, buf, buflen, k );
|
||||
}
|
||||
else
|
||||
|
|
|
@ -34,15 +34,16 @@
|
|||
|
||||
#include "polarssl/ssl_cache.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#define polarssl_malloc malloc
|
||||
#define polarssl_free free
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
void ssl_cache_init( ssl_cache_context *cache )
|
||||
{
|
||||
memset( cache, 0, sizeof( ssl_cache_context ) );
|
||||
|
@ -102,7 +103,7 @@ int ssl_cache_get( void *data, ssl_session *session )
|
|||
*/
|
||||
if( entry->peer_cert.p != NULL )
|
||||
{
|
||||
if( ( session->peer_cert = (x509_crt *) polarssl_malloc(
|
||||
if( ( session->peer_cert = polarssl_malloc(
|
||||
sizeof(x509_crt) ) ) == NULL )
|
||||
{
|
||||
ret = 1;
|
||||
|
@ -221,7 +222,7 @@ int ssl_cache_set( void *data, const ssl_session *session )
|
|||
/*
|
||||
* max_entries not reached, create new entry
|
||||
*/
|
||||
cur = (ssl_cache_entry *) polarssl_malloc( sizeof(ssl_cache_entry) );
|
||||
cur = polarssl_malloc( sizeof(ssl_cache_entry) );
|
||||
if( cur == NULL )
|
||||
{
|
||||
ret = 1;
|
||||
|
@ -258,8 +259,7 @@ int ssl_cache_set( void *data, const ssl_session *session )
|
|||
*/
|
||||
if( session->peer_cert != NULL )
|
||||
{
|
||||
cur->peer_cert.p = (unsigned char *) polarssl_malloc(
|
||||
session->peer_cert->raw.len );
|
||||
cur->peer_cert.p = polarssl_malloc( session->peer_cert->raw.len );
|
||||
if( cur->peer_cert.p == NULL )
|
||||
{
|
||||
ret = 1;
|
||||
|
|
|
@ -33,7 +33,8 @@
|
|||
#include "polarssl/ssl_ciphersuites.h"
|
||||
#include "polarssl/ssl.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
// #include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(_MSC_VER) && !defined strcasecmp && !defined(EFIX64) && \
|
||||
!defined(EFI32)
|
||||
|
@ -1673,7 +1674,9 @@ static const ssl_ciphersuite_t ciphersuite_definitions[] =
|
|||
#endif /* POLARSSL_DES_C */
|
||||
#endif /* POLARSSL_ENABLE_WEAK_CIPHERSUITES */
|
||||
|
||||
{ 0, "", 0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
{ 0, "",
|
||||
POLARSSL_CIPHER_NONE, POLARSSL_MD_NONE, POLARSSL_KEY_EXCHANGE_NONE,
|
||||
0, 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
#if defined(SSL_CIPHERSUITES)
|
||||
|
|
|
@ -31,16 +31,16 @@
|
|||
#include "polarssl/debug.h"
|
||||
#include "polarssl/ssl.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#define polarssl_malloc malloc
|
||||
#define polarssl_free free
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
|
||||
#include <basetsd.h>
|
||||
typedef UINT32 uint32_t;
|
||||
|
|
|
@ -41,6 +41,8 @@
|
|||
#define polarssl_free free
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/* Implementation that should never be optimized out by the compiler */
|
||||
static void polarssl_zeroize( void *v, size_t n ) {
|
||||
volatile unsigned char *p = v; while( n-- ) *p++ = 0;
|
||||
|
|
|
@ -30,6 +30,9 @@
|
|||
|
||||
#include "polarssl/debug.h"
|
||||
#include "polarssl/ssl.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(POLARSSL_ECP_C)
|
||||
#include "polarssl/ecp.h"
|
||||
#endif
|
||||
|
@ -37,13 +40,11 @@
|
|||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#define polarssl_malloc malloc
|
||||
#define polarssl_free free
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined(POLARSSL_HAVE_TIME)
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
@ -3220,7 +3221,6 @@ static int ssl_parse_encrypted_pms( ssl_context *ssl,
|
|||
unsigned char ver[2];
|
||||
unsigned char fake_pms[48], peer_pms[48];
|
||||
unsigned char mask;
|
||||
unsigned int uret;
|
||||
size_t i;
|
||||
|
||||
if( ! pk_can_do( ssl_own_key( ssl ), POLARSSL_PK_RSA ) )
|
||||
|
@ -3287,10 +3287,7 @@ static int ssl_parse_encrypted_pms( ssl_context *ssl,
|
|||
}
|
||||
ssl->handshake->pmslen = 48;
|
||||
|
||||
uret = (unsigned) ret;
|
||||
uret |= -uret; /* msb = ( ret != 0 ) */
|
||||
uret >>= 8 * sizeof( uret ) - 1; /* uret = ( ret != 0 ) */
|
||||
mask = (unsigned char)( -uret ) ; /* ret ? 0xff : 0x00 */
|
||||
mask = (unsigned char)( - ( ret != 0 ) ); /* ret ? 0xff : 0x00 */
|
||||
for( i = 0; i < ssl->handshake->pmslen; i++ )
|
||||
pms[i] = ( mask & fake_pms[i] ) | ( (~mask) & peer_pms[i] );
|
||||
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
#include "polarssl/debug.h"
|
||||
#include "polarssl/ssl.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(POLARSSL_X509_CRT_PARSE_C) && \
|
||||
defined(POLARSSL_X509_CHECK_EXTENDED_KEY_USAGE)
|
||||
#include "polarssl/oid.h"
|
||||
|
@ -47,12 +49,11 @@
|
|||
#if defined(POLARSSL_PLATFORM_C)
|
||||
#include "polarssl/platform.h"
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#define polarssl_malloc malloc
|
||||
#define polarssl_free free
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#if defined(_MSC_VER) && !defined strcasecmp && !defined(EFIX64) && \
|
||||
!defined(EFI32)
|
||||
#define strcasecmp _stricmp
|
||||
|
@ -166,7 +167,7 @@ static int ssl_session_copy( ssl_session *dst, const ssl_session *src )
|
|||
{
|
||||
int ret;
|
||||
|
||||
dst->peer_cert = (x509_crt *) polarssl_malloc( sizeof(x509_crt) );
|
||||
dst->peer_cert = polarssl_malloc( sizeof(x509_crt) );
|
||||
if( dst->peer_cert == NULL )
|
||||
return( POLARSSL_ERR_SSL_MALLOC_FAILED );
|
||||
|
||||
|
@ -185,7 +186,7 @@ static int ssl_session_copy( ssl_session *dst, const ssl_session *src )
|
|||
#if defined(POLARSSL_SSL_SESSION_TICKETS)
|
||||
if( src->ticket != NULL )
|
||||
{
|
||||
dst->ticket = (unsigned char *) polarssl_malloc( src->ticket_len );
|
||||
dst->ticket = polarssl_malloc( src->ticket_len );
|
||||
if( dst->ticket == NULL )
|
||||
return( POLARSSL_ERR_SSL_MALLOC_FAILED );
|
||||
|
||||
|
@ -1553,7 +1554,7 @@ static int ssl_decrypt_buf( ssl_context *ssl )
|
|||
unsigned char explicit_iv_len = ssl->transform_in->ivlen -
|
||||
ssl->transform_in->fixed_ivlen;
|
||||
|
||||
if( ssl->in_msglen < explicit_iv_len + taglen )
|
||||
if( ssl->in_msglen < (size_t) explicit_iv_len + taglen )
|
||||
{
|
||||
SSL_DEBUG_MSG( 1, ( "msglen (%d) < explicit_iv_len (%d) "
|
||||
"+ taglen (%d)", ssl->in_msglen,
|
||||
|
@ -3892,7 +3893,7 @@ int ssl_parse_certificate( ssl_context *ssl )
|
|||
polarssl_free( ssl->session_negotiate->peer_cert );
|
||||
}
|
||||
|
||||
if( ( ssl->session_negotiate->peer_cert = (x509_crt *) polarssl_malloc(
|
||||
if( ( ssl->session_negotiate->peer_cert = polarssl_malloc(
|
||||
sizeof( x509_crt ) ) ) == NULL )
|
||||
{
|
||||
SSL_DEBUG_MSG( 1, ( "malloc(%d bytes) failed",
|
||||
|
@ -4798,20 +4799,17 @@ static int ssl_handshake_init( ssl_context *ssl )
|
|||
*/
|
||||
if( ssl->transform_negotiate == NULL )
|
||||
{
|
||||
ssl->transform_negotiate = (ssl_transform *) polarssl_malloc(
|
||||
sizeof(ssl_transform) );
|
||||
ssl->transform_negotiate = polarssl_malloc( sizeof(ssl_transform) );
|
||||
}
|
||||
|
||||
if( ssl->session_negotiate == NULL )
|
||||
{
|
||||
ssl->session_negotiate = (ssl_session *) polarssl_malloc(
|
||||
sizeof(ssl_session) );
|
||||
ssl->session_negotiate = polarssl_malloc( sizeof(ssl_session) );
|
||||
}
|
||||
|
||||
if( ssl->handshake == NULL )
|
||||
{
|
||||
ssl->handshake = (ssl_handshake_params *)
|
||||
polarssl_malloc( sizeof(ssl_handshake_params) );
|
||||
ssl->handshake = polarssl_malloc( sizeof(ssl_handshake_params) );
|
||||
}
|
||||
|
||||
/* All pointers should exist and can be directly freed without issue */
|
||||
|
@ -4927,8 +4925,8 @@ int ssl_init( ssl_context *ssl )
|
|||
/*
|
||||
* Prepare base structures
|
||||
*/
|
||||
ssl->in_buf = (unsigned char *) polarssl_malloc( len );
|
||||
ssl->out_buf = (unsigned char *) polarssl_malloc( len );
|
||||
ssl->in_buf = polarssl_malloc( len );
|
||||
ssl->out_buf = polarssl_malloc( len );
|
||||
|
||||
if( ssl->in_buf == NULL || ssl->out_buf == NULL )
|
||||
{
|
||||
|
@ -5098,7 +5096,7 @@ static int ssl_ticket_keys_init( ssl_context *ssl )
|
|||
if( ssl->ticket_keys != NULL )
|
||||
return( 0 );
|
||||
|
||||
tkeys = (ssl_ticket_keys *) polarssl_malloc( sizeof(ssl_ticket_keys) );
|
||||
tkeys = polarssl_malloc( sizeof(ssl_ticket_keys) );
|
||||
if( tkeys == NULL )
|
||||
return( POLARSSL_ERR_SSL_MALLOC_FAILED );
|
||||
|
||||
|
@ -5350,7 +5348,7 @@ static ssl_key_cert *ssl_add_key_cert( ssl_context *ssl )
|
|||
{
|
||||
ssl_key_cert *key_cert, *last;
|
||||
|
||||
key_cert = (ssl_key_cert *) polarssl_malloc( sizeof(ssl_key_cert) );
|
||||
key_cert = polarssl_malloc( sizeof(ssl_key_cert) );
|
||||
if( key_cert == NULL )
|
||||
return( NULL );
|
||||
|
||||
|
@ -5406,7 +5404,7 @@ int ssl_set_own_cert_rsa( ssl_context *ssl, x509_crt *own_cert,
|
|||
if( key_cert == NULL )
|
||||
return( POLARSSL_ERR_SSL_MALLOC_FAILED );
|
||||
|
||||
key_cert->key = (pk_context *) polarssl_malloc( sizeof(pk_context) );
|
||||
key_cert->key = polarssl_malloc( sizeof(pk_context) );
|
||||
if( key_cert->key == NULL )
|
||||
return( POLARSSL_ERR_SSL_MALLOC_FAILED );
|
||||
|
||||
|
@ -5438,7 +5436,7 @@ int ssl_set_own_cert_alt( ssl_context *ssl, x509_crt *own_cert,
|
|||
if( key_cert == NULL )
|
||||
return( POLARSSL_ERR_SSL_MALLOC_FAILED );
|
||||
|
||||
key_cert->key = (pk_context *) polarssl_malloc( sizeof(pk_context) );
|
||||
key_cert->key = polarssl_malloc( sizeof(pk_context) );
|
||||
if( key_cert->key == NULL )
|
||||
return( POLARSSL_ERR_SSL_MALLOC_FAILED );
|
||||
|
||||
|
@ -5474,9 +5472,8 @@ int ssl_set_psk( ssl_context *ssl, const unsigned char *psk, size_t psk_len,
|
|||
ssl->psk_len = psk_len;
|
||||
ssl->psk_identity_len = psk_identity_len;
|
||||
|
||||
ssl->psk = (unsigned char *) polarssl_malloc( ssl->psk_len );
|
||||
ssl->psk_identity = (unsigned char *)
|
||||
polarssl_malloc( ssl->psk_identity_len );
|
||||
ssl->psk = polarssl_malloc( ssl->psk_len );
|
||||
ssl->psk_identity = polarssl_malloc( ssl->psk_identity_len );
|
||||
|
||||
if( ssl->psk == NULL || ssl->psk_identity == NULL )
|
||||
return( POLARSSL_ERR_SSL_MALLOC_FAILED );
|
||||
|
@ -5558,7 +5555,7 @@ int ssl_set_hostname( ssl_context *ssl, const char *hostname )
|
|||
if( ssl->hostname_len + 1 == 0 )
|
||||
return( POLARSSL_ERR_SSL_BAD_INPUT_DATA );
|
||||
|
||||
ssl->hostname = (unsigned char *) polarssl_malloc( ssl->hostname_len + 1 );
|
||||
ssl->hostname = polarssl_malloc( ssl->hostname_len + 1 );
|
||||
|
||||
if( ssl->hostname == NULL )
|
||||
return( POLARSSL_ERR_SSL_MALLOC_FAILED );
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue