mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-06-21 23:00:39 +08:00
feat(esp-wolfssl): add esp-wolfssl component
It is from original component "ssl".
This commit is contained in:
@ -9,7 +9,6 @@ menu "ESP-TLS"
|
||||
config ESP_TLS_USING_MBEDTLS
|
||||
bool "mbedTLS"
|
||||
config ESP_TLS_USING_WOLFSSL
|
||||
depends on TLS_STACK_WOLFSSL
|
||||
bool "wolfSSL (License info in wolfSSL directory README)"
|
||||
endchoice
|
||||
|
||||
|
16
components/esp-wolfssl/CMakeLists.txt
Normal file
16
components/esp-wolfssl/CMakeLists.txt
Normal file
@ -0,0 +1,16 @@
|
||||
|
||||
if(CONFIG_ESP_WOLFSSL_INTERNAL)
|
||||
set(COMPONENT_ADD_INCLUDEDIRS wolfssl/include wolfssl/wolfssl wolfssl/wolfssl/wolfssl)
|
||||
set(COMPONENT_SRCDIRS "wolfssl/source")
|
||||
|
||||
set(COMPONENT_REQUIRES "lwip" "esp8266" "util")
|
||||
endif()
|
||||
|
||||
register_component()
|
||||
|
||||
if(CONFIG_ESP_WOLFSSL_INTERNAL)
|
||||
target_compile_options(${COMPONENT_NAME} PUBLIC -DWOLFSSL_USER_SETTINGS)
|
||||
|
||||
target_link_libraries(${COMPONENT_NAME} "-L ${CMAKE_CURRENT_SOURCE_DIR}/wolfssl/lib")
|
||||
target_link_libraries(${COMPONENT_NAME} wolfssl)
|
||||
endif()
|
11
components/esp-wolfssl/Kconfig
Normal file
11
components/esp-wolfssl/Kconfig
Normal file
@ -0,0 +1,11 @@
|
||||
menu "esp-wolfssl(internal)"
|
||||
|
||||
config ESP_WOLFSSL_INTERNAL
|
||||
bool "Enable esp-wolfssl(internal)"
|
||||
default n
|
||||
help
|
||||
Enable esp-wolfssl(internal).
|
||||
|
||||
If users want to use external wolfssl, please disable this option.
|
||||
|
||||
endmenu
|
10
components/esp-wolfssl/Makefile.projbuild
Normal file
10
components/esp-wolfssl/Makefile.projbuild
Normal file
@ -0,0 +1,10 @@
|
||||
# Anyone compiling mbedTLS code needs the name of the
|
||||
# alternative config file
|
||||
|
||||
#ifdef CONFIG_SSL_USING_MBEDTLS
|
||||
CPPFLAGS += -DMBEDTLS_CONFIG_FILE='"mbedtls/esp_config.h"'
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SSL_USING_WOLFSSL
|
||||
CPPFLAGS += -DWOLFSSL_USER_SETTINGS
|
||||
#endif
|
18
components/esp-wolfssl/component.mk
Normal file
18
components/esp-wolfssl/component.mk
Normal file
@ -0,0 +1,18 @@
|
||||
#
|
||||
# Component Makefile
|
||||
#
|
||||
|
||||
ifdef CONFIG_ESP_WOLFSSL_INTERNAL
|
||||
COMPONENT_ADD_INCLUDEDIRS := wolfssl/include wolfssl/wolfssl wolfssl/wolfssl/wolfssl
|
||||
|
||||
ifdef CONFIG_WOLFSSL_DEBUG
|
||||
WOLFSSLLIB = wolfssl_debug
|
||||
COMPONENT_ADD_LDFLAGS := -L $(COMPONENT_PATH)/wolfssl/lib -lwolfssl_debug
|
||||
else
|
||||
WOLFSSLLIB = wolfssl
|
||||
COMPONENT_ADD_LDFLAGS := -L $(COMPONENT_PATH)/wolfssl/lib -lwolfssl
|
||||
endif
|
||||
|
||||
# re-link program if wolfssl library change
|
||||
COMPONENT_ADD_LINKER_DEPS := $(patsubst %,$(COMPONENT_PATH)/wolfssl/lib/lib%.a,$(WOLFSSLLIB))
|
||||
endif
|
8
components/esp-wolfssl/wolfssl/README
Normal file
8
components/esp-wolfssl/wolfssl/README
Normal file
@ -0,0 +1,8 @@
|
||||
Espressif has a license to distribute wolfSSL royalty-free in binary form on all Espressif MCU products.
|
||||
You can use the binary wolfSSL library on Espressif devices in products, without additional royalty costs.
|
||||
The binary library does not include wolfSSL features for TLS 1.3, FIPS or DTLS 1.2.
|
||||
|
||||
Updates to these wolfSSL binary libraries will be available until at least March 2021.
|
||||
|
||||
To discuss additional features, additional support and updates, or to obtain a quote for
|
||||
other individual licensing options then please contact licensing@wolfssl.com
|
66
components/esp-wolfssl/wolfssl/include/user_settings.h
Normal file
66
components/esp-wolfssl/wolfssl/include/user_settings.h
Normal file
@ -0,0 +1,66 @@
|
||||
/* user_settings.h
|
||||
*
|
||||
* Copyright (C) 2006-2017 wolfSSL Inc. All rights reserved.
|
||||
* Additions Copyright 2018 Espressif Systems (Shanghai) PTE LTD.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is distributed in binary form as licensed by Espressif Systems.
|
||||
* See README file or contact licensing@wolfssl.com with any questions or comments.
|
||||
*
|
||||
* http://www.wolfssl.com
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __USER_SETTINGS_H__
|
||||
#define __USER_SETTINGS_H__
|
||||
|
||||
#define WOLFSSL_LWIP
|
||||
#define NO_WRITEV
|
||||
#define NO_WOLFSSL_DIR
|
||||
#define NO_INLINE
|
||||
#define NO_WOLFSSL_MEMORY
|
||||
#define HAVE_PK_CALLBACKS
|
||||
#define WOLFSSL_KEY_GEN
|
||||
#define WOLFSSL_RIPEMD
|
||||
#define USE_WOLFSSL_IO
|
||||
#define WOLFSSL_STATIC_RSA
|
||||
#define NO_DH
|
||||
#define NO_MD4
|
||||
#define NO_DES3
|
||||
#define NO_DSA
|
||||
#define NO_RC4
|
||||
#define NO_RABBIT
|
||||
#define HAVE_ECC
|
||||
#define HAVE_AES_ECB
|
||||
#define WOLFSSL_AES_DIRECT
|
||||
#define WC_NO_HARDEN
|
||||
#define FREERTOS
|
||||
#define WOLFSSL_TYPES
|
||||
#define NO_FILESYSTEM
|
||||
#define WOLFSSL_ALT_CERT_CHAINS
|
||||
#define WOLFSSL_ALLOW_TLSV10
|
||||
#define WOLFSSL_SMALL_STACK
|
||||
#define SMALL_SESSION_CACHE
|
||||
#define OPENSSL_EXTRA
|
||||
|
||||
#define SSL_CTX_use_certificate_ASN1(ctx,len,buf) wolfSSL_CTX_use_certificate_buffer(ctx,buf,len,WOLFSSL_FILETYPE_PEM)
|
||||
#define SSL_CTX_use_PrivateKey_ASN1(type,ctx,buf,len) wolfSSL_CTX_use_PrivateKey_buffer(ctx,buf,len, WOLFSSL_FILETYPE_PEM)
|
||||
#define SSL_CTX_load_verify_buffer(ctx,buf,len) wolfSSL_CTX_load_verify_buffer(ctx,buf,len, WOLFSSL_FILETYPE_PEM)
|
||||
|
||||
#ifdef WOLFSSL_TYPES
|
||||
#ifndef byte
|
||||
typedef unsigned char byte;
|
||||
#endif
|
||||
typedef unsigned short word16;
|
||||
typedef unsigned int word32;
|
||||
typedef byte word24[3];
|
||||
#endif
|
||||
|
||||
#ifndef CUSTOM_RAND_GENERATE_BLOCK
|
||||
#include "esp_libc.h"
|
||||
/* To use define the following:*/
|
||||
#define CUSTOM_RAND_GENERATE_BLOCK os_get_random
|
||||
#endif
|
||||
|
||||
#endif
|
BIN
components/esp-wolfssl/wolfssl/lib/libwolfssl.a
Normal file
BIN
components/esp-wolfssl/wolfssl/lib/libwolfssl.a
Normal file
Binary file not shown.
BIN
components/esp-wolfssl/wolfssl/lib/libwolfssl_debug.a
Normal file
BIN
components/esp-wolfssl/wolfssl/lib/libwolfssl_debug.a
Normal file
Binary file not shown.
1
components/esp-wolfssl/wolfssl/source/cmake_compiling.c
Normal file
1
components/esp-wolfssl/wolfssl/source/cmake_compiling.c
Normal file
@ -0,0 +1 @@
|
||||
// Just for passing cmake project compiling.
|
@ -0,0 +1,51 @@
|
||||
/* asn1.h
|
||||
*
|
||||
* Copyright (C) 2006-2018 wolfSSL Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is distributed in binary form as licensed by Espressif Systems.
|
||||
* See README file or contact licensing@wolfssl.com with any questions or comments.
|
||||
*
|
||||
* https://www.wolfssl.com
|
||||
*/
|
||||
|
||||
|
||||
/* asn1.h for openssl */
|
||||
|
||||
#ifndef WOLFSSL_ASN1_H_
|
||||
#define WOLFSSL_ASN1_H_
|
||||
|
||||
#include <wolfssl/openssl/ssl.h>
|
||||
|
||||
#define ASN1_STRING_new wolfSSL_ASN1_STRING_type_new
|
||||
#define ASN1_STRING_type_new wolfSSL_ASN1_STRING_type_new
|
||||
#define ASN1_STRING_set wolfSSL_ASN1_STRING_set
|
||||
#define ASN1_STRING_free wolfSSL_ASN1_STRING_free
|
||||
|
||||
#define V_ASN1_OCTET_STRING 0x04 /* tag for ASN1_OCTET_STRING */
|
||||
#define V_ASN1_NEG 0x100
|
||||
#define V_ASN1_NEG_INTEGER (2 | V_ASN1_NEG)
|
||||
#define V_ASN1_NEG_ENUMERATED (10 | V_ASN1_NEG)
|
||||
|
||||
/* Type for ASN1_print_ex */
|
||||
# define ASN1_STRFLGS_ESC_2253 1
|
||||
# define ASN1_STRFLGS_ESC_CTRL 2
|
||||
# define ASN1_STRFLGS_ESC_MSB 4
|
||||
# define ASN1_STRFLGS_ESC_QUOTE 8
|
||||
# define ASN1_STRFLGS_UTF8_CONVERT 0x10
|
||||
# define ASN1_STRFLGS_IGNORE_TYPE 0x20
|
||||
# define ASN1_STRFLGS_SHOW_TYPE 0x40
|
||||
# define ASN1_STRFLGS_DUMP_ALL 0x80
|
||||
# define ASN1_STRFLGS_DUMP_UNKNOWN 0x100
|
||||
# define ASN1_STRFLGS_DUMP_DER 0x200
|
||||
# define ASN1_STRFLGS_RFC2253 (ASN1_STRFLGS_ESC_2253 | \
|
||||
ASN1_STRFLGS_ESC_CTRL | \
|
||||
ASN1_STRFLGS_ESC_MSB | \
|
||||
ASN1_STRFLGS_UTF8_CONVERT | \
|
||||
ASN1_STRFLGS_DUMP_UNKNOWN | \
|
||||
ASN1_STRFLGS_DUMP_DER)
|
||||
|
||||
#define MBSTRING_UTF8 0x1000
|
||||
|
||||
#endif /* WOLFSSL_ASN1_H_ */
|
181
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/openssl/bn.h
Normal file
181
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/openssl/bn.h
Normal file
@ -0,0 +1,181 @@
|
||||
/* bn.h
|
||||
*
|
||||
* Copyright (C) 2006-2018 wolfSSL Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is distributed in binary form as licensed by Espressif Systems.
|
||||
* See README file or contact licensing@wolfssl.com with any questions or comments.
|
||||
*
|
||||
* https://www.wolfssl.com
|
||||
*/
|
||||
|
||||
|
||||
/* bn.h for openssl */
|
||||
|
||||
/*!
|
||||
\file wolfssl/openssl/bn.h
|
||||
\brief bn.h for openssl
|
||||
*/
|
||||
|
||||
|
||||
#ifndef WOLFSSL_BN_H_
|
||||
#define WOLFSSL_BN_H_
|
||||
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
#include <wolfssl/wolfcrypt/integer.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct WOLFSSL_BIGNUM {
|
||||
int neg; /* openssh deference */
|
||||
void* internal; /* our big num */
|
||||
} WOLFSSL_BIGNUM;
|
||||
|
||||
|
||||
#define WOLFSSL_BN_ULONG mp_digit
|
||||
|
||||
typedef struct WOLFSSL_BN_CTX WOLFSSL_BN_CTX;
|
||||
typedef struct WOLFSSL_BN_GENCB WOLFSSL_BN_GENCB;
|
||||
|
||||
WOLFSSL_API WOLFSSL_BN_CTX* wolfSSL_BN_CTX_new(void);
|
||||
WOLFSSL_API void wolfSSL_BN_CTX_init(WOLFSSL_BN_CTX*);
|
||||
WOLFSSL_API void wolfSSL_BN_CTX_free(WOLFSSL_BN_CTX*);
|
||||
|
||||
WOLFSSL_API WOLFSSL_BIGNUM* wolfSSL_BN_new(void);
|
||||
WOLFSSL_API void wolfSSL_BN_free(WOLFSSL_BIGNUM*);
|
||||
WOLFSSL_API void wolfSSL_BN_clear_free(WOLFSSL_BIGNUM*);
|
||||
|
||||
|
||||
WOLFSSL_API int wolfSSL_BN_sub(WOLFSSL_BIGNUM*, const WOLFSSL_BIGNUM*,
|
||||
const WOLFSSL_BIGNUM*);
|
||||
WOLFSSL_API int wolfSSL_BN_mod(WOLFSSL_BIGNUM*, const WOLFSSL_BIGNUM*,
|
||||
const WOLFSSL_BIGNUM*, const WOLFSSL_BN_CTX*);
|
||||
WOLFSSL_API int wolfSSL_BN_mod_exp(WOLFSSL_BIGNUM *r, const WOLFSSL_BIGNUM *a,
|
||||
const WOLFSSL_BIGNUM *p, const WOLFSSL_BIGNUM *m, WOLFSSL_BN_CTX *ctx);
|
||||
WOLFSSL_API int wolfSSL_BN_mod_mul(WOLFSSL_BIGNUM *r, const WOLFSSL_BIGNUM *a,
|
||||
const WOLFSSL_BIGNUM *b, const WOLFSSL_BIGNUM *m, WOLFSSL_BN_CTX *ctx);
|
||||
WOLFSSL_API const WOLFSSL_BIGNUM* wolfSSL_BN_value_one(void);
|
||||
|
||||
|
||||
WOLFSSL_API int wolfSSL_BN_num_bytes(const WOLFSSL_BIGNUM*);
|
||||
WOLFSSL_API int wolfSSL_BN_num_bits(const WOLFSSL_BIGNUM*);
|
||||
|
||||
WOLFSSL_API int wolfSSL_BN_is_zero(const WOLFSSL_BIGNUM*);
|
||||
WOLFSSL_API int wolfSSL_BN_is_one(const WOLFSSL_BIGNUM*);
|
||||
WOLFSSL_API int wolfSSL_BN_is_odd(const WOLFSSL_BIGNUM*);
|
||||
|
||||
WOLFSSL_API int wolfSSL_BN_cmp(const WOLFSSL_BIGNUM*, const WOLFSSL_BIGNUM*);
|
||||
|
||||
WOLFSSL_API int wolfSSL_BN_bn2bin(const WOLFSSL_BIGNUM*, unsigned char*);
|
||||
WOLFSSL_API WOLFSSL_BIGNUM* wolfSSL_BN_bin2bn(const unsigned char*, int len,
|
||||
WOLFSSL_BIGNUM* ret);
|
||||
|
||||
WOLFSSL_API int wolfSSL_mask_bits(WOLFSSL_BIGNUM*, int n);
|
||||
|
||||
WOLFSSL_API int wolfSSL_BN_pseudo_rand(WOLFSSL_BIGNUM*, int bits, int top,
|
||||
int bottom);
|
||||
WOLFSSL_API int wolfSSL_BN_rand(WOLFSSL_BIGNUM*, int bits, int top, int bottom);
|
||||
WOLFSSL_API int wolfSSL_BN_is_bit_set(const WOLFSSL_BIGNUM*, int n);
|
||||
WOLFSSL_API int wolfSSL_BN_hex2bn(WOLFSSL_BIGNUM**, const char* str);
|
||||
|
||||
WOLFSSL_API WOLFSSL_BIGNUM* wolfSSL_BN_dup(const WOLFSSL_BIGNUM*);
|
||||
WOLFSSL_API WOLFSSL_BIGNUM* wolfSSL_BN_copy(WOLFSSL_BIGNUM*,
|
||||
const WOLFSSL_BIGNUM*);
|
||||
|
||||
WOLFSSL_API int wolfSSL_BN_dec2bn(WOLFSSL_BIGNUM**, const char* str);
|
||||
WOLFSSL_API char* wolfSSL_BN_bn2dec(const WOLFSSL_BIGNUM*);
|
||||
|
||||
WOLFSSL_API int wolfSSL_BN_lshift(WOLFSSL_BIGNUM*, const WOLFSSL_BIGNUM*, int);
|
||||
WOLFSSL_API int wolfSSL_BN_add_word(WOLFSSL_BIGNUM*, WOLFSSL_BN_ULONG);
|
||||
WOLFSSL_API int wolfSSL_BN_set_bit(WOLFSSL_BIGNUM*, int);
|
||||
WOLFSSL_API int wolfSSL_BN_set_word(WOLFSSL_BIGNUM*, WOLFSSL_BN_ULONG);
|
||||
WOLFSSL_API unsigned long wolfSSL_BN_get_word(const WOLFSSL_BIGNUM*);
|
||||
|
||||
WOLFSSL_API int wolfSSL_BN_add(WOLFSSL_BIGNUM*, WOLFSSL_BIGNUM*,
|
||||
WOLFSSL_BIGNUM*);
|
||||
WOLFSSL_API char *wolfSSL_BN_bn2hex(const WOLFSSL_BIGNUM*);
|
||||
WOLFSSL_API int wolfSSL_BN_is_prime_ex(const WOLFSSL_BIGNUM*, int,
|
||||
WOLFSSL_BN_CTX*, WOLFSSL_BN_GENCB*);
|
||||
WOLFSSL_API WOLFSSL_BN_ULONG wolfSSL_BN_mod_word(const WOLFSSL_BIGNUM*,
|
||||
WOLFSSL_BN_ULONG);
|
||||
#if !defined(NO_FILESYSTEM) && !defined(NO_STDIO_FILESYSTEM)
|
||||
WOLFSSL_API int wolfSSL_BN_print_fp(XFILE, const WOLFSSL_BIGNUM*);
|
||||
#endif
|
||||
WOLFSSL_API int wolfSSL_BN_rshift(WOLFSSL_BIGNUM*, const WOLFSSL_BIGNUM*, int);
|
||||
WOLFSSL_API WOLFSSL_BIGNUM *wolfSSL_BN_CTX_get(WOLFSSL_BN_CTX *ctx);
|
||||
WOLFSSL_API void wolfSSL_BN_CTX_start(WOLFSSL_BN_CTX *ctx);
|
||||
WOLFSSL_API WOLFSSL_BIGNUM *wolfSSL_BN_mod_inverse(WOLFSSL_BIGNUM*, WOLFSSL_BIGNUM*,
|
||||
const WOLFSSL_BIGNUM*, WOLFSSL_BN_CTX *ctx);
|
||||
typedef WOLFSSL_BIGNUM BIGNUM;
|
||||
typedef WOLFSSL_BN_CTX BN_CTX;
|
||||
typedef WOLFSSL_BN_GENCB BN_GENCB;
|
||||
|
||||
#define BN_CTX_new wolfSSL_BN_CTX_new
|
||||
#define BN_CTX_init wolfSSL_BN_CTX_init
|
||||
#define BN_CTX_free wolfSSL_BN_CTX_free
|
||||
|
||||
#define BN_new wolfSSL_BN_new
|
||||
#define BN_free wolfSSL_BN_free
|
||||
#define BN_clear_free wolfSSL_BN_clear_free
|
||||
|
||||
#define BN_num_bytes wolfSSL_BN_num_bytes
|
||||
#define BN_num_bits wolfSSL_BN_num_bits
|
||||
|
||||
#define BN_is_zero wolfSSL_BN_is_zero
|
||||
#define BN_is_one wolfSSL_BN_is_one
|
||||
#define BN_is_odd wolfSSL_BN_is_odd
|
||||
|
||||
#define BN_cmp wolfSSL_BN_cmp
|
||||
|
||||
#define BN_bn2bin wolfSSL_BN_bn2bin
|
||||
#define BN_bin2bn wolfSSL_BN_bin2bn
|
||||
|
||||
#define BN_mod wolfSSL_BN_mod
|
||||
#define BN_mod_exp wolfSSL_BN_mod_exp
|
||||
#define BN_mod_mul wolfSSL_BN_mod_mul
|
||||
#define BN_sub wolfSSL_BN_sub
|
||||
#define BN_value_one wolfSSL_BN_value_one
|
||||
|
||||
#define BN_mask_bits wolfSSL_mask_bits
|
||||
|
||||
#define BN_pseudo_rand wolfSSL_BN_pseudo_rand
|
||||
#define BN_rand wolfSSL_BN_rand
|
||||
#define BN_is_bit_set wolfSSL_BN_is_bit_set
|
||||
#define BN_hex2bn wolfSSL_BN_hex2bn
|
||||
|
||||
#define BN_dup wolfSSL_BN_dup
|
||||
#define BN_copy wolfSSL_BN_copy
|
||||
|
||||
#define BN_get_word wolfSSL_BN_get_word
|
||||
#define BN_set_word wolfSSL_BN_set_word
|
||||
|
||||
#define BN_dec2bn wolfSSL_BN_dec2bn
|
||||
#define BN_bn2dec wolfSSL_BN_bn2dec
|
||||
#define BN_bn2hex wolfSSL_BN_bn2hex
|
||||
|
||||
#define BN_lshift wolfSSL_BN_lshift
|
||||
#define BN_add_word wolfSSL_BN_add_word
|
||||
#define BN_add wolfSSL_BN_add
|
||||
#define BN_set_word wolfSSL_BN_set_word
|
||||
#define BN_set_bit wolfSSL_BN_set_bit
|
||||
|
||||
|
||||
#define BN_is_prime_ex wolfSSL_BN_is_prime_ex
|
||||
#define BN_print_fp wolfSSL_BN_print_fp
|
||||
#define BN_rshift wolfSSL_BN_rshift
|
||||
#define BN_mod_word wolfSSL_BN_mod_word
|
||||
|
||||
#define BN_CTX_get wolfSSL_BN_CTX_get
|
||||
#define BN_CTX_start wolfSSL_BN_CTX_start
|
||||
|
||||
#define BN_mod_inverse wolfSSL_BN_mod_inverse
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* WOLFSSL__H_ */
|
@ -0,0 +1,72 @@
|
||||
/* crypto.h
|
||||
*
|
||||
* Copyright (C) 2006-2018 wolfSSL Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is distributed in binary form as licensed by Espressif Systems.
|
||||
* See README file or contact licensing@wolfssl.com with any questions or comments.
|
||||
*
|
||||
* https://www.wolfssl.com
|
||||
*/
|
||||
|
||||
|
||||
/* crypto.h for openSSL */
|
||||
|
||||
#ifndef WOLFSSL_CRYPTO_H_
|
||||
#define WOLFSSL_CRYPTO_H_
|
||||
|
||||
#include <wolfssl/openssl/opensslv.h>
|
||||
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#ifdef WOLFSSL_PREFIX
|
||||
#include "prefix_crypto.h"
|
||||
#endif
|
||||
|
||||
|
||||
WOLFSSL_API const char* wolfSSLeay_version(int type);
|
||||
WOLFSSL_API unsigned long wolfSSLeay(void);
|
||||
|
||||
#ifdef OPENSSL_EXTRA
|
||||
WOLFSSL_API void wolfSSL_OPENSSL_free(void*);
|
||||
WOLFSSL_API void *wolfSSL_OPENSSL_malloc(size_t a);
|
||||
#endif
|
||||
|
||||
#define CRYPTO_THREADID void
|
||||
|
||||
#define SSLeay_version wolfSSLeay_version
|
||||
#define SSLeay wolfSSLeay
|
||||
|
||||
|
||||
#define SSLEAY_VERSION 0x0090600fL
|
||||
#define SSLEAY_VERSION_NUMBER SSLEAY_VERSION
|
||||
#define CRYPTO_lock wc_LockMutex_ex
|
||||
|
||||
/* this function was used to set the default malloc, free, and realloc */
|
||||
#define CRYPTO_malloc_init() /* CRYPTO_malloc_init is not needed */
|
||||
|
||||
#define OPENSSL_free wolfSSL_OPENSSL_free
|
||||
#define OPENSSL_malloc wolfSSL_OPENSSL_malloc
|
||||
|
||||
#if defined(OPENSSL_ALL) || defined(HAVE_STUNNEL) || defined(WOLFSSL_NGINX) || \
|
||||
defined(WOLFSSL_HAPROXY) || defined(OPENSSL_EXTRA)
|
||||
#define CRYPTO_set_mem_ex_functions wolfSSL_CRYPTO_set_mem_ex_functions
|
||||
#define FIPS_mode wolfSSL_FIPS_mode
|
||||
#define FIPS_mode_set wolfSSL_FIPS_mode_set
|
||||
typedef struct CRYPTO_EX_DATA CRYPTO_EX_DATA;
|
||||
typedef void (CRYPTO_free_func)(void*parent, void*ptr, CRYPTO_EX_DATA *ad, int idx,
|
||||
long argl, void* argp);
|
||||
#define CRYPTO_THREADID_set_callback wolfSSL_THREADID_set_callback
|
||||
#define CRYPTO_THREADID_set_numeric wolfSSL_THREADID_set_numeric
|
||||
|
||||
#define CRYPTO_r_lock wc_LockMutex_ex
|
||||
#define CRYPTO_unlock wc_LockMutex_ex
|
||||
|
||||
#define CRYPTO_THREAD_lock wc_LockMutex
|
||||
#define CRYPTO_THREAD_r_lock wc_LockMutex
|
||||
#define CRYPTO_THREAD_unlock wc_UnLockMutex
|
||||
|
||||
#endif /* OPENSSL_ALL || HAVE_STUNNEL || WOLFSSL_NGINX || WOLFSSL_HAPROXY */
|
||||
|
||||
#endif /* header */
|
79
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/openssl/dsa.h
Normal file
79
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/openssl/dsa.h
Normal file
@ -0,0 +1,79 @@
|
||||
/* dsa.h
|
||||
*
|
||||
* Copyright (C) 2006-2018 wolfSSL Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is distributed in binary form as licensed by Espressif Systems.
|
||||
* See README file or contact licensing@wolfssl.com with any questions or comments.
|
||||
*
|
||||
* https://www.wolfssl.com
|
||||
*/
|
||||
|
||||
|
||||
/* dsa.h for openSSL */
|
||||
|
||||
|
||||
#ifndef WOLFSSL_DSA_H_
|
||||
#define WOLFSSL_DSA_H_
|
||||
|
||||
#include <wolfssl/openssl/bn.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef WOLFSSL_DSA_TYPE_DEFINED /* guard on redeclaration */
|
||||
typedef struct WOLFSSL_DSA WOLFSSL_DSA;
|
||||
#define WOLFSSL_DSA_TYPE_DEFINED
|
||||
#endif
|
||||
|
||||
typedef WOLFSSL_DSA DSA;
|
||||
|
||||
struct WOLFSSL_DSA {
|
||||
WOLFSSL_BIGNUM* p;
|
||||
WOLFSSL_BIGNUM* q;
|
||||
WOLFSSL_BIGNUM* g;
|
||||
WOLFSSL_BIGNUM* pub_key; /* our y */
|
||||
WOLFSSL_BIGNUM* priv_key; /* our x */
|
||||
void* internal; /* our Dsa Key */
|
||||
char inSet; /* internal set from external ? */
|
||||
char exSet; /* external set from internal ? */
|
||||
};
|
||||
|
||||
|
||||
WOLFSSL_API WOLFSSL_DSA* wolfSSL_DSA_new(void);
|
||||
WOLFSSL_API void wolfSSL_DSA_free(WOLFSSL_DSA*);
|
||||
|
||||
WOLFSSL_API int wolfSSL_DSA_generate_key(WOLFSSL_DSA*);
|
||||
|
||||
typedef void (*WOLFSSL_BN_CB)(int i, int j, void* exArg);
|
||||
WOLFSSL_API WOLFSSL_DSA* wolfSSL_DSA_generate_parameters(int bits,
|
||||
unsigned char* seed, int seedLen, int* counterRet,
|
||||
unsigned long* hRet, WOLFSSL_BN_CB cb, void* CBArg);
|
||||
WOLFSSL_API int wolfSSL_DSA_generate_parameters_ex(WOLFSSL_DSA*, int bits,
|
||||
unsigned char* seed, int seedLen, int* counterRet,
|
||||
unsigned long* hRet, void* cb);
|
||||
|
||||
WOLFSSL_API int wolfSSL_DSA_LoadDer(WOLFSSL_DSA*, const unsigned char*, int sz);
|
||||
|
||||
WOLFSSL_API int wolfSSL_DSA_do_sign(const unsigned char* d,
|
||||
unsigned char* sigRet, WOLFSSL_DSA* dsa);
|
||||
|
||||
WOLFSSL_API int wolfSSL_DSA_do_verify(const unsigned char* d,
|
||||
unsigned char* sig,
|
||||
WOLFSSL_DSA* dsa, int *dsacheck);
|
||||
|
||||
#define DSA_new wolfSSL_DSA_new
|
||||
#define DSA_free wolfSSL_DSA_free
|
||||
|
||||
#define DSA_generate_key wolfSSL_DSA_generate_key
|
||||
#define DSA_generate_parameters wolfSSL_DSA_generate_parameters
|
||||
#define DSA_generate_parameters_ex wolfSSL_DSA_generate_parameters_ex
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* header */
|
225
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/openssl/ec.h
Normal file
225
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/openssl/ec.h
Normal file
@ -0,0 +1,225 @@
|
||||
/* ec.h
|
||||
*
|
||||
* Copyright (C) 2006-2018 wolfSSL Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is distributed in binary form as licensed by Espressif Systems.
|
||||
* See README file or contact licensing@wolfssl.com with any questions or comments.
|
||||
*
|
||||
* https://www.wolfssl.com
|
||||
*/
|
||||
|
||||
|
||||
/* ec.h for openssl */
|
||||
|
||||
#ifndef WOLFSSL_EC_H_
|
||||
#define WOLFSSL_EC_H_
|
||||
|
||||
#include <wolfssl/openssl/bn.h>
|
||||
#include <wolfssl/wolfcrypt/ecc.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Map OpenSSL NID value */
|
||||
enum {
|
||||
POINT_CONVERSION_COMPRESSED = 2,
|
||||
POINT_CONVERSION_UNCOMPRESSED = 4,
|
||||
|
||||
#ifdef HAVE_ECC
|
||||
/* Use ecc_curve_type enum values for NID */
|
||||
NID_X9_62_prime192v1 = ECC_SECP192R1,
|
||||
NID_X9_62_prime256v1 = ECC_SECP256R1,
|
||||
NID_secp112r1 = ECC_SECP112R1,
|
||||
NID_secp112r2 = ECC_SECP112R2,
|
||||
NID_secp128r1 = ECC_SECP128R1,
|
||||
NID_secp128r2 = ECC_SECP128R2,
|
||||
NID_secp160r1 = ECC_SECP160R1,
|
||||
NID_secp160r2 = ECC_SECP160R2,
|
||||
NID_secp224r1 = ECC_SECP224R1,
|
||||
NID_secp384r1 = ECC_SECP384R1,
|
||||
NID_secp521r1 = ECC_SECP521R1,
|
||||
NID_secp160k1 = ECC_SECP160K1,
|
||||
NID_secp192k1 = ECC_SECP192K1,
|
||||
NID_secp224k1 = ECC_SECP224K1,
|
||||
NID_secp256k1 = ECC_SECP256K1,
|
||||
NID_brainpoolP160r1 = ECC_BRAINPOOLP160R1,
|
||||
NID_brainpoolP192r1 = ECC_BRAINPOOLP192R1,
|
||||
NID_brainpoolP224r1 = ECC_BRAINPOOLP224R1,
|
||||
NID_brainpoolP256r1 = ECC_BRAINPOOLP256R1,
|
||||
NID_brainpoolP320r1 = ECC_BRAINPOOLP320R1,
|
||||
NID_brainpoolP384r1 = ECC_BRAINPOOLP384R1,
|
||||
NID_brainpoolP512r1 = ECC_BRAINPOOLP512R1,
|
||||
#endif
|
||||
|
||||
OPENSSL_EC_NAMED_CURVE = 0x001
|
||||
};
|
||||
|
||||
#ifndef WOLFSSL_EC_TYPE_DEFINED /* guard on redeclaration */
|
||||
typedef struct WOLFSSL_EC_KEY WOLFSSL_EC_KEY;
|
||||
typedef struct WOLFSSL_EC_POINT WOLFSSL_EC_POINT;
|
||||
typedef struct WOLFSSL_EC_GROUP WOLFSSL_EC_GROUP;
|
||||
#define WOLFSSL_EC_TYPE_DEFINED
|
||||
#endif
|
||||
|
||||
typedef WOLFSSL_EC_KEY EC_KEY;
|
||||
typedef WOLFSSL_EC_GROUP EC_GROUP;
|
||||
typedef WOLFSSL_EC_POINT EC_POINT;
|
||||
|
||||
struct WOLFSSL_EC_POINT {
|
||||
WOLFSSL_BIGNUM *X;
|
||||
WOLFSSL_BIGNUM *Y;
|
||||
WOLFSSL_BIGNUM *Z;
|
||||
|
||||
void* internal; /* our ECC point */
|
||||
char inSet; /* internal set from external ? */
|
||||
char exSet; /* external set from internal ? */
|
||||
};
|
||||
|
||||
struct WOLFSSL_EC_GROUP {
|
||||
int curve_idx; /* index of curve, used by WolfSSL as reference */
|
||||
int curve_nid; /* NID of curve, used by OpenSSL/OpenSSH as reference */
|
||||
int curve_oid; /* OID of curve, used by OpenSSL/OpenSSH as reference */
|
||||
};
|
||||
|
||||
struct WOLFSSL_EC_KEY {
|
||||
WOLFSSL_EC_GROUP *group;
|
||||
WOLFSSL_EC_POINT *pub_key;
|
||||
WOLFSSL_BIGNUM *priv_key;
|
||||
|
||||
void* internal; /* our ECC Key */
|
||||
char inSet; /* internal set from external ? */
|
||||
char exSet; /* external set from internal ? */
|
||||
};
|
||||
|
||||
|
||||
#define WOLFSSL_EC_KEY_LOAD_PRIVATE 1
|
||||
#define WOLFSSL_EC_KEY_LOAD_PUBLIC 2
|
||||
|
||||
WOLFSSL_API
|
||||
int wolfSSL_ECPoint_i2d(const WOLFSSL_EC_GROUP *curve,
|
||||
const WOLFSSL_EC_POINT *p,
|
||||
unsigned char *out, unsigned int *len);
|
||||
WOLFSSL_API
|
||||
int wolfSSL_ECPoint_d2i(unsigned char *in, unsigned int len,
|
||||
const WOLFSSL_EC_GROUP *curve, WOLFSSL_EC_POINT *p);
|
||||
WOLFSSL_API
|
||||
int wolfSSL_EC_KEY_LoadDer(WOLFSSL_EC_KEY* key,
|
||||
const unsigned char* der, int derSz);
|
||||
WOLFSSL_API
|
||||
int wolfSSL_EC_KEY_LoadDer_ex(WOLFSSL_EC_KEY* key,
|
||||
const unsigned char* der, int derSz, int opt);
|
||||
WOLFSSL_API
|
||||
void wolfSSL_EC_KEY_free(WOLFSSL_EC_KEY *key);
|
||||
WOLFSSL_API
|
||||
WOLFSSL_EC_POINT *wolfSSL_EC_KEY_get0_public_key(const WOLFSSL_EC_KEY *key);
|
||||
WOLFSSL_API
|
||||
const WOLFSSL_EC_GROUP *wolfSSL_EC_KEY_get0_group(const WOLFSSL_EC_KEY *key);
|
||||
WOLFSSL_API
|
||||
int wolfSSL_EC_KEY_set_private_key(WOLFSSL_EC_KEY *key,
|
||||
const WOLFSSL_BIGNUM *priv_key);
|
||||
WOLFSSL_API
|
||||
WOLFSSL_BIGNUM *wolfSSL_EC_KEY_get0_private_key(const WOLFSSL_EC_KEY *key);
|
||||
WOLFSSL_API
|
||||
WOLFSSL_EC_KEY *wolfSSL_EC_KEY_new_by_curve_name(int nid);
|
||||
WOLFSSL_API
|
||||
WOLFSSL_EC_KEY *wolfSSL_EC_KEY_new(void);
|
||||
WOLFSSL_API
|
||||
int wolfSSL_EC_KEY_set_group(WOLFSSL_EC_KEY *key, WOLFSSL_EC_GROUP *group);
|
||||
WOLFSSL_API
|
||||
int wolfSSL_EC_KEY_generate_key(WOLFSSL_EC_KEY *key);
|
||||
WOLFSSL_API
|
||||
void wolfSSL_EC_KEY_set_asn1_flag(WOLFSSL_EC_KEY *key, int asn1_flag);
|
||||
WOLFSSL_API
|
||||
int wolfSSL_EC_KEY_set_public_key(WOLFSSL_EC_KEY *key,
|
||||
const WOLFSSL_EC_POINT *pub);
|
||||
WOLFSSL_API
|
||||
void wolfSSL_EC_GROUP_set_asn1_flag(WOLFSSL_EC_GROUP *group, int flag);
|
||||
WOLFSSL_API
|
||||
WOLFSSL_EC_GROUP *wolfSSL_EC_GROUP_new_by_curve_name(int nid);
|
||||
WOLFSSL_API
|
||||
int wolfSSL_EC_GROUP_cmp(const WOLFSSL_EC_GROUP *a, const WOLFSSL_EC_GROUP *b,
|
||||
WOLFSSL_BN_CTX *ctx);
|
||||
WOLFSSL_API
|
||||
int wolfSSL_EC_GROUP_get_curve_name(const WOLFSSL_EC_GROUP *group);
|
||||
WOLFSSL_API
|
||||
int wolfSSL_EC_GROUP_get_degree(const WOLFSSL_EC_GROUP *group);
|
||||
WOLFSSL_API
|
||||
int wolfSSL_EC_GROUP_get_order(const WOLFSSL_EC_GROUP *group,
|
||||
WOLFSSL_BIGNUM *order, WOLFSSL_BN_CTX *ctx);
|
||||
WOLFSSL_API
|
||||
void wolfSSL_EC_GROUP_free(WOLFSSL_EC_GROUP *group);
|
||||
WOLFSSL_API
|
||||
WOLFSSL_EC_POINT *wolfSSL_EC_POINT_new(const WOLFSSL_EC_GROUP *group);
|
||||
WOLFSSL_API
|
||||
int wolfSSL_EC_POINT_get_affine_coordinates_GFp(const WOLFSSL_EC_GROUP *group,
|
||||
const WOLFSSL_EC_POINT *p,
|
||||
WOLFSSL_BIGNUM *x,
|
||||
WOLFSSL_BIGNUM *y,
|
||||
WOLFSSL_BN_CTX *ctx);
|
||||
WOLFSSL_API
|
||||
int wolfSSL_EC_POINT_mul(const WOLFSSL_EC_GROUP *group, WOLFSSL_EC_POINT *r,
|
||||
const WOLFSSL_BIGNUM *n,
|
||||
const WOLFSSL_EC_POINT *q, const WOLFSSL_BIGNUM *m,
|
||||
WOLFSSL_BN_CTX *ctx);
|
||||
WOLFSSL_API
|
||||
void wolfSSL_EC_POINT_clear_free(WOLFSSL_EC_POINT *point);
|
||||
WOLFSSL_API
|
||||
int wolfSSL_EC_POINT_cmp(const WOLFSSL_EC_GROUP *group,
|
||||
const WOLFSSL_EC_POINT *a, const WOLFSSL_EC_POINT *b,
|
||||
WOLFSSL_BN_CTX *ctx);
|
||||
WOLFSSL_API
|
||||
void wolfSSL_EC_POINT_free(WOLFSSL_EC_POINT *point);
|
||||
WOLFSSL_API
|
||||
int wolfSSL_EC_POINT_is_at_infinity(const WOLFSSL_EC_GROUP *group,
|
||||
const WOLFSSL_EC_POINT *a);
|
||||
|
||||
#ifndef HAVE_SELFTEST
|
||||
WOLFSSL_API
|
||||
char* wolfSSL_EC_POINT_point2hex(const WOLFSSL_EC_GROUP* group,
|
||||
const WOLFSSL_EC_POINT* point, int form,
|
||||
WOLFSSL_BN_CTX* ctx);
|
||||
#endif
|
||||
|
||||
#define EC_KEY_new wolfSSL_EC_KEY_new
|
||||
#define EC_KEY_free wolfSSL_EC_KEY_free
|
||||
#define EC_KEY_get0_public_key wolfSSL_EC_KEY_get0_public_key
|
||||
#define EC_KEY_get0_group wolfSSL_EC_KEY_get0_group
|
||||
#define EC_KEY_set_private_key wolfSSL_EC_KEY_set_private_key
|
||||
#define EC_KEY_get0_private_key wolfSSL_EC_KEY_get0_private_key
|
||||
#define EC_KEY_new_by_curve_name wolfSSL_EC_KEY_new_by_curve_name
|
||||
#define EC_KEY_set_group wolfSSL_EC_KEY_set_group
|
||||
#define EC_KEY_generate_key wolfSSL_EC_KEY_generate_key
|
||||
#define EC_KEY_set_asn1_flag wolfSSL_EC_KEY_set_asn1_flag
|
||||
#define EC_KEY_set_public_key wolfSSL_EC_KEY_set_public_key
|
||||
|
||||
#define EC_GROUP_free wolfSSL_EC_GROUP_free
|
||||
#define EC_GROUP_set_asn1_flag wolfSSL_EC_GROUP_set_asn1_flag
|
||||
#define EC_GROUP_new_by_curve_name wolfSSL_EC_GROUP_new_by_curve_name
|
||||
#define EC_GROUP_cmp wolfSSL_EC_GROUP_cmp
|
||||
#define EC_GROUP_get_curve_name wolfSSL_EC_GROUP_get_curve_name
|
||||
#define EC_GROUP_get_degree wolfSSL_EC_GROUP_get_degree
|
||||
#define EC_GROUP_get_order wolfSSL_EC_GROUP_get_order
|
||||
|
||||
#define EC_POINT_new wolfSSL_EC_POINT_new
|
||||
#define EC_POINT_free wolfSSL_EC_POINT_free
|
||||
#define EC_POINT_get_affine_coordinates_GFp \
|
||||
wolfSSL_EC_POINT_get_affine_coordinates_GFp
|
||||
#define EC_POINT_mul wolfSSL_EC_POINT_mul
|
||||
#define EC_POINT_clear_free wolfSSL_EC_POINT_clear_free
|
||||
#define EC_POINT_cmp wolfSSL_EC_POINT_cmp
|
||||
#define EC_POINT_is_at_infinity wolfSSL_EC_POINT_is_at_infinity
|
||||
|
||||
#ifndef HAVE_SELFTEST
|
||||
#define EC_POINT_point2hex wolfSSL_EC_POINT_point2hex
|
||||
#endif
|
||||
|
||||
#define EC_POINT_dump wolfSSL_EC_POINT_dump
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* header */
|
612
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/openssl/evp.h
Normal file
612
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/openssl/evp.h
Normal file
@ -0,0 +1,612 @@
|
||||
/* evp.h
|
||||
*
|
||||
* Copyright (C) 2006-2018 wolfSSL Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is distributed in binary form as licensed by Espressif Systems.
|
||||
* See README file or contact licensing@wolfssl.com with any questions or comments.
|
||||
*
|
||||
* https://www.wolfssl.com
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
\file wolfssl/openssl/evp.h
|
||||
\brief evp.h defines mini evp openssl compatibility layer
|
||||
*/
|
||||
|
||||
|
||||
#ifndef WOLFSSL_EVP_H_
|
||||
#define WOLFSSL_EVP_H_
|
||||
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#ifdef WOLFSSL_PREFIX
|
||||
#include "prefix_evp.h"
|
||||
#endif
|
||||
|
||||
#ifndef NO_MD4
|
||||
#include <wolfssl/openssl/md4.h>
|
||||
#endif
|
||||
#ifndef NO_MD5
|
||||
#include <wolfssl/openssl/md5.h>
|
||||
#endif
|
||||
#include <wolfssl/openssl/sha.h>
|
||||
#include <wolfssl/openssl/ripemd.h>
|
||||
#include <wolfssl/openssl/rsa.h>
|
||||
#include <wolfssl/openssl/dsa.h>
|
||||
#include <wolfssl/openssl/ec.h>
|
||||
|
||||
#include <wolfssl/wolfcrypt/aes.h>
|
||||
#include <wolfssl/wolfcrypt/des3.h>
|
||||
#include <wolfssl/wolfcrypt/arc4.h>
|
||||
#include <wolfssl/wolfcrypt/hmac.h>
|
||||
#ifdef HAVE_IDEA
|
||||
#include <wolfssl/wolfcrypt/idea.h>
|
||||
#endif
|
||||
#include <wolfssl/wolfcrypt/pwdbased.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
typedef char WOLFSSL_EVP_CIPHER;
|
||||
#ifndef WOLFSSL_EVP_TYPE_DEFINED /* guard on redeclaration */
|
||||
typedef char WOLFSSL_EVP_MD;
|
||||
typedef struct WOLFSSL_EVP_PKEY WOLFSSL_EVP_PKEY;
|
||||
#define WOLFSSL_EVP_TYPE_DEFINED
|
||||
#endif
|
||||
|
||||
typedef WOLFSSL_EVP_PKEY EVP_PKEY;
|
||||
typedef WOLFSSL_EVP_PKEY PKCS8_PRIV_KEY_INFO;
|
||||
|
||||
#ifndef NO_MD4
|
||||
WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_md4(void);
|
||||
#endif
|
||||
#ifndef NO_MD5
|
||||
WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_md5(void);
|
||||
#endif
|
||||
WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_sha1(void);
|
||||
WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_sha224(void);
|
||||
WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_sha256(void);
|
||||
WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_sha384(void);
|
||||
WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_sha512(void);
|
||||
WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_ripemd160(void);
|
||||
|
||||
WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_128_ecb(void);
|
||||
WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_192_ecb(void);
|
||||
WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_256_ecb(void);
|
||||
WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_128_cbc(void);
|
||||
#if !defined(NO_AES) && defined(HAVE_AES_CBC)
|
||||
WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_192_cbc(void);
|
||||
WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_256_cbc(void);
|
||||
#endif
|
||||
WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_128_ctr(void);
|
||||
WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_192_ctr(void);
|
||||
WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_256_ctr(void);
|
||||
WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_des_ecb(void);
|
||||
WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_des_ede3_ecb(void);
|
||||
WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_des_cbc(void);
|
||||
WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_des_ede3_cbc(void);
|
||||
WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_rc4(void);
|
||||
WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_idea_cbc(void);
|
||||
WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_enc_null(void);
|
||||
|
||||
|
||||
typedef union {
|
||||
#ifndef NO_MD4
|
||||
WOLFSSL_MD4_CTX md4;
|
||||
#endif
|
||||
#ifndef NO_MD5
|
||||
WOLFSSL_MD5_CTX md5;
|
||||
#endif
|
||||
WOLFSSL_SHA_CTX sha;
|
||||
#ifdef WOLFSSL_SHA224
|
||||
WOLFSSL_SHA224_CTX sha224;
|
||||
#endif
|
||||
WOLFSSL_SHA256_CTX sha256;
|
||||
#ifdef WOLFSSL_SHA384
|
||||
WOLFSSL_SHA384_CTX sha384;
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA512
|
||||
WOLFSSL_SHA512_CTX sha512;
|
||||
#endif
|
||||
#ifdef WOLFSSL_RIPEMD
|
||||
WOLFSSL_RIPEMD_CTX ripemd;
|
||||
#endif
|
||||
} WOLFSSL_Hasher;
|
||||
|
||||
typedef struct WOLFSSL_EVP_PKEY_CTX WOLFSSL_EVP_PKEY_CTX;
|
||||
|
||||
typedef struct WOLFSSL_EVP_MD_CTX {
|
||||
union {
|
||||
WOLFSSL_Hasher digest;
|
||||
Hmac hmac;
|
||||
} hash;
|
||||
unsigned char macType;
|
||||
WOLFSSL_EVP_PKEY_CTX *pctx;
|
||||
} WOLFSSL_EVP_MD_CTX;
|
||||
|
||||
|
||||
typedef union {
|
||||
#ifndef NO_AES
|
||||
Aes aes;
|
||||
#endif
|
||||
#ifndef NO_DES3
|
||||
Des des;
|
||||
Des3 des3;
|
||||
#endif
|
||||
Arc4 arc4;
|
||||
#ifdef HAVE_IDEA
|
||||
Idea idea;
|
||||
#endif
|
||||
} WOLFSSL_Cipher;
|
||||
|
||||
|
||||
enum {
|
||||
AES_128_CBC_TYPE = 1,
|
||||
AES_192_CBC_TYPE = 2,
|
||||
AES_256_CBC_TYPE = 3,
|
||||
AES_128_CTR_TYPE = 4,
|
||||
AES_192_CTR_TYPE = 5,
|
||||
AES_256_CTR_TYPE = 6,
|
||||
AES_128_ECB_TYPE = 7,
|
||||
AES_192_ECB_TYPE = 8,
|
||||
AES_256_ECB_TYPE = 9,
|
||||
DES_CBC_TYPE = 10,
|
||||
DES_ECB_TYPE = 11,
|
||||
DES_EDE3_CBC_TYPE = 12,
|
||||
DES_EDE3_ECB_TYPE = 13,
|
||||
ARC4_TYPE = 14,
|
||||
NULL_CIPHER_TYPE = 15,
|
||||
EVP_PKEY_RSA = 16,
|
||||
EVP_PKEY_DSA = 17,
|
||||
EVP_PKEY_EC = 18,
|
||||
#ifdef HAVE_IDEA
|
||||
IDEA_CBC_TYPE = 19,
|
||||
#endif
|
||||
NID_sha1 = 64,
|
||||
NID_sha224 = 65,
|
||||
NID_md2 = 77,
|
||||
NID_md5 = 4,
|
||||
NID_hmac = 855,
|
||||
EVP_PKEY_HMAC = NID_hmac
|
||||
};
|
||||
|
||||
enum {
|
||||
NID_aes_128_cbc = 419,
|
||||
NID_aes_192_cbc = 423,
|
||||
NID_aes_256_cbc = 427,
|
||||
NID_aes_128_ctr = 904,
|
||||
NID_aes_192_ctr = 905,
|
||||
NID_aes_256_ctr = 906,
|
||||
NID_aes_128_ecb = 418,
|
||||
NID_aes_192_ecb = 422,
|
||||
NID_aes_256_ecb = 426,
|
||||
NID_des_cbc = 31,
|
||||
NID_des_ecb = 29,
|
||||
NID_des_ede3_cbc= 44,
|
||||
NID_des_ede3_ecb= 33,
|
||||
NID_idea_cbc = 34,
|
||||
};
|
||||
|
||||
#define WOLFSSL_EVP_BUF_SIZE 16
|
||||
typedef struct WOLFSSL_EVP_CIPHER_CTX {
|
||||
int keyLen; /* user may set for variable */
|
||||
int block_size;
|
||||
unsigned long flags;
|
||||
unsigned char enc; /* if encrypt side, then true */
|
||||
unsigned char cipherType;
|
||||
#ifndef NO_AES
|
||||
/* working iv pointer into cipher */
|
||||
ALIGN16 unsigned char iv[AES_BLOCK_SIZE];
|
||||
#elif !defined(NO_DES3)
|
||||
/* working iv pointer into cipher */
|
||||
ALIGN16 unsigned char iv[DES_BLOCK_SIZE];
|
||||
#endif
|
||||
WOLFSSL_Cipher cipher;
|
||||
ALIGN16 byte buf[WOLFSSL_EVP_BUF_SIZE];
|
||||
int bufUsed;
|
||||
ALIGN16 byte lastBlock[WOLFSSL_EVP_BUF_SIZE];
|
||||
int lastUsed;
|
||||
} WOLFSSL_EVP_CIPHER_CTX;
|
||||
|
||||
struct WOLFSSL_EVP_PKEY_CTX {
|
||||
WOLFSSL_EVP_PKEY *pkey;
|
||||
int op; /* operation */
|
||||
int padding;
|
||||
};
|
||||
|
||||
typedef int WOLFSSL_ENGINE ;
|
||||
typedef WOLFSSL_ENGINE ENGINE;
|
||||
typedef WOLFSSL_EVP_PKEY_CTX EVP_PKEY_CTX;
|
||||
|
||||
#define EVP_PKEY_OP_ENCRYPT (1 << 6)
|
||||
#define EVP_PKEY_OP_DECRYPT (1 << 7)
|
||||
|
||||
WOLFSSL_API void wolfSSL_EVP_init(void);
|
||||
WOLFSSL_API int wolfSSL_EVP_MD_size(const WOLFSSL_EVP_MD* md);
|
||||
WOLFSSL_API int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD *md);
|
||||
|
||||
WOLFSSL_API WOLFSSL_EVP_MD_CTX *wolfSSL_EVP_MD_CTX_new (void);
|
||||
WOLFSSL_API void wolfSSL_EVP_MD_CTX_free(WOLFSSL_EVP_MD_CTX* ctx);
|
||||
WOLFSSL_API void wolfSSL_EVP_MD_CTX_init(WOLFSSL_EVP_MD_CTX* ctx);
|
||||
WOLFSSL_API int wolfSSL_EVP_MD_CTX_cleanup(WOLFSSL_EVP_MD_CTX* ctx);
|
||||
WOLFSSL_API int wolfSSL_EVP_MD_CTX_copy(WOLFSSL_EVP_MD_CTX *out, const WOLFSSL_EVP_MD_CTX *in);
|
||||
WOLFSSL_API int wolfSSL_EVP_MD_CTX_copy_ex(WOLFSSL_EVP_MD_CTX *out, const WOLFSSL_EVP_MD_CTX *in);
|
||||
WOLFSSL_API int wolfSSL_EVP_MD_CTX_type(const WOLFSSL_EVP_MD_CTX *ctx);
|
||||
WOLFSSL_API const WOLFSSL_EVP_MD *wolfSSL_EVP_MD_CTX_md(const WOLFSSL_EVP_MD_CTX *ctx);
|
||||
WOLFSSL_API const WOLFSSL_EVP_CIPHER *wolfSSL_EVP_get_cipherbyname(const char *name);
|
||||
WOLFSSL_API const WOLFSSL_EVP_MD *wolfSSL_EVP_get_digestbyname(const char *name);
|
||||
|
||||
WOLFSSL_API int wolfSSL_EVP_DigestInit(WOLFSSL_EVP_MD_CTX* ctx,
|
||||
const WOLFSSL_EVP_MD* type);
|
||||
WOLFSSL_API int wolfSSL_EVP_DigestInit_ex(WOLFSSL_EVP_MD_CTX* ctx,
|
||||
const WOLFSSL_EVP_MD* type,
|
||||
WOLFSSL_ENGINE *impl);
|
||||
WOLFSSL_API int wolfSSL_EVP_DigestUpdate(WOLFSSL_EVP_MD_CTX* ctx, const void* data,
|
||||
size_t sz);
|
||||
WOLFSSL_API int wolfSSL_EVP_DigestFinal(WOLFSSL_EVP_MD_CTX* ctx, unsigned char* md,
|
||||
unsigned int* s);
|
||||
WOLFSSL_API int wolfSSL_EVP_DigestFinal_ex(WOLFSSL_EVP_MD_CTX* ctx,
|
||||
unsigned char* md, unsigned int* s);
|
||||
|
||||
WOLFSSL_API int wolfSSL_EVP_DigestSignInit(WOLFSSL_EVP_MD_CTX *ctx,
|
||||
WOLFSSL_EVP_PKEY_CTX **pctx,
|
||||
const WOLFSSL_EVP_MD *type,
|
||||
WOLFSSL_ENGINE *e,
|
||||
WOLFSSL_EVP_PKEY *pkey);
|
||||
WOLFSSL_API int wolfSSL_EVP_DigestSignUpdate(WOLFSSL_EVP_MD_CTX *ctx,
|
||||
const void *d, unsigned int cnt);
|
||||
WOLFSSL_API int wolfSSL_EVP_DigestSignFinal(WOLFSSL_EVP_MD_CTX *ctx,
|
||||
unsigned char *sig, size_t *siglen);
|
||||
|
||||
WOLFSSL_API int wolfSSL_EVP_DigestVerifyInit(WOLFSSL_EVP_MD_CTX *ctx,
|
||||
WOLFSSL_EVP_PKEY_CTX **pctx,
|
||||
const WOLFSSL_EVP_MD *type,
|
||||
WOLFSSL_ENGINE *e,
|
||||
WOLFSSL_EVP_PKEY *pkey);
|
||||
WOLFSSL_API int wolfSSL_EVP_DigestVerifyUpdate(WOLFSSL_EVP_MD_CTX *ctx,
|
||||
const void *d, size_t cnt);
|
||||
WOLFSSL_API int wolfSSL_EVP_DigestVerifyFinal(WOLFSSL_EVP_MD_CTX *ctx,
|
||||
const unsigned char *sig,
|
||||
size_t siglen);
|
||||
|
||||
|
||||
WOLFSSL_API int wolfSSL_EVP_BytesToKey(const WOLFSSL_EVP_CIPHER*,
|
||||
const WOLFSSL_EVP_MD*, const unsigned char*,
|
||||
const unsigned char*, int, int, unsigned char*,
|
||||
unsigned char*);
|
||||
|
||||
WOLFSSL_API void wolfSSL_EVP_CIPHER_CTX_init(WOLFSSL_EVP_CIPHER_CTX* ctx);
|
||||
WOLFSSL_API int wolfSSL_EVP_CIPHER_CTX_cleanup(WOLFSSL_EVP_CIPHER_CTX* ctx);
|
||||
|
||||
WOLFSSL_API int wolfSSL_EVP_CIPHER_CTX_iv_length(const WOLFSSL_EVP_CIPHER_CTX*);
|
||||
WOLFSSL_API int wolfSSL_EVP_CIPHER_iv_length(const WOLFSSL_EVP_CIPHER*);
|
||||
WOLFSSL_API int wolfSSL_EVP_Cipher_key_length(const WOLFSSL_EVP_CIPHER* c);
|
||||
|
||||
|
||||
WOLFSSL_API int wolfSSL_EVP_CipherInit(WOLFSSL_EVP_CIPHER_CTX* ctx,
|
||||
const WOLFSSL_EVP_CIPHER* type,
|
||||
const unsigned char* key,
|
||||
const unsigned char* iv,
|
||||
int enc);
|
||||
WOLFSSL_API int wolfSSL_EVP_CipherInit_ex(WOLFSSL_EVP_CIPHER_CTX* ctx,
|
||||
const WOLFSSL_EVP_CIPHER* type,
|
||||
WOLFSSL_ENGINE *impl,
|
||||
const unsigned char* key,
|
||||
const unsigned char* iv,
|
||||
int enc);
|
||||
WOLFSSL_API int wolfSSL_EVP_EncryptInit(WOLFSSL_EVP_CIPHER_CTX* ctx,
|
||||
const WOLFSSL_EVP_CIPHER* type,
|
||||
const unsigned char* key,
|
||||
const unsigned char* iv);
|
||||
WOLFSSL_API int wolfSSL_EVP_EncryptInit_ex(WOLFSSL_EVP_CIPHER_CTX* ctx,
|
||||
const WOLFSSL_EVP_CIPHER* type,
|
||||
WOLFSSL_ENGINE *impl,
|
||||
const unsigned char* key,
|
||||
const unsigned char* iv);
|
||||
WOLFSSL_API int wolfSSL_EVP_DecryptInit(WOLFSSL_EVP_CIPHER_CTX* ctx,
|
||||
const WOLFSSL_EVP_CIPHER* type,
|
||||
const unsigned char* key,
|
||||
const unsigned char* iv);
|
||||
WOLFSSL_API int wolfSSL_EVP_DecryptInit_ex(WOLFSSL_EVP_CIPHER_CTX* ctx,
|
||||
const WOLFSSL_EVP_CIPHER* type,
|
||||
WOLFSSL_ENGINE *impl,
|
||||
const unsigned char* key,
|
||||
const unsigned char* iv);
|
||||
WOLFSSL_API int wolfSSL_EVP_CipherUpdate(WOLFSSL_EVP_CIPHER_CTX *ctx,
|
||||
unsigned char *out, int *outl,
|
||||
const unsigned char *in, int inl);
|
||||
WOLFSSL_API int wolfSSL_EVP_CipherFinal(WOLFSSL_EVP_CIPHER_CTX *ctx,
|
||||
unsigned char *out, int *outl);
|
||||
WOLFSSL_API int wolfSSL_EVP_CipherFinal_ex(WOLFSSL_EVP_CIPHER_CTX *ctx,
|
||||
unsigned char *out, int *outl, int enc);
|
||||
WOLFSSL_API int wolfSSL_EVP_EncryptFinal(WOLFSSL_EVP_CIPHER_CTX *ctx,
|
||||
unsigned char *out, int *outl);
|
||||
WOLFSSL_API int wolfSSL_EVP_EncryptFinal_ex(WOLFSSL_EVP_CIPHER_CTX *ctx,
|
||||
unsigned char *out, int *outl);
|
||||
WOLFSSL_API int wolfSSL_EVP_DecryptFinal(WOLFSSL_EVP_CIPHER_CTX *ctx,
|
||||
unsigned char *out, int *outl);
|
||||
WOLFSSL_API int wolfSSL_EVP_DecryptFinal_ex(WOLFSSL_EVP_CIPHER_CTX *ctx,
|
||||
unsigned char *out, int *outl);
|
||||
|
||||
WOLFSSL_API WOLFSSL_EVP_CIPHER_CTX *wolfSSL_EVP_CIPHER_CTX_new(void);
|
||||
WOLFSSL_API void wolfSSL_EVP_CIPHER_CTX_free(WOLFSSL_EVP_CIPHER_CTX *ctx);
|
||||
WOLFSSL_API int wolfSSL_EVP_CIPHER_CTX_key_length(WOLFSSL_EVP_CIPHER_CTX* ctx);
|
||||
WOLFSSL_API int wolfSSL_EVP_CIPHER_CTX_set_key_length(WOLFSSL_EVP_CIPHER_CTX* ctx,
|
||||
int keylen);
|
||||
WOLFSSL_API int wolfSSL_EVP_Cipher(WOLFSSL_EVP_CIPHER_CTX* ctx,
|
||||
unsigned char* dst, unsigned char* src,
|
||||
unsigned int len);
|
||||
|
||||
WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_get_cipherbynid(int);
|
||||
WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_get_digestbynid(int);
|
||||
|
||||
WOLFSSL_API int wolfSSL_EVP_PKEY_assign_RSA(WOLFSSL_EVP_PKEY* pkey,
|
||||
WOLFSSL_RSA* key);
|
||||
WOLFSSL_API int wolfSSL_EVP_PKEY_assign_EC_KEY(WOLFSSL_EVP_PKEY* pkey,
|
||||
WOLFSSL_EC_KEY* key);
|
||||
WOLFSSL_API WOLFSSL_RSA* wolfSSL_EVP_PKEY_get1_RSA(WOLFSSL_EVP_PKEY*);
|
||||
WOLFSSL_API WOLFSSL_DSA* wolfSSL_EVP_PKEY_get1_DSA(WOLFSSL_EVP_PKEY*);
|
||||
WOLFSSL_API WOLFSSL_EC_KEY *wolfSSL_EVP_PKEY_get1_EC_KEY(WOLFSSL_EVP_PKEY *key);
|
||||
WOLFSSL_API int wolfSSL_EVP_PKEY_set1_RSA(WOLFSSL_EVP_PKEY *pkey, WOLFSSL_RSA *key);
|
||||
|
||||
WOLFSSL_API WOLFSSL_EVP_PKEY* wolfSSL_EVP_PKEY_new_mac_key(int type, ENGINE* e,
|
||||
const unsigned char* key, int keylen);
|
||||
WOLFSSL_API const unsigned char* wolfSSL_EVP_PKEY_get0_hmac(const WOLFSSL_EVP_PKEY* pkey,
|
||||
size_t* len);
|
||||
WOLFSSL_API int wolfSSL_EVP_PKEY_bits(const WOLFSSL_EVP_PKEY *pkey);
|
||||
WOLFSSL_API int wolfSSL_EVP_PKEY_CTX_free(WOLFSSL_EVP_PKEY_CTX *ctx);
|
||||
WOLFSSL_API WOLFSSL_EVP_PKEY_CTX *wolfSSL_EVP_PKEY_CTX_new(WOLFSSL_EVP_PKEY *pkey, WOLFSSL_ENGINE *e);
|
||||
WOLFSSL_API int wolfSSL_EVP_PKEY_CTX_set_rsa_padding(WOLFSSL_EVP_PKEY_CTX *ctx, int padding);
|
||||
WOLFSSL_API int wolfSSL_EVP_PKEY_decrypt(WOLFSSL_EVP_PKEY_CTX *ctx,
|
||||
unsigned char *out, size_t *outlen,
|
||||
const unsigned char *in, size_t inlen);
|
||||
WOLFSSL_API int wolfSSL_EVP_PKEY_decrypt_init(WOLFSSL_EVP_PKEY_CTX *ctx);
|
||||
WOLFSSL_API int wolfSSL_EVP_PKEY_encrypt(WOLFSSL_EVP_PKEY_CTX *ctx,
|
||||
unsigned char *out, size_t *outlen,
|
||||
const unsigned char *in, size_t inlen);
|
||||
WOLFSSL_API int wolfSSL_EVP_PKEY_encrypt_init(WOLFSSL_EVP_PKEY_CTX *ctx);
|
||||
WOLFSSL_API WOLFSSL_EVP_PKEY *wolfSSL_EVP_PKEY_new(void);
|
||||
WOLFSSL_API void wolfSSL_EVP_PKEY_free(WOLFSSL_EVP_PKEY*);
|
||||
WOLFSSL_API int wolfSSL_EVP_PKEY_size(WOLFSSL_EVP_PKEY *pkey);
|
||||
WOLFSSL_API int wolfSSL_EVP_PKEY_type(int type);
|
||||
WOLFSSL_API int wolfSSL_EVP_PKEY_id(const EVP_PKEY *pkey);
|
||||
WOLFSSL_API int wolfSSL_EVP_PKEY_base_id(const EVP_PKEY *pkey);
|
||||
WOLFSSL_API int wolfSSL_EVP_SignFinal(WOLFSSL_EVP_MD_CTX *ctx, unsigned char *sigret,
|
||||
unsigned int *siglen, WOLFSSL_EVP_PKEY *pkey);
|
||||
WOLFSSL_API int wolfSSL_EVP_SignInit(WOLFSSL_EVP_MD_CTX *ctx, const WOLFSSL_EVP_MD *type);
|
||||
WOLFSSL_API int wolfSSL_EVP_SignUpdate(WOLFSSL_EVP_MD_CTX *ctx, const void *data, size_t len);
|
||||
WOLFSSL_API int wolfSSL_EVP_VerifyFinal(WOLFSSL_EVP_MD_CTX *ctx,
|
||||
unsigned char* sig, unsigned int sig_len, WOLFSSL_EVP_PKEY *pkey);
|
||||
WOLFSSL_API int wolfSSL_EVP_VerifyInit(WOLFSSL_EVP_MD_CTX *ctx, const WOLFSSL_EVP_MD *type);
|
||||
WOLFSSL_API int wolfSSL_EVP_VerifyUpdate(WOLFSSL_EVP_MD_CTX *ctx, const void *data, size_t len);
|
||||
|
||||
|
||||
/* these next ones don't need real OpenSSL type, for OpenSSH compat only */
|
||||
WOLFSSL_API void* wolfSSL_EVP_X_STATE(const WOLFSSL_EVP_CIPHER_CTX* ctx);
|
||||
WOLFSSL_API int wolfSSL_EVP_X_STATE_LEN(const WOLFSSL_EVP_CIPHER_CTX* ctx);
|
||||
|
||||
WOLFSSL_API void wolfSSL_3des_iv(WOLFSSL_EVP_CIPHER_CTX* ctx, int doset,
|
||||
unsigned char* iv, int len);
|
||||
WOLFSSL_API void wolfSSL_aes_ctr_iv(WOLFSSL_EVP_CIPHER_CTX* ctx, int doset,
|
||||
unsigned char* iv, int len);
|
||||
|
||||
WOLFSSL_API int wolfSSL_StoreExternalIV(WOLFSSL_EVP_CIPHER_CTX* ctx);
|
||||
WOLFSSL_API int wolfSSL_SetInternalIV(WOLFSSL_EVP_CIPHER_CTX* ctx);
|
||||
|
||||
WOLFSSL_API int wolfSSL_EVP_CIPHER_CTX_block_size(const WOLFSSL_EVP_CIPHER_CTX *ctx);
|
||||
WOLFSSL_API int wolfSSL_EVP_CIPHER_block_size(const WOLFSSL_EVP_CIPHER *cipher);
|
||||
WOLFSSL_API unsigned long WOLFSSL_EVP_CIPHER_mode(const WOLFSSL_EVP_CIPHER *cipher);
|
||||
WOLFSSL_API unsigned long WOLFSSL_CIPHER_mode(const WOLFSSL_EVP_CIPHER *cipher);
|
||||
WOLFSSL_API unsigned long wolfSSL_EVP_CIPHER_flags(const WOLFSSL_EVP_CIPHER *cipher);
|
||||
WOLFSSL_API void wolfSSL_EVP_CIPHER_CTX_set_flags(WOLFSSL_EVP_CIPHER_CTX *ctx, int flags);
|
||||
WOLFSSL_API void wolfSSL_EVP_CIPHER_CTX_clear_flags(WOLFSSL_EVP_CIPHER_CTX *ctx, int flags);
|
||||
WOLFSSL_API unsigned long wolfSSL_EVP_CIPHER_CTX_mode(const WOLFSSL_EVP_CIPHER_CTX *ctx);
|
||||
WOLFSSL_API int wolfSSL_EVP_CIPHER_CTX_set_padding(WOLFSSL_EVP_CIPHER_CTX *c, int pad);
|
||||
WOLFSSL_API int wolfSSL_EVP_add_digest(const WOLFSSL_EVP_MD *digest);
|
||||
WOLFSSL_API int wolfSSL_EVP_add_cipher(const WOLFSSL_EVP_CIPHER *cipher);
|
||||
WOLFSSL_API void wolfSSL_EVP_cleanup(void);
|
||||
WOLFSSL_API int wolfSSL_add_all_algorithms(void);
|
||||
WOLFSSL_API int wolfSSL_OpenSSL_add_all_algorithms_noconf(void);
|
||||
|
||||
WOLFSSL_API int wolfSSL_PKCS5_PBKDF2_HMAC_SHA1(const char * pass, int passlen,
|
||||
const unsigned char * salt,
|
||||
int saltlen, int iter,
|
||||
int keylen, unsigned char *out);
|
||||
|
||||
#define EVP_CIPH_STREAM_CIPHER WOLFSSL_EVP_CIPH_STREAM_CIPHER
|
||||
#define EVP_CIPH_ECB_MODE WOLFSSL_EVP_CIPH_ECB_MODE
|
||||
#define EVP_CIPH_CBC_MODE WOLFSSL_EVP_CIPH_CBC_MODE
|
||||
#define EVP_CIPH_CFB_MODE WOLFSSL_EVP_CIPH_CFB_MODE
|
||||
#define EVP_CIPH_OFB_MODE WOLFSSL_EVP_CIPH_OFB_MODE
|
||||
#define EVP_CIPH_CTR_MODE WOLFSSL_EVP_CIPH_CTR_MODE
|
||||
#define EVP_CIPH_GCM_MODE WOLFSSL_EVP_CIPH_GCM_MODE
|
||||
#define EVP_CIPH_CCM_MODE WOLFSSL_EVP_CIPH_CCM_MODE
|
||||
|
||||
#define WOLFSSL_EVP_CIPH_MODE 0x0007
|
||||
#define WOLFSSL_EVP_CIPH_STREAM_CIPHER 0x0
|
||||
#define WOLFSSL_EVP_CIPH_ECB_MODE 0x1
|
||||
#define WOLFSSL_EVP_CIPH_CBC_MODE 0x2
|
||||
#define WOLFSSL_EVP_CIPH_CFB_MODE 0x3
|
||||
#define WOLFSSL_EVP_CIPH_OFB_MODE 0x4
|
||||
#define WOLFSSL_EVP_CIPH_CTR_MODE 0x5
|
||||
#define WOLFSSL_EVP_CIPH_GCM_MODE 0x6
|
||||
#define WOLFSSL_EVP_CIPH_CCM_MODE 0x7
|
||||
#define WOLFSSL_EVP_CIPH_NO_PADDING 0x100
|
||||
#define WOLFSSL_EVP_CIPH_TYPE_INIT 0xff
|
||||
|
||||
/* end OpenSSH compat */
|
||||
|
||||
typedef WOLFSSL_EVP_MD EVP_MD;
|
||||
typedef WOLFSSL_EVP_CIPHER EVP_CIPHER;
|
||||
typedef WOLFSSL_EVP_MD_CTX EVP_MD_CTX;
|
||||
typedef WOLFSSL_EVP_CIPHER_CTX EVP_CIPHER_CTX;
|
||||
|
||||
#ifndef NO_MD4
|
||||
#define EVP_md4 wolfSSL_EVP_md4
|
||||
#endif
|
||||
#ifndef NO_MD5
|
||||
#define EVP_md5 wolfSSL_EVP_md5
|
||||
#endif
|
||||
#define EVP_sha1 wolfSSL_EVP_sha1
|
||||
#define EVP_dds1 wolfSSL_EVP_sha1
|
||||
#define EVP_sha224 wolfSSL_EVP_sha224
|
||||
#define EVP_sha256 wolfSSL_EVP_sha256
|
||||
#define EVP_sha384 wolfSSL_EVP_sha384
|
||||
#define EVP_sha512 wolfSSL_EVP_sha512
|
||||
#define EVP_ripemd160 wolfSSL_EVP_ripemd160
|
||||
|
||||
#define EVP_aes_128_cbc wolfSSL_EVP_aes_128_cbc
|
||||
#define EVP_aes_192_cbc wolfSSL_EVP_aes_192_cbc
|
||||
#define EVP_aes_256_cbc wolfSSL_EVP_aes_256_cbc
|
||||
#define EVP_aes_128_ecb wolfSSL_EVP_aes_128_ecb
|
||||
#define EVP_aes_192_ecb wolfSSL_EVP_aes_192_ecb
|
||||
#define EVP_aes_256_ecb wolfSSL_EVP_aes_256_ecb
|
||||
#define EVP_aes_128_ctr wolfSSL_EVP_aes_128_ctr
|
||||
#define EVP_aes_192_ctr wolfSSL_EVP_aes_192_ctr
|
||||
#define EVP_aes_256_ctr wolfSSL_EVP_aes_256_ctr
|
||||
#define EVP_des_cbc wolfSSL_EVP_des_cbc
|
||||
#define EVP_des_ecb wolfSSL_EVP_des_ecb
|
||||
#define EVP_des_ede3_cbc wolfSSL_EVP_des_ede3_cbc
|
||||
#define EVP_des_ede3_ecb wolfSSL_EVP_des_ede3_ecb
|
||||
#define EVP_rc4 wolfSSL_EVP_rc4
|
||||
#define EVP_idea_cbc wolfSSL_EVP_idea_cbc
|
||||
#define EVP_enc_null wolfSSL_EVP_enc_null
|
||||
|
||||
#define EVP_MD_size wolfSSL_EVP_MD_size
|
||||
#define EVP_MD_CTX_new wolfSSL_EVP_MD_CTX_new
|
||||
#define EVP_MD_CTX_create wolfSSL_EVP_MD_CTX_new
|
||||
#define EVP_MD_CTX_free wolfSSL_EVP_MD_CTX_free
|
||||
#define EVP_MD_CTX_destroy wolfSSL_EVP_MD_CTX_free
|
||||
#define EVP_MD_CTX_init wolfSSL_EVP_MD_CTX_init
|
||||
#define EVP_MD_CTX_cleanup wolfSSL_EVP_MD_CTX_cleanup
|
||||
#define EVP_MD_CTX_md wolfSSL_EVP_MD_CTX_md
|
||||
#define EVP_MD_CTX_type wolfSSL_EVP_MD_CTX_type
|
||||
#define EVP_MD_type wolfSSL_EVP_MD_type
|
||||
|
||||
#define EVP_DigestInit wolfSSL_EVP_DigestInit
|
||||
#define EVP_DigestInit_ex wolfSSL_EVP_DigestInit_ex
|
||||
#define EVP_DigestUpdate wolfSSL_EVP_DigestUpdate
|
||||
#define EVP_DigestFinal wolfSSL_EVP_DigestFinal
|
||||
#define EVP_DigestFinal_ex wolfSSL_EVP_DigestFinal_ex
|
||||
#define EVP_DigestSignInit wolfSSL_EVP_DigestSignInit
|
||||
#define EVP_DigestSignUpdate wolfSSL_EVP_DigestSignUpdate
|
||||
#define EVP_DigestSignFinal wolfSSL_EVP_DigestSignFinal
|
||||
#define EVP_DigestVerifyInit wolfSSL_EVP_DigestVerifyInit
|
||||
#define EVP_DigestVerifyUpdate wolfSSL_EVP_DigestVerifyUpdate
|
||||
#define EVP_DigestVerifyFinal wolfSSL_EVP_DigestVerifyFinal
|
||||
#define EVP_BytesToKey wolfSSL_EVP_BytesToKey
|
||||
|
||||
#define EVP_get_cipherbyname wolfSSL_EVP_get_cipherbyname
|
||||
#define EVP_get_digestbyname wolfSSL_EVP_get_digestbyname
|
||||
|
||||
#define EVP_CIPHER_CTX_init wolfSSL_EVP_CIPHER_CTX_init
|
||||
#define EVP_CIPHER_CTX_cleanup wolfSSL_EVP_CIPHER_CTX_cleanup
|
||||
#define EVP_CIPHER_CTX_iv_length wolfSSL_EVP_CIPHER_CTX_iv_length
|
||||
#define EVP_CIPHER_CTX_key_length wolfSSL_EVP_CIPHER_CTX_key_length
|
||||
#define EVP_CIPHER_CTX_set_key_length wolfSSL_EVP_CIPHER_CTX_set_key_length
|
||||
#define EVP_CIPHER_CTX_mode wolfSSL_EVP_CIPHER_CTX_mode
|
||||
|
||||
#define EVP_CIPHER_iv_length wolfSSL_EVP_CIPHER_iv_length
|
||||
#define EVP_CIPHER_key_length wolfSSL_EVP_Cipher_key_length
|
||||
|
||||
#define EVP_CipherInit wolfSSL_EVP_CipherInit
|
||||
#define EVP_CipherInit_ex wolfSSL_EVP_CipherInit_ex
|
||||
#define EVP_EncryptInit wolfSSL_EVP_EncryptInit
|
||||
#define EVP_EncryptInit_ex wolfSSL_EVP_EncryptInit_ex
|
||||
#define EVP_DecryptInit wolfSSL_EVP_DecryptInit
|
||||
#define EVP_DecryptInit_ex wolfSSL_EVP_DecryptInit_ex
|
||||
|
||||
#define EVP_Cipher wolfSSL_EVP_Cipher
|
||||
#define EVP_CipherUpdate wolfSSL_EVP_CipherUpdate
|
||||
#define EVP_EncryptUpdate wolfSSL_EVP_CipherUpdate
|
||||
#define EVP_DecryptUpdate wolfSSL_EVP_CipherUpdate
|
||||
#define EVP_CipherFinal wolfSSL_EVP_CipherFinal
|
||||
#define EVP_CipherFinal_ex wolfSSL_EVP_CipherFinal
|
||||
#define EVP_EncryptFinal wolfSSL_EVP_CipherFinal
|
||||
#define EVP_EncryptFinal_ex wolfSSL_EVP_CipherFinal
|
||||
#define EVP_DecryptFinal wolfSSL_EVP_CipherFinal
|
||||
#define EVP_DecryptFinal_ex wolfSSL_EVP_CipherFinal
|
||||
|
||||
#define EVP_CIPHER_CTX_free wolfSSL_EVP_CIPHER_CTX_free
|
||||
#define EVP_CIPHER_CTX_new wolfSSL_EVP_CIPHER_CTX_new
|
||||
|
||||
#define EVP_get_cipherbynid wolfSSL_EVP_get_cipherbynid
|
||||
#define EVP_get_digestbynid wolfSSL_EVP_get_digestbynid
|
||||
#define EVP_get_cipherbyname wolfSSL_EVP_get_cipherbyname
|
||||
#define EVP_get_digestbyname wolfSSL_EVP_get_digestbyname
|
||||
|
||||
#define EVP_PKEY_asign_RSA wolfSSL_EVP_PKEY_assign_RSA
|
||||
#define EVP_PKEY_asign_EC_KEY wolfSSL_EVP_PKEY_assign_EC_KEY
|
||||
#define EVP_PKEY_get1_DSA wolfSSL_EVP_PKEY_get1_DSA
|
||||
#define EVP_PKEY_get1_RSA wolfSSL_EVP_PKEY_get1_RSA
|
||||
#define EVP_PKEY_get1_DSA wolfSSL_EVP_PKEY_get1_DSA
|
||||
#define EVP_PKEY_set1_RSA wolfSSL_EVP_PKEY_set1_RSA
|
||||
#define EVP_PKEY_get1_EC_KEY wolfSSL_EVP_PKEY_get1_EC_KEY
|
||||
#define EVP_PKEY_get0_hmac wolfSSL_EVP_PKEY_get0_hmac
|
||||
#define EVP_PKEY_new_mac_key wolfSSL_EVP_PKEY_new_mac_key
|
||||
#define EVP_MD_CTX_copy wolfSSL_EVP_MD_CTX_copy
|
||||
#define EVP_MD_CTX_copy_ex wolfSSL_EVP_MD_CTX_copy_ex
|
||||
#define EVP_PKEY_bits wolfSSL_EVP_PKEY_bits
|
||||
#define EVP_PKEY_CTX_free wolfSSL_EVP_PKEY_CTX_free
|
||||
#define EVP_PKEY_CTX_new wolfSSL_EVP_PKEY_CTX_new
|
||||
#define EVP_PKEY_CTX_set_rsa_padding wolfSSL_EVP_PKEY_CTX_set_rsa_padding
|
||||
#define EVP_PKEY_decrypt wolfSSL_EVP_PKEY_decrypt
|
||||
#define EVP_PKEY_decrypt_init wolfSSL_EVP_PKEY_decrypt_init
|
||||
#define EVP_PKEY_encrypt wolfSSL_EVP_PKEY_encrypt
|
||||
#define EVP_PKEY_encrypt_init wolfSSL_EVP_PKEY_encrypt_init
|
||||
#define EVP_PKEY_new wolfSSL_PKEY_new
|
||||
#define EVP_PKEY_free wolfSSL_EVP_PKEY_free
|
||||
#define EVP_PKEY_size wolfSSL_EVP_PKEY_size
|
||||
#define EVP_PKEY_type wolfSSL_EVP_PKEY_type
|
||||
#define EVP_PKEY_base_id wolfSSL_EVP_PKEY_base_id
|
||||
#define EVP_PKEY_id wolfSSL_EVP_PKEY_id
|
||||
#define EVP_SignFinal wolfSSL_EVP_SignFinal
|
||||
#define EVP_SignInit wolfSSL_EVP_SignInit
|
||||
#define EVP_SignUpdate wolfSSL_EVP_SignUpdate
|
||||
#define EVP_VerifyFinal wolfSSL_EVP_VerifyFinal
|
||||
#define EVP_VerifyInit wolfSSL_EVP_VerifyInit
|
||||
#define EVP_VerifyUpdate wolfSSL_EVP_VerifyUpdate
|
||||
|
||||
#define EVP_CIPHER_CTX_block_size wolfSSL_EVP_CIPHER_CTX_block_size
|
||||
#define EVP_CIPHER_block_size wolfSSL_EVP_CIPHER_block_size
|
||||
#define EVP_CIPHER_flags wolfSSL_EVP_CIPHER_flags
|
||||
#define EVP_CIPHER_CTX_set_flags wolfSSL_EVP_CIPHER_CTX_set_flags
|
||||
#define EVP_CIPHER_CTX_clear_flags wolfSSL_EVP_CIPHER_CTX_clear_flags
|
||||
#define EVP_CIPHER_CTX_set_padding wolfSSL_EVP_CIPHER_CTX_set_padding
|
||||
#define EVP_CIPHER_CTX_flags wolfSSL_EVP_CIPHER_CTX_flags
|
||||
#define EVP_add_digest wolfSSL_EVP_add_digest
|
||||
#define EVP_add_cipher wolfSSL_EVP_add_cipher
|
||||
#define EVP_cleanup wolfSSL_EVP_cleanup
|
||||
|
||||
#define OpenSSL_add_all_digests() wolfCrypt_Init()
|
||||
#define OpenSSL_add_all_ciphers() wolfCrypt_Init()
|
||||
#define OpenSSL_add_all_algorithms wolfSSL_add_all_algorithms
|
||||
#define OpenSSL_add_all_algorithms_noconf wolfSSL_OpenSSL_add_all_algorithms_noconf
|
||||
#define wolfSSL_OPENSSL_add_all_algorithms_noconf wolfSSL_OpenSSL_add_all_algorithms_noconf
|
||||
|
||||
#define PKCS5_PBKDF2_HMAC_SHA1 wolfSSL_PKCS5_PBKDF2_HMAC_SHA1
|
||||
|
||||
#ifndef EVP_MAX_MD_SIZE
|
||||
#define EVP_MAX_MD_SIZE 64 /* sha512 */
|
||||
#endif
|
||||
|
||||
#ifndef EVP_MAX_BLOCK_LENGTH
|
||||
#define EVP_MAX_BLOCK_LENGTH 32 /* 2 * blocklen(AES)? */
|
||||
/* They define this as 32. Using the same value here. */
|
||||
#endif
|
||||
|
||||
WOLFSSL_API void printPKEY(WOLFSSL_EVP_PKEY *k);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* WOLFSSL_EVP_H_ */
|
@ -0,0 +1,85 @@
|
||||
/* hmac.h
|
||||
*
|
||||
* Copyright (C) 2006-2018 wolfSSL Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is distributed in binary form as licensed by Espressif Systems.
|
||||
* See README file or contact licensing@wolfssl.com with any questions or comments.
|
||||
*
|
||||
* https://www.wolfssl.com
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/* hmac.h defines mini hamc openssl compatibility layer
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef WOLFSSL_HMAC_H_
|
||||
#define WOLFSSL_HMAC_H_
|
||||
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#ifdef WOLFSSL_PREFIX
|
||||
#include "prefix_hmac.h"
|
||||
#endif
|
||||
|
||||
#include <wolfssl/openssl/evp.h>
|
||||
#include <wolfssl/openssl/opensslv.h>
|
||||
#include <wolfssl/wolfcrypt/hmac.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
WOLFSSL_API unsigned char* wolfSSL_HMAC(const WOLFSSL_EVP_MD* evp_md,
|
||||
const void* key, int key_len,
|
||||
const unsigned char* d, int n, unsigned char* md,
|
||||
unsigned int* md_len);
|
||||
|
||||
|
||||
typedef struct WOLFSSL_HMAC_CTX {
|
||||
Hmac hmac;
|
||||
int type;
|
||||
word32 save_ipad[WC_HMAC_BLOCK_SIZE / sizeof(word32)]; /* same block size all*/
|
||||
word32 save_opad[WC_HMAC_BLOCK_SIZE / sizeof(word32)];
|
||||
} WOLFSSL_HMAC_CTX;
|
||||
|
||||
|
||||
WOLFSSL_API int wolfSSL_HMAC_CTX_Init(WOLFSSL_HMAC_CTX* ctx);
|
||||
WOLFSSL_API int wolfSSL_HMAC_CTX_copy(WOLFSSL_HMAC_CTX* des,
|
||||
WOLFSSL_HMAC_CTX* src);
|
||||
WOLFSSL_LOCAL int wolfSSL_HmacCopy(Hmac* des, Hmac* src);
|
||||
WOLFSSL_API int wolfSSL_HMAC_Init(WOLFSSL_HMAC_CTX* ctx, const void* key,
|
||||
int keylen, const EVP_MD* type);
|
||||
WOLFSSL_API int wolfSSL_HMAC_Init_ex(WOLFSSL_HMAC_CTX* ctx, const void* key,
|
||||
int keylen, const EVP_MD* type, WOLFSSL_ENGINE* e);
|
||||
WOLFSSL_API int wolfSSL_HMAC_Update(WOLFSSL_HMAC_CTX* ctx,
|
||||
const unsigned char* data, int len);
|
||||
WOLFSSL_API int wolfSSL_HMAC_Final(WOLFSSL_HMAC_CTX* ctx, unsigned char* hash,
|
||||
unsigned int* len);
|
||||
WOLFSSL_API int wolfSSL_HMAC_cleanup(WOLFSSL_HMAC_CTX* ctx);
|
||||
|
||||
typedef struct WOLFSSL_HMAC_CTX HMAC_CTX;
|
||||
|
||||
#define HMAC(a,b,c,d,e,f,g) wolfSSL_HMAC((a),(b),(c),(d),(e),(f),(g))
|
||||
|
||||
#define HMAC_CTX_init wolfSSL_HMAC_CTX_Init
|
||||
#define HMAC_CTX_copy wolfSSL_HMAC_CTX_copy
|
||||
#define HMAC_Init_ex wolfSSL_HMAC_Init_ex
|
||||
#define HMAC_Init wolfSSL_HMAC_Init
|
||||
#define HMAC_Update wolfSSL_HMAC_Update
|
||||
#define HMAC_Final wolfSSL_HMAC_Final
|
||||
#define HMAC_cleanup wolfSSL_HMAC_cleanup
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* WOLFSSL_HMAC_H_ */
|
68
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/openssl/md5.h
Normal file
68
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/openssl/md5.h
Normal file
@ -0,0 +1,68 @@
|
||||
/* md5.h
|
||||
*
|
||||
* Copyright (C) 2006-2018 wolfSSL Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is distributed in binary form as licensed by Espressif Systems.
|
||||
* See README file or contact licensing@wolfssl.com with any questions or comments.
|
||||
*
|
||||
* https://www.wolfssl.com
|
||||
*/
|
||||
|
||||
|
||||
/* md5.h for openssl */
|
||||
|
||||
|
||||
#ifndef WOLFSSL_MD5_H_
|
||||
#define WOLFSSL_MD5_H_
|
||||
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#ifndef NO_MD5
|
||||
|
||||
#include <wolfssl/wolfcrypt/hash.h>
|
||||
|
||||
#ifdef WOLFSSL_PREFIX
|
||||
#include "prefix_md5.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct WOLFSSL_MD5_CTX {
|
||||
void* holder[(112 + WC_ASYNC_DEV_SIZE) / sizeof(void*)]; /* big enough to hold wolfcrypt md5, but check on init */
|
||||
} WOLFSSL_MD5_CTX;
|
||||
|
||||
WOLFSSL_API int wolfSSL_MD5_Init(WOLFSSL_MD5_CTX*);
|
||||
WOLFSSL_API int wolfSSL_MD5_Update(WOLFSSL_MD5_CTX*, const void*, unsigned long);
|
||||
WOLFSSL_API int wolfSSL_MD5_Final(unsigned char*, WOLFSSL_MD5_CTX*);
|
||||
|
||||
|
||||
typedef WOLFSSL_MD5_CTX MD5_CTX;
|
||||
|
||||
#define MD5_Init wolfSSL_MD5_Init
|
||||
#define MD5_Update wolfSSL_MD5_Update
|
||||
#define MD5_Final wolfSSL_MD5_Final
|
||||
|
||||
#ifdef OPENSSL_EXTRA_BSD
|
||||
#define MD5Init wolfSSL_MD5_Init
|
||||
#define MD5Update wolfSSL_MD5_Update
|
||||
#define MD5Final wolfSSL_MD5_Final
|
||||
#endif
|
||||
|
||||
#ifndef MD5
|
||||
#define MD5(d, n, md) wc_Md5Hash((d), (n), (md))
|
||||
#endif
|
||||
|
||||
#define MD5_DIGEST_LENGTH MD5_DIGEST_SIZE
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* NO_MD5 */
|
||||
|
||||
#endif /* WOLFSSL_MD5_H_ */
|
@ -0,0 +1,33 @@
|
||||
/* opensslv.h
|
||||
*
|
||||
* Copyright (C) 2006-2018 wolfSSL Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is distributed in binary form as licensed by Espressif Systems.
|
||||
* See README file or contact licensing@wolfssl.com with any questions or comments.
|
||||
*
|
||||
* https://www.wolfssl.com
|
||||
*/
|
||||
|
||||
|
||||
/* opensslv.h compatibility */
|
||||
|
||||
#ifndef WOLFSSL_OPENSSLV_H_
|
||||
#define WOLFSSL_OPENSSLV_H_
|
||||
|
||||
|
||||
/* api version compatibility */
|
||||
#if defined(OPENSSL_ALL) || defined(HAVE_STUNNEL) || defined(HAVE_LIGHTY) || \
|
||||
defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY)
|
||||
/* version number can be increased for Lighty after compatibility for ECDH
|
||||
is added */
|
||||
#define OPENSSL_VERSION_NUMBER 0x10001000L
|
||||
#else
|
||||
#define OPENSSL_VERSION_NUMBER 0x0090810fL
|
||||
#endif
|
||||
|
||||
#define OPENSSL_VERSION_TEXT LIBWOLFSSL_VERSION_STRING
|
||||
|
||||
|
||||
#endif /* header */
|
@ -0,0 +1,50 @@
|
||||
/* ripemd.h
|
||||
*
|
||||
* Copyright (C) 2006-2018 wolfSSL Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is distributed in binary form as licensed by Espressif Systems.
|
||||
* See README file or contact licensing@wolfssl.com with any questions or comments.
|
||||
*
|
||||
* https://www.wolfssl.com
|
||||
*/
|
||||
|
||||
|
||||
/* ripemd.h for openssl */
|
||||
|
||||
|
||||
#ifndef WOLFSSL_RIPEMD_H_
|
||||
#define WOLFSSL_RIPEMD_H_
|
||||
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct WOLFSSL_RIPEMD_CTX {
|
||||
int holder[32]; /* big enough to hold wolfcrypt, but check on init */
|
||||
} WOLFSSL_RIPEMD_CTX;
|
||||
|
||||
WOLFSSL_API void wolfSSL_RIPEMD_Init(WOLFSSL_RIPEMD_CTX*);
|
||||
WOLFSSL_API void wolfSSL_RIPEMD_Update(WOLFSSL_RIPEMD_CTX*, const void*,
|
||||
unsigned long);
|
||||
WOLFSSL_API void wolfSSL_RIPEMD_Final(unsigned char*, WOLFSSL_RIPEMD_CTX*);
|
||||
|
||||
|
||||
typedef WOLFSSL_RIPEMD_CTX RIPEMD_CTX;
|
||||
|
||||
#define RIPEMD_Init wolfSSL_RIPEMD_Init
|
||||
#define RIPEMD_Update wolfSSL_RIPEMD_Update
|
||||
#define RIPEMD_Final wolfSSL_RIPEMD_Final
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* WOLFSSL_MD5_H_ */
|
||||
|
113
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/openssl/rsa.h
Normal file
113
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/openssl/rsa.h
Normal file
@ -0,0 +1,113 @@
|
||||
/* rsa.h
|
||||
*
|
||||
* Copyright (C) 2006-2018 wolfSSL Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is distributed in binary form as licensed by Espressif Systems.
|
||||
* See README file or contact licensing@wolfssl.com with any questions or comments.
|
||||
*
|
||||
* https://www.wolfssl.com
|
||||
*/
|
||||
|
||||
|
||||
/* rsa.h for openSSL */
|
||||
|
||||
|
||||
#ifndef WOLFSSL_RSA_H_
|
||||
#define WOLFSSL_RSA_H_
|
||||
|
||||
#include <wolfssl/openssl/bn.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Padding types */
|
||||
#define RSA_PKCS1_PADDING 0
|
||||
#define RSA_PKCS1_OAEP_PADDING 1
|
||||
|
||||
#ifndef WOLFSSL_RSA_TYPE_DEFINED /* guard on redeclaration */
|
||||
typedef struct WOLFSSL_RSA WOLFSSL_RSA;
|
||||
#define WOLFSSL_RSA_TYPE_DEFINED
|
||||
#endif
|
||||
|
||||
typedef WOLFSSL_RSA RSA;
|
||||
|
||||
struct WOLFSSL_RSA {
|
||||
#ifdef WC_RSA_BLINDING
|
||||
WC_RNG* rng; /* for PrivateDecrypt blinding */
|
||||
#endif
|
||||
WOLFSSL_BIGNUM* n;
|
||||
WOLFSSL_BIGNUM* e;
|
||||
WOLFSSL_BIGNUM* d;
|
||||
WOLFSSL_BIGNUM* p;
|
||||
WOLFSSL_BIGNUM* q;
|
||||
WOLFSSL_BIGNUM* dmp1; /* dP */
|
||||
WOLFSSL_BIGNUM* dmq1; /* dQ */
|
||||
WOLFSSL_BIGNUM* iqmp; /* u */
|
||||
void* heap;
|
||||
void* internal; /* our RSA */
|
||||
char inSet; /* internal set from external ? */
|
||||
char exSet; /* external set from internal ? */
|
||||
char ownRng; /* flag for if the rng should be free'd */
|
||||
};
|
||||
|
||||
|
||||
WOLFSSL_API WOLFSSL_RSA* wolfSSL_RSA_new(void);
|
||||
WOLFSSL_API void wolfSSL_RSA_free(WOLFSSL_RSA*);
|
||||
|
||||
WOLFSSL_API int wolfSSL_RSA_generate_key_ex(WOLFSSL_RSA*, int bits, WOLFSSL_BIGNUM*,
|
||||
void* cb);
|
||||
|
||||
WOLFSSL_API int wolfSSL_RSA_blinding_on(WOLFSSL_RSA*, WOLFSSL_BN_CTX*);
|
||||
WOLFSSL_API int wolfSSL_RSA_public_encrypt(int len, const unsigned char* fr,
|
||||
unsigned char* to, WOLFSSL_RSA*, int padding);
|
||||
WOLFSSL_API int wolfSSL_RSA_private_decrypt(int len, const unsigned char* fr,
|
||||
unsigned char* to, WOLFSSL_RSA*, int padding);
|
||||
WOLFSSL_API int wolfSSL_RSA_private_encrypt(int len, unsigned char* in,
|
||||
unsigned char* out, WOLFSSL_RSA* rsa, int padding);
|
||||
|
||||
WOLFSSL_API int wolfSSL_RSA_size(const WOLFSSL_RSA*);
|
||||
WOLFSSL_API int wolfSSL_RSA_sign(int type, const unsigned char* m,
|
||||
unsigned int mLen, unsigned char* sigRet,
|
||||
unsigned int* sigLen, WOLFSSL_RSA*);
|
||||
WOLFSSL_API int wolfSSL_RSA_sign_ex(int type, const unsigned char* m,
|
||||
unsigned int mLen, unsigned char* sigRet,
|
||||
unsigned int* sigLen, WOLFSSL_RSA*, int);
|
||||
WOLFSSL_API int wolfSSL_RSA_verify(int type, const unsigned char* m,
|
||||
unsigned int mLen, const unsigned char* sig,
|
||||
unsigned int sigLen, WOLFSSL_RSA*);
|
||||
WOLFSSL_API int wolfSSL_RSA_public_decrypt(int flen, const unsigned char* from,
|
||||
unsigned char* to, WOLFSSL_RSA*, int padding);
|
||||
WOLFSSL_API int wolfSSL_RSA_GenAdd(WOLFSSL_RSA*);
|
||||
WOLFSSL_API int wolfSSL_RSA_LoadDer(WOLFSSL_RSA*, const unsigned char*, int sz);
|
||||
WOLFSSL_API int wolfSSL_RSA_LoadDer_ex(WOLFSSL_RSA*, const unsigned char*, int sz, int opt);
|
||||
|
||||
#define WOLFSSL_RSA_LOAD_PRIVATE 1
|
||||
#define WOLFSSL_RSA_LOAD_PUBLIC 2
|
||||
#define WOLFSSL_RSA_F4 0x10001L
|
||||
|
||||
#define RSA_new wolfSSL_RSA_new
|
||||
#define RSA_free wolfSSL_RSA_free
|
||||
|
||||
#define RSA_generate_key_ex wolfSSL_RSA_generate_key_ex
|
||||
|
||||
#define RSA_blinding_on wolfSSL_RSA_blinding_on
|
||||
#define RSA_public_encrypt wolfSSL_RSA_public_encrypt
|
||||
#define RSA_private_decrypt wolfSSL_RSA_private_decrypt
|
||||
#define RSA_private_encrypt wolfSSL_RSA_private_encrypt
|
||||
|
||||
#define RSA_size wolfSSL_RSA_size
|
||||
#define RSA_sign wolfSSL_RSA_sign
|
||||
#define RSA_verify wolfSSL_RSA_verify
|
||||
#define RSA_public_decrypt wolfSSL_RSA_public_decrypt
|
||||
|
||||
#define RSA_F4 WOLFSSL_RSA_F4
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* header */
|
188
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/openssl/sha.h
Normal file
188
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/openssl/sha.h
Normal file
@ -0,0 +1,188 @@
|
||||
/* sha.h
|
||||
*
|
||||
* Copyright (C) 2006-2018 wolfSSL Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is distributed in binary form as licensed by Espressif Systems.
|
||||
* See README file or contact licensing@wolfssl.com with any questions or comments.
|
||||
*
|
||||
* https://www.wolfssl.com
|
||||
*/
|
||||
|
||||
|
||||
/* sha.h for openssl */
|
||||
|
||||
|
||||
#ifndef WOLFSSL_SHA_H_
|
||||
#define WOLFSSL_SHA_H_
|
||||
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
#include <wolfssl/wolfcrypt/types.h>
|
||||
|
||||
#ifdef WOLFSSL_PREFIX
|
||||
#include "prefix_sha.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct WOLFSSL_SHA_CTX {
|
||||
/* big enough to hold wolfcrypt Sha, but check on init */
|
||||
void* holder[(112 + WC_ASYNC_DEV_SIZE) / sizeof(void*)];
|
||||
} WOLFSSL_SHA_CTX;
|
||||
|
||||
WOLFSSL_API int wolfSSL_SHA_Init(WOLFSSL_SHA_CTX*);
|
||||
WOLFSSL_API int wolfSSL_SHA_Update(WOLFSSL_SHA_CTX*, const void*, unsigned long);
|
||||
WOLFSSL_API int wolfSSL_SHA_Final(unsigned char*, WOLFSSL_SHA_CTX*);
|
||||
|
||||
/* SHA1 points to above, shouldn't use SHA0 ever */
|
||||
WOLFSSL_API int wolfSSL_SHA1_Init(WOLFSSL_SHA_CTX*);
|
||||
WOLFSSL_API int wolfSSL_SHA1_Update(WOLFSSL_SHA_CTX*, const void*, unsigned long);
|
||||
WOLFSSL_API int wolfSSL_SHA1_Final(unsigned char*, WOLFSSL_SHA_CTX*);
|
||||
|
||||
enum {
|
||||
SHA_DIGEST_LENGTH = 20
|
||||
};
|
||||
|
||||
|
||||
typedef WOLFSSL_SHA_CTX SHA_CTX;
|
||||
|
||||
#define SHA_Init wolfSSL_SHA_Init
|
||||
#define SHA_Update wolfSSL_SHA_Update
|
||||
#define SHA_Final wolfSSL_SHA_Final
|
||||
|
||||
#define SHA1_Init wolfSSL_SHA1_Init
|
||||
#define SHA1_Update wolfSSL_SHA1_Update
|
||||
#define SHA1_Final wolfSSL_SHA1_Final
|
||||
|
||||
|
||||
#ifdef WOLFSSL_SHA224
|
||||
|
||||
/* Using ALIGN16 because when AES-NI is enabled digest and buffer in Sha256
|
||||
* struct are 16 byte aligned. Any derefrence to those elements after casting to
|
||||
* Sha224, is expected to also be 16 byte aligned addresses. */
|
||||
typedef struct WOLFSSL_SHA224_CTX {
|
||||
/* big enough to hold wolfcrypt Sha224, but check on init */
|
||||
ALIGN16 void* holder[(272 + WC_ASYNC_DEV_SIZE) / sizeof(void*)];
|
||||
} WOLFSSL_SHA224_CTX;
|
||||
|
||||
WOLFSSL_API int wolfSSL_SHA224_Init(WOLFSSL_SHA224_CTX*);
|
||||
WOLFSSL_API int wolfSSL_SHA224_Update(WOLFSSL_SHA224_CTX*, const void*,
|
||||
unsigned long);
|
||||
WOLFSSL_API int wolfSSL_SHA224_Final(unsigned char*, WOLFSSL_SHA224_CTX*);
|
||||
|
||||
enum {
|
||||
SHA224_DIGEST_LENGTH = 28
|
||||
};
|
||||
|
||||
|
||||
typedef WOLFSSL_SHA224_CTX SHA224_CTX;
|
||||
|
||||
#define SHA224_Init wolfSSL_SHA224_Init
|
||||
#define SHA224_Update wolfSSL_SHA224_Update
|
||||
#define SHA224_Final wolfSSL_SHA224_Final
|
||||
|
||||
#endif /* WOLFSSL_SHA224 */
|
||||
|
||||
|
||||
/* Using ALIGN16 because when AES-NI is enabled digest and buffer in Sha256
|
||||
* struct are 16 byte aligned. Any derefrence to those elements after casting to
|
||||
* Sha256, is expected to also be 16 byte aligned addresses. */
|
||||
typedef struct WOLFSSL_SHA256_CTX {
|
||||
/* big enough to hold wolfcrypt Sha256, but check on init */
|
||||
ALIGN16 void* holder[(272 + WC_ASYNC_DEV_SIZE) / sizeof(void*)];
|
||||
} WOLFSSL_SHA256_CTX;
|
||||
|
||||
WOLFSSL_API int wolfSSL_SHA256_Init(WOLFSSL_SHA256_CTX*);
|
||||
WOLFSSL_API int wolfSSL_SHA256_Update(WOLFSSL_SHA256_CTX*, const void*,
|
||||
unsigned long);
|
||||
WOLFSSL_API int wolfSSL_SHA256_Final(unsigned char*, WOLFSSL_SHA256_CTX*);
|
||||
|
||||
enum {
|
||||
SHA256_DIGEST_LENGTH = 32
|
||||
};
|
||||
|
||||
|
||||
typedef WOLFSSL_SHA256_CTX SHA256_CTX;
|
||||
|
||||
#define SHA256_Init wolfSSL_SHA256_Init
|
||||
#define SHA256_Update wolfSSL_SHA256_Update
|
||||
#define SHA256_Final wolfSSL_SHA256_Final
|
||||
#if defined(NO_OLD_SHA_NAMES) && !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST)
|
||||
/* SHA256 is only available in non-fips mode because of SHA256 enum in FIPS
|
||||
* build. */
|
||||
#define SHA256 wolfSSL_SHA256
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef WOLFSSL_SHA384
|
||||
|
||||
typedef struct WOLFSSL_SHA384_CTX {
|
||||
/* big enough to hold wolfCrypt Sha384, but check on init */
|
||||
void* holder[(256 + WC_ASYNC_DEV_SIZE) / sizeof(void*)];
|
||||
} WOLFSSL_SHA384_CTX;
|
||||
|
||||
WOLFSSL_API int wolfSSL_SHA384_Init(WOLFSSL_SHA384_CTX*);
|
||||
WOLFSSL_API int wolfSSL_SHA384_Update(WOLFSSL_SHA384_CTX*, const void*,
|
||||
unsigned long);
|
||||
WOLFSSL_API int wolfSSL_SHA384_Final(unsigned char*, WOLFSSL_SHA384_CTX*);
|
||||
|
||||
enum {
|
||||
SHA384_DIGEST_LENGTH = 48
|
||||
};
|
||||
|
||||
|
||||
typedef WOLFSSL_SHA384_CTX SHA384_CTX;
|
||||
|
||||
#define SHA384_Init wolfSSL_SHA384_Init
|
||||
#define SHA384_Update wolfSSL_SHA384_Update
|
||||
#define SHA384_Final wolfSSL_SHA384_Final
|
||||
#if defined(NO_OLD_SHA_NAMES) && !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST)
|
||||
/* SHA384 is only available in non-fips mode because of SHA384 enum in FIPS
|
||||
* build. */
|
||||
#define SHA384 wolfSSL_SHA384
|
||||
#endif
|
||||
#endif /* WOLFSSL_SHA384 */
|
||||
|
||||
#ifdef WOLFSSL_SHA512
|
||||
|
||||
typedef struct WOLFSSL_SHA512_CTX {
|
||||
/* big enough to hold wolfCrypt Sha384, but check on init */
|
||||
void* holder[(288 + WC_ASYNC_DEV_SIZE) / sizeof(void*)];
|
||||
} WOLFSSL_SHA512_CTX;
|
||||
|
||||
WOLFSSL_API int wolfSSL_SHA512_Init(WOLFSSL_SHA512_CTX*);
|
||||
WOLFSSL_API int wolfSSL_SHA512_Update(WOLFSSL_SHA512_CTX*, const void*,
|
||||
unsigned long);
|
||||
WOLFSSL_API int wolfSSL_SHA512_Final(unsigned char*, WOLFSSL_SHA512_CTX*);
|
||||
|
||||
enum {
|
||||
SHA512_DIGEST_LENGTH = 64
|
||||
};
|
||||
|
||||
|
||||
typedef WOLFSSL_SHA512_CTX SHA512_CTX;
|
||||
|
||||
#define SHA512_Init wolfSSL_SHA512_Init
|
||||
#define SHA512_Update wolfSSL_SHA512_Update
|
||||
#define SHA512_Final wolfSSL_SHA512_Final
|
||||
#if defined(NO_OLD_SHA_NAMES) && !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST)
|
||||
/* SHA512 is only available in non-fips mode because of SHA512 enum in FIPS
|
||||
* build. */
|
||||
#define SHA512 wolfSSL_SHA512
|
||||
#endif
|
||||
#endif /* WOLFSSL_SHA512 */
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* WOLFSSL_SHA_H_ */
|
||||
|
971
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/openssl/ssl.h
Normal file
971
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/openssl/ssl.h
Normal file
@ -0,0 +1,971 @@
|
||||
/* ssl.h
|
||||
*
|
||||
* Copyright (C) 2006-2018 wolfSSL Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is distributed in binary form as licensed by Espressif Systems.
|
||||
* See README file or contact licensing@wolfssl.com with any questions or comments.
|
||||
*
|
||||
* https://www.wolfssl.com
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/* ssl.h defines wolfssl_openssl compatibility layer
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef WOLFSSL_OPENSSL_H_
|
||||
#define WOLFSSL_OPENSSL_H_
|
||||
|
||||
/* wolfssl_openssl compatibility layer */
|
||||
#ifndef OPENSSL_EXTRA_SSL_GUARD
|
||||
#define OPENSSL_EXTRA_SSL_GUARD
|
||||
#include <wolfssl/ssl.h>
|
||||
#endif /* OPENSSL_EXTRA_SSL_GUARD */
|
||||
|
||||
#include <wolfssl/openssl/evp.h>
|
||||
#ifdef OPENSSL_EXTRA
|
||||
#include <wolfssl/openssl/crypto.h>
|
||||
#endif
|
||||
|
||||
#if defined(WOLFSSL_ASIO) || defined(WOLFSSL_HAPROXY)
|
||||
#include <wolfssl/wolfcrypt/asn.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
/* wincrypt.h clashes */
|
||||
#undef X509_NAME
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_UTASKER
|
||||
/* tcpip.h clashes */
|
||||
#undef ASN1_INTEGER
|
||||
#endif
|
||||
|
||||
|
||||
typedef WOLFSSL SSL;
|
||||
typedef WOLFSSL_SESSION SSL_SESSION;
|
||||
typedef WOLFSSL_METHOD SSL_METHOD;
|
||||
typedef WOLFSSL_CTX SSL_CTX;
|
||||
|
||||
typedef WOLFSSL_X509 X509;
|
||||
typedef WOLFSSL_X509 X509_REQ;
|
||||
typedef WOLFSSL_X509_NAME X509_NAME;
|
||||
typedef WOLFSSL_X509_CHAIN X509_CHAIN;
|
||||
|
||||
typedef WOLFSSL_STACK EXTENDED_KEY_USAGE;
|
||||
|
||||
|
||||
/* redeclare guard */
|
||||
#define WOLFSSL_TYPES_DEFINED
|
||||
|
||||
typedef WOLFSSL_BIO BIO;
|
||||
typedef WOLFSSL_BIO_METHOD BIO_METHOD;
|
||||
typedef WOLFSSL_CIPHER SSL_CIPHER;
|
||||
typedef WOLFSSL_X509_LOOKUP X509_LOOKUP;
|
||||
typedef WOLFSSL_X509_LOOKUP_METHOD X509_LOOKUP_METHOD;
|
||||
typedef WOLFSSL_X509_CRL X509_CRL;
|
||||
typedef WOLFSSL_X509_EXTENSION X509_EXTENSION;
|
||||
typedef WOLFSSL_ASN1_TIME ASN1_TIME;
|
||||
typedef WOLFSSL_ASN1_INTEGER ASN1_INTEGER;
|
||||
typedef WOLFSSL_ASN1_OBJECT ASN1_OBJECT;
|
||||
typedef WOLFSSL_ASN1_STRING ASN1_STRING;
|
||||
typedef WOLFSSL_dynlock_value CRYPTO_dynlock_value;
|
||||
typedef WOLFSSL_BUF_MEM BUF_MEM;
|
||||
|
||||
/* GENERAL_NAME and BASIC_CONSTRAINTS structs may need implemented as
|
||||
* compatibility layer expands. For now treating them as an ASN1_OBJECT */
|
||||
typedef WOLFSSL_ASN1_OBJECT GENERAL_NAME;
|
||||
typedef WOLFSSL_ASN1_OBJECT BASIC_CONSTRAINTS;
|
||||
|
||||
#define ASN1_UTCTIME WOLFSSL_ASN1_TIME
|
||||
#define ASN1_GENERALIZEDTIME WOLFSSL_ASN1_TIME
|
||||
|
||||
typedef WOLFSSL_COMP_METHOD COMP_METHOD;
|
||||
typedef WOLFSSL_X509_REVOKED X509_REVOKED;
|
||||
typedef WOLFSSL_X509_OBJECT X509_OBJECT;
|
||||
typedef WOLFSSL_X509_STORE X509_STORE;
|
||||
typedef WOLFSSL_X509_STORE_CTX X509_STORE_CTX;
|
||||
|
||||
#define EVP_CIPHER_INFO EncryptedInfo
|
||||
|
||||
#define STACK_OF(x) WOLFSSL_STACK
|
||||
|
||||
#define CRYPTO_free XFREE
|
||||
#define CRYPTO_malloc XMALLOC
|
||||
#define CRYPTO_EX_new WOLFSSL_CRYPTO_EX_new
|
||||
#define CRYPTO_EX_dup WOLFSSL_CRYPTO_EX_dup
|
||||
#define CRYPTO_EX_free WOLFSSL_CRYPTO_EX_free
|
||||
|
||||
/* depreciated */
|
||||
#define CRYPTO_thread_id wolfSSL_thread_id
|
||||
#define CRYPTO_set_id_callback wolfSSL_set_id_callback
|
||||
|
||||
#define CRYPTO_LOCK 0x01
|
||||
#define CRYPTO_UNLOCK 0x02
|
||||
#define CRYPTO_READ 0x04
|
||||
#define CRYPTO_WRITE 0x08
|
||||
|
||||
#define CRYPTO_set_locking_callback wolfSSL_set_locking_callback
|
||||
#define CRYPTO_set_dynlock_create_callback wolfSSL_set_dynlock_create_callback
|
||||
#define CRYPTO_set_dynlock_lock_callback wolfSSL_set_dynlock_lock_callback
|
||||
#define CRYPTO_set_dynlock_destroy_callback wolfSSL_set_dynlock_destroy_callback
|
||||
#define CRYPTO_num_locks wolfSSL_num_locks
|
||||
#define CRYPTO_dynlock_value WOLFSSL_dynlock_value
|
||||
|
||||
#define CRYPTO_cleanup_all_ex_data wolfSSL_cleanup_all_ex_data
|
||||
|
||||
/* this function was used to set the default malloc, free, and realloc */
|
||||
#define CRYPTO_malloc_init() /* CRYPTO_malloc_init is not needed */
|
||||
|
||||
#define SSL_get_client_random(ssl,out,outSz) \
|
||||
wolfSSL_get_client_random((ssl),(out),(outSz))
|
||||
#define SSL_get_cipher_list(ctx,i) wolfSSL_get_cipher_list_ex((ctx),(i))
|
||||
#define SSL_get_cipher_name(ctx) wolfSSL_get_cipher((ctx))
|
||||
#define SSL_get_shared_ciphers(ctx,buf,len) \
|
||||
wolfSSL_get_shared_ciphers((ctx),(buf),(len))
|
||||
|
||||
/* at the moment only returns ok */
|
||||
#define SSL_get_verify_result wolfSSL_get_verify_result
|
||||
#define SSL_get_verify_mode wolfSSL_SSL_get_mode
|
||||
#define SSL_get_verify_depth wolfSSL_get_verify_depth
|
||||
#define SSL_CTX_get_verify_mode wolfSSL_CTX_get_verify_mode
|
||||
#define SSL_CTX_get_verify_depth wolfSSL_CTX_get_verify_depth
|
||||
#define SSL_get_certificate wolfSSL_get_certificate
|
||||
#define SSL_use_certificate wolfSSL_use_certificate
|
||||
#define SSL_use_certificate_ASN1 wolfSSL_use_certificate_ASN1
|
||||
#define d2i_PKCS8_PRIV_KEY_INFO_bio wolfSSL_d2i_PKCS8_PKEY_bio
|
||||
#define d2i_PKCS8PrivateKey_bio wolfSSL_d2i_PKCS8PrivateKey_bio
|
||||
#define PKCS8_PRIV_KEY_INFO_free wolfSSL_EVP_PKEY_free
|
||||
#define d2i_PKCS12_fp wolfSSL_d2i_PKCS12_fp
|
||||
|
||||
#define d2i_PUBKEY wolfSSL_d2i_PUBKEY
|
||||
#define d2i_PUBKEY_bio wolfSSL_d2i_PUBKEY_bio
|
||||
#define d2i_PrivateKey wolfSSL_d2i_PrivateKey
|
||||
#define d2i_AutoPrivateKey wolfSSL_d2i_AutoPrivateKey
|
||||
#define SSL_use_PrivateKey wolfSSL_use_PrivateKey
|
||||
#define SSL_use_PrivateKey_ASN1 wolfSSL_use_PrivateKey_ASN1
|
||||
#define SSL_use_RSAPrivateKey_ASN1 wolfSSL_use_RSAPrivateKey_ASN1
|
||||
#define SSL_get_privatekey wolfSSL_get_privatekey
|
||||
|
||||
#define SSLv23_method wolfSSLv23_method
|
||||
#define SSLv23_client_method wolfSSLv23_client_method
|
||||
#define SSLv2_client_method wolfSSLv2_client_method
|
||||
#define SSLv2_server_method wolfSSLv2_server_method
|
||||
#define SSLv3_server_method wolfSSLv3_server_method
|
||||
#define SSLv3_client_method wolfSSLv3_client_method
|
||||
#define TLSv1_method wolfTLSv1_method
|
||||
#define TLSv1_server_method wolfTLSv1_server_method
|
||||
#define TLSv1_client_method wolfTLSv1_client_method
|
||||
#define TLSv1_1_method wolfTLSv1_1_method
|
||||
#define TLSv1_1_server_method wolfTLSv1_1_server_method
|
||||
#define TLSv1_1_client_method wolfTLSv1_1_client_method
|
||||
#define TLSv1_2_method wolfTLSv1_2_method
|
||||
#define TLSv1_2_server_method wolfTLSv1_2_server_method
|
||||
#define TLSv1_2_client_method wolfTLSv1_2_client_method
|
||||
#define TLSv1_3_method wolfTLSv1_3_method
|
||||
#define TLSv1_3_server_method wolfTLSv1_3_server_method
|
||||
#define TLSv1_3_client_method wolfTLSv1_3_client_method
|
||||
|
||||
#define X509_FILETYPE_ASN1 SSL_FILETYPE_ASN1
|
||||
|
||||
#ifdef WOLFSSL_DTLS
|
||||
#define DTLSv1_client_method wolfDTLSv1_client_method
|
||||
#define DTLSv1_server_method wolfDTLSv1_server_method
|
||||
#define DTLSv1_2_client_method wolfDTLSv1_2_client_method
|
||||
#define DTLSv1_2_server_method wolfDTLSv1_2_server_method
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef NO_FILESYSTEM
|
||||
#define SSL_CTX_use_certificate_file wolfSSL_CTX_use_certificate_file
|
||||
#define SSL_CTX_use_PrivateKey_file wolfSSL_CTX_use_PrivateKey_file
|
||||
#define SSL_CTX_load_verify_locations wolfSSL_CTX_load_verify_locations
|
||||
#define SSL_CTX_use_certificate_chain_file wolfSSL_CTX_use_certificate_chain_file
|
||||
#define SSL_CTX_use_RSAPrivateKey_file wolfSSL_CTX_use_RSAPrivateKey_file
|
||||
|
||||
#define SSL_use_certificate_file wolfSSL_use_certificate_file
|
||||
#define SSL_use_PrivateKey_file wolfSSL_use_PrivateKey_file
|
||||
#define SSL_use_certificate_chain_file wolfSSL_use_certificate_chain_file
|
||||
#define SSL_use_RSAPrivateKey_file wolfSSL_use_RSAPrivateKey_file
|
||||
#endif
|
||||
|
||||
#define SSL_CTX_new wolfSSL_CTX_new
|
||||
#define SSL_new wolfSSL_new
|
||||
#define SSL_set_fd wolfSSL_set_fd
|
||||
#define SSL_get_fd wolfSSL_get_fd
|
||||
#define SSL_connect wolfSSL_connect
|
||||
#define SSL_clear wolfSSL_clear
|
||||
#define SSL_state wolfSSL_state
|
||||
|
||||
#define SSL_write wolfSSL_write
|
||||
#define SSL_read wolfSSL_read
|
||||
#define SSL_peek wolfSSL_peek
|
||||
#define SSL_accept wolfSSL_accept
|
||||
#define SSL_CTX_free wolfSSL_CTX_free
|
||||
#define SSL_free wolfSSL_free
|
||||
#define SSL_shutdown wolfSSL_shutdown
|
||||
|
||||
#define SSL_CTX_set_quiet_shutdown wolfSSL_CTX_set_quiet_shutdown
|
||||
#define SSL_set_quiet_shutdown wolfSSL_set_quiet_shutdown
|
||||
#define SSL_get_error wolfSSL_get_error
|
||||
#define SSL_set_session wolfSSL_set_session
|
||||
#define SSL_get_session wolfSSL_get_session
|
||||
#define SSL_flush_sessions wolfSSL_flush_sessions
|
||||
/* assume unlimited temporarily */
|
||||
#define SSL_CTX_get_session_cache_mode(ctx) 0
|
||||
|
||||
#define SSL_CTX_set_verify wolfSSL_CTX_set_verify
|
||||
#define SSL_set_verify wolfSSL_set_verify
|
||||
#define SSL_pending wolfSSL_pending
|
||||
#define SSL_load_error_strings wolfSSL_load_error_strings
|
||||
#define SSL_library_init wolfSSL_library_init
|
||||
#define SSL_CTX_set_session_cache_mode wolfSSL_CTX_set_session_cache_mode
|
||||
#define SSL_CTX_set_cipher_list wolfSSL_CTX_set_cipher_list
|
||||
#define SSL_set_cipher_list wolfSSL_set_cipher_list
|
||||
|
||||
#define SSL_set_ex_data wolfSSL_set_ex_data
|
||||
#define SSL_get_shutdown wolfSSL_get_shutdown
|
||||
#define SSL_set_rfd wolfSSL_set_rfd
|
||||
#define SSL_set_wfd wolfSSL_set_wfd
|
||||
#define SSL_set_shutdown wolfSSL_set_shutdown
|
||||
#define SSL_set_session_id_context wolfSSL_set_session_id_context
|
||||
#define SSL_set_connect_state wolfSSL_set_connect_state
|
||||
#define SSL_set_accept_state wolfSSL_set_accept_state
|
||||
#define SSL_session_reused wolfSSL_session_reused
|
||||
#define SSL_SESSION_free wolfSSL_SESSION_free
|
||||
#define SSL_is_init_finished wolfSSL_is_init_finished
|
||||
|
||||
#define SSL_get_version wolfSSL_get_version
|
||||
#define SSL_get_current_cipher wolfSSL_get_current_cipher
|
||||
|
||||
/* use wolfSSL_get_cipher_name for its return format */
|
||||
#define SSL_get_cipher wolfSSL_get_cipher_name
|
||||
#define SSL_CIPHER_description wolfSSL_CIPHER_description
|
||||
#define SSL_CIPHER_get_name wolfSSL_CIPHER_get_name
|
||||
#define SSL_get1_session wolfSSL_get1_session
|
||||
|
||||
#define SSL_get_keyblock_size wolfSSL_get_keyblock_size
|
||||
#define SSL_get_keys wolfSSL_get_keys
|
||||
#define SSL_SESSION_get_master_key wolfSSL_SESSION_get_master_key
|
||||
#define SSL_SESSION_get_master_key_length wolfSSL_SESSION_get_master_key_length
|
||||
|
||||
#define DSA_dup_DH wolfSSL_DSA_dup_DH
|
||||
|
||||
#define i2d_X509_bio wolfSSL_i2d_X509_bio
|
||||
#define d2i_X509_bio wolfSSL_d2i_X509_bio
|
||||
#define d2i_X509_fp wolfSSL_d2i_X509_fp
|
||||
#define i2d_X509 wolfSSL_i2d_X509
|
||||
#define d2i_X509 wolfSSL_d2i_X509
|
||||
#define PEM_read_bio_X509 wolfSSL_PEM_read_bio_X509
|
||||
#define PEM_read_bio_X509_AUX wolfSSL_PEM_read_bio_X509_AUX
|
||||
#define PEM_read_X509 wolfSSL_PEM_read_X509
|
||||
#define PEM_write_bio_X509 wolfSSL_PEM_write_bio_X509
|
||||
#define PEM_write_bio_X509_AUX wolfSSL_PEM_write_bio_X509_AUX
|
||||
|
||||
#define i2d_X509_REQ wolfSSL_i2d_X509_REQ
|
||||
#define X509_REQ_new wolfSSL_X509_REQ_new
|
||||
#define X509_REQ_free wolfSSL_X509_REQ_free
|
||||
#define X509_REQ_sign wolfSSL_X509_REQ_sign
|
||||
#define X509_REQ_set_subject_name wolfSSL_X509_REQ_set_subject_name
|
||||
#define X509_REQ_set_pubkey wolfSSL_X509_REQ_set_pubkey
|
||||
#define PEM_write_bio_X509_REQ wolfSSL_PEM_write_bio_X509_REQ
|
||||
|
||||
#define X509_new wolfSSL_X509_new
|
||||
#define X509_free wolfSSL_X509_free
|
||||
#define X509_load_certificate_file wolfSSL_X509_load_certificate_file
|
||||
#define X509_digest wolfSSL_X509_digest
|
||||
#define X509_get_ext_d2i wolfSSL_X509_get_ext_d2i
|
||||
#define X509_get_issuer_name wolfSSL_X509_get_issuer_name
|
||||
#define X509_get_subject_name wolfSSL_X509_get_subject_name
|
||||
#define X509_get_pubkey wolfSSL_X509_get_pubkey
|
||||
#define X509_get_notBefore(cert) (ASN1_TIME*)wolfSSL_X509_notBefore((cert))
|
||||
#define X509_get_notAfter(cert) (ASN1_TIME*)wolfSSL_X509_notAfter((cert))
|
||||
#define X509_get_serialNumber wolfSSL_X509_get_serialNumber
|
||||
#define X509_get0_pubkey_bitstr wolfSSL_X509_get0_pubkey_bitstr
|
||||
#define X509_get_ex_new_index wolfSSL_X509_get_ex_new_index
|
||||
#define X509_get_ex_data wolfSSL_X509_get_ex_data
|
||||
#define X509_set_ex_data wolfSSL_X509_set_ex_data
|
||||
#define X509_get1_ocsp wolfSSL_X509_get1_ocsp
|
||||
#ifndef WOLFSSL_HAPROXY
|
||||
#define X509_get_version wolfSSL_X509_get_version
|
||||
#endif
|
||||
#define X509_get_signature_nid wolfSSL_X509_get_signature_nid
|
||||
#define X509_set_subject_name wolfSSL_X509_set_subject_name
|
||||
#define X509_set_pubkey wolfSSL_X509_set_pubkey
|
||||
#define X509_print wolfSSL_X509_print
|
||||
#define X509_verify_cert_error_string wolfSSL_X509_verify_cert_error_string
|
||||
#define X509_verify_cert wolfSSL_X509_verify_cert
|
||||
#define X509_check_private_key wolfSSL_X509_check_private_key
|
||||
#define X509_check_ca wolfSSL_X509_check_ca
|
||||
#define X509_check_host wolfSSL_X509_check_host
|
||||
#define X509_email_free wolfSSL_X509_email_free
|
||||
#define X509_check_issued wolfSSL_X509_check_issued
|
||||
#define X509_dup wolfSSL_X509_dup
|
||||
|
||||
#define sk_X509_new wolfSSL_sk_X509_new
|
||||
#define sk_X509_num wolfSSL_sk_X509_num
|
||||
#define sk_X509_value wolfSSL_sk_X509_value
|
||||
#define sk_X509_push wolfSSL_sk_X509_push
|
||||
#define sk_X509_pop wolfSSL_sk_X509_pop
|
||||
#define sk_X509_pop_free wolfSSL_sk_X509_pop_free
|
||||
#define sk_X509_free wolfSSL_sk_X509_free
|
||||
|
||||
#define i2d_X509_NAME wolfSSL_i2d_X509_NAME
|
||||
#define X509_NAME_new wolfSSL_X509_NAME_new
|
||||
#define X509_NAME_free wolfSSL_X509_NAME_free
|
||||
#define X509_NAME_get_text_by_NID wolfSSL_X509_NAME_get_text_by_NID
|
||||
#define X509_NAME_cmp wolfSSL_X509_NAME_cmp
|
||||
#define X509_NAME_ENTRY_free wolfSSL_X509_NAME_ENTRY_free
|
||||
#define X509_NAME_ENTRY_create_by_NID wolfSSL_X509_NAME_ENTRY_create_by_NID
|
||||
#define X509_NAME_add_entry wolfSSL_X509_NAME_add_entry
|
||||
#define X509_NAME_add_entry_by_txt wolfSSL_X509_NAME_add_entry_by_txt
|
||||
#define X509_NAME_oneline wolfSSL_X509_NAME_oneline
|
||||
#define X509_NAME_get_index_by_NID wolfSSL_X509_NAME_get_index_by_NID
|
||||
#define X509_NAME_print_ex wolfSSL_X509_NAME_print_ex
|
||||
#define X509_NAME_digest wolfSSL_X509_NAME_digest
|
||||
#define X509_cmp_current_time wolfSSL_X509_cmp_current_time
|
||||
|
||||
#define sk_X509_NAME_pop_free wolfSSL_sk_X509_NAME_pop_free
|
||||
#define sk_X509_NAME_num wolfSSL_sk_X509_NAME_num
|
||||
#define sk_X509_NAME_value wolfSSL_sk_X509_NAME_value
|
||||
|
||||
typedef WOLFSSL_X509_NAME_ENTRY X509_NAME_ENTRY;
|
||||
|
||||
#define X509_NAME_entry_count wolfSSL_X509_NAME_entry_count
|
||||
#define X509_NAME_ENTRY_get_object wolfSSL_X509_NAME_ENTRY_get_object
|
||||
#define X509_NAME_get_entry wolfSSL_X509_NAME_get_entry
|
||||
#define X509_NAME_ENTRY_get_data wolfSSL_X509_NAME_ENTRY_get_data
|
||||
#define X509_NAME_ENTRY_get_object wolfSSL_X509_NAME_ENTRY_get_object
|
||||
|
||||
#define X509_V_FLAG_CRL_CHECK WOLFSSL_CRL_CHECK
|
||||
#define X509_V_FLAG_CRL_CHECK_ALL WOLFSSL_CRL_CHECKALL
|
||||
|
||||
#define X509_V_FLAG_USE_CHECK_TIME WOLFSSL_USE_CHECK_TIME
|
||||
#define X509_V_FLAG_NO_CHECK_TIME WOLFSSL_NO_CHECK_TIME
|
||||
#define X509_CHECK_FLAG_NO_WILDCARDS WOLFSSL_NO_WILDCARDS
|
||||
|
||||
#define X509_STORE_CTX_get_current_cert wolfSSL_X509_STORE_CTX_get_current_cert
|
||||
#define X509_STORE_CTX_set_verify_cb wolfSSL_X509_STORE_CTX_set_verify_cb
|
||||
#define X509_STORE_CTX_new wolfSSL_X509_STORE_CTX_new
|
||||
#define X509_STORE_CTX_free wolfSSL_X509_STORE_CTX_free
|
||||
#define X509_STORE_CTX_get_chain wolfSSL_X509_STORE_CTX_get_chain
|
||||
#define X509_STORE_CTX_get_error wolfSSL_X509_STORE_CTX_get_error
|
||||
#define X509_STORE_CTX_get_error_depth wolfSSL_X509_STORE_CTX_get_error_depth
|
||||
#define X509_STORE_CTX_init wolfSSL_X509_STORE_CTX_init
|
||||
#define X509_STORE_CTX_cleanup wolfSSL_X509_STORE_CTX_cleanup
|
||||
#define X509_STORE_CTX_set_error wolfSSL_X509_STORE_CTX_set_error
|
||||
#define X509_STORE_CTX_get_ex_data wolfSSL_X509_STORE_CTX_get_ex_data
|
||||
|
||||
#define X509_STORE_new wolfSSL_X509_STORE_new
|
||||
#define X509_STORE_free wolfSSL_X509_STORE_free
|
||||
#define X509_STORE_add_lookup wolfSSL_X509_STORE_add_lookup
|
||||
#define X509_STORE_add_cert wolfSSL_X509_STORE_add_cert
|
||||
#define X509_STORE_add_crl wolfSSL_X509_STORE_add_crl
|
||||
#define X509_STORE_set_flags wolfSSL_X509_STORE_set_flags
|
||||
#define X509_STORE_get1_certs wolfSSL_X509_STORE_get1_certs
|
||||
#define X509_STORE_get_by_subject wolfSSL_X509_STORE_get_by_subject
|
||||
#define X509_STORE_CTX_get1_issuer wolfSSL_X509_STORE_CTX_get1_issuer
|
||||
#define X509_STORE_CTX_set_time wolfSSL_X509_STORE_CTX_set_time
|
||||
|
||||
#define X509_LOOKUP_add_dir wolfSSL_X509_LOOKUP_add_dir
|
||||
#define X509_LOOKUP_load_file wolfSSL_X509_LOOKUP_load_file
|
||||
#define X509_LOOKUP_hash_dir wolfSSL_X509_LOOKUP_hash_dir
|
||||
#define X509_LOOKUP_file wolfSSL_X509_LOOKUP_file
|
||||
|
||||
#define d2i_X509_CRL wolfSSL_d2i_X509_CRL
|
||||
#define d2i_X509_CRL_fp wolfSSL_d2i_X509_CRL_fp
|
||||
#define PEM_read_X509_CRL wolfSSL_PEM_read_X509_CRL
|
||||
|
||||
#define X509_CRL_free wolfSSL_X509_CRL_free
|
||||
#define X509_CRL_get_lastUpdate wolfSSL_X509_CRL_get_lastUpdate
|
||||
#define X509_CRL_get_nextUpdate wolfSSL_X509_CRL_get_nextUpdate
|
||||
#define X509_CRL_verify wolfSSL_X509_CRL_verify
|
||||
#define X509_CRL_get_REVOKED wolfSSL_X509_CRL_get_REVOKED
|
||||
|
||||
#define sk_X509_REVOKED_num wolfSSL_sk_X509_REVOKED_num
|
||||
#define sk_X509_REVOKED_value wolfSSL_sk_X509_REVOKED_value
|
||||
|
||||
#define X509_OBJECT_free_contents wolfSSL_X509_OBJECT_free_contents
|
||||
|
||||
#define OCSP_parse_url wolfSSL_OCSP_parse_url
|
||||
|
||||
#define MD4_Init wolfSSL_MD4_Init
|
||||
#define MD4_Update wolfSSL_MD4_Update
|
||||
#define MD4_Final wolfSSL_MD4_Final
|
||||
|
||||
#define BIO_new wolfSSL_BIO_new
|
||||
#define BIO_free wolfSSL_BIO_free
|
||||
#define BIO_free_all wolfSSL_BIO_free_all
|
||||
#define BIO_nread0 wolfSSL_BIO_nread0
|
||||
#define BIO_nread wolfSSL_BIO_nread
|
||||
#define BIO_read wolfSSL_BIO_read
|
||||
#define BIO_nwrite0 wolfSSL_BIO_nwrite0
|
||||
#define BIO_nwrite wolfSSL_BIO_nwrite
|
||||
#define BIO_write wolfSSL_BIO_write
|
||||
#define BIO_push wolfSSL_BIO_push
|
||||
#define BIO_pop wolfSSL_BIO_pop
|
||||
#define BIO_flush wolfSSL_BIO_flush
|
||||
#define BIO_pending wolfSSL_BIO_pending
|
||||
|
||||
#define BIO_get_mem_data wolfSSL_BIO_get_mem_data
|
||||
#define BIO_new_mem_buf wolfSSL_BIO_new_mem_buf
|
||||
|
||||
#define BIO_f_buffer wolfSSL_BIO_f_buffer
|
||||
#define BIO_set_write_buffer_size wolfSSL_BIO_set_write_buffer_size
|
||||
#define BIO_f_ssl wolfSSL_BIO_f_ssl
|
||||
#define BIO_new_socket wolfSSL_BIO_new_socket
|
||||
#define SSL_set_bio wolfSSL_set_bio
|
||||
#define BIO_eof wolfSSL_BIO_eof
|
||||
#define BIO_set_ss wolfSSL_BIO_set_ss
|
||||
|
||||
#define BIO_s_mem wolfSSL_BIO_s_mem
|
||||
#define BIO_f_base64 wolfSSL_BIO_f_base64
|
||||
#define BIO_set_flags wolfSSL_BIO_set_flags
|
||||
|
||||
#define SSLeay_add_ssl_algorithms wolfSSL_add_all_algorithms
|
||||
#define SSLeay_add_all_algorithms wolfSSL_add_all_algorithms
|
||||
|
||||
#define RAND_screen wolfSSL_RAND_screen
|
||||
#define RAND_file_name wolfSSL_RAND_file_name
|
||||
#define RAND_write_file wolfSSL_RAND_write_file
|
||||
#define RAND_load_file wolfSSL_RAND_load_file
|
||||
#define RAND_egd wolfSSL_RAND_egd
|
||||
#define RAND_seed wolfSSL_RAND_seed
|
||||
#define RAND_cleanup wolfSSL_RAND_Cleanup
|
||||
#define RAND_add wolfSSL_RAND_add
|
||||
#define RAND_poll wolfSSL_RAND_poll
|
||||
#define RAND_status wolfSSL_RAND_status
|
||||
#define RAND_bytes wolfSSL_RAND_bytes
|
||||
#define RAND_pseudo_bytes wolfSSL_RAND_pseudo_bytes
|
||||
|
||||
#define COMP_zlib wolfSSL_COMP_zlib
|
||||
#define COMP_rle wolfSSL_COMP_rle
|
||||
#define SSL_COMP_add_compression_method wolfSSL_COMP_add_compression_method
|
||||
|
||||
#define SSL_get_ex_new_index wolfSSL_get_ex_new_index
|
||||
|
||||
|
||||
typedef WOLFSSL_ASN1_BIT_STRING ASN1_BIT_STRING;
|
||||
|
||||
#define ASN1_TIME_adj wolfSSL_ASN1_TIME_adj
|
||||
#define ASN1_TIME_print wolfSSL_ASN1_TIME_print
|
||||
#define ASN1_TIME_to_generalizedtime wolfSSL_ASN1_TIME_to_generalizedtime
|
||||
#define ASN1_GENERALIZEDTIME_print wolfSSL_ASN1_GENERALIZEDTIME_print
|
||||
#define ASN1_GENERALIZEDTIME_free wolfSSL_ASN1_GENERALIZEDTIME_free
|
||||
|
||||
#define ASN1_tag2str wolfSSL_ASN1_tag2str
|
||||
|
||||
#define i2a_ASN1_INTEGER wolfSSL_i2a_ASN1_INTEGER
|
||||
#define i2c_ASN1_INTEGER wolfSSL_i2c_ASN1_INTEGER
|
||||
#define ASN1_INTEGER_new wolfSSL_ASN1_INTEGER_new
|
||||
#define ASN1_INTEGER_free wolfSSL_ASN1_INTEGER_free
|
||||
#define ASN1_INTEGER_cmp wolfSSL_ASN1_INTEGER_cmp
|
||||
#define ASN1_INTEGER_get wolfSSL_ASN1_INTEGER_get
|
||||
#define ASN1_INTEGER_to_BN wolfSSL_ASN1_INTEGER_to_BN
|
||||
|
||||
#define ASN1_STRING_data wolfSSL_ASN1_STRING_data
|
||||
#define ASN1_STRING_get0_data wolfSSL_ASN1_STRING_data
|
||||
#define ASN1_STRING_length wolfSSL_ASN1_STRING_length
|
||||
#define ASN1_STRING_to_UTF8 wolfSSL_ASN1_STRING_to_UTF8
|
||||
#define ASN1_STRING_print_ex wolfSSL_ASN1_STRING_print_ex
|
||||
|
||||
#define ASN1_UTCTIME_pr wolfSSL_ASN1_UTCTIME_pr
|
||||
|
||||
#define ASN1_IA5STRING WOLFSSL_ASN1_STRING
|
||||
|
||||
#define ASN1_OCTET_STRING WOLFSSL_ASN1_STRING
|
||||
|
||||
#define SSL_load_client_CA_file wolfSSL_load_client_CA_file
|
||||
|
||||
#define SSL_CTX_get_client_CA_list wolfSSL_SSL_CTX_get_client_CA_list
|
||||
#define SSL_CTX_set_client_CA_list wolfSSL_CTX_set_client_CA_list
|
||||
#define SSL_CTX_set_cert_store wolfSSL_CTX_set_cert_store
|
||||
#define SSL_CTX_get_cert_store wolfSSL_CTX_get_cert_store
|
||||
#define SSL_get_ex_data_X509_STORE_CTX_idx wolfSSL_get_ex_data_X509_STORE_CTX_idx
|
||||
#define SSL_get_ex_data wolfSSL_get_ex_data
|
||||
|
||||
#define SSL_CTX_set_default_passwd_cb_userdata wolfSSL_CTX_set_default_passwd_cb_userdata
|
||||
#define SSL_CTX_set_default_passwd_cb wolfSSL_CTX_set_default_passwd_cb
|
||||
|
||||
#define SSL_CTX_set_timeout(ctx, to) \
|
||||
wolfSSL_CTX_set_timeout(ctx, (unsigned int) to)
|
||||
#define SSL_CTX_set_info_callback wolfSSL_CTX_set_info_callback
|
||||
#define SSL_CTX_set_alpn_protos wolfSSL_CTX_set_alpn_protos
|
||||
|
||||
#define SSL_alert_type_string wolfSSL_alert_type_string
|
||||
#define SSL_alert_desc_string wolfSSL_alert_desc_string
|
||||
#define SSL_state_string wolfSSL_state_string
|
||||
|
||||
#define RSA_free wolfSSL_RSA_free
|
||||
#define RSA_generate_key wolfSSL_RSA_generate_key
|
||||
#define SSL_CTX_set_tmp_rsa_callback wolfSSL_CTX_set_tmp_rsa_callback
|
||||
|
||||
#define PEM_def_callback wolfSSL_PEM_def_callback
|
||||
|
||||
#define SSL_CTX_sess_accept wolfSSL_CTX_sess_accept
|
||||
#define SSL_CTX_sess_connect wolfSSL_CTX_sess_connect
|
||||
#define SSL_CTX_sess_accept_good wolfSSL_CTX_sess_accept_good
|
||||
#define SSL_CTX_sess_connect_good wolfSSL_CTX_sess_connect_good
|
||||
#define SSL_CTX_sess_accept_renegotiate wolfSSL_CTX_sess_accept_renegotiate
|
||||
#define SSL_CTX_sess_connect_renegotiate wolfSSL_CTX_sess_connect_renegotiate
|
||||
#define SSL_CTX_sess_hits wolfSSL_CTX_sess_hits
|
||||
#define SSL_CTX_sess_cb_hits wolfSSL_CTX_sess_cb_hits
|
||||
#define SSL_CTX_sess_cache_full wolfSSL_CTX_sess_cache_full
|
||||
#define SSL_CTX_sess_misses wolfSSL_CTX_sess_misses
|
||||
#define SSL_CTX_sess_timeouts wolfSSL_CTX_sess_timeouts
|
||||
#define SSL_CTX_sess_number wolfSSL_CTX_sess_number
|
||||
#define SSL_CTX_sess_get_cache_size wolfSSL_CTX_sess_get_cache_size
|
||||
|
||||
|
||||
#define SSL_DEFAULT_CIPHER_LIST WOLFSSL_DEFAULT_CIPHER_LIST
|
||||
|
||||
#define SSL_CTX_set_psk_client_callback wolfSSL_CTX_set_psk_client_callback
|
||||
#define SSL_set_psk_client_callback wolfSSL_set_psk_client_callback
|
||||
|
||||
#define SSL_get_psk_identity_hint wolfSSL_get_psk_identity_hint
|
||||
#define SSL_get_psk_identity wolfSSL_get_psk_identity
|
||||
|
||||
#define SSL_CTX_use_psk_identity_hint wolfSSL_CTX_use_psk_identity_hint
|
||||
#define SSL_use_psk_identity_hint wolfSSL_use_psk_identity_hint
|
||||
|
||||
#define SSL_CTX_set_psk_server_callback wolfSSL_CTX_set_psk_server_callback
|
||||
#define SSL_set_psk_server_callback wolfSSL_set_psk_server_callback
|
||||
|
||||
/* system file ints for ERR_put_error */
|
||||
#define SYS_F_ACCEPT WOLFSSL_SYS_ACCEPT
|
||||
#define SYS_F_BIND WOLFSSL_SYS_BIND
|
||||
#define SYS_F_CONNECT WOLFSSL_SYS_CONNECT
|
||||
#define SYS_F_FOPEN WOLFSSL_SYS_FOPEN
|
||||
#define SYS_F_FREAD WOLFSSL_SYS_FREAD
|
||||
#define SYS_F_GETADDRINFO WOLFSSL_SYS_GETADDRINFO
|
||||
#define SYS_F_GETSOCKOPT WOLFSSL_SYS_GETSOCKOPT
|
||||
#define SYS_F_GETSOCKNAME WOLFSSL_SYS_GETSOCKNAME
|
||||
#define SYS_F_OPENDIR WOLFSSL_SYS_OPENDIR
|
||||
#define SYS_F_SETSOCKOPT WOLFSSL_SYS_SETSOCKOPT
|
||||
#define SYS_F_SOCKET WOLFSSL_SYS_SOCKET
|
||||
#define SYS_F_GETHOSTBYNAME WOLFSSL_SYS_GETHOSTBYNAME
|
||||
#define SYS_F_GETNAMEINFO WOLFSSL_SYS_GETNAMEINFO
|
||||
#define SYS_F_GETSERVBYNAME WOLFSSL_SYS_GETSERVBYNAME
|
||||
#define SYS_F_IOCTLSOCKET WOLFSSL_SYS_IOCTLSOCKET
|
||||
#define SYS_F_LISTEN WOLFSSL_SYS_LISTEN
|
||||
|
||||
#define ERR_GET_REASON wolfSSL_ERR_GET_REASON
|
||||
|
||||
#define ERR_put_error wolfSSL_ERR_put_error
|
||||
#define ERR_peek_error wolfSSL_ERR_peek_error
|
||||
#define ERR_peek_errors_fp wolfSSL_ERR_peek_errors_fp
|
||||
#define ERR_peek_error_line_data wolfSSL_ERR_peek_error_line_data
|
||||
#define ERR_peek_last_error wolfSSL_ERR_peek_last_error
|
||||
#define ERR_peek_last_error_line wolfSSL_ERR_peek_last_error_line
|
||||
#define ERR_get_error_line wolfSSL_ERR_get_error_line
|
||||
#define ERR_get_error_line_data wolfSSL_ERR_get_error_line_data
|
||||
#define ERR_get_error wolfSSL_ERR_get_error
|
||||
#define ERR_print_errors_fp(file) wolfSSL_ERR_dump_errors_fp((file))
|
||||
#define ERR_clear_error wolfSSL_ERR_clear_error
|
||||
#define ERR_free_strings wolfSSL_ERR_free_strings
|
||||
#define ERR_remove_state wolfSSL_ERR_remove_state
|
||||
#define ERR_remove_thread_state wolfSSL_ERR_remove_thread_state
|
||||
#define ERR_error_string wolfSSL_ERR_error_string
|
||||
#define ERR_error_string_n wolfSSL_ERR_error_string_n
|
||||
#define ERR_reason_error_string wolfSSL_ERR_reason_error_string
|
||||
#define ERR_load_BIO_strings wolfSSL_ERR_load_BIO_strings
|
||||
|
||||
#define SSLv23_server_method wolfSSLv23_server_method
|
||||
#define SSL_CTX_set_options wolfSSL_CTX_set_options
|
||||
#define SSL_CTX_get_options wolfSSL_CTX_get_options
|
||||
#define SSL_CTX_clear_options wolfSSL_CTX_clear_options
|
||||
|
||||
#define SSL_CTX_check_private_key wolfSSL_CTX_check_private_key
|
||||
#define SSL_check_private_key wolfSSL_check_private_key
|
||||
|
||||
#define SSL_CTX_set_mode wolfSSL_CTX_set_mode
|
||||
#define SSL_CTX_get_mode wolfSSL_CTX_get_mode
|
||||
#define SSL_CTX_set_default_read_ahead wolfSSL_CTX_set_default_read_ahead
|
||||
|
||||
#define SSL_CTX_sess_set_cache_size wolfSSL_CTX_sess_set_cache_size
|
||||
#define SSL_CTX_set_default_verify_paths wolfSSL_CTX_set_default_verify_paths
|
||||
|
||||
#define SSL_CTX_set_session_id_context wolfSSL_CTX_set_session_id_context
|
||||
#define SSL_get_peer_certificate wolfSSL_get_peer_certificate
|
||||
#define SSL_get_peer_cert_chain wolfSSL_get_peer_cert_chain
|
||||
|
||||
#define SSL_want_read wolfSSL_want_read
|
||||
#define SSL_want_write wolfSSL_want_write
|
||||
|
||||
#define BIO_prf wolfSSL_BIO_prf
|
||||
|
||||
#define sk_num wolfSSL_sk_num
|
||||
#define sk_value wolfSSL_sk_value
|
||||
|
||||
#define d2i_PKCS12_bio wolfSSL_d2i_PKCS12_bio
|
||||
#define d2i_PKCS12_fp wolfSSL_d2i_PKCS12_fp
|
||||
|
||||
#define d2i_RSAPublicKey wolfSSL_d2i_RSAPublicKey
|
||||
#define d2i_RSAPrivateKey wolfSSL_d2i_RSAPrivateKey
|
||||
#define i2d_RSAPrivateKey wolfSSL_i2d_RSAPrivateKey
|
||||
#define i2d_RSAPublicKey wolfSSL_i2d_RSAPublicKey
|
||||
|
||||
#define SSL_CTX_get_ex_data wolfSSL_CTX_get_ex_data
|
||||
#define SSL_CTX_set_ex_data wolfSSL_CTX_set_ex_data
|
||||
#define SSL_CTX_sess_set_get_cb wolfSSL_CTX_sess_set_get_cb
|
||||
#define SSL_CTX_sess_set_new_cb wolfSSL_CTX_sess_set_new_cb
|
||||
#define SSL_CTX_sess_set_remove_cb wolfSSL_CTX_sess_set_remove_cb
|
||||
|
||||
#define i2d_SSL_SESSION wolfSSL_i2d_SSL_SESSION
|
||||
#define d2i_SSL_SESSION wolfSSL_d2i_SSL_SESSION
|
||||
#define SSL_SESSION_set_timeout wolfSSL_SSL_SESSION_set_timeout
|
||||
#define SSL_SESSION_get_timeout wolfSSL_SESSION_get_timeout
|
||||
#define SSL_SESSION_get_time wolfSSL_SESSION_get_time
|
||||
#define SSL_CTX_get_ex_new_index wolfSSL_CTX_get_ex_new_index
|
||||
#define PEM_read wolfSSL_PEM_read
|
||||
#define PEM_write wolfSSL_PEM_write
|
||||
#define PEM_get_EVP_CIPHER_INFO wolfSSL_PEM_get_EVP_CIPHER_INFO
|
||||
#define PEM_do_header wolfSSL_PEM_do_header
|
||||
|
||||
/*#if OPENSSL_API_COMPAT < 0x10100000L*/
|
||||
#define CONF_modules_free()
|
||||
#define ENGINE_cleanup()
|
||||
#define HMAC_CTX_cleanup wolfSSL_HMAC_cleanup
|
||||
#define SSL_CTX_need_tmp_RSA(ctx) 0
|
||||
#define SSL_CTX_set_tmp_rsa(ctx,rsa) 1
|
||||
#define SSL_need_tmp_RSA(ssl) 0
|
||||
#define SSL_set_tmp_rsa(ssl,rsa) 1
|
||||
/*#endif*/
|
||||
|
||||
#define CONF_modules_unload(a)
|
||||
|
||||
#define SSL_get_hit wolfSSL_session_reused
|
||||
|
||||
/* yassl had set the default to be 500 */
|
||||
#define SSL_get_default_timeout(ctx) 500
|
||||
|
||||
#define SSL_CTX_use_certificate wolfSSL_CTX_use_certificate
|
||||
#define SSL_CTX_use_PrivateKey wolfSSL_CTX_use_PrivateKey
|
||||
#define BIO_read_filename wolfSSL_BIO_read_filename
|
||||
#define BIO_s_file wolfSSL_BIO_s_file
|
||||
#define SSL_CTX_set_verify_depth wolfSSL_CTX_set_verify_depth
|
||||
#define SSL_set_verify_depth wolfSSL_set_verify_depth
|
||||
#define SSL_get_app_data wolfSSL_get_app_data
|
||||
#define SSL_set_app_data wolfSSL_set_app_data
|
||||
#define SHA1 wolfSSL_SHA1
|
||||
|
||||
#define SSL_dup_CA_list wolfSSL_dup_CA_list
|
||||
|
||||
enum {
|
||||
GEN_DNS = 0x02, /* ASN_DNS_TYPE */
|
||||
GEN_EMAIL = 0x01, /* ASN_RFC822_TYPE */
|
||||
GEN_URI = 0x06 /* ASN_URI_TYPE */
|
||||
};
|
||||
|
||||
#define PEM_read_bio_DHparams wolfSSL_PEM_read_bio_DHparams
|
||||
#define PEM_read_bio_DSAparams wolfSSL_PEM_read_bio_DSAparams
|
||||
|
||||
#if defined(OPENSSL_ALL) || defined(WOLFSSL_HAPROXY)
|
||||
#define SSL_get_rbio wolfSSL_SSL_get_rbio
|
||||
#define SSL_get_wbio wolfSSL_SSL_get_wbio
|
||||
#define SSL_do_handshake wolfSSL_SSL_do_handshake
|
||||
#define SSL_get_ciphers(x) wolfSSL_get_ciphers_compat(x)
|
||||
#define SSL_SESSION_get_id wolfSSL_SESSION_get_id
|
||||
#define SSL_get_cipher_bits(s,np) \
|
||||
wolfSSL_CIPHER_get_bits(SSL_get_current_cipher(s),np)
|
||||
#define sk_SSL_CIPHER_num wolfSSL_sk_SSL_CIPHER_num
|
||||
#define sk_SSL_COMP_zero wolfSSL_sk_SSL_COMP_zero
|
||||
#define sk_SSL_CIPHER_value wolfSSL_sk_SSL_CIPHER_value
|
||||
#endif /* OPENSSL_ALL || WOLFSSL_HAPROXY */
|
||||
|
||||
#if defined(OPENSSL_ALL) || defined(WOLFSSL_ASIO)
|
||||
#include <wolfssl/openssl/pem.h>
|
||||
|
||||
typedef STACK_OF(WOLFSSL_ASN1_OBJECT) GENERAL_NAMES;
|
||||
#define SSL_CTRL_CHAIN 88
|
||||
#define BIO_CTRL_WPENDING 13
|
||||
#define GEN_IPADD 7
|
||||
#define ERR_LIB_SSL 20
|
||||
#define SSL_R_SHORT_READ 10
|
||||
#define ERR_R_PEM_LIB 9
|
||||
#define V_ASN1_IA5STRING 22
|
||||
#define SSL_CTRL_MODE 33
|
||||
|
||||
#define SSL_CTX_clear_chain_certs(ctx) SSL_CTX_set0_chain(ctx,NULL)
|
||||
#define d2i_RSAPrivateKey_bio wolfSSL_d2i_RSAPrivateKey_bio
|
||||
#define SSL_CTX_use_RSAPrivateKey wolfSSL_CTX_use_RSAPrivateKey
|
||||
#define d2i_PrivateKey_bio wolfSSL_d2i_PrivateKey_bio
|
||||
#define BIO_new_bio_pair wolfSSL_BIO_new_bio_pair
|
||||
#define SSL_get_verify_callback wolfSSL_get_verify_callback
|
||||
#define GENERAL_NAMES_free(GENERAL_NAMES)NULL
|
||||
|
||||
#define SSL_set_mode(ssl,op) wolfSSL_ctrl((ssl),SSL_CTRL_MODE,(op),NULL)
|
||||
|
||||
#define SSL_CTX_use_certificate_ASN1 wolfSSL_CTX_use_certificate_ASN1
|
||||
#define SSL_CTX_set0_chain(ctx,sk) \
|
||||
wolfSSL_CTX_ctrl(ctx,SSL_CTRL_CHAIN,0,(char *)(sk))
|
||||
#define SSL_CTX_get_app_data(ctx) wolfSSL_CTX_get_ex_data(ctx,0)
|
||||
#define SSL_CTX_set_app_data(ctx,arg) wolfSSL_CTX_set_ex_data(ctx,0, \
|
||||
(char *)(arg))
|
||||
#endif /* OPENSSL_ALL || WOLFSSL_ASIO */
|
||||
|
||||
#define SSL_CTX_set_tmp_dh wolfSSL_CTX_set_tmp_dh
|
||||
|
||||
#define BIO_new_file wolfSSL_BIO_new_file
|
||||
#define BIO_ctrl wolfSSL_BIO_ctrl
|
||||
#define BIO_ctrl_pending wolfSSL_BIO_ctrl_pending
|
||||
#define BIO_wpending wolfSSL_BIO_wpending
|
||||
#define BIO_get_mem_ptr wolfSSL_BIO_get_mem_ptr
|
||||
#define BIO_int_ctrl wolfSSL_BIO_int_ctrl
|
||||
#define BIO_reset wolfSSL_BIO_reset
|
||||
#define BIO_s_file wolfSSL_BIO_s_file
|
||||
#define BIO_s_bio wolfSSL_BIO_s_bio
|
||||
#define BIO_s_socket wolfSSL_BIO_s_socket
|
||||
#define BIO_set_fd wolfSSL_BIO_set_fd
|
||||
#define BIO_ctrl_reset_read_request wolfSSL_BIO_ctrl_reset_read_request
|
||||
|
||||
#define BIO_set_write_buf_size wolfSSL_BIO_set_write_buf_size
|
||||
#define BIO_make_bio_pair wolfSSL_BIO_make_bio_pair
|
||||
|
||||
#define BIO_set_fp wolfSSL_BIO_set_fp
|
||||
#define BIO_get_fp wolfSSL_BIO_get_fp
|
||||
#define BIO_seek wolfSSL_BIO_seek
|
||||
#define BIO_write_filename wolfSSL_BIO_write_filename
|
||||
#define BIO_set_mem_eof_return wolfSSL_BIO_set_mem_eof_return
|
||||
|
||||
#define TLSEXT_STATUSTYPE_ocsp 1
|
||||
|
||||
#define SSL_set_options wolfSSL_set_options
|
||||
#define SSL_get_options wolfSSL_get_options
|
||||
#define SSL_clear_options wolfSSL_clear_options
|
||||
#define SSL_set_tmp_dh wolfSSL_set_tmp_dh
|
||||
#define SSL_clear_num_renegotiations wolfSSL_clear_num_renegotiations
|
||||
#define SSL_total_renegotiations wolfSSL_total_renegotiations
|
||||
#define SSL_set_tlsext_debug_arg wolfSSL_set_tlsext_debug_arg
|
||||
#define SSL_set_tlsext_status_type wolfSSL_set_tlsext_status_type
|
||||
#define SSL_set_tlsext_status_exts wolfSSL_set_tlsext_status_exts
|
||||
#define SSL_get_tlsext_status_ids wolfSSL_get_tlsext_status_ids
|
||||
#define SSL_set_tlsext_status_ids wolfSSL_set_tlsext_status_ids
|
||||
#define SSL_get_tlsext_status_ocsp_res wolfSSL_get_tlsext_status_ocsp_resp
|
||||
#define SSL_set_tlsext_status_ocsp_res wolfSSL_set_tlsext_status_ocsp_resp
|
||||
#define SSL_set_tlsext_status_ocsp_resp wolfSSL_set_tlsext_status_ocsp_resp
|
||||
#define SSL_get_tlsext_status_ocsp_resp wolfSSL_get_tlsext_status_ocsp_resp
|
||||
|
||||
#define SSL_CTX_add_extra_chain_cert wolfSSL_CTX_add_extra_chain_cert
|
||||
#define SSL_CTX_get_read_ahead wolfSSL_CTX_get_read_ahead
|
||||
#define SSL_CTX_set_read_ahead wolfSSL_CTX_set_read_ahead
|
||||
#define SSL_CTX_set_tlsext_status_arg wolfSSL_CTX_set_tlsext_status_arg
|
||||
#define SSL_CTX_set_tlsext_opaque_prf_input_callback_arg \
|
||||
wolfSSL_CTX_set_tlsext_opaque_prf_input_callback_arg
|
||||
#define SSL_get_server_random wolfSSL_get_server_random
|
||||
|
||||
#define SSL_get_tlsext_status_exts wolfSSL_get_tlsext_status_exts
|
||||
|
||||
#define BIO_C_SET_FILE_PTR 106
|
||||
#define BIO_C_GET_FILE_PTR 107
|
||||
#define BIO_C_SET_FILENAME 108
|
||||
#define BIO_C_FILE_SEEK 128
|
||||
#define BIO_C_SET_BUF_MEM_EOF_RETURN 130
|
||||
#define BIO_C_SET_WRITE_BUF_SIZE 136
|
||||
#define BIO_C_MAKE_BIO_PAIR 138
|
||||
|
||||
#define BIO_CTRL_RESET 1
|
||||
#define BIO_CTRL_INFO 3
|
||||
#define BIO_CTRL_FLUSH 11
|
||||
#define BIO_CLOSE 0x01
|
||||
#define BIO_FP_WRITE 0x04
|
||||
|
||||
#define SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS 11
|
||||
#define SSL_CTRL_GET_TOTAL_RENEGOTIATIONS 12
|
||||
#define SSL_CTRL_SET_TMP_DH 3
|
||||
#define SSL_CTRL_SET_TLSEXT_DEBUG_ARG 57
|
||||
#define SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE 65
|
||||
#define SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS 66
|
||||
#define SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS 67
|
||||
#define SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS 68
|
||||
#define SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS 69
|
||||
#define SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP 70
|
||||
#define SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP 71
|
||||
|
||||
#define SSL_CTRL_SET_TMP_DH 3
|
||||
#define SSL_CTRL_EXTRA_CHAIN_CERT 14
|
||||
|
||||
#define SSL_CTRL_SET_SESS_CACHE_SIZE 42
|
||||
#define SSL_CTRL_GET_READ_AHEAD 40
|
||||
#define SSL_CTRL_SET_READ_AHEAD 41
|
||||
|
||||
#define SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB 63
|
||||
#define SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG 64
|
||||
|
||||
#define SSL_CTRL_GET_EXTRA_CHAIN_CERTS 82
|
||||
|
||||
#define SSL_ctrl wolfSSL_ctrl
|
||||
#define SSL_CTX_ctrl wolfSSL_CTX_ctrl
|
||||
|
||||
#define SSL3_RANDOM_SIZE 32 /* same as RAN_LEN in internal.h */
|
||||
#if defined(HAVE_STUNNEL) || defined(WOLFSSL_NGINX) || defined(OPENSSL_EXTRA) \
|
||||
|| defined(OPENSSL_ALL)
|
||||
#include <wolfssl/openssl/asn1.h>
|
||||
|
||||
#define SSL2_VERSION 0x0002
|
||||
#define SSL3_VERSION 0x0300
|
||||
#define TLS1_VERSION 0x0301
|
||||
#define DTLS1_VERSION 0xFEFF
|
||||
#define SSL23_ST_SR_CLNT_HELLO_A (0x210|0x2000)
|
||||
#define SSL3_ST_SR_CLNT_HELLO_A (0x110|0x2000)
|
||||
#define ASN1_STRFLGS_ESC_MSB 4
|
||||
|
||||
#define SSL_MAX_MASTER_KEY_LENGTH WOLFSSL_MAX_MASTER_KEY_LENGTH
|
||||
|
||||
#define SSL_alert_desc_string_long wolfSSL_alert_desc_string_long
|
||||
#define SSL_alert_type_string_long wolfSSL_alert_type_string_long
|
||||
#define SSL_CIPHER_get_bits wolfSSL_CIPHER_get_bits
|
||||
#define sk_GENERAL_NAME_num wolfSSL_sk_GENERAL_NAME_num
|
||||
#define SSL_CTX_get_options wolfSSL_CTX_get_options
|
||||
|
||||
#define SSL_CTX_flush_sessions wolfSSL_flush_sessions
|
||||
#define SSL_CTX_add_session wolfSSL_CTX_add_session
|
||||
#define SSL_version wolfSSL_version
|
||||
#define SSL_get_state wolfSSL_get_state
|
||||
#define SSL_state_string_long wolfSSL_state_string_long
|
||||
|
||||
#define sk_GENERAL_NAME_value wolfSSL_sk_GENERAL_NAME_value
|
||||
#define SSL_SESSION_get_ex_data wolfSSL_SESSION_get_ex_data
|
||||
#define SSL_SESSION_set_ex_data wolfSSL_SESSION_set_ex_data
|
||||
#define SSL_SESSION_get_ex_new_index wolfSSL_SESSION_get_ex_new_index
|
||||
#define SSL_SESSION_get_id wolfSSL_SESSION_get_id
|
||||
#define sk_GENERAL_NAME_pop_free wolfSSL_sk_GENERAL_NAME_pop_free
|
||||
#define GENERAL_NAME_free NULL
|
||||
|
||||
#define SSL3_AL_FATAL 2
|
||||
#define SSL_TLSEXT_ERR_OK 0
|
||||
#define SSL_TLSEXT_ERR_ALERT_FATAL alert_fatal
|
||||
#define SSL_TLSEXT_ERR_NOACK alert_warning
|
||||
#define TLSEXT_NAMETYPE_host_name WOLFSSL_SNI_HOST_NAME
|
||||
|
||||
#define SSL_set_tlsext_host_name wolfSSL_set_tlsext_host_name
|
||||
#define SSL_get_servername wolfSSL_get_servername
|
||||
#define SSL_set_SSL_CTX wolfSSL_set_SSL_CTX
|
||||
#define SSL_CTX_get_verify_callback wolfSSL_CTX_get_verify_callback
|
||||
#define SSL_CTX_set_tlsext_servername_callback wolfSSL_CTX_set_tlsext_servername_callback
|
||||
#define SSL_CTX_set_tlsext_servername_arg wolfSSL_CTX_set_servername_arg
|
||||
|
||||
#define PSK_MAX_PSK_LEN 256
|
||||
#define PSK_MAX_IDENTITY_LEN 128
|
||||
#define SSL_CTX_clear_options wolfSSL_CTX_clear_options
|
||||
|
||||
|
||||
#endif /* HAVE_STUNNEL || WOLFSSL_NGINX */
|
||||
#define SSL_CTX_get_default_passwd_cb wolfSSL_CTX_get_default_passwd_cb
|
||||
#define SSL_CTX_get_default_passwd_cb_userdata wolfSSL_CTX_get_default_passwd_cb_userdata
|
||||
|
||||
#define SSL_CTX_set_msg_callback wolfSSL_CTX_set_msg_callback
|
||||
#define SSL_set_msg_callback wolfSSL_set_msg_callback
|
||||
#define SSL_CTX_set_msg_callback_arg wolfSSL_CTX_set_msg_callback_arg
|
||||
#define SSL_set_msg_callback_arg wolfSSL_set_msg_callback_arg
|
||||
|
||||
|
||||
/* Nginx uses this to determine if reached end of certs in file.
|
||||
* PEM_read_bio_X509 is called and the return error is lost.
|
||||
* The error that needs to be detected is: SSL_NO_PEM_HEADER.
|
||||
*/
|
||||
#define ERR_GET_LIB(l) (int)((((unsigned long)l)>>24L)&0xffL)
|
||||
#define PEM_R_NO_START_LINE 108
|
||||
#define ERR_LIB_PEM 9
|
||||
#define ERR_LIB_X509 10
|
||||
|
||||
#if defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY) || \
|
||||
defined(WOLFSSL_MYSQL_COMPATIBLE) || defined(OPENSSL_ALL) || \
|
||||
defined(HAVE_LIGHTY)
|
||||
|
||||
#include <wolfssl/error-ssl.h>
|
||||
|
||||
#define OPENSSL_STRING WOLFSSL_STRING
|
||||
|
||||
#define TLSEXT_TYPE_application_layer_protocol_negotiation 16
|
||||
|
||||
#define OPENSSL_NPN_UNSUPPORTED 0
|
||||
#define OPENSSL_NPN_NEGOTIATED 1
|
||||
#define OPENSSL_NPN_NO_OVERLAP 2
|
||||
|
||||
/* Nginx checks these to see if the error was a handshake error. */
|
||||
#define SSL_R_BAD_CHANGE_CIPHER_SPEC LENGTH_ERROR
|
||||
#define SSL_R_BLOCK_CIPHER_PAD_IS_WRONG BUFFER_E
|
||||
#define SSL_R_DIGEST_CHECK_FAILED VERIFY_MAC_ERROR
|
||||
#define SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST SUITES_ERROR
|
||||
#define SSL_R_EXCESSIVE_MESSAGE_SIZE BUFFER_ERROR
|
||||
#define SSL_R_LENGTH_MISMATCH LENGTH_ERROR
|
||||
#define SSL_R_NO_CIPHERS_SPECIFIED SUITES_ERROR
|
||||
#define SSL_R_NO_COMPRESSION_SPECIFIED COMPRESSION_ERROR
|
||||
#define SSL_R_NO_SHARED_CIPHER MATCH_SUITE_ERROR
|
||||
#define SSL_R_RECORD_LENGTH_MISMATCH HANDSHAKE_SIZE_ERROR
|
||||
#define SSL_R_UNEXPECTED_MESSAGE OUT_OF_ORDER_E
|
||||
#define SSL_R_UNEXPECTED_RECORD SANITY_MSG_E
|
||||
#define SSL_R_UNKNOWN_ALERT_TYPE BUFFER_ERROR
|
||||
#define SSL_R_UNKNOWN_PROTOCOL VERSION_ERROR
|
||||
#define SSL_R_WRONG_VERSION_NUMBER VERSION_ERROR
|
||||
#define SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC ENCRYPT_ERROR
|
||||
#define SSL_R_HTTPS_PROXY_REQUEST PARSE_ERROR
|
||||
#define SSL_R_HTTP_REQUEST PARSE_ERROR
|
||||
#define SSL_R_UNSUPPORTED_PROTOCOL VERSION_ERROR
|
||||
|
||||
|
||||
#ifdef HAVE_SESSION_TICKET
|
||||
#define SSL_OP_NO_TICKET SSL_OP_NO_TICKET
|
||||
#define SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB 72
|
||||
#endif
|
||||
|
||||
#define OPENSSL_config wolfSSL_OPENSSL_config
|
||||
#define OPENSSL_memdup wolfSSL_OPENSSL_memdup
|
||||
#define SSL_CTX_get_timeout wolfSSL_SSL_CTX_get_timeout
|
||||
#define SSL_CTX_set_tmp_ecdh wolfSSL_SSL_CTX_set_tmp_ecdh
|
||||
#define SSL_CTX_remove_session wolfSSL_SSL_CTX_remove_session
|
||||
#define SSL_get_rbio wolfSSL_SSL_get_rbio
|
||||
#define SSL_get_wbio wolfSSL_SSL_get_wbio
|
||||
#define SSL_do_handshake wolfSSL_SSL_do_handshake
|
||||
#define SSL_in_init wolfSSL_SSL_in_init
|
||||
#define SSL_get0_session wolfSSL_SSL_get0_session
|
||||
#define SSL_CTX_set_tlsext_ticket_key_cb wolfSSL_CTX_set_tlsext_ticket_key_cb
|
||||
#define SSL_CTX_set_tlsext_status_cb wolfSSL_CTX_set_tlsext_status_cb
|
||||
#define SSL_CTX_get_extra_chain_certs wolfSSL_CTX_get_extra_chain_certs
|
||||
#define sk_OPENSSL_STRING_value wolfSSL_sk_WOLFSSL_STRING_value
|
||||
#define SSL_get0_alpn_selected wolfSSL_get0_alpn_selected
|
||||
#define SSL_select_next_proto wolfSSL_select_next_proto
|
||||
#define SSL_CTX_set_alpn_select_cb wolfSSL_CTX_set_alpn_select_cb
|
||||
#define SSL_CTX_set_next_protos_advertised_cb wolfSSL_CTX_set_next_protos_advertised_cb
|
||||
#define SSL_CTX_set_next_proto_select_cb wolfSSL_CTX_set_next_proto_select_cb
|
||||
#define SSL_get0_next_proto_negotiated wolfSSL_get0_next_proto_negotiated
|
||||
#define SSL_is_server wolfSSL_is_server
|
||||
#define SSL_CTX_set1_curves_list wolfSSL_CTX_set1_curves_list
|
||||
|
||||
#endif /* WOLFSSL_NGINX || WOLFSSL_HAPROXY || WOLFSSL_MYSQL_COMPATIBLE ||
|
||||
OPENSSL_ALL || HAVE_LIGHTY */
|
||||
|
||||
#ifdef OPENSSL_EXTRA
|
||||
#define SSL_CTX_add_client_CA wolfSSL_CTX_add_client_CA
|
||||
#define SSL_CTX_set_srp_password wolfSSL_CTX_set_srp_password
|
||||
#define SSL_CTX_set_srp_username wolfSSL_CTX_set_srp_username
|
||||
#define SSL_get_SSL_CTX wolfSSL_get_SSL_CTX
|
||||
|
||||
#define ERR_NUM_ERRORS 16
|
||||
#define EVP_PKEY_RSA 6
|
||||
#define EVP_PKEY_RSA2 19
|
||||
#define SN_pkcs9_emailAddress "Email"
|
||||
#define LN_pkcs9_emailAddress "emailAddress"
|
||||
#define NID_pkcs9_emailAddress 48
|
||||
#define OBJ_pkcs9_emailAddress 1L,2L,840L,113539L,1L,9L,1L
|
||||
|
||||
#define SSL_get_rbio wolfSSL_SSL_get_rbio
|
||||
#define SSL_get_wbio wolfSSL_SSL_get_wbio
|
||||
#define SSL_do_handshake wolfSSL_SSL_do_handshake
|
||||
#endif /* OPENSSL_EXTRA */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* wolfSSL_openssl_h__ */
|
3065
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/ssl.h
Normal file
3065
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/ssl.h
Normal file
File diff suppressed because it is too large
Load Diff
32
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/version.h
Normal file
32
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/version.h
Normal file
@ -0,0 +1,32 @@
|
||||
/* wolfssl_version.h.in
|
||||
*
|
||||
* Copyright (C) 2006-2018 wolfSSL Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is distributed in binary form as licensed by Espressif Systems.
|
||||
* See README file or contact licensing@wolfssl.com with any questions or comments.
|
||||
*
|
||||
* https://www.wolfssl.com
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef WOLFSSL_VERSION_H
|
||||
#define WOLFSSL_VERSION_H
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define LIBWOLFSSL_VERSION_STRING "3.15.7"
|
||||
#define LIBWOLFSSL_VERSION_HEX 0x03015007
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* WOLFSSL_VERSION_H */
|
||||
|
359
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/wolfcrypt/aes.h
Normal file
359
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/wolfcrypt/aes.h
Normal file
@ -0,0 +1,359 @@
|
||||
/* aes.h
|
||||
*
|
||||
* Copyright (C) 2006-2018 wolfSSL Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is distributed in binary form as licensed by Espressif Systems.
|
||||
* See README file or contact licensing@wolfssl.com with any questions or comments.
|
||||
*
|
||||
* https://www.wolfssl.com
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/aes.h
|
||||
*/
|
||||
|
||||
|
||||
#ifndef WOLF_CRYPT_AES_H
|
||||
#define WOLF_CRYPT_AES_H
|
||||
|
||||
#include <wolfssl/wolfcrypt/types.h>
|
||||
|
||||
#ifndef NO_AES
|
||||
|
||||
#if defined(HAVE_FIPS) && \
|
||||
defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)
|
||||
#include <wolfssl/wolfcrypt/fips.h>
|
||||
#endif /* HAVE_FIPS_VERSION >= 2 */
|
||||
|
||||
/* included for fips @wc_fips */
|
||||
#if defined(HAVE_FIPS) && \
|
||||
(!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2))
|
||||
#include <cyassl/ctaocrypt/aes.h>
|
||||
#if defined(CYASSL_AES_COUNTER) && !defined(WOLFSSL_AES_COUNTER)
|
||||
#define WOLFSSL_AES_COUNTER
|
||||
#endif
|
||||
#if !defined(WOLFSSL_AES_DIRECT) && defined(CYASSL_AES_DIRECT)
|
||||
#define WOLFSSL_AES_DIRECT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef WC_NO_RNG
|
||||
#include <wolfssl/wolfcrypt/random.h>
|
||||
#endif
|
||||
#ifdef STM32_CRYPTO
|
||||
#include <wolfssl/wolfcrypt/port/st/stm32.h>
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_AESNI
|
||||
|
||||
#include <wmmintrin.h>
|
||||
#include <emmintrin.h>
|
||||
#include <smmintrin.h>
|
||||
|
||||
#endif /* WOLFSSL_AESNI */
|
||||
|
||||
|
||||
#ifdef WOLFSSL_XILINX_CRYPT
|
||||
#include "xsecure_aes.h"
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_AFALG
|
||||
/* included for struct msghdr */
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
#if defined(WOLFSSL_DEVCRYPTO_AES) || defined(WOLFSSL_DEVCRYPTO_CBC)
|
||||
#include <wolfssl/wolfcrypt/port/devcrypto/wc_devcrypto.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_AESGCM) && !defined(WC_NO_RNG)
|
||||
#include <wolfssl/wolfcrypt/random.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* these are required for FIPS and non-FIPS */
|
||||
enum {
|
||||
AES_128_KEY_SIZE = 16, /* for 128 bit */
|
||||
AES_192_KEY_SIZE = 24, /* for 192 bit */
|
||||
AES_256_KEY_SIZE = 32, /* for 256 bit */
|
||||
|
||||
AES_IV_SIZE = 16, /* always block size */
|
||||
};
|
||||
|
||||
|
||||
/* avoid redefinition of structs */
|
||||
#if !defined(HAVE_FIPS) || \
|
||||
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2))
|
||||
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
#include <wolfssl/wolfcrypt/async.h>
|
||||
#endif
|
||||
|
||||
enum {
|
||||
AES_ENC_TYPE = WC_CIPHER_AES, /* cipher unique type */
|
||||
AES_ENCRYPTION = 0,
|
||||
AES_DECRYPTION = 1,
|
||||
|
||||
AES_BLOCK_SIZE = 16,
|
||||
|
||||
KEYWRAP_BLOCK_SIZE = 8,
|
||||
|
||||
GCM_NONCE_MAX_SZ = 16, /* wolfCrypt's maximum nonce size allowed. */
|
||||
GCM_NONCE_MID_SZ = 12, /* The usual default nonce size for AES-GCM. */
|
||||
GCM_NONCE_MIN_SZ = 8, /* wolfCrypt's minimum nonce size allowed. */
|
||||
CCM_NONCE_MIN_SZ = 7,
|
||||
CCM_NONCE_MAX_SZ = 13,
|
||||
CTR_SZ = 4,
|
||||
AES_IV_FIXED_SZ = 4,
|
||||
|
||||
#ifdef HAVE_PKCS11
|
||||
AES_MAX_ID_LEN = 32,
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
typedef struct Aes {
|
||||
/* AESNI needs key first, rounds 2nd, not sure why yet */
|
||||
ALIGN16 word32 key[60];
|
||||
word32 rounds;
|
||||
int keylen;
|
||||
|
||||
ALIGN16 word32 reg[AES_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
|
||||
ALIGN16 word32 tmp[AES_BLOCK_SIZE / sizeof(word32)]; /* same */
|
||||
|
||||
#if defined(HAVE_AESGCM) || defined(HAVE_AESCCM)
|
||||
word32 invokeCtr[2];
|
||||
word32 nonceSz;
|
||||
#endif
|
||||
#ifdef HAVE_AESGCM
|
||||
ALIGN16 byte H[AES_BLOCK_SIZE];
|
||||
#ifdef GCM_TABLE
|
||||
/* key-based fast multiplication table. */
|
||||
ALIGN16 byte M0[256][AES_BLOCK_SIZE];
|
||||
#endif /* GCM_TABLE */
|
||||
#endif /* HAVE_AESGCM */
|
||||
#ifdef WOLFSSL_AESNI
|
||||
byte use_aesni;
|
||||
#endif /* WOLFSSL_AESNI */
|
||||
#ifdef WOLF_CRYPTO_DEV
|
||||
int devId;
|
||||
#endif
|
||||
#ifdef HAVE_PKCS11
|
||||
byte id[AES_MAX_ID_LEN];
|
||||
int idLen;
|
||||
#endif
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
word32 asyncKey[AES_MAX_KEY_SIZE/8/sizeof(word32)]; /* raw key */
|
||||
word32 asyncIv[AES_BLOCK_SIZE/sizeof(word32)]; /* raw IV */
|
||||
WC_ASYNC_DEV asyncDev;
|
||||
#endif /* WOLFSSL_ASYNC_CRYPT */
|
||||
#if defined(WOLFSSL_AES_COUNTER) || defined(WOLFSSL_AES_CFB)
|
||||
word32 left; /* unused bytes left from last call */
|
||||
#endif
|
||||
#ifdef WOLFSSL_XILINX_CRYPT
|
||||
XSecure_Aes xilAes;
|
||||
XCsuDma dma;
|
||||
word32 key_init[8];
|
||||
word32 kup;
|
||||
#endif
|
||||
#ifdef WOLFSSL_AFALG
|
||||
int alFd; /* server socket to bind to */
|
||||
int rdFd; /* socket to read from */
|
||||
struct msghdr msg;
|
||||
int dir; /* flag for encrpyt or decrypt */
|
||||
#endif
|
||||
#if defined(WOLFSSL_DEVCRYPTO) && \
|
||||
(defined(WOLFSSL_DEVCRYPTO_AES) || defined(WOLFSSL_DEVCRYPTO_CBC))
|
||||
word32 devKey[AES_MAX_KEY_SIZE/WOLFSSL_BIT_SIZE/sizeof(word32)]; /* raw key */
|
||||
WC_CRYPTODEV ctx;
|
||||
#endif
|
||||
void* heap; /* memory hint to use */
|
||||
} Aes;
|
||||
|
||||
#ifdef WOLFSSL_AES_XTS
|
||||
typedef struct XtsAes {
|
||||
Aes aes;
|
||||
Aes tweak;
|
||||
} XtsAes;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_AESGCM
|
||||
typedef struct Gmac {
|
||||
Aes aes;
|
||||
} Gmac;
|
||||
#endif /* HAVE_AESGCM */
|
||||
#endif /* HAVE_FIPS */
|
||||
|
||||
|
||||
/* Authenticate cipher function prototypes */
|
||||
typedef int (*wc_AesAuthEncryptFunc)(Aes* aes, byte* out,
|
||||
const byte* in, word32 sz,
|
||||
const byte* iv, word32 ivSz,
|
||||
byte* authTag, word32 authTagSz,
|
||||
const byte* authIn, word32 authInSz);
|
||||
typedef int (*wc_AesAuthDecryptFunc)(Aes* aes, byte* out,
|
||||
const byte* in, word32 sz,
|
||||
const byte* iv, word32 ivSz,
|
||||
const byte* authTag, word32 authTagSz,
|
||||
const byte* authIn, word32 authInSz);
|
||||
|
||||
/* AES-CBC */
|
||||
WOLFSSL_API int wc_AesSetKey(Aes* aes, const byte* key, word32 len,
|
||||
const byte* iv, int dir);
|
||||
WOLFSSL_API int wc_AesSetIV(Aes* aes, const byte* iv);
|
||||
|
||||
#ifdef HAVE_AES_CBC
|
||||
WOLFSSL_API int wc_AesCbcEncrypt(Aes* aes, byte* out,
|
||||
const byte* in, word32 sz);
|
||||
WOLFSSL_API int wc_AesCbcDecrypt(Aes* aes, byte* out,
|
||||
const byte* in, word32 sz);
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_AES_CFB
|
||||
WOLFSSL_API int wc_AesCfbEncrypt(Aes* aes, byte* out,
|
||||
const byte* in, word32 sz);
|
||||
#ifdef HAVE_AES_DECRYPT
|
||||
WOLFSSL_API int wc_AesCfbDecrypt(Aes* aes, byte* out,
|
||||
const byte* in, word32 sz);
|
||||
#endif /* HAVE_AES_DECRYPT */
|
||||
#endif /* WOLFSSL_AES_CFB */
|
||||
|
||||
#ifdef HAVE_AES_ECB
|
||||
WOLFSSL_API int wc_AesEcbEncrypt(Aes* aes, byte* out,
|
||||
const byte* in, word32 sz);
|
||||
WOLFSSL_API int wc_AesEcbDecrypt(Aes* aes, byte* out,
|
||||
const byte* in, word32 sz);
|
||||
#endif
|
||||
|
||||
/* AES-CTR */
|
||||
#ifdef WOLFSSL_AES_COUNTER
|
||||
WOLFSSL_API int wc_AesCtrEncrypt(Aes* aes, byte* out,
|
||||
const byte* in, word32 sz);
|
||||
#endif
|
||||
/* AES-DIRECT */
|
||||
#if defined(WOLFSSL_AES_DIRECT)
|
||||
WOLFSSL_API void wc_AesEncryptDirect(Aes* aes, byte* out, const byte* in);
|
||||
WOLFSSL_API void wc_AesDecryptDirect(Aes* aes, byte* out, const byte* in);
|
||||
WOLFSSL_API int wc_AesSetKeyDirect(Aes* aes, const byte* key, word32 len,
|
||||
const byte* iv, int dir);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_AESGCM
|
||||
#ifdef WOLFSSL_XILINX_CRYPT
|
||||
WOLFSSL_API int wc_AesGcmSetKey_ex(Aes* aes, const byte* key, word32 len,
|
||||
word32 kup);
|
||||
#endif
|
||||
WOLFSSL_API int wc_AesGcmSetKey(Aes* aes, const byte* key, word32 len);
|
||||
WOLFSSL_API int wc_AesGcmEncrypt(Aes* aes, byte* out,
|
||||
const byte* in, word32 sz,
|
||||
const byte* iv, word32 ivSz,
|
||||
byte* authTag, word32 authTagSz,
|
||||
const byte* authIn, word32 authInSz);
|
||||
WOLFSSL_API int wc_AesGcmDecrypt(Aes* aes, byte* out,
|
||||
const byte* in, word32 sz,
|
||||
const byte* iv, word32 ivSz,
|
||||
const byte* authTag, word32 authTagSz,
|
||||
const byte* authIn, word32 authInSz);
|
||||
|
||||
#ifndef WC_NO_RNG
|
||||
WOLFSSL_API int wc_AesGcmSetExtIV(Aes* aes, const byte* iv, word32 ivSz);
|
||||
WOLFSSL_API int wc_AesGcmSetIV(Aes* aes, word32 ivSz,
|
||||
const byte* ivFixed, word32 ivFixedSz,
|
||||
WC_RNG* rng);
|
||||
WOLFSSL_API int wc_AesGcmEncrypt_ex(Aes* aes, byte* out,
|
||||
const byte* in, word32 sz,
|
||||
byte* ivOut, word32 ivOutSz,
|
||||
byte* authTag, word32 authTagSz,
|
||||
const byte* authIn, word32 authInSz);
|
||||
#endif /* WC_NO_RNG */
|
||||
|
||||
WOLFSSL_API int wc_GmacSetKey(Gmac* gmac, const byte* key, word32 len);
|
||||
WOLFSSL_API int wc_GmacUpdate(Gmac* gmac, const byte* iv, word32 ivSz,
|
||||
const byte* authIn, word32 authInSz,
|
||||
byte* authTag, word32 authTagSz);
|
||||
#ifndef WC_NO_RNG
|
||||
WOLFSSL_API int wc_Gmac(const byte* key, word32 keySz, byte* iv, word32 ivSz,
|
||||
const byte* authIn, word32 authInSz,
|
||||
byte* authTag, word32 authTagSz, WC_RNG* rng);
|
||||
WOLFSSL_API int wc_GmacVerify(const byte* key, word32 keySz,
|
||||
const byte* iv, word32 ivSz,
|
||||
const byte* authIn, word32 authInSz,
|
||||
const byte* authTag, word32 authTagSz);
|
||||
#endif /* WC_NO_RNG */
|
||||
WOLFSSL_LOCAL void GHASH(Aes* aes, const byte* a, word32 aSz, const byte* c,
|
||||
word32 cSz, byte* s, word32 sSz);
|
||||
#endif /* HAVE_AESGCM */
|
||||
#ifdef HAVE_AESCCM
|
||||
WOLFSSL_API int wc_AesCcmSetKey(Aes* aes, const byte* key, word32 keySz);
|
||||
WOLFSSL_API int wc_AesCcmEncrypt(Aes* aes, byte* out,
|
||||
const byte* in, word32 inSz,
|
||||
const byte* nonce, word32 nonceSz,
|
||||
byte* authTag, word32 authTagSz,
|
||||
const byte* authIn, word32 authInSz);
|
||||
WOLFSSL_API int wc_AesCcmDecrypt(Aes* aes, byte* out,
|
||||
const byte* in, word32 inSz,
|
||||
const byte* nonce, word32 nonceSz,
|
||||
const byte* authTag, word32 authTagSz,
|
||||
const byte* authIn, word32 authInSz);
|
||||
WOLFSSL_API int wc_AesCcmSetNonce(Aes* aes,
|
||||
const byte* nonce, word32 nonceSz);
|
||||
WOLFSSL_API int wc_AesCcmEncrypt_ex(Aes* aes, byte* out,
|
||||
const byte* in, word32 sz,
|
||||
byte* ivOut, word32 ivOutSz,
|
||||
byte* authTag, word32 authTagSz,
|
||||
const byte* authIn, word32 authInSz);
|
||||
#endif /* HAVE_AESCCM */
|
||||
#ifdef HAVE_AES_KEYWRAP
|
||||
WOLFSSL_API int wc_AesKeyWrap(const byte* key, word32 keySz,
|
||||
const byte* in, word32 inSz,
|
||||
byte* out, word32 outSz,
|
||||
const byte* iv);
|
||||
WOLFSSL_API int wc_AesKeyUnWrap(const byte* key, word32 keySz,
|
||||
const byte* in, word32 inSz,
|
||||
byte* out, word32 outSz,
|
||||
const byte* iv);
|
||||
#endif /* HAVE_AES_KEYWRAP */
|
||||
|
||||
#ifdef WOLFSSL_AES_XTS
|
||||
|
||||
WOLFSSL_API int wc_AesXtsSetKey(XtsAes* aes, const byte* key,
|
||||
word32 len, int dir, void* heap, int devId);
|
||||
|
||||
WOLFSSL_API int wc_AesXtsEncryptSector(XtsAes* aes, byte* out,
|
||||
const byte* in, word32 sz, word64 sector);
|
||||
|
||||
WOLFSSL_API int wc_AesXtsDecryptSector(XtsAes* aes, byte* out,
|
||||
const byte* in, word32 sz, word64 sector);
|
||||
|
||||
WOLFSSL_API int wc_AesXtsEncrypt(XtsAes* aes, byte* out,
|
||||
const byte* in, word32 sz, const byte* i, word32 iSz);
|
||||
|
||||
WOLFSSL_API int wc_AesXtsDecrypt(XtsAes* aes, byte* out,
|
||||
const byte* in, word32 sz, const byte* i, word32 iSz);
|
||||
|
||||
WOLFSSL_API int wc_AesXtsFree(XtsAes* aes);
|
||||
#endif
|
||||
|
||||
WOLFSSL_API int wc_AesGetKeySize(Aes* aes, word32* keySize);
|
||||
|
||||
WOLFSSL_API int wc_AesInit(Aes* aes, void* heap, int devId);
|
||||
#ifdef HAVE_PKCS11
|
||||
WOLFSSL_API int wc_AesInit_Id(Aes* aes, unsigned char* id, int len, void* heap,
|
||||
int devId);
|
||||
#endif
|
||||
WOLFSSL_API void wc_AesFree(Aes* aes);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* NO_AES */
|
||||
#endif /* WOLF_CRYPT_AES_H */
|
@ -0,0 +1,60 @@
|
||||
/* arc4.h
|
||||
*
|
||||
* Copyright (C) 2006-2018 wolfSSL Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is distributed in binary form as licensed by Espressif Systems.
|
||||
* See README file or contact licensing@wolfssl.com with any questions or comments.
|
||||
*
|
||||
* https://www.wolfssl.com
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/arc4.h
|
||||
*/
|
||||
|
||||
#ifndef WOLF_CRYPT_ARC4_H
|
||||
#define WOLF_CRYPT_ARC4_H
|
||||
|
||||
#include <wolfssl/wolfcrypt/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
#include <wolfssl/wolfcrypt/async.h>
|
||||
#endif
|
||||
|
||||
enum {
|
||||
ARC4_ENC_TYPE = 4, /* cipher unique type */
|
||||
ARC4_STATE_SIZE = 256,
|
||||
RC4_KEY_SIZE = 16, /* always 128bit */
|
||||
};
|
||||
|
||||
/* ARC4 encryption and decryption */
|
||||
typedef struct Arc4 {
|
||||
byte x;
|
||||
byte y;
|
||||
byte state[ARC4_STATE_SIZE];
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
WC_ASYNC_DEV asyncDev;
|
||||
#endif
|
||||
void* heap;
|
||||
} Arc4;
|
||||
|
||||
WOLFSSL_API int wc_Arc4Process(Arc4*, byte*, const byte*, word32);
|
||||
WOLFSSL_API int wc_Arc4SetKey(Arc4*, const byte*, word32);
|
||||
|
||||
WOLFSSL_API int wc_Arc4Init(Arc4*, void*, int);
|
||||
WOLFSSL_API void wc_Arc4Free(Arc4*);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* WOLF_CRYPT_ARC4_H */
|
||||
|
@ -0,0 +1,508 @@
|
||||
/* asn_public.h
|
||||
*
|
||||
* Copyright (C) 2006-2018 wolfSSL Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is distributed in binary form as licensed by Espressif Systems.
|
||||
* See README file or contact licensing@wolfssl.com with any questions or comments.
|
||||
*
|
||||
* https://www.wolfssl.com
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/asn_public.h
|
||||
*/
|
||||
|
||||
#ifndef WOLF_CRYPT_ASN_PUBLIC_H
|
||||
#define WOLF_CRYPT_ASN_PUBLIC_H
|
||||
|
||||
#include <wolfssl/wolfcrypt/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* guard on redeclaration */
|
||||
#ifndef WC_ECCKEY_TYPE_DEFINED
|
||||
typedef struct ecc_key ecc_key;
|
||||
#define WC_ECCKEY_TYPE_DEFINED
|
||||
#endif
|
||||
#ifndef WC_ED25519KEY_TYPE_DEFINED
|
||||
typedef struct ed25519_key ed25519_key;
|
||||
#define WC_ED25519KEY_TYPE_DEFINED
|
||||
#endif
|
||||
#ifndef WC_RSAKEY_TYPE_DEFINED
|
||||
typedef struct RsaKey RsaKey;
|
||||
#define WC_RSAKEY_TYPE_DEFINED
|
||||
#endif
|
||||
#ifndef WC_RNG_TYPE_DEFINED
|
||||
typedef struct WC_RNG WC_RNG;
|
||||
#define WC_RNG_TYPE_DEFINED
|
||||
#endif
|
||||
|
||||
|
||||
/* Certificate file Type */
|
||||
enum CertType {
|
||||
CERT_TYPE = 0,
|
||||
PRIVATEKEY_TYPE,
|
||||
DH_PARAM_TYPE,
|
||||
DSA_PARAM_TYPE,
|
||||
CRL_TYPE,
|
||||
CA_TYPE,
|
||||
ECC_PRIVATEKEY_TYPE,
|
||||
DSA_PRIVATEKEY_TYPE,
|
||||
CERTREQ_TYPE,
|
||||
DSA_TYPE,
|
||||
ECC_TYPE,
|
||||
RSA_TYPE,
|
||||
PUBLICKEY_TYPE,
|
||||
RSA_PUBLICKEY_TYPE,
|
||||
ECC_PUBLICKEY_TYPE,
|
||||
TRUSTED_PEER_TYPE,
|
||||
EDDSA_PRIVATEKEY_TYPE,
|
||||
ED25519_TYPE,
|
||||
PKCS12_TYPE,
|
||||
PKCS8_PRIVATEKEY_TYPE,
|
||||
PKCS8_ENC_PRIVATEKEY_TYPE
|
||||
};
|
||||
|
||||
|
||||
/* Signature type, by OID sum */
|
||||
enum Ctc_SigType {
|
||||
CTC_SHAwDSA = 517,
|
||||
CTC_MD2wRSA = 646,
|
||||
CTC_MD5wRSA = 648,
|
||||
CTC_SHAwRSA = 649,
|
||||
CTC_SHAwECDSA = 520,
|
||||
CTC_SHA224wRSA = 658,
|
||||
CTC_SHA224wECDSA = 523,
|
||||
CTC_SHA256wRSA = 655,
|
||||
CTC_SHA256wECDSA = 524,
|
||||
CTC_SHA384wRSA = 656,
|
||||
CTC_SHA384wECDSA = 525,
|
||||
CTC_SHA512wRSA = 657,
|
||||
CTC_SHA512wECDSA = 526,
|
||||
CTC_ED25519 = 256
|
||||
};
|
||||
|
||||
enum Ctc_Encoding {
|
||||
CTC_UTF8 = 0x0c, /* utf8 */
|
||||
CTC_PRINTABLE = 0x13 /* printable */
|
||||
};
|
||||
|
||||
#ifndef WC_CTC_NAME_SIZE
|
||||
#define WC_CTC_NAME_SIZE 64
|
||||
#endif
|
||||
#ifndef WC_CTC_MAX_ALT_SIZE
|
||||
#define WC_CTC_MAX_ALT_SIZE 16384
|
||||
#endif
|
||||
|
||||
enum Ctc_Misc {
|
||||
CTC_COUNTRY_SIZE = 2,
|
||||
CTC_NAME_SIZE = WC_CTC_NAME_SIZE,
|
||||
CTC_DATE_SIZE = 32,
|
||||
CTC_MAX_ALT_SIZE = WC_CTC_MAX_ALT_SIZE, /* may be huge, default: 16384 */
|
||||
CTC_SERIAL_SIZE = 16,
|
||||
#ifdef WOLFSSL_CERT_EXT
|
||||
/* AKID could contains: hash + (Option) AuthCertIssuer,AuthCertSerialNum
|
||||
* We support only hash */
|
||||
CTC_MAX_SKID_SIZE = 32, /* SHA256_DIGEST_SIZE */
|
||||
CTC_MAX_AKID_SIZE = 32, /* SHA256_DIGEST_SIZE */
|
||||
CTC_MAX_CERTPOL_SZ = 64,
|
||||
CTC_MAX_CERTPOL_NB = 2 /* Max number of Certificate Policy */
|
||||
#endif /* WOLFSSL_CERT_EXT */
|
||||
};
|
||||
|
||||
/* DER buffer */
|
||||
typedef struct DerBuffer {
|
||||
byte* buffer;
|
||||
void* heap;
|
||||
word32 length;
|
||||
int type; /* enum CertType */
|
||||
int dynType; /* DYNAMIC_TYPE_* */
|
||||
} DerBuffer;
|
||||
|
||||
enum {
|
||||
IV_SZ = 32, /* max iv sz */
|
||||
NAME_SZ = 80, /* max one line */
|
||||
|
||||
PEM_PASS_READ = 0,
|
||||
PEM_PASS_WRITE = 1,
|
||||
};
|
||||
|
||||
|
||||
typedef int (pem_password_cb)(char* passwd, int sz, int rw, void* userdata);
|
||||
|
||||
typedef struct EncryptedInfo {
|
||||
pem_password_cb* passwd_cb;
|
||||
void* passwd_userdata;
|
||||
|
||||
long consumed; /* tracks PEM bytes consumed */
|
||||
|
||||
int cipherType;
|
||||
word32 keySz;
|
||||
word32 ivSz; /* salt or encrypted IV size */
|
||||
|
||||
char name[NAME_SZ]; /* cipher name, such as "DES-CBC" */
|
||||
byte iv[IV_SZ]; /* salt or encrypted IV */
|
||||
|
||||
word16 set:1; /* if encryption set */
|
||||
} EncryptedInfo;
|
||||
|
||||
|
||||
#if defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_CERT_EXT)
|
||||
#ifdef WOLFSSL_EKU_OID
|
||||
#ifndef CTC_MAX_EKU_NB
|
||||
#define CTC_MAX_EKU_NB 1
|
||||
#endif
|
||||
#ifndef CTC_MAX_EKU_OID_SZ
|
||||
#define CTC_MAX_EKU_OID_SZ 30
|
||||
#endif
|
||||
#else
|
||||
#undef CTC_MAX_EKU_OID_SZ
|
||||
#define CTC_MAX_EKU_OID_SZ 0
|
||||
#endif
|
||||
#endif /* WOLFSSL_CERT_GEN || WOLFSSL_CERT_EXT */
|
||||
|
||||
#ifdef WOLFSSL_CERT_GEN
|
||||
|
||||
#ifdef WOLFSSL_MULTI_ATTRIB
|
||||
#ifndef CTC_MAX_ATTRIB
|
||||
#define CTC_MAX_ATTRIB 4
|
||||
#endif
|
||||
|
||||
/* ASN Encoded Name field */
|
||||
typedef struct NameAttrib {
|
||||
int sz; /* actual string value length */
|
||||
int id; /* id of name */
|
||||
int type; /* enc of name */
|
||||
char value[CTC_NAME_SIZE]; /* name */
|
||||
} NameAttrib;
|
||||
#endif /* WOLFSSL_MULTI_ATTRIB */
|
||||
|
||||
|
||||
typedef struct CertName {
|
||||
char country[CTC_NAME_SIZE];
|
||||
char countryEnc;
|
||||
char state[CTC_NAME_SIZE];
|
||||
char stateEnc;
|
||||
char locality[CTC_NAME_SIZE];
|
||||
char localityEnc;
|
||||
char sur[CTC_NAME_SIZE];
|
||||
char surEnc;
|
||||
char org[CTC_NAME_SIZE];
|
||||
char orgEnc;
|
||||
char unit[CTC_NAME_SIZE];
|
||||
char unitEnc;
|
||||
char commonName[CTC_NAME_SIZE];
|
||||
char commonNameEnc;
|
||||
char serialDev[CTC_NAME_SIZE];
|
||||
char serialDevEnc;
|
||||
#ifdef WOLFSSL_CERT_EXT
|
||||
char busCat[CTC_NAME_SIZE];
|
||||
char busCatEnc;
|
||||
char joiC[CTC_NAME_SIZE];
|
||||
char joiCEnc;
|
||||
char joiSt[CTC_NAME_SIZE];
|
||||
char joiStEnc;
|
||||
#endif
|
||||
char email[CTC_NAME_SIZE]; /* !!!! email has to be last !!!! */
|
||||
#ifdef WOLFSSL_MULTI_ATTRIB
|
||||
NameAttrib name[CTC_MAX_ATTRIB];
|
||||
#endif
|
||||
} CertName;
|
||||
|
||||
|
||||
/* for user to fill for certificate generation */
|
||||
typedef struct Cert {
|
||||
int version; /* x509 version */
|
||||
byte serial[CTC_SERIAL_SIZE]; /* serial number */
|
||||
int serialSz; /* serial size */
|
||||
int sigType; /* signature algo type */
|
||||
CertName issuer; /* issuer info */
|
||||
int daysValid; /* validity days */
|
||||
int selfSigned; /* self signed flag */
|
||||
CertName subject; /* subject info */
|
||||
int isCA; /* is this going to be a CA */
|
||||
/* internal use only */
|
||||
int bodySz; /* pre sign total size */
|
||||
int keyType; /* public key type of subject */
|
||||
#ifdef WOLFSSL_ALT_NAMES
|
||||
byte altNames[CTC_MAX_ALT_SIZE]; /* altNames copy */
|
||||
int altNamesSz; /* altNames size in bytes */
|
||||
byte beforeDate[CTC_DATE_SIZE]; /* before date copy */
|
||||
int beforeDateSz; /* size of copy */
|
||||
byte afterDate[CTC_DATE_SIZE]; /* after date copy */
|
||||
int afterDateSz; /* size of copy */
|
||||
#endif
|
||||
#ifdef WOLFSSL_CERT_EXT
|
||||
byte skid[CTC_MAX_SKID_SIZE]; /* Subject Key Identifier */
|
||||
int skidSz; /* SKID size in bytes */
|
||||
byte akid[CTC_MAX_AKID_SIZE]; /* Authority Key Identifier */
|
||||
int akidSz; /* AKID size in bytes */
|
||||
word16 keyUsage; /* Key Usage */
|
||||
byte extKeyUsage; /* Extended Key Usage */
|
||||
#ifdef WOLFSSL_EKU_OID
|
||||
/* Extended Key Usage OIDs */
|
||||
byte extKeyUsageOID[CTC_MAX_EKU_NB][CTC_MAX_EKU_OID_SZ];
|
||||
byte extKeyUsageOIDSz[CTC_MAX_EKU_NB];
|
||||
#endif
|
||||
char certPolicies[CTC_MAX_CERTPOL_NB][CTC_MAX_CERTPOL_SZ];
|
||||
word16 certPoliciesNb; /* Number of Cert Policy */
|
||||
byte issRaw[sizeof(CertName)]; /* raw issuer info */
|
||||
byte sbjRaw[sizeof(CertName)]; /* raw subject info */
|
||||
#endif
|
||||
#ifdef WOLFSSL_CERT_REQ
|
||||
char challengePw[CTC_NAME_SIZE];
|
||||
#endif
|
||||
void* heap; /* heap hint */
|
||||
} Cert;
|
||||
|
||||
|
||||
|
||||
/* Initialize and Set Certificate defaults:
|
||||
version = 3 (0x2)
|
||||
serial = 0 (Will be randomly generated)
|
||||
sigType = SHA_WITH_RSA
|
||||
issuer = blank
|
||||
daysValid = 500
|
||||
selfSigned = 1 (true) use subject as issuer
|
||||
subject = blank
|
||||
isCA = 0 (false)
|
||||
keyType = RSA_KEY (default)
|
||||
*/
|
||||
WOLFSSL_API int wc_InitCert(Cert*);
|
||||
WOLFSSL_API int wc_MakeCert_ex(Cert* cert, byte* derBuffer, word32 derSz,
|
||||
int keyType, void* key, WC_RNG* rng);
|
||||
WOLFSSL_API int wc_MakeCert(Cert*, byte* derBuffer, word32 derSz, RsaKey*,
|
||||
ecc_key*, WC_RNG*);
|
||||
#ifdef WOLFSSL_CERT_REQ
|
||||
WOLFSSL_API int wc_MakeCertReq_ex(Cert*, byte* derBuffer, word32 derSz,
|
||||
int, void*);
|
||||
WOLFSSL_API int wc_MakeCertReq(Cert*, byte* derBuffer, word32 derSz,
|
||||
RsaKey*, ecc_key*);
|
||||
#endif
|
||||
WOLFSSL_API int wc_SignCert_ex(int requestSz, int sType, byte* buffer,
|
||||
word32 buffSz, int keyType, void* key,
|
||||
WC_RNG* rng);
|
||||
WOLFSSL_API int wc_SignCert(int requestSz, int sigType, byte* derBuffer,
|
||||
word32 derSz, RsaKey*, ecc_key*, WC_RNG*);
|
||||
WOLFSSL_API int wc_MakeSelfCert(Cert*, byte* derBuffer, word32 derSz, RsaKey*,
|
||||
WC_RNG*);
|
||||
WOLFSSL_API int wc_SetIssuer(Cert*, const char*);
|
||||
WOLFSSL_API int wc_SetSubject(Cert*, const char*);
|
||||
#ifdef WOLFSSL_ALT_NAMES
|
||||
WOLFSSL_API int wc_SetAltNames(Cert*, const char*);
|
||||
#endif
|
||||
WOLFSSL_API int wc_SetIssuerBuffer(Cert*, const byte*, int);
|
||||
WOLFSSL_API int wc_SetSubjectBuffer(Cert*, const byte*, int);
|
||||
WOLFSSL_API int wc_SetAltNamesBuffer(Cert*, const byte*, int);
|
||||
WOLFSSL_API int wc_SetDatesBuffer(Cert*, const byte*, int);
|
||||
|
||||
#ifndef NO_ASN_TIME
|
||||
WOLFSSL_API int wc_GetCertDates(Cert* cert, struct tm* before,
|
||||
struct tm* after);
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_CERT_EXT
|
||||
WOLFSSL_API int wc_SetAuthKeyIdFromPublicKey_ex(Cert *cert, int keyType,
|
||||
void* key);
|
||||
WOLFSSL_API int wc_SetAuthKeyIdFromPublicKey(Cert *cert, RsaKey *rsakey,
|
||||
ecc_key *eckey);
|
||||
WOLFSSL_API int wc_SetAuthKeyIdFromCert(Cert *cert, const byte *der, int derSz);
|
||||
WOLFSSL_API int wc_SetAuthKeyId(Cert *cert, const char* file);
|
||||
WOLFSSL_API int wc_SetSubjectKeyIdFromPublicKey_ex(Cert *cert, int keyType,
|
||||
void* key);
|
||||
WOLFSSL_API int wc_SetSubjectKeyIdFromPublicKey(Cert *cert, RsaKey *rsakey,
|
||||
ecc_key *eckey);
|
||||
WOLFSSL_API int wc_SetSubjectKeyId(Cert *cert, const char* file);
|
||||
WOLFSSL_API int wc_GetSubjectRaw(byte **subjectRaw, Cert *cert);
|
||||
WOLFSSL_API int wc_SetSubjectRaw(Cert* cert, const byte* der, int derSz);
|
||||
WOLFSSL_API int wc_SetIssuerRaw(Cert* cert, const byte* der, int derSz);
|
||||
|
||||
#ifdef HAVE_NTRU
|
||||
WOLFSSL_API int wc_SetSubjectKeyIdFromNtruPublicKey(Cert *cert, byte *ntruKey,
|
||||
word16 ntruKeySz);
|
||||
#endif
|
||||
|
||||
/* Set the KeyUsage.
|
||||
* Value is a string separated tokens with ','. Accepted tokens are :
|
||||
* digitalSignature,nonRepudiation,contentCommitment,keyCertSign,cRLSign,
|
||||
* dataEncipherment,keyAgreement,keyEncipherment,encipherOnly and decipherOnly.
|
||||
*
|
||||
* nonRepudiation and contentCommitment are for the same usage.
|
||||
*/
|
||||
WOLFSSL_API int wc_SetKeyUsage(Cert *cert, const char *value);
|
||||
|
||||
/* Set ExtendedKeyUsage
|
||||
* Value is a string separated tokens with ','. Accepted tokens are :
|
||||
* any,serverAuth,clientAuth,codeSigning,emailProtection,timeStamping,OCSPSigning
|
||||
*/
|
||||
WOLFSSL_API int wc_SetExtKeyUsage(Cert *cert, const char *value);
|
||||
|
||||
|
||||
#ifdef WOLFSSL_EKU_OID
|
||||
/* Set ExtendedKeyUsage with unique OID
|
||||
* oid is expected to be in byte representation
|
||||
*/
|
||||
WOLFSSL_API int wc_SetExtKeyUsageOID(Cert *cert, const char *oid, word32 sz,
|
||||
byte idx, void* heap);
|
||||
#endif /* WOLFSSL_EKU_OID */
|
||||
#endif /* WOLFSSL_CERT_EXT */
|
||||
|
||||
#ifdef HAVE_NTRU
|
||||
WOLFSSL_API int wc_MakeNtruCert(Cert*, byte* derBuffer, word32 derSz,
|
||||
const byte* ntruKey, word16 keySz,
|
||||
WC_RNG*);
|
||||
#endif
|
||||
|
||||
#endif /* WOLFSSL_CERT_GEN */
|
||||
|
||||
WOLFSSL_API int wc_GetDateInfo(const byte* certDate, int certDateSz,
|
||||
const byte** date, byte* format, int* length);
|
||||
#ifndef NO_ASN_TIME
|
||||
WOLFSSL_API int wc_GetDateAsCalendarTime(const byte* date, int length,
|
||||
byte format, struct tm* time);
|
||||
#endif
|
||||
|
||||
#if defined(WOLFSSL_PEM_TO_DER) || defined(WOLFSSL_DER_TO_PEM)
|
||||
|
||||
WOLFSSL_API int wc_PemGetHeaderFooter(int type, const char** header,
|
||||
const char** footer);
|
||||
|
||||
#endif
|
||||
|
||||
WOLFSSL_API int wc_AllocDer(DerBuffer** pDer, word32 length, int type, void* heap);
|
||||
WOLFSSL_API void wc_FreeDer(DerBuffer** pDer);
|
||||
|
||||
#ifdef WOLFSSL_PEM_TO_DER
|
||||
WOLFSSL_API int wc_PemToDer(const unsigned char* buff, long longSz, int type,
|
||||
DerBuffer** pDer, void* heap, EncryptedInfo* info, int* eccKey);
|
||||
|
||||
WOLFSSL_API int wc_KeyPemToDer(const unsigned char*, int,
|
||||
unsigned char*, int, const char*);
|
||||
WOLFSSL_API int wc_CertPemToDer(const unsigned char*, int,
|
||||
unsigned char*, int, int);
|
||||
#endif /* WOLFSSL_PEM_TO_DER */
|
||||
|
||||
#if defined(WOLFSSL_CERT_EXT) || defined(WOLFSSL_PUB_PEM_TO_DER)
|
||||
#ifndef NO_FILESYSTEM
|
||||
WOLFSSL_API int wc_PemPubKeyToDer(const char* fileName,
|
||||
unsigned char* derBuf, int derSz);
|
||||
#endif
|
||||
|
||||
WOLFSSL_API int wc_PubKeyPemToDer(const unsigned char*, int,
|
||||
unsigned char*, int);
|
||||
#endif /* WOLFSSL_CERT_EXT || WOLFSSL_PUB_PEM_TO_DER */
|
||||
|
||||
#ifdef WOLFSSL_CERT_GEN
|
||||
#ifndef NO_FILESYSTEM
|
||||
WOLFSSL_API int wc_PemCertToDer(const char* fileName,
|
||||
unsigned char* derBuf, int derSz);
|
||||
#endif
|
||||
#endif /* WOLFSSL_CERT_GEN */
|
||||
|
||||
#ifdef WOLFSSL_DER_TO_PEM
|
||||
WOLFSSL_API int wc_DerToPem(const byte* der, word32 derSz, byte* output,
|
||||
word32 outputSz, int type);
|
||||
WOLFSSL_API int wc_DerToPemEx(const byte* der, word32 derSz, byte* output,
|
||||
word32 outputSz, byte *cipherIno, int type);
|
||||
#endif
|
||||
|
||||
#if !defined(NO_RSA) && !defined(HAVE_USER_RSA)
|
||||
WOLFSSL_API int wc_RsaPublicKeyDecode_ex(const byte* input, word32* inOutIdx,
|
||||
word32 inSz, const byte** n, word32* nSz, const byte** e, word32* eSz);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ECC
|
||||
/* private key helpers */
|
||||
WOLFSSL_API int wc_EccPrivateKeyDecode(const byte*, word32*,
|
||||
ecc_key*, word32);
|
||||
WOLFSSL_API int wc_EccKeyToDer(ecc_key*, byte* output, word32 inLen);
|
||||
WOLFSSL_API int wc_EccPrivateKeyToDer(ecc_key* key, byte* output,
|
||||
word32 inLen);
|
||||
WOLFSSL_API int wc_EccPrivateKeyToPKCS8(ecc_key* key, byte* output,
|
||||
word32* outLen);
|
||||
|
||||
/* public key helper */
|
||||
WOLFSSL_API int wc_EccPublicKeyDecode(const byte*, word32*,
|
||||
ecc_key*, word32);
|
||||
WOLFSSL_API int wc_EccPublicKeyToDer(ecc_key*, byte* output,
|
||||
word32 inLen, int with_AlgCurve);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ED25519
|
||||
/* private key helpers */
|
||||
WOLFSSL_API int wc_Ed25519PrivateKeyDecode(const byte*, word32*,
|
||||
ed25519_key*, word32);
|
||||
WOLFSSL_API int wc_Ed25519KeyToDer(ed25519_key* key, byte* output,
|
||||
word32 inLen);
|
||||
WOLFSSL_API int wc_Ed25519PrivateKeyToDer(ed25519_key* key, byte* output,
|
||||
word32 inLen);
|
||||
|
||||
/* public key helper */
|
||||
WOLFSSL_API int wc_Ed25519PublicKeyDecode(const byte*, word32*,
|
||||
ed25519_key*, word32);
|
||||
#if (defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_KEY_GEN))
|
||||
WOLFSSL_API int wc_Ed25519PublicKeyToDer(ed25519_key*, byte* output,
|
||||
word32 inLen, int with_AlgCurve);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* DER encode signature */
|
||||
WOLFSSL_API word32 wc_EncodeSignature(byte* out, const byte* digest,
|
||||
word32 digSz, int hashOID);
|
||||
WOLFSSL_API int wc_GetCTC_HashOID(int type);
|
||||
|
||||
WOLFSSL_API int wc_GetPkcs8TraditionalOffset(byte* input,
|
||||
word32* inOutIdx, word32 sz);
|
||||
WOLFSSL_API int wc_CreatePKCS8Key(byte* out, word32* outSz,
|
||||
byte* key, word32 keySz, int algoID, const byte* curveOID, word32 oidSz);
|
||||
|
||||
#ifndef NO_ASN_TIME
|
||||
/* Time */
|
||||
/* Returns seconds (Epoch/UTC)
|
||||
* timePtr: is "time_t", which is typically "long"
|
||||
* Example:
|
||||
long lTime;
|
||||
rc = wc_GetTime(&lTime, (word32)sizeof(lTime));
|
||||
*/
|
||||
WOLFSSL_API int wc_GetTime(void* timePtr, word32 timeSize);
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_ENCRYPTED_KEYS
|
||||
WOLFSSL_API int wc_EncryptedInfoGet(EncryptedInfo* info,
|
||||
const char* cipherInfo);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef WOLFSSL_CERT_PIV
|
||||
|
||||
typedef struct _wc_CertPIV {
|
||||
const byte* cert;
|
||||
word32 certSz;
|
||||
const byte* certErrDet;
|
||||
word32 certErrDetSz;
|
||||
const byte* nonce; /* Identiv Only */
|
||||
word32 nonceSz; /* Identiv Only */
|
||||
const byte* signedNonce; /* Identiv Only */
|
||||
word32 signedNonceSz; /* Identiv Only */
|
||||
|
||||
/* flags */
|
||||
word16 compression:2;
|
||||
word16 isX509:1;
|
||||
word16 isIdentiv:1;
|
||||
} wc_CertPIV;
|
||||
|
||||
WOLFSSL_API int wc_ParseCertPIV(wc_CertPIV* cert, const byte* buf, word32 totalSz);
|
||||
#endif /* WOLFSSL_CERT_PIV */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* WOLF_CRYPT_ASN_PUBLIC_H */
|
||||
|
139
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/wolfcrypt/des3.h
Normal file
139
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/wolfcrypt/des3.h
Normal file
@ -0,0 +1,139 @@
|
||||
/* des3.h
|
||||
*
|
||||
* Copyright (C) 2006-2018 wolfSSL Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is distributed in binary form as licensed by Espressif Systems.
|
||||
* See README file or contact licensing@wolfssl.com with any questions or comments.
|
||||
*
|
||||
* https://www.wolfssl.com
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/des3.h
|
||||
*/
|
||||
|
||||
#ifndef WOLF_CRYPT_DES3_H
|
||||
#define WOLF_CRYPT_DES3_H
|
||||
|
||||
#include <wolfssl/wolfcrypt/types.h>
|
||||
|
||||
#ifndef NO_DES3
|
||||
|
||||
#if defined(HAVE_FIPS) && \
|
||||
defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)
|
||||
#include <wolfssl/wolfcrypt/fips.h>
|
||||
#endif /* HAVE_FIPS_VERSION >= 2 */
|
||||
|
||||
#if defined(HAVE_FIPS) && \
|
||||
(!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2))
|
||||
/* included for fips @wc_fips */
|
||||
#include <cyassl/ctaocrypt/des3.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* these are required for FIPS and non-FIPS */
|
||||
enum {
|
||||
DES_KEY_SIZE = 8, /* des */
|
||||
DES3_KEY_SIZE = 24, /* 3 des ede */
|
||||
DES_IV_SIZE = 8, /* should be the same as DES_BLOCK_SIZE */
|
||||
};
|
||||
|
||||
|
||||
/* avoid redefinition of structs */
|
||||
#if !defined(HAVE_FIPS) || \
|
||||
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2))
|
||||
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
#include <wolfssl/wolfcrypt/async.h>
|
||||
#endif
|
||||
|
||||
enum {
|
||||
DES_ENC_TYPE = WC_CIPHER_DES, /* cipher unique type */
|
||||
DES3_ENC_TYPE = WC_CIPHER_DES3, /* cipher unique type */
|
||||
|
||||
DES_BLOCK_SIZE = 8,
|
||||
DES_KS_SIZE = 32, /* internal DES key buffer size */
|
||||
|
||||
DES_ENCRYPTION = 0,
|
||||
DES_DECRYPTION = 1
|
||||
};
|
||||
|
||||
#define DES_IVLEN 8
|
||||
#define DES_KEYLEN 8
|
||||
#define DES3_IVLEN 8
|
||||
#define DES3_KEYLEN 24
|
||||
|
||||
|
||||
#if defined(STM32_CRYPTO)
|
||||
enum {
|
||||
DES_CBC = 0,
|
||||
DES_ECB = 1
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
/* DES encryption and decryption */
|
||||
typedef struct Des {
|
||||
word32 reg[DES_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
|
||||
word32 tmp[DES_BLOCK_SIZE / sizeof(word32)]; /* same */
|
||||
word32 key[DES_KS_SIZE];
|
||||
} Des;
|
||||
|
||||
|
||||
/* DES3 encryption and decryption */
|
||||
typedef struct Des3 {
|
||||
word32 key[3][DES_KS_SIZE];
|
||||
word32 reg[DES_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
|
||||
word32 tmp[DES_BLOCK_SIZE / sizeof(word32)]; /* same */
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
const byte* key_raw;
|
||||
const byte* iv_raw;
|
||||
WC_ASYNC_DEV asyncDev;
|
||||
#endif
|
||||
void* heap;
|
||||
} Des3;
|
||||
#endif /* HAVE_FIPS */
|
||||
|
||||
|
||||
WOLFSSL_API int wc_Des_SetKey(Des* des, const byte* key,
|
||||
const byte* iv, int dir);
|
||||
WOLFSSL_API void wc_Des_SetIV(Des* des, const byte* iv);
|
||||
WOLFSSL_API int wc_Des_CbcEncrypt(Des* des, byte* out,
|
||||
const byte* in, word32 sz);
|
||||
WOLFSSL_API int wc_Des_CbcDecrypt(Des* des, byte* out,
|
||||
const byte* in, word32 sz);
|
||||
WOLFSSL_API int wc_Des_EcbEncrypt(Des* des, byte* out,
|
||||
const byte* in, word32 sz);
|
||||
WOLFSSL_API int wc_Des3_EcbEncrypt(Des3* des, byte* out,
|
||||
const byte* in, word32 sz);
|
||||
|
||||
/* ECB decrypt same process as encrypt but with decrypt key */
|
||||
#define wc_Des_EcbDecrypt wc_Des_EcbEncrypt
|
||||
#define wc_Des3_EcbDecrypt wc_Des3_EcbEncrypt
|
||||
|
||||
WOLFSSL_API int wc_Des3_SetKey(Des3* des, const byte* key,
|
||||
const byte* iv,int dir);
|
||||
WOLFSSL_API int wc_Des3_SetIV(Des3* des, const byte* iv);
|
||||
WOLFSSL_API int wc_Des3_CbcEncrypt(Des3* des, byte* out,
|
||||
const byte* in,word32 sz);
|
||||
WOLFSSL_API int wc_Des3_CbcDecrypt(Des3* des, byte* out,
|
||||
const byte* in,word32 sz);
|
||||
|
||||
/* These are only required when using either:
|
||||
static memory (WOLFSSL_STATIC_MEMORY) or asynchronous (WOLFSSL_ASYNC_CRYPT) */
|
||||
WOLFSSL_API int wc_Des3Init(Des3*, void*, int);
|
||||
WOLFSSL_API void wc_Des3Free(Des3*);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* NO_DES3 */
|
||||
#endif /* WOLF_CRYPT_DES3_H */
|
||||
|
686
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/wolfcrypt/ecc.h
Normal file
686
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/wolfcrypt/ecc.h
Normal file
@ -0,0 +1,686 @@
|
||||
/* ecc.h
|
||||
*
|
||||
* Copyright (C) 2006-2018 wolfSSL Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is distributed in binary form as licensed by Espressif Systems.
|
||||
* See README file or contact licensing@wolfssl.com with any questions or comments.
|
||||
*
|
||||
* https://www.wolfssl.com
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/ecc.h
|
||||
*/
|
||||
|
||||
|
||||
#ifndef WOLF_CRYPT_ECC_H
|
||||
#define WOLF_CRYPT_ECC_H
|
||||
|
||||
#include <wolfssl/wolfcrypt/types.h>
|
||||
|
||||
#ifdef HAVE_ECC
|
||||
|
||||
#if defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)
|
||||
#include <wolfssl/wolfcrypt/fips.h>
|
||||
#endif /* HAVE_FIPS_VERSION >= 2 */
|
||||
|
||||
#include <wolfssl/wolfcrypt/integer.h>
|
||||
#include <wolfssl/wolfcrypt/random.h>
|
||||
|
||||
#ifdef HAVE_X963_KDF
|
||||
#include <wolfssl/wolfcrypt/hash.h>
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
#include <wolfssl/wolfcrypt/async.h>
|
||||
#ifdef WOLFSSL_CERT_GEN
|
||||
#include <wolfssl/wolfcrypt/asn.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_ATECC508A
|
||||
#include <wolfssl/wolfcrypt/port/atmel/atmel.h>
|
||||
#endif /* WOLFSSL_ATECC508A */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Enable curve B parameter if needed */
|
||||
#if defined(HAVE_COMP_KEY) || defined(ECC_CACHE_CURVE)
|
||||
#ifndef USE_ECC_B_PARAM /* Allow someone to force enable */
|
||||
#define USE_ECC_B_PARAM
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* Use this as the key->idx if a custom ecc_set is used for key->dp */
|
||||
#define ECC_CUSTOM_IDX (-1)
|
||||
|
||||
|
||||
/* Determine max ECC bits based on enabled curves */
|
||||
#if defined(HAVE_ECC521) || defined(HAVE_ALL_CURVES)
|
||||
#define MAX_ECC_BITS 521
|
||||
#elif defined(HAVE_ECC512)
|
||||
#define MAX_ECC_BITS 512
|
||||
#elif defined(HAVE_ECC384)
|
||||
#define MAX_ECC_BITS 384
|
||||
#elif defined(HAVE_ECC320)
|
||||
#define MAX_ECC_BITS 320
|
||||
#elif !defined(NO_ECC256)
|
||||
#define MAX_ECC_BITS 256
|
||||
#elif defined(HAVE_ECC239)
|
||||
#define MAX_ECC_BITS 239
|
||||
#elif defined(HAVE_ECC224)
|
||||
#define MAX_ECC_BITS 224
|
||||
#elif defined(HAVE_ECC192)
|
||||
#define MAX_ECC_BITS 192
|
||||
#elif defined(HAVE_ECC160)
|
||||
#define MAX_ECC_BITS 160
|
||||
#elif defined(HAVE_ECC128)
|
||||
#define MAX_ECC_BITS 128
|
||||
#elif defined(HAVE_ECC112)
|
||||
#define MAX_ECC_BITS 112
|
||||
#endif
|
||||
|
||||
/* calculate max ECC bytes */
|
||||
#if ((MAX_ECC_BITS * 2) % 8) == 0
|
||||
#define MAX_ECC_BYTES (MAX_ECC_BITS / 8)
|
||||
#else
|
||||
/* add byte if not aligned */
|
||||
#define MAX_ECC_BYTES ((MAX_ECC_BITS / 8) + 1)
|
||||
#endif
|
||||
|
||||
|
||||
enum {
|
||||
ECC_PUBLICKEY = 1,
|
||||
ECC_PRIVATEKEY = 2,
|
||||
ECC_PRIVATEKEY_ONLY = 3,
|
||||
ECC_MAXNAME = 16, /* MAX CURVE NAME LENGTH */
|
||||
SIG_HEADER_SZ = 6, /* ECC signature header size */
|
||||
ECC_BUFSIZE = 256, /* for exported keys temp buffer */
|
||||
ECC_MINSIZE = 20, /* MIN Private Key size */
|
||||
ECC_MAXSIZE = 66, /* MAX Private Key size */
|
||||
ECC_MAXSIZE_GEN = 74, /* MAX Buffer size required when generating ECC keys*/
|
||||
ECC_MAX_PAD_SZ = 4, /* ECC maximum padding size */
|
||||
ECC_MAX_OID_LEN = 16,
|
||||
ECC_MAX_SIG_SIZE= ((MAX_ECC_BYTES * 2) + ECC_MAX_PAD_SZ + SIG_HEADER_SZ),
|
||||
|
||||
/* max crypto hardware size */
|
||||
#ifdef WOLFSSL_ATECC508A
|
||||
ECC_MAX_CRYPTO_HW_SIZE = ATECC_KEY_SIZE, /* from port/atmel/atmel.h */
|
||||
ECC_MAX_CRYPTO_HW_PUBKEY_SIZE = (ATECC_KEY_SIZE*2),
|
||||
#elif defined(PLUTON_CRYPTO_ECC)
|
||||
ECC_MAX_CRYPTO_HW_SIZE = 32,
|
||||
#endif
|
||||
|
||||
/* point compression type */
|
||||
ECC_POINT_COMP_EVEN = 0x02,
|
||||
ECC_POINT_COMP_ODD = 0x03,
|
||||
ECC_POINT_UNCOMP = 0x04,
|
||||
|
||||
/* Shamir's dual add constants */
|
||||
SHAMIR_PRECOMP_SZ = 16,
|
||||
|
||||
#ifdef HAVE_PKCS11
|
||||
ECC_MAX_ID_LEN = 32,
|
||||
#endif
|
||||
};
|
||||
|
||||
/* Curve Types */
|
||||
typedef enum ecc_curve_id {
|
||||
ECC_CURVE_INVALID = -1,
|
||||
ECC_CURVE_DEF = 0, /* NIST or SECP */
|
||||
|
||||
/* NIST Prime Curves */
|
||||
ECC_SECP192R1,
|
||||
ECC_PRIME192V2,
|
||||
ECC_PRIME192V3,
|
||||
ECC_PRIME239V1,
|
||||
ECC_PRIME239V2,
|
||||
ECC_PRIME239V3,
|
||||
ECC_SECP256R1,
|
||||
|
||||
/* SECP Curves */
|
||||
ECC_SECP112R1,
|
||||
ECC_SECP112R2,
|
||||
ECC_SECP128R1,
|
||||
ECC_SECP128R2,
|
||||
ECC_SECP160R1,
|
||||
ECC_SECP160R2,
|
||||
ECC_SECP224R1,
|
||||
ECC_SECP384R1,
|
||||
ECC_SECP521R1,
|
||||
|
||||
/* Koblitz */
|
||||
ECC_SECP160K1,
|
||||
ECC_SECP192K1,
|
||||
ECC_SECP224K1,
|
||||
ECC_SECP256K1,
|
||||
|
||||
/* Brainpool Curves */
|
||||
ECC_BRAINPOOLP160R1,
|
||||
ECC_BRAINPOOLP192R1,
|
||||
ECC_BRAINPOOLP224R1,
|
||||
ECC_BRAINPOOLP256R1,
|
||||
ECC_BRAINPOOLP320R1,
|
||||
ECC_BRAINPOOLP384R1,
|
||||
ECC_BRAINPOOLP512R1,
|
||||
|
||||
/* Twisted Edwards Curves */
|
||||
#ifdef HAVE_CURVE25519
|
||||
ECC_X25519,
|
||||
#endif
|
||||
#ifdef HAVE_X448
|
||||
ECC_X448,
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_CUSTOM_CURVES
|
||||
ECC_CURVE_CUSTOM,
|
||||
#endif
|
||||
} ecc_curve_id;
|
||||
|
||||
#ifdef HAVE_OID_ENCODING
|
||||
typedef word16 ecc_oid_t;
|
||||
#else
|
||||
typedef byte ecc_oid_t;
|
||||
/* OID encoded with ASN scheme:
|
||||
first element = (oid[0] * 40) + oid[1]
|
||||
if any element > 127 then MSB 0x80 indicates additional byte */
|
||||
#endif
|
||||
|
||||
/* ECC set type defined a GF(p) curve */
|
||||
#ifndef USE_WINDOWS_API
|
||||
typedef struct ecc_set_type {
|
||||
int size; /* The size of the curve in octets */
|
||||
int id; /* id of this curve */
|
||||
const char* name; /* name of this curve */
|
||||
const char* prime; /* prime that defines the field, curve is in (hex) */
|
||||
const char* Af; /* fields A param (hex) */
|
||||
const char* Bf; /* fields B param (hex) */
|
||||
const char* order; /* order of the curve (hex) */
|
||||
const char* Gx; /* x coordinate of the base point on curve (hex) */
|
||||
const char* Gy; /* y coordinate of the base point on curve (hex) */
|
||||
const ecc_oid_t* oid;
|
||||
word32 oidSz;
|
||||
word32 oidSum; /* sum of encoded OID bytes */
|
||||
int cofactor;
|
||||
} ecc_set_type;
|
||||
#else
|
||||
/* MSC does something different with the pointers to the arrays than GCC,
|
||||
* and it causes the FIPS checksum to fail. In the case of windows builds,
|
||||
* store everything as arrays instead of pointers to strings. */
|
||||
|
||||
#define MAX_ECC_NAME 16
|
||||
#define MAX_ECC_STRING ((MAX_ECC_BYTES * 2) + 1)
|
||||
/* The values are stored as text strings. */
|
||||
|
||||
typedef struct ecc_set_type {
|
||||
int size; /* The size of the curve in octets */
|
||||
int id; /* id of this curve */
|
||||
const char name[MAX_ECC_NAME]; /* name of this curve */
|
||||
const char prime[MAX_ECC_STRING]; /* prime that defines the field, curve is in (hex) */
|
||||
const char Af[MAX_ECC_STRING]; /* fields A param (hex) */
|
||||
const char Bf[MAX_ECC_STRING]; /* fields B param (hex) */
|
||||
const char order[MAX_ECC_STRING]; /* order of the curve (hex) */
|
||||
const char Gx[MAX_ECC_STRING]; /* x coordinate of the base point on curve (hex) */
|
||||
const char Gy[MAX_ECC_STRING]; /* y coordinate of the base point on curve (hex) */
|
||||
const ecc_oid_t oid[10];
|
||||
word32 oidSz;
|
||||
word32 oidSum; /* sum of encoded OID bytes */
|
||||
int cofactor;
|
||||
} ecc_set_type;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef ALT_ECC_SIZE
|
||||
|
||||
/* Note on ALT_ECC_SIZE:
|
||||
* The fast math code uses an array of a fixed size to store the big integers.
|
||||
* By default, the array is big enough for RSA keys. There is a size,
|
||||
* FP_MAX_BITS which can be used to make the array smaller when one wants ECC
|
||||
* but not RSA. Some people want fast math sized for both RSA and ECC, where
|
||||
* ECC won't use as much as RSA. The flag ALT_ECC_SIZE switches in an alternate
|
||||
* ecc_point structure that uses an alternate fp_int that has a shorter array
|
||||
* of fp_digits.
|
||||
*
|
||||
* Now, without ALT_ECC_SIZE, the ecc_point has three single item arrays of
|
||||
* mp_ints for the components of the point. With ALT_ECC_SIZE, the components
|
||||
* of the point are pointers that are set to each of a three item array of
|
||||
* alt_fp_ints. While an mp_int will have 4096 bits of digit inside the
|
||||
* structure, the alt_fp_int will only have 528 bits. A size value was added
|
||||
* in the ALT case, as well, and is set by mp_init() and alt_fp_init(). The
|
||||
* functions fp_zero() and fp_copy() use the size parameter. An int needs to
|
||||
* be initialized before using it instead of just fp_zeroing it, the init will
|
||||
* call zero. FP_MAX_BITS_ECC defaults to 528, but can be set to change the
|
||||
* number of bits used in the alternate FP_INT.
|
||||
*
|
||||
* Do not enable ALT_ECC_SIZE and disable fast math in the configuration.
|
||||
*/
|
||||
|
||||
#ifndef USE_FAST_MATH
|
||||
#error USE_FAST_MATH must be defined to use ALT_ECC_SIZE
|
||||
#endif
|
||||
|
||||
/* determine max bits required for ECC math */
|
||||
#ifndef FP_MAX_BITS_ECC
|
||||
/* check alignment */
|
||||
#if ((MAX_ECC_BITS * 2) % DIGIT_BIT) == 0
|
||||
/* max bits is double */
|
||||
#define FP_MAX_BITS_ECC (MAX_ECC_BITS * 2)
|
||||
#else
|
||||
/* max bits is doubled, plus one digit of fudge */
|
||||
#define FP_MAX_BITS_ECC ((MAX_ECC_BITS * 2) + DIGIT_BIT)
|
||||
#endif
|
||||
#else
|
||||
/* verify alignment */
|
||||
#if FP_MAX_BITS_ECC % CHAR_BIT
|
||||
#error FP_MAX_BITS_ECC must be a multiple of CHAR_BIT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* determine buffer size */
|
||||
#define FP_SIZE_ECC (FP_MAX_BITS_ECC/DIGIT_BIT)
|
||||
|
||||
|
||||
/* This needs to match the size of the fp_int struct, except the
|
||||
* fp_digit array will be shorter. */
|
||||
typedef struct alt_fp_int {
|
||||
int used, sign, size;
|
||||
mp_digit dp[FP_SIZE_ECC];
|
||||
} alt_fp_int;
|
||||
#endif /* ALT_ECC_SIZE */
|
||||
|
||||
#ifndef WC_ECCKEY_TYPE_DEFINED
|
||||
typedef struct ecc_key ecc_key;
|
||||
#define WC_ECCKEY_TYPE_DEFINED
|
||||
#endif
|
||||
|
||||
|
||||
/* A point on an ECC curve, stored in Jacbobian format such that (x,y,z) =>
|
||||
(x/z^2, y/z^3, 1) when interpreted as affine */
|
||||
typedef struct {
|
||||
#ifndef ALT_ECC_SIZE
|
||||
mp_int x[1]; /* The x coordinate */
|
||||
mp_int y[1]; /* The y coordinate */
|
||||
mp_int z[1]; /* The z coordinate */
|
||||
#else
|
||||
mp_int* x; /* The x coordinate */
|
||||
mp_int* y; /* The y coordinate */
|
||||
mp_int* z; /* The z coordinate */
|
||||
alt_fp_int xyz[3];
|
||||
#endif
|
||||
#ifdef WOLFSSL_SMALL_STACK_CACHE
|
||||
ecc_key* key;
|
||||
#endif
|
||||
} ecc_point;
|
||||
|
||||
/* ECC Flags */
|
||||
enum {
|
||||
WC_ECC_FLAG_NONE = 0x00,
|
||||
#ifdef HAVE_ECC_CDH
|
||||
WC_ECC_FLAG_COFACTOR = 0x01,
|
||||
#endif
|
||||
};
|
||||
|
||||
/* An ECC Key */
|
||||
struct ecc_key {
|
||||
int type; /* Public or Private */
|
||||
int idx; /* Index into the ecc_sets[] for the parameters of
|
||||
this curve if -1, this key is using user supplied
|
||||
curve in dp */
|
||||
int state;
|
||||
word32 flags;
|
||||
const ecc_set_type* dp; /* domain parameters, either points to NIST
|
||||
curves (idx >= 0) or user supplied */
|
||||
#ifdef WOLFSSL_CUSTOM_CURVES
|
||||
int deallocSet;
|
||||
#endif
|
||||
void* heap; /* heap hint */
|
||||
ecc_point pubkey; /* public key */
|
||||
mp_int k; /* private key */
|
||||
#ifdef WOLFSSL_ATECC508A
|
||||
int slot; /* Key Slot Number (-1 unknown) */
|
||||
byte pubkey_raw[ECC_MAX_CRYPTO_HW_PUBKEY_SIZE];
|
||||
#endif
|
||||
#if defined(PLUTON_CRYPTO_ECC) || defined(WOLF_CRYPTO_DEV)
|
||||
int devId;
|
||||
#endif
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
mp_int* r; /* sign/verify temps */
|
||||
mp_int* s;
|
||||
WC_ASYNC_DEV asyncDev;
|
||||
#ifdef HAVE_CAVIUM_V
|
||||
mp_int* e; /* Sign, Verify and Shared Secret */
|
||||
mp_int* signK;
|
||||
#endif
|
||||
#ifdef WOLFSSL_CERT_GEN
|
||||
CertSignCtx certSignCtx; /* context info for cert sign (MakeSignature) */
|
||||
#endif
|
||||
#endif /* WOLFSSL_ASYNC_CRYPT */
|
||||
#ifdef HAVE_PKCS11
|
||||
byte id[ECC_MAX_ID_LEN];
|
||||
int idLen;
|
||||
#endif
|
||||
#ifdef WOLFSSL_SMALL_STACK_CACHE
|
||||
mp_int* t1;
|
||||
mp_int* t2;
|
||||
#ifdef ALT_ECC_SIZE
|
||||
mp_int* x;
|
||||
mp_int* y;
|
||||
mp_int* z;
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
/* ECC predefined curve sets */
|
||||
extern const ecc_set_type ecc_sets[];
|
||||
|
||||
WOLFSSL_API
|
||||
const char* wc_ecc_get_name(int curve_id);
|
||||
|
||||
#ifndef WOLFSSL_ATECC508A
|
||||
|
||||
#ifdef WOLFSSL_PUBLIC_ECC_ADD_DBL
|
||||
#define ECC_API WOLFSSL_API
|
||||
#else
|
||||
#define ECC_API WOLFSSL_LOCAL
|
||||
#endif
|
||||
|
||||
ECC_API int ecc_mul2add(ecc_point* A, mp_int* kA,
|
||||
ecc_point* B, mp_int* kB,
|
||||
ecc_point* C, mp_int* a, mp_int* modulus, void* heap);
|
||||
|
||||
ECC_API int ecc_map(ecc_point*, mp_int*, mp_digit);
|
||||
ECC_API int ecc_projective_add_point(ecc_point* P, ecc_point* Q, ecc_point* R,
|
||||
mp_int* a, mp_int* modulus, mp_digit mp);
|
||||
ECC_API int ecc_projective_dbl_point(ecc_point* P, ecc_point* R, mp_int* a,
|
||||
mp_int* modulus, mp_digit mp);
|
||||
|
||||
#endif
|
||||
|
||||
WOLFSSL_API
|
||||
int wc_ecc_make_key(WC_RNG* rng, int keysize, ecc_key* key);
|
||||
WOLFSSL_API
|
||||
int wc_ecc_make_key_ex(WC_RNG* rng, int keysize, ecc_key* key,
|
||||
int curve_id);
|
||||
WOLFSSL_API
|
||||
int wc_ecc_make_pub(ecc_key* key, ecc_point* pubOut);
|
||||
WOLFSSL_API
|
||||
int wc_ecc_check_key(ecc_key* key);
|
||||
WOLFSSL_API
|
||||
int wc_ecc_is_point(ecc_point* ecp, mp_int* a, mp_int* b, mp_int* prime);
|
||||
|
||||
#ifdef HAVE_ECC_DHE
|
||||
WOLFSSL_API
|
||||
int wc_ecc_shared_secret(ecc_key* private_key, ecc_key* public_key, byte* out,
|
||||
word32* outlen);
|
||||
WOLFSSL_LOCAL
|
||||
int wc_ecc_shared_secret_gen(ecc_key* private_key, ecc_point* point,
|
||||
byte* out, word32 *outlen);
|
||||
WOLFSSL_API
|
||||
int wc_ecc_shared_secret_ex(ecc_key* private_key, ecc_point* point,
|
||||
byte* out, word32 *outlen);
|
||||
#define wc_ecc_shared_secret_ssh wc_ecc_shared_secret_ex /* For backwards compat */
|
||||
#endif /* HAVE_ECC_DHE */
|
||||
|
||||
#ifdef HAVE_ECC_SIGN
|
||||
WOLFSSL_API
|
||||
int wc_ecc_sign_hash(const byte* in, word32 inlen, byte* out, word32 *outlen,
|
||||
WC_RNG* rng, ecc_key* key);
|
||||
WOLFSSL_API
|
||||
int wc_ecc_sign_hash_ex(const byte* in, word32 inlen, WC_RNG* rng,
|
||||
ecc_key* key, mp_int *r, mp_int *s);
|
||||
#endif /* HAVE_ECC_SIGN */
|
||||
|
||||
#ifdef HAVE_ECC_VERIFY
|
||||
WOLFSSL_API
|
||||
int wc_ecc_verify_hash(const byte* sig, word32 siglen, const byte* hash,
|
||||
word32 hashlen, int* stat, ecc_key* key);
|
||||
WOLFSSL_API
|
||||
int wc_ecc_verify_hash_ex(mp_int *r, mp_int *s, const byte* hash,
|
||||
word32 hashlen, int* stat, ecc_key* key);
|
||||
#endif /* HAVE_ECC_VERIFY */
|
||||
|
||||
WOLFSSL_API
|
||||
int wc_ecc_init(ecc_key* key);
|
||||
WOLFSSL_API
|
||||
int wc_ecc_init_ex(ecc_key* key, void* heap, int devId);
|
||||
#ifdef HAVE_PKCS11
|
||||
WOLFSSL_API
|
||||
int wc_ecc_init_id(ecc_key* key, unsigned char* id, int len, void* heap,
|
||||
int devId);
|
||||
#endif
|
||||
#ifdef WOLFSSL_CUSTOM_CURVES
|
||||
WOLFSSL_LOCAL
|
||||
void wc_ecc_free_curve(const ecc_set_type* curve, void* heap);
|
||||
#endif
|
||||
WOLFSSL_API
|
||||
int wc_ecc_free(ecc_key* key);
|
||||
WOLFSSL_API
|
||||
int wc_ecc_set_flags(ecc_key* key, word32 flags);
|
||||
WOLFSSL_API
|
||||
void wc_ecc_fp_free(void);
|
||||
|
||||
WOLFSSL_API
|
||||
int wc_ecc_set_curve(ecc_key* key, int keysize, int curve_id);
|
||||
|
||||
WOLFSSL_API
|
||||
int wc_ecc_is_valid_idx(int n);
|
||||
WOLFSSL_API
|
||||
int wc_ecc_get_curve_idx(int curve_id);
|
||||
WOLFSSL_API
|
||||
int wc_ecc_get_curve_id(int curve_idx);
|
||||
#define wc_ecc_get_curve_name_from_id wc_ecc_get_name
|
||||
WOLFSSL_API
|
||||
int wc_ecc_get_curve_size_from_id(int curve_id);
|
||||
|
||||
WOLFSSL_API
|
||||
int wc_ecc_get_curve_idx_from_name(const char* curveName);
|
||||
WOLFSSL_API
|
||||
int wc_ecc_get_curve_size_from_name(const char* curveName);
|
||||
WOLFSSL_API
|
||||
int wc_ecc_get_curve_id_from_name(const char* curveName);
|
||||
WOLFSSL_API
|
||||
int wc_ecc_get_curve_id_from_params(int fieldSize,
|
||||
const byte* prime, word32 primeSz, const byte* Af, word32 AfSz,
|
||||
const byte* Bf, word32 BfSz, const byte* order, word32 orderSz,
|
||||
const byte* Gx, word32 GxSz, const byte* Gy, word32 GySz, int cofactor);
|
||||
|
||||
WOLFSSL_API
|
||||
int wc_ecc_get_curve_id_from_oid(const byte* oid, word32 len);
|
||||
|
||||
WOLFSSL_API
|
||||
ecc_point* wc_ecc_new_point(void);
|
||||
WOLFSSL_API
|
||||
ecc_point* wc_ecc_new_point_h(void* h);
|
||||
WOLFSSL_API
|
||||
void wc_ecc_del_point(ecc_point* p);
|
||||
WOLFSSL_API
|
||||
void wc_ecc_del_point_h(ecc_point* p, void* h);
|
||||
WOLFSSL_API
|
||||
int wc_ecc_copy_point(ecc_point* p, ecc_point *r);
|
||||
WOLFSSL_API
|
||||
int wc_ecc_cmp_point(ecc_point* a, ecc_point *b);
|
||||
WOLFSSL_API
|
||||
int wc_ecc_point_is_at_infinity(ecc_point *p);
|
||||
|
||||
#ifndef WOLFSSL_ATECC508A
|
||||
WOLFSSL_API
|
||||
int wc_ecc_mulmod(mp_int* k, ecc_point *G, ecc_point *R,
|
||||
mp_int* a, mp_int* modulus, int map);
|
||||
WOLFSSL_LOCAL
|
||||
int wc_ecc_mulmod_ex(mp_int* k, ecc_point *G, ecc_point *R,
|
||||
mp_int* a, mp_int* modulus, int map, void* heap);
|
||||
#endif /* !WOLFSSL_ATECC508A */
|
||||
|
||||
|
||||
#ifdef HAVE_ECC_KEY_EXPORT
|
||||
/* ASN key helpers */
|
||||
WOLFSSL_API
|
||||
int wc_ecc_export_x963(ecc_key*, byte* out, word32* outLen);
|
||||
WOLFSSL_API
|
||||
int wc_ecc_export_x963_ex(ecc_key*, byte* out, word32* outLen, int compressed);
|
||||
/* extended functionality with compressed option */
|
||||
#endif /* HAVE_ECC_KEY_EXPORT */
|
||||
|
||||
#ifdef HAVE_ECC_KEY_IMPORT
|
||||
WOLFSSL_API
|
||||
int wc_ecc_import_x963(const byte* in, word32 inLen, ecc_key* key);
|
||||
WOLFSSL_API
|
||||
int wc_ecc_import_x963_ex(const byte* in, word32 inLen, ecc_key* key,
|
||||
int curve_id);
|
||||
WOLFSSL_API
|
||||
int wc_ecc_import_private_key(const byte* priv, word32 privSz, const byte* pub,
|
||||
word32 pubSz, ecc_key* key);
|
||||
WOLFSSL_API
|
||||
int wc_ecc_import_private_key_ex(const byte* priv, word32 privSz,
|
||||
const byte* pub, word32 pubSz, ecc_key* key, int curve_id);
|
||||
WOLFSSL_API
|
||||
int wc_ecc_rs_to_sig(const char* r, const char* s, byte* out, word32* outlen);
|
||||
WOLFSSL_API
|
||||
int wc_ecc_rs_raw_to_sig(const byte* r, word32 rSz, const byte* s, word32 sSz,
|
||||
byte* out, word32* outlen);
|
||||
WOLFSSL_API
|
||||
int wc_ecc_sig_to_rs(const byte* sig, word32 sigLen, byte* r, word32* rLen,
|
||||
byte* s, word32* sLen);
|
||||
WOLFSSL_API
|
||||
int wc_ecc_import_raw(ecc_key* key, const char* qx, const char* qy,
|
||||
const char* d, const char* curveName);
|
||||
WOLFSSL_API
|
||||
int wc_ecc_import_raw_ex(ecc_key* key, const char* qx, const char* qy,
|
||||
const char* d, int curve_id);
|
||||
WOLFSSL_API
|
||||
int wc_ecc_import_unsigned(ecc_key* key, byte* qx, byte* qy,
|
||||
byte* d, int curve_id);
|
||||
#endif /* HAVE_ECC_KEY_IMPORT */
|
||||
|
||||
#ifdef HAVE_ECC_KEY_EXPORT
|
||||
WOLFSSL_API
|
||||
int wc_ecc_export_ex(ecc_key* key, byte* qx, word32* qxLen,
|
||||
byte* qy, word32* qyLen, byte* d, word32* dLen,
|
||||
int encType);
|
||||
WOLFSSL_API
|
||||
int wc_ecc_export_private_only(ecc_key* key, byte* out, word32* outLen);
|
||||
WOLFSSL_API
|
||||
int wc_ecc_export_public_raw(ecc_key* key, byte* qx, word32* qxLen,
|
||||
byte* qy, word32* qyLen);
|
||||
WOLFSSL_API
|
||||
int wc_ecc_export_private_raw(ecc_key* key, byte* qx, word32* qxLen,
|
||||
byte* qy, word32* qyLen, byte* d, word32* dLen);
|
||||
#endif /* HAVE_ECC_KEY_EXPORT */
|
||||
|
||||
#ifdef HAVE_ECC_KEY_EXPORT
|
||||
|
||||
WOLFSSL_API
|
||||
int wc_ecc_export_point_der(const int curve_idx, ecc_point* point,
|
||||
byte* out, word32* outLen);
|
||||
#endif /* HAVE_ECC_KEY_EXPORT */
|
||||
|
||||
|
||||
#ifdef HAVE_ECC_KEY_IMPORT
|
||||
WOLFSSL_API
|
||||
int wc_ecc_import_point_der(byte* in, word32 inLen, const int curve_idx,
|
||||
ecc_point* point);
|
||||
#endif /* HAVE_ECC_KEY_IMPORT */
|
||||
|
||||
/* size helper */
|
||||
WOLFSSL_API
|
||||
int wc_ecc_size(ecc_key* key);
|
||||
WOLFSSL_API
|
||||
int wc_ecc_sig_size_calc(int sz);
|
||||
WOLFSSL_API
|
||||
int wc_ecc_sig_size(ecc_key* key);
|
||||
|
||||
WOLFSSL_API
|
||||
int wc_ecc_get_oid(word32 oidSum, const byte** oid, word32* oidSz);
|
||||
|
||||
#ifdef WOLFSSL_CUSTOM_CURVES
|
||||
WOLFSSL_API
|
||||
int wc_ecc_set_custom_curve(ecc_key* key, const ecc_set_type* dp);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ECC_ENCRYPT
|
||||
/* ecc encrypt */
|
||||
|
||||
enum ecEncAlgo {
|
||||
ecAES_128_CBC = 1, /* default */
|
||||
ecAES_256_CBC = 2
|
||||
};
|
||||
|
||||
enum ecKdfAlgo {
|
||||
ecHKDF_SHA256 = 1, /* default */
|
||||
ecHKDF_SHA1 = 2
|
||||
};
|
||||
|
||||
enum ecMacAlgo {
|
||||
ecHMAC_SHA256 = 1, /* default */
|
||||
ecHMAC_SHA1 = 2
|
||||
};
|
||||
|
||||
enum {
|
||||
KEY_SIZE_128 = 16,
|
||||
KEY_SIZE_256 = 32,
|
||||
IV_SIZE_64 = 8,
|
||||
IV_SIZE_128 = 16,
|
||||
EXCHANGE_SALT_SZ = 16,
|
||||
EXCHANGE_INFO_SZ = 23
|
||||
};
|
||||
|
||||
enum ecFlags {
|
||||
REQ_RESP_CLIENT = 1,
|
||||
REQ_RESP_SERVER = 2
|
||||
};
|
||||
|
||||
|
||||
typedef struct ecEncCtx ecEncCtx;
|
||||
|
||||
WOLFSSL_API
|
||||
ecEncCtx* wc_ecc_ctx_new(int flags, WC_RNG* rng);
|
||||
WOLFSSL_API
|
||||
ecEncCtx* wc_ecc_ctx_new_ex(int flags, WC_RNG* rng, void* heap);
|
||||
WOLFSSL_API
|
||||
void wc_ecc_ctx_free(ecEncCtx*);
|
||||
WOLFSSL_API
|
||||
int wc_ecc_ctx_reset(ecEncCtx*, WC_RNG*); /* reset for use again w/o alloc/free */
|
||||
|
||||
WOLFSSL_API
|
||||
const byte* wc_ecc_ctx_get_own_salt(ecEncCtx*);
|
||||
WOLFSSL_API
|
||||
int wc_ecc_ctx_set_peer_salt(ecEncCtx*, const byte* salt);
|
||||
WOLFSSL_API
|
||||
int wc_ecc_ctx_set_info(ecEncCtx*, const byte* info, int sz);
|
||||
|
||||
WOLFSSL_API
|
||||
int wc_ecc_encrypt(ecc_key* privKey, ecc_key* pubKey, const byte* msg,
|
||||
word32 msgSz, byte* out, word32* outSz, ecEncCtx* ctx);
|
||||
WOLFSSL_API
|
||||
int wc_ecc_decrypt(ecc_key* privKey, ecc_key* pubKey, const byte* msg,
|
||||
word32 msgSz, byte* out, word32* outSz, ecEncCtx* ctx);
|
||||
|
||||
#endif /* HAVE_ECC_ENCRYPT */
|
||||
|
||||
#ifdef HAVE_X963_KDF
|
||||
WOLFSSL_API int wc_X963_KDF(enum wc_HashType type, const byte* secret,
|
||||
word32 secretSz, const byte* sinfo, word32 sinfoSz,
|
||||
byte* out, word32 outSz);
|
||||
#endif
|
||||
|
||||
#ifdef ECC_CACHE_CURVE
|
||||
WOLFSSL_API int wc_ecc_curve_cache_init(void);
|
||||
WOLFSSL_API void wc_ecc_curve_cache_free(void);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* HAVE_ECC */
|
||||
#endif /* WOLF_CRYPT_ECC_H */
|
165
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/wolfcrypt/hash.h
Normal file
165
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/wolfcrypt/hash.h
Normal file
@ -0,0 +1,165 @@
|
||||
/* hash.h
|
||||
*
|
||||
* Copyright (C) 2006-2018 wolfSSL Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is distributed in binary form as licensed by Espressif Systems.
|
||||
* See README file or contact licensing@wolfssl.com with any questions or comments.
|
||||
*
|
||||
* https://www.wolfssl.com
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/hash.h
|
||||
*/
|
||||
|
||||
#ifndef WOLF_CRYPT_HASH_H
|
||||
#define WOLF_CRYPT_HASH_H
|
||||
|
||||
#include <wolfssl/wolfcrypt/types.h>
|
||||
|
||||
#ifndef NO_MD5
|
||||
#include <wolfssl/wolfcrypt/md5.h>
|
||||
#endif
|
||||
#ifndef NO_SHA
|
||||
#include <wolfssl/wolfcrypt/sha.h>
|
||||
#endif
|
||||
#if defined(WOLFSSL_SHA224) || !defined(NO_SHA256)
|
||||
#include <wolfssl/wolfcrypt/sha256.h>
|
||||
#endif
|
||||
#if defined(WOLFSSL_SHA384) || defined(WOLFSSL_SHA512)
|
||||
#include <wolfssl/wolfcrypt/sha512.h>
|
||||
#endif
|
||||
#ifdef HAVE_BLAKE2
|
||||
#include <wolfssl/wolfcrypt/blake2.h>
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA3
|
||||
#include <wolfssl/wolfcrypt/sha3.h>
|
||||
#endif
|
||||
#ifndef NO_MD4
|
||||
#include <wolfssl/wolfcrypt/md4.h>
|
||||
#endif
|
||||
#ifdef WOLFSSL_MD2
|
||||
#include <wolfssl/wolfcrypt/md2.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_FIPS) && !defined(NO_OLD_WC_NAMES)
|
||||
#define MAX_DIGEST_SIZE WC_MAX_DIGEST_SIZE
|
||||
#endif
|
||||
|
||||
|
||||
typedef union {
|
||||
#ifndef NO_MD5
|
||||
wc_Md5 md5;
|
||||
#endif
|
||||
#ifndef NO_SHA
|
||||
wc_Sha sha;
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA224
|
||||
wc_Sha224 sha224;
|
||||
#endif
|
||||
#ifndef NO_SHA256
|
||||
wc_Sha256 sha256;
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA384
|
||||
wc_Sha384 sha384;
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA512
|
||||
wc_Sha512 sha512;
|
||||
#endif
|
||||
} wc_HashAlg;
|
||||
|
||||
/* Find largest possible digest size
|
||||
Note if this gets up to the size of 80 or over check smallstack build */
|
||||
#if defined(WOLFSSL_SHA3)
|
||||
#define WC_MAX_DIGEST_SIZE WC_SHA3_512_DIGEST_SIZE
|
||||
#define WC_MAX_BLOCK_SIZE WC_SHA3_224_BLOCK_SIZE /* 224 is the largest block size */
|
||||
#elif defined(WOLFSSL_SHA512)
|
||||
#define WC_MAX_DIGEST_SIZE WC_SHA512_DIGEST_SIZE
|
||||
#define WC_MAX_BLOCK_SIZE WC_SHA512_BLOCK_SIZE
|
||||
#elif defined(HAVE_BLAKE2)
|
||||
#define WC_MAX_DIGEST_SIZE BLAKE2B_OUTBYTES
|
||||
#define WC_MAX_BLOCK_SIZE BLAKE2B_BLOCKBYTES
|
||||
#elif defined(WOLFSSL_SHA384)
|
||||
#define WC_MAX_DIGEST_SIZE WC_SHA384_DIGEST_SIZE
|
||||
#define WC_MAX_BLOCK_SIZE WC_SHA384_BLOCK_SIZE
|
||||
#elif !defined(NO_SHA256)
|
||||
#define WC_MAX_DIGEST_SIZE WC_SHA256_DIGEST_SIZE
|
||||
#define WC_MAX_BLOCK_SIZE WC_SHA256_BLOCK_SIZE
|
||||
#elif defined(WOLFSSL_SHA224)
|
||||
#define WC_MAX_DIGEST_SIZE WC_SHA224_DIGEST_SIZE
|
||||
#define WC_MAX_BLOCK_SIZE WC_SHA224_BLOCK_SIZE
|
||||
#elif !defined(NO_SHA)
|
||||
#define WC_MAX_DIGEST_SIZE WC_SHA_DIGEST_SIZE
|
||||
#define WC_MAX_BLOCK_SIZE WC_SHA_BLOCK_SIZE
|
||||
#elif !defined(NO_MD5)
|
||||
#define WC_MAX_DIGEST_SIZE WC_MD5_DIGEST_SIZE
|
||||
#define WC_MAX_BLOCK_SIZE WC_MD5_BLOCK_SIZE
|
||||
#else
|
||||
#define WC_MAX_DIGEST_SIZE 64 /* default to max size of 64 */
|
||||
#define WC_MAX_BLOCK_SIZE 128
|
||||
#endif
|
||||
|
||||
#if !defined(NO_ASN) || !defined(NO_DH) || defined(HAVE_ECC)
|
||||
WOLFSSL_API int wc_HashGetOID(enum wc_HashType hash_type);
|
||||
WOLFSSL_API enum wc_HashType wc_OidGetHash(int oid);
|
||||
#endif
|
||||
|
||||
WOLFSSL_API enum wc_HashType wc_HashTypeConvert(int hashType);
|
||||
|
||||
WOLFSSL_API int wc_HashGetDigestSize(enum wc_HashType hash_type);
|
||||
WOLFSSL_API int wc_HashGetBlockSize(enum wc_HashType hash_type);
|
||||
WOLFSSL_API int wc_Hash(enum wc_HashType hash_type,
|
||||
const byte* data, word32 data_len,
|
||||
byte* hash, word32 hash_len);
|
||||
|
||||
/* generic hash operation wrappers */
|
||||
WOLFSSL_API int wc_HashInit(wc_HashAlg* hash, enum wc_HashType type);
|
||||
WOLFSSL_API int wc_HashUpdate(wc_HashAlg* hash, enum wc_HashType type,
|
||||
const byte* data, word32 dataSz);
|
||||
WOLFSSL_API int wc_HashFinal(wc_HashAlg* hash, enum wc_HashType type,
|
||||
byte* out);
|
||||
WOLFSSL_API int wc_HashFree(wc_HashAlg* hash, enum wc_HashType type);
|
||||
|
||||
#ifndef NO_MD5
|
||||
#include <wolfssl/wolfcrypt/md5.h>
|
||||
WOLFSSL_API int wc_Md5Hash(const byte* data, word32 len, byte* hash);
|
||||
#endif
|
||||
|
||||
#ifndef NO_SHA
|
||||
#include <wolfssl/wolfcrypt/sha.h>
|
||||
WOLFSSL_API int wc_ShaHash(const byte*, word32, byte*);
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_SHA224
|
||||
#include <wolfssl/wolfcrypt/sha256.h>
|
||||
WOLFSSL_API int wc_Sha224Hash(const byte*, word32, byte*);
|
||||
#endif /* defined(WOLFSSL_SHA224) */
|
||||
|
||||
#ifndef NO_SHA256
|
||||
#include <wolfssl/wolfcrypt/sha256.h>
|
||||
WOLFSSL_API int wc_Sha256Hash(const byte*, word32, byte*);
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_SHA384
|
||||
#include <wolfssl/wolfcrypt/sha512.h>
|
||||
WOLFSSL_API int wc_Sha384Hash(const byte*, word32, byte*);
|
||||
#endif /* defined(WOLFSSL_SHA384) */
|
||||
|
||||
#ifdef WOLFSSL_SHA512
|
||||
#include <wolfssl/wolfcrypt/sha512.h>
|
||||
WOLFSSL_API int wc_Sha512Hash(const byte*, word32, byte*);
|
||||
#endif /* WOLFSSL_SHA512 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* WOLF_CRYPT_HASH_H */
|
181
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/wolfcrypt/hmac.h
Normal file
181
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/wolfcrypt/hmac.h
Normal file
@ -0,0 +1,181 @@
|
||||
/* hmac.h
|
||||
*
|
||||
* Copyright (C) 2006-2018 wolfSSL Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is distributed in binary form as licensed by Espressif Systems.
|
||||
* See README file or contact licensing@wolfssl.com with any questions or comments.
|
||||
*
|
||||
* https://www.wolfssl.com
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/hmac.h
|
||||
*/
|
||||
|
||||
#ifndef NO_HMAC
|
||||
|
||||
#ifndef WOLF_CRYPT_HMAC_H
|
||||
#define WOLF_CRYPT_HMAC_H
|
||||
|
||||
#include <wolfssl/wolfcrypt/hash.h>
|
||||
|
||||
#if defined(HAVE_FIPS) && \
|
||||
(!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2))
|
||||
/* for fips @wc_fips */
|
||||
#include <cyassl/ctaocrypt/hmac.h>
|
||||
#define WC_HMAC_BLOCK_SIZE HMAC_BLOCK_SIZE
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(HAVE_FIPS) && \
|
||||
defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)
|
||||
#include <wolfssl/wolfcrypt/fips.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* avoid redefinition of structs */
|
||||
#if !defined(HAVE_FIPS) || \
|
||||
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2))
|
||||
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
#include <wolfssl/wolfcrypt/async.h>
|
||||
#endif
|
||||
|
||||
#ifndef NO_OLD_WC_NAMES
|
||||
#define HMAC_BLOCK_SIZE WC_HMAC_BLOCK_SIZE
|
||||
#endif
|
||||
|
||||
enum {
|
||||
HMAC_FIPS_MIN_KEY = 14, /* 112 bit key length minimum */
|
||||
|
||||
IPAD = 0x36,
|
||||
OPAD = 0x5C,
|
||||
|
||||
/* If any hash is not enabled, add the ID here. */
|
||||
#ifdef NO_MD5
|
||||
WC_MD5 = WC_HASH_TYPE_MD5,
|
||||
#endif
|
||||
#ifdef NO_SHA
|
||||
WC_SHA = WC_HASH_TYPE_SHA,
|
||||
#endif
|
||||
#ifdef NO_SHA256
|
||||
WC_SHA256 = WC_HASH_TYPE_SHA256,
|
||||
#endif
|
||||
#ifndef WOLFSSL_SHA512
|
||||
WC_SHA512 = WC_HASH_TYPE_SHA512,
|
||||
#endif
|
||||
#ifndef WOLFSSL_SHA384
|
||||
WC_SHA384 = WC_HASH_TYPE_SHA384,
|
||||
#endif
|
||||
#ifndef HAVE_BLAKE2
|
||||
BLAKE2B_ID = WC_HASH_TYPE_BLAKE2B,
|
||||
#endif
|
||||
#ifndef WOLFSSL_SHA224
|
||||
WC_SHA224 = WC_HASH_TYPE_SHA224,
|
||||
#endif
|
||||
#ifndef WOLFSSL_SHA3
|
||||
WC_SHA3_224 = WC_HASH_TYPE_SHA3_224,
|
||||
WC_SHA3_256 = WC_HASH_TYPE_SHA3_256,
|
||||
WC_SHA3_384 = WC_HASH_TYPE_SHA3_384,
|
||||
WC_SHA3_512 = WC_HASH_TYPE_SHA3_512,
|
||||
#endif
|
||||
};
|
||||
|
||||
/* Select the largest available hash for the buffer size. */
|
||||
#define WC_HMAC_BLOCK_SIZE WC_MAX_BLOCK_SIZE
|
||||
|
||||
#if !defined(WOLFSSL_SHA3) && !defined(WOLFSSL_SHA512) && !defined(HAVE_BLAKE2) && \
|
||||
!defined(WOLFSSL_SHA384) && defined(NO_SHA256) && defined(WOLFSSL_SHA224) && \
|
||||
defined(NO_SHA) && defined(NO_MD5)
|
||||
#error "You have to have some kind of hash if you want to use HMAC."
|
||||
#endif
|
||||
|
||||
|
||||
/* hash union */
|
||||
typedef union {
|
||||
#ifndef NO_MD5
|
||||
wc_Md5 md5;
|
||||
#endif
|
||||
#ifndef NO_SHA
|
||||
wc_Sha sha;
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA224
|
||||
wc_Sha224 sha224;
|
||||
#endif
|
||||
#ifndef NO_SHA256
|
||||
wc_Sha256 sha256;
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA384
|
||||
wc_Sha384 sha384;
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA512
|
||||
wc_Sha512 sha512;
|
||||
#endif
|
||||
#ifdef HAVE_BLAKE2
|
||||
Blake2b blake2b;
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA3
|
||||
wc_Sha3 sha3;
|
||||
#endif
|
||||
} Hash;
|
||||
|
||||
/* Hmac digest */
|
||||
typedef struct Hmac {
|
||||
Hash hash;
|
||||
word32 ipad[WC_HMAC_BLOCK_SIZE / sizeof(word32)]; /* same block size all*/
|
||||
word32 opad[WC_HMAC_BLOCK_SIZE / sizeof(word32)];
|
||||
word32 innerHash[WC_MAX_DIGEST_SIZE / sizeof(word32)];
|
||||
void* heap; /* heap hint */
|
||||
byte macType; /* md5 sha or sha256 */
|
||||
byte innerHashKeyed; /* keyed flag */
|
||||
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
WC_ASYNC_DEV asyncDev;
|
||||
word16 keyLen; /* hmac key length (key in ipad) */
|
||||
#endif /* WOLFSSL_ASYNC_CRYPT */
|
||||
} Hmac;
|
||||
|
||||
#endif /* HAVE_FIPS */
|
||||
|
||||
/* does init */
|
||||
WOLFSSL_API int wc_HmacSetKey(Hmac*, int type, const byte* key, word32 keySz);
|
||||
WOLFSSL_API int wc_HmacUpdate(Hmac*, const byte*, word32);
|
||||
WOLFSSL_API int wc_HmacFinal(Hmac*, byte*);
|
||||
WOLFSSL_API int wc_HmacSizeByType(int type);
|
||||
|
||||
WOLFSSL_API int wc_HmacInit(Hmac* hmac, void* heap, int devId);
|
||||
WOLFSSL_API void wc_HmacFree(Hmac*);
|
||||
|
||||
WOLFSSL_API int wolfSSL_GetHmacMaxSize(void);
|
||||
|
||||
WOLFSSL_LOCAL int _InitHmac(Hmac* hmac, int type, void* heap);
|
||||
|
||||
#ifdef HAVE_HKDF
|
||||
|
||||
WOLFSSL_API int wc_HKDF_Extract(int type, const byte* salt, word32 saltSz,
|
||||
const byte* inKey, word32 inKeySz, byte* out);
|
||||
WOLFSSL_API int wc_HKDF_Expand(int type, const byte* inKey, word32 inKeySz,
|
||||
const byte* info, word32 infoSz,
|
||||
byte* out, word32 outSz);
|
||||
|
||||
WOLFSSL_API int wc_HKDF(int type, const byte* inKey, word32 inKeySz,
|
||||
const byte* salt, word32 saltSz,
|
||||
const byte* info, word32 infoSz,
|
||||
byte* out, word32 outSz);
|
||||
|
||||
#endif /* HAVE_HKDF */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* WOLF_CRYPT_HMAC_H */
|
||||
|
||||
#endif /* NO_HMAC */
|
||||
|
@ -0,0 +1,398 @@
|
||||
/* integer.h
|
||||
*
|
||||
* Copyright (C) 2006-2018 wolfSSL Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is distributed in binary form as licensed by Espressif Systems.
|
||||
* See README file or contact licensing@wolfssl.com with any questions or comments.
|
||||
*
|
||||
* https://www.wolfssl.com
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Based on public domain LibTomMath 0.38 by Tom St Denis, tomstdenis@iahu.ca,
|
||||
* http://math.libtomcrypt.com
|
||||
*/
|
||||
|
||||
|
||||
#ifndef WOLF_CRYPT_INTEGER_H
|
||||
#define WOLF_CRYPT_INTEGER_H
|
||||
|
||||
/* may optionally use fast math instead, not yet supported on all platforms and
|
||||
may not be faster on all
|
||||
*/
|
||||
#include <wolfssl/wolfcrypt/types.h> /* will set MP_xxBIT if not default */
|
||||
#ifdef WOLFSSL_SP_MATH
|
||||
#include <wolfssl/wolfcrypt/sp_int.h>
|
||||
#elif defined(USE_FAST_MATH)
|
||||
#include <wolfssl/wolfcrypt/tfm.h>
|
||||
#else
|
||||
|
||||
#include <wolfssl/wolfcrypt/random.h>
|
||||
|
||||
#ifndef CHAR_BIT
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/mpi_class.h>
|
||||
|
||||
/* wolf big int and common functions */
|
||||
#include <wolfssl/wolfcrypt/wolfmath.h>
|
||||
|
||||
|
||||
#ifdef WOLFSSL_PUBLIC_MP
|
||||
#define MP_API WOLFSSL_API
|
||||
#else
|
||||
#define MP_API
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(x,y) ((x)<(y)?(x):(y))
|
||||
#endif
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(x,y) ((x)>(y)?(x):(y))
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
/* C++ compilers don't like assigning void * to mp_digit * */
|
||||
#define OPT_CAST(x) (x *)
|
||||
|
||||
#elif defined(_SH3)
|
||||
|
||||
/* SuperH SH3 compiler doesn't like assigning voi* to mp_digit* */
|
||||
#define OPT_CAST(x) (x *)
|
||||
|
||||
#else
|
||||
|
||||
/* C on the other hand doesn't care */
|
||||
#define OPT_CAST(x)
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
/* detect 64-bit mode if possible */
|
||||
#if defined(__x86_64__)
|
||||
#if !(defined(MP_64BIT) && defined(MP_16BIT) && defined(MP_8BIT))
|
||||
#define MP_64BIT
|
||||
#endif
|
||||
#endif
|
||||
/* if intel compiler doesn't provide 128 bit type don't turn on 64bit */
|
||||
#if defined(MP_64BIT) && defined(__INTEL_COMPILER) && !defined(HAVE___UINT128_T)
|
||||
#undef MP_64BIT
|
||||
#endif
|
||||
|
||||
|
||||
/* allow user to define on mp_digit, mp_word, DIGIT_BIT types */
|
||||
#ifndef WOLFSSL_BIGINT_TYPES
|
||||
|
||||
/* some default configurations.
|
||||
*
|
||||
* A "mp_digit" must be able to hold DIGIT_BIT + 1 bits
|
||||
* A "mp_word" must be able to hold 2*DIGIT_BIT + 1 bits
|
||||
*
|
||||
* At the very least a mp_digit must be able to hold 7 bits
|
||||
* [any size beyond that is ok provided it doesn't overflow the data type]
|
||||
*/
|
||||
#ifdef MP_8BIT
|
||||
typedef unsigned char mp_digit;
|
||||
typedef unsigned short mp_word;
|
||||
#elif defined(MP_16BIT) || defined(NO_64BIT)
|
||||
typedef unsigned short mp_digit;
|
||||
typedef unsigned int mp_word;
|
||||
#define DIGIT_BIT 12
|
||||
#elif defined(MP_64BIT)
|
||||
/* for GCC only on supported platforms */
|
||||
typedef unsigned long long mp_digit; /* 64 bit type, 128 uses mode(TI) */
|
||||
typedef unsigned long mp_word __attribute__ ((mode(TI)));
|
||||
|
||||
#define DIGIT_BIT 60
|
||||
#else
|
||||
/* this is the default case, 28-bit digits */
|
||||
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
||||
typedef unsigned __int64 ulong64;
|
||||
#else
|
||||
typedef unsigned long long ulong64;
|
||||
#endif
|
||||
|
||||
typedef unsigned int mp_digit; /* long could be 64 now, changed TAO */
|
||||
typedef ulong64 mp_word;
|
||||
|
||||
#ifdef MP_31BIT
|
||||
/* this is an extension that uses 31-bit digits */
|
||||
#define DIGIT_BIT 31
|
||||
#else
|
||||
/* default case is 28-bit digits, defines MP_28BIT as a handy test macro */
|
||||
#define DIGIT_BIT 28
|
||||
#define MP_28BIT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* WOLFSSL_BIGINT_TYPES */
|
||||
|
||||
/* otherwise the bits per digit is calculated automatically from the size of
|
||||
a mp_digit */
|
||||
#ifndef DIGIT_BIT
|
||||
#define DIGIT_BIT ((int)((CHAR_BIT * sizeof(mp_digit) - 1)))
|
||||
/* bits per digit */
|
||||
#endif
|
||||
|
||||
#define MP_DIGIT_BIT DIGIT_BIT
|
||||
#define MP_MASK ((((mp_digit)1)<<((mp_digit)DIGIT_BIT))-((mp_digit)1))
|
||||
#define MP_DIGIT_MAX MP_MASK
|
||||
|
||||
/* equalities */
|
||||
#define MP_LT -1 /* less than */
|
||||
#define MP_EQ 0 /* equal to */
|
||||
#define MP_GT 1 /* greater than */
|
||||
|
||||
#define MP_ZPOS 0 /* positive integer */
|
||||
#define MP_NEG 1 /* negative */
|
||||
|
||||
#define MP_OKAY 0 /* ok result */
|
||||
#define MP_MEM -2 /* out of mem */
|
||||
#define MP_VAL -3 /* invalid input */
|
||||
#define MP_NOT_INF -4 /* point not at infinity */
|
||||
#define MP_RANGE MP_NOT_INF
|
||||
|
||||
#define MP_YES 1 /* yes response */
|
||||
#define MP_NO 0 /* no response */
|
||||
|
||||
/* Primality generation flags */
|
||||
#define LTM_PRIME_BBS 0x0001 /* BBS style prime */
|
||||
#define LTM_PRIME_SAFE 0x0002 /* Safe prime (p-1)/2 == prime */
|
||||
#define LTM_PRIME_2MSB_ON 0x0008 /* force 2nd MSB to 1 */
|
||||
|
||||
typedef int mp_err;
|
||||
|
||||
/* define this to use lower memory usage routines (exptmods mostly) */
|
||||
#define MP_LOW_MEM
|
||||
|
||||
/* default precision */
|
||||
#ifndef MP_PREC
|
||||
#ifndef MP_LOW_MEM
|
||||
#define MP_PREC 32 /* default digits of precision */
|
||||
#else
|
||||
#define MP_PREC 1 /* default digits of precision */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* size of comba arrays, should be at least 2 * 2**(BITS_PER_WORD -
|
||||
BITS_PER_DIGIT*2) */
|
||||
#define MP_WARRAY (1 << (sizeof(mp_word) * CHAR_BIT - 2 * DIGIT_BIT + 1))
|
||||
|
||||
#ifdef HAVE_WOLF_BIGINT
|
||||
struct WC_BIGINT;
|
||||
#endif
|
||||
|
||||
/* the mp_int structure */
|
||||
typedef struct mp_int {
|
||||
int used, alloc, sign;
|
||||
mp_digit *dp;
|
||||
|
||||
#ifdef HAVE_WOLF_BIGINT
|
||||
struct WC_BIGINT raw; /* unsigned binary (big endian) */
|
||||
#endif
|
||||
} mp_int;
|
||||
#define MP_INT_DEFINED
|
||||
|
||||
/* callback for mp_prime_random, should fill dst with random bytes and return
|
||||
how many read [up to len] */
|
||||
typedef int ltm_prime_callback(unsigned char *dst, int len, void *dat);
|
||||
|
||||
|
||||
#define USED(m) ((m)->used)
|
||||
#define DIGIT(m,k) ((m)->dp[(k)])
|
||||
#define SIGN(m) ((m)->sign)
|
||||
|
||||
|
||||
/* ---> Basic Manipulations <--- */
|
||||
#define mp_iszero(a) (((a)->used == 0) ? MP_YES : MP_NO)
|
||||
#define mp_isone(a) \
|
||||
(((((a)->used == 1)) && ((a)->dp[0] == 1u)) ? MP_YES : MP_NO)
|
||||
#define mp_iseven(a) \
|
||||
(((a)->used > 0 && (((a)->dp[0] & 1u) == 0u)) ? MP_YES : MP_NO)
|
||||
#define mp_isodd(a) \
|
||||
(((a)->used > 0 && (((a)->dp[0] & 1u) == 1u)) ? MP_YES : MP_NO)
|
||||
#define mp_isneg(a) (((a)->sign != MP_ZPOS) ? MP_YES : MP_NO)
|
||||
|
||||
/* number of primes */
|
||||
#ifdef MP_8BIT
|
||||
#define PRIME_SIZE 31
|
||||
#else
|
||||
#define PRIME_SIZE 256
|
||||
#endif
|
||||
|
||||
#ifndef MAX_INVMOD_SZ
|
||||
#if defined(WOLFSSL_MYSQL_COMPATIBLE)
|
||||
#define MAX_INVMOD_SZ 8192
|
||||
#else
|
||||
#define MAX_INVMOD_SZ 4096
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define mp_prime_random(a, t, size, bbs, cb, dat) \
|
||||
mp_prime_random_ex(a, t, ((size) * 8) + 1, (bbs==1)?LTM_PRIME_BBS:0, cb, dat)
|
||||
|
||||
#define mp_read_raw(mp, str, len) mp_read_signed_bin((mp), (str), (len))
|
||||
#define mp_raw_size(mp) mp_signed_bin_size(mp)
|
||||
#define mp_toraw(mp, str) mp_to_signed_bin((mp), (str))
|
||||
#define mp_read_mag(mp, str, len) mp_read_unsigned_bin((mp), (str), (len))
|
||||
#define mp_mag_size(mp) mp_unsigned_bin_size(mp)
|
||||
#define mp_tomag(mp, str) mp_to_unsigned_bin((mp), (str))
|
||||
|
||||
#define MP_RADIX_BIN 2
|
||||
#define MP_RADIX_OCT 8
|
||||
#define MP_RADIX_DEC 10
|
||||
#define MP_RADIX_HEX 16
|
||||
#define MP_RADIX_MAX 64
|
||||
|
||||
#define mp_tobinary(M, S) mp_toradix((M), (S), MP_RADIX_BIN)
|
||||
#define mp_tooctal(M, S) mp_toradix((M), (S), MP_RADIX_OCT)
|
||||
#define mp_todecimal(M, S) mp_toradix((M), (S), MP_RADIX_DEC)
|
||||
#define mp_tohex(M, S) mp_toradix((M), (S), MP_RADIX_HEX)
|
||||
|
||||
#define s_mp_mul(a, b, c) s_mp_mul_digs(a, b, c, (a)->used + (b)->used + 1)
|
||||
|
||||
#if defined(HAVE_ECC) || defined(WOLFSSL_KEY_GEN) || defined(HAVE_COMP_KEY) || \
|
||||
defined(WOLFSSL_DEBUG_MATH) || defined(DEBUG_WOLFSSL)
|
||||
extern const char *mp_s_rmap;
|
||||
#endif
|
||||
|
||||
/* 6 functions needed by Rsa */
|
||||
MP_API int mp_init (mp_int * a);
|
||||
MP_API void mp_clear (mp_int * a);
|
||||
MP_API void mp_free (mp_int * a);
|
||||
MP_API void mp_forcezero(mp_int * a);
|
||||
MP_API int mp_unsigned_bin_size(mp_int * a);
|
||||
MP_API int mp_read_unsigned_bin (mp_int * a, const unsigned char *b, int c);
|
||||
MP_API int mp_to_unsigned_bin_at_pos(int x, mp_int *t, unsigned char *b);
|
||||
MP_API int mp_to_unsigned_bin (mp_int * a, unsigned char *b);
|
||||
MP_API int mp_to_unsigned_bin_len(mp_int * a, unsigned char *b, int c);
|
||||
MP_API int mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y);
|
||||
/* end functions needed by Rsa */
|
||||
|
||||
/* functions added to support above needed, removed TOOM and KARATSUBA */
|
||||
MP_API int mp_count_bits (mp_int * a);
|
||||
MP_API int mp_leading_bit (mp_int * a);
|
||||
MP_API int mp_init_copy (mp_int * a, mp_int * b);
|
||||
MP_API int mp_copy (mp_int * a, mp_int * b);
|
||||
MP_API int mp_grow (mp_int * a, int size);
|
||||
MP_API int mp_div_2d (mp_int * a, int b, mp_int * c, mp_int * d);
|
||||
MP_API void mp_zero (mp_int * a);
|
||||
MP_API void mp_clamp (mp_int * a);
|
||||
MP_API void mp_exch (mp_int * a, mp_int * b);
|
||||
MP_API void mp_rshd (mp_int * a, int b);
|
||||
MP_API void mp_rshb (mp_int * a, int b);
|
||||
MP_API int mp_mod_2d (mp_int * a, int b, mp_int * c);
|
||||
MP_API int mp_mul_2d (mp_int * a, int b, mp_int * c);
|
||||
MP_API int mp_lshd (mp_int * a, int b);
|
||||
MP_API int mp_abs (mp_int * a, mp_int * b);
|
||||
MP_API int mp_invmod (mp_int * a, mp_int * b, mp_int * c);
|
||||
int fast_mp_invmod (mp_int * a, mp_int * b, mp_int * c);
|
||||
MP_API int mp_invmod_slow (mp_int * a, mp_int * b, mp_int * c);
|
||||
MP_API int mp_cmp_mag (mp_int * a, mp_int * b);
|
||||
MP_API int mp_cmp (mp_int * a, mp_int * b);
|
||||
MP_API int mp_cmp_d(mp_int * a, mp_digit b);
|
||||
MP_API int mp_set (mp_int * a, mp_digit b);
|
||||
MP_API int mp_is_bit_set (mp_int * a, mp_digit b);
|
||||
MP_API int mp_mod (mp_int * a, mp_int * b, mp_int * c);
|
||||
MP_API int mp_div(mp_int * a, mp_int * b, mp_int * c, mp_int * d);
|
||||
MP_API int mp_div_2(mp_int * a, mp_int * b);
|
||||
MP_API int mp_add (mp_int * a, mp_int * b, mp_int * c);
|
||||
int s_mp_add (mp_int * a, mp_int * b, mp_int * c);
|
||||
int s_mp_sub (mp_int * a, mp_int * b, mp_int * c);
|
||||
MP_API int mp_sub (mp_int * a, mp_int * b, mp_int * c);
|
||||
MP_API int mp_reduce_is_2k_l(mp_int *a);
|
||||
MP_API int mp_reduce_is_2k(mp_int *a);
|
||||
MP_API int mp_dr_is_modulus(mp_int *a);
|
||||
MP_API int mp_exptmod_fast (mp_int * G, mp_int * X, mp_int * P, mp_int * Y,
|
||||
int);
|
||||
MP_API int mp_montgomery_setup (mp_int * n, mp_digit * rho);
|
||||
int fast_mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho);
|
||||
MP_API int mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho);
|
||||
MP_API void mp_dr_setup(mp_int *a, mp_digit *d);
|
||||
MP_API int mp_dr_reduce (mp_int * x, mp_int * n, mp_digit k);
|
||||
MP_API int mp_reduce_2k(mp_int *a, mp_int *n, mp_digit d);
|
||||
int fast_s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs);
|
||||
int s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs);
|
||||
MP_API int mp_reduce_2k_setup_l(mp_int *a, mp_int *d);
|
||||
MP_API int mp_reduce_2k_l(mp_int *a, mp_int *n, mp_int *d);
|
||||
MP_API int mp_reduce (mp_int * x, mp_int * m, mp_int * mu);
|
||||
MP_API int mp_reduce_setup (mp_int * a, mp_int * b);
|
||||
int s_mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode);
|
||||
MP_API int mp_montgomery_calc_normalization (mp_int * a, mp_int * b);
|
||||
int s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs);
|
||||
int s_mp_sqr (mp_int * a, mp_int * b);
|
||||
int fast_s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs);
|
||||
int fast_s_mp_sqr (mp_int * a, mp_int * b);
|
||||
MP_API int mp_init_size (mp_int * a, int size);
|
||||
MP_API int mp_div_3 (mp_int * a, mp_int *c, mp_digit * d);
|
||||
MP_API int mp_mul_2(mp_int * a, mp_int * b);
|
||||
MP_API int mp_mul (mp_int * a, mp_int * b, mp_int * c);
|
||||
MP_API int mp_sqr (mp_int * a, mp_int * b);
|
||||
MP_API int mp_mulmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d);
|
||||
MP_API int mp_submod (mp_int* a, mp_int* b, mp_int* c, mp_int* d);
|
||||
MP_API int mp_addmod (mp_int* a, mp_int* b, mp_int* c, mp_int* d);
|
||||
MP_API int mp_mul_d (mp_int * a, mp_digit b, mp_int * c);
|
||||
MP_API int mp_2expt (mp_int * a, int b);
|
||||
MP_API int mp_set_bit (mp_int * a, int b);
|
||||
MP_API int mp_reduce_2k_setup(mp_int *a, mp_digit *d);
|
||||
MP_API int mp_add_d (mp_int* a, mp_digit b, mp_int* c);
|
||||
MP_API int mp_set_int (mp_int * a, unsigned long b);
|
||||
MP_API int mp_sub_d (mp_int * a, mp_digit b, mp_int * c);
|
||||
/* end support added functions */
|
||||
|
||||
/* added */
|
||||
MP_API int mp_init_multi(mp_int* a, mp_int* b, mp_int* c, mp_int* d, mp_int* e,
|
||||
mp_int* f);
|
||||
MP_API int mp_toradix (mp_int *a, char *str, int radix);
|
||||
MP_API int mp_radix_size (mp_int * a, int radix, int *size);
|
||||
|
||||
#ifdef WOLFSSL_DEBUG_MATH
|
||||
MP_API void mp_dump(const char* desc, mp_int* a, byte verbose);
|
||||
#else
|
||||
#define mp_dump(desc, a, verbose)
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_ECC) || defined(WOLFSSL_KEY_GEN) || !defined(NO_RSA) || \
|
||||
!defined(NO_DSA) || !defined(NO_DH)
|
||||
MP_API int mp_sqrmod(mp_int* a, mp_int* b, mp_int* c);
|
||||
#endif
|
||||
#if !defined(NO_DSA) || defined(HAVE_ECC)
|
||||
MP_API int mp_read_radix(mp_int* a, const char* str, int radix);
|
||||
#endif
|
||||
|
||||
#if defined(WOLFSSL_KEY_GEN) || !defined(NO_RSA) || !defined(NO_DSA) || !defined(NO_DH)
|
||||
MP_API int mp_prime_is_prime (mp_int * a, int t, int *result);
|
||||
MP_API int mp_prime_is_prime_ex (mp_int * a, int t, int *result, WC_RNG*);
|
||||
#endif /* WOLFSSL_KEY_GEN NO_RSA NO_DSA NO_DH */
|
||||
#ifdef WOLFSSL_KEY_GEN
|
||||
MP_API int mp_gcd (mp_int * a, mp_int * b, mp_int * c);
|
||||
MP_API int mp_lcm (mp_int * a, mp_int * b, mp_int * c);
|
||||
MP_API int mp_rand_prime(mp_int* N, int len, WC_RNG* rng, void* heap);
|
||||
#endif
|
||||
|
||||
MP_API int mp_cnt_lsb(mp_int *a);
|
||||
MP_API int mp_mod_d(mp_int* a, mp_digit b, mp_digit* c);
|
||||
|
||||
|
||||
/* wolf big int and common functions */
|
||||
#include <wolfssl/wolfcrypt/wolfmath.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* USE_FAST_MATH */
|
||||
|
||||
#endif /* WOLF_CRYPT_INTEGER_H */
|
||||
|
@ -0,0 +1,179 @@
|
||||
/* logging.h
|
||||
*
|
||||
* Copyright (C) 2006-2018 wolfSSL Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is distributed in binary form as licensed by Espressif Systems.
|
||||
* See README file or contact licensing@wolfssl.com with any questions or comments.
|
||||
*
|
||||
* https://www.wolfssl.com
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/logging.h
|
||||
*/
|
||||
|
||||
|
||||
/* submitted by eof */
|
||||
|
||||
|
||||
#ifndef WOLFSSL_LOGGING_H
|
||||
#define WOLFSSL_LOGGING_H
|
||||
|
||||
#include <wolfssl/wolfcrypt/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
enum wc_LogLevels {
|
||||
ERROR_LOG = 0,
|
||||
INFO_LOG,
|
||||
ENTER_LOG,
|
||||
LEAVE_LOG,
|
||||
OTHER_LOG
|
||||
};
|
||||
|
||||
#ifdef WOLFSSL_FUNC_TIME
|
||||
/* WARNING: This code is only to be used for debugging performance.
|
||||
* The code is not thread-safe.
|
||||
* Do not use WOLFSSL_FUNC_TIME in production code.
|
||||
*/
|
||||
enum wc_FuncNum {
|
||||
WC_FUNC_HELLO_REQUEST_SEND = 0,
|
||||
WC_FUNC_HELLO_REQUEST_DO,
|
||||
WC_FUNC_CLIENT_HELLO_SEND,
|
||||
WC_FUNC_CLIENT_HELLO_DO,
|
||||
WC_FUNC_SERVER_HELLO_SEND,
|
||||
WC_FUNC_SERVER_HELLO_DO,
|
||||
WC_FUNC_ENCRYPTED_EXTENSIONS_SEND,
|
||||
WC_FUNC_ENCRYPTED_EXTENSIONS_DO,
|
||||
WC_FUNC_CERTIFICATE_REQUEST_SEND,
|
||||
WC_FUNC_CERTIFICATE_REQUEST_DO,
|
||||
WC_FUNC_CERTIFICATE_SEND,
|
||||
WC_FUNC_CERTIFICATE_DO,
|
||||
WC_FUNC_CERTIFICATE_VERIFY_SEND,
|
||||
WC_FUNC_CERTIFICATE_VERIFY_DO,
|
||||
WC_FUNC_FINISHED_SEND,
|
||||
WC_FUNC_FINISHED_DO,
|
||||
WC_FUNC_KEY_UPDATE_SEND,
|
||||
WC_FUNC_KEY_UPDATE_DO,
|
||||
WC_FUNC_EARLY_DATA_SEND,
|
||||
WC_FUNC_EARLY_DATA_DO,
|
||||
WC_FUNC_NEW_SESSION_TICKET_SEND,
|
||||
WC_FUNC_NEW_SESSION_TICKET_DO,
|
||||
WC_FUNC_SERVER_HELLO_DONE_SEND,
|
||||
WC_FUNC_SERVER_HELLO_DONE_DO,
|
||||
WC_FUNC_TICKET_SEND,
|
||||
WC_FUNC_TICKET_DO,
|
||||
WC_FUNC_CLIENT_KEY_EXCHANGE_SEND,
|
||||
WC_FUNC_CLIENT_KEY_EXCHANGE_DO,
|
||||
WC_FUNC_CERTIFICATE_STATUS_SEND,
|
||||
WC_FUNC_CERTIFICATE_STATUS_DO,
|
||||
WC_FUNC_SERVER_KEY_EXCHANGE_SEND,
|
||||
WC_FUNC_SERVER_KEY_EXCHANGE_DO,
|
||||
WC_FUNC_END_OF_EARLY_DATA_SEND,
|
||||
WC_FUNC_END_OF_EARLY_DATA_DO,
|
||||
WC_FUNC_COUNT
|
||||
};
|
||||
#endif
|
||||
|
||||
typedef void (*wolfSSL_Logging_cb)(const int logLevel,
|
||||
const char *const logMessage);
|
||||
|
||||
WOLFSSL_API int wolfSSL_SetLoggingCb(wolfSSL_Logging_cb log_function);
|
||||
|
||||
/* turn logging on, only if compiled in */
|
||||
WOLFSSL_API int wolfSSL_Debugging_ON(void);
|
||||
/* turn logging off */
|
||||
WOLFSSL_API void wolfSSL_Debugging_OFF(void);
|
||||
|
||||
|
||||
#if defined(OPENSSL_EXTRA) || defined(DEBUG_WOLFSSL_VERBOSE)
|
||||
WOLFSSL_LOCAL int wc_LoggingInit(void);
|
||||
WOLFSSL_LOCAL int wc_LoggingCleanup(void);
|
||||
WOLFSSL_LOCAL int wc_AddErrorNode(int error, int line, char* buf,
|
||||
char* file);
|
||||
WOLFSSL_LOCAL int wc_PeekErrorNode(int index, const char **file,
|
||||
const char **reason, int *line);
|
||||
WOLFSSL_LOCAL void wc_RemoveErrorNode(int index);
|
||||
WOLFSSL_LOCAL void wc_ClearErrorNodes(void);
|
||||
WOLFSSL_LOCAL int wc_PullErrorNode(const char **file, const char **reason,
|
||||
int *line);
|
||||
WOLFSSL_API int wc_SetLoggingHeap(void* h);
|
||||
WOLFSSL_API int wc_ERR_remove_state(void);
|
||||
#if !defined(NO_FILESYSTEM) && !defined(NO_STDIO_FILESYSTEM)
|
||||
WOLFSSL_API void wc_ERR_print_errors_fp(XFILE fp);
|
||||
#endif
|
||||
#endif /* OPENSSL_EXTRA || DEBUG_WOLFSSL_VERBOSE */
|
||||
|
||||
#ifdef WOLFSSL_FUNC_TIME
|
||||
/* WARNING: This code is only to be used for debugging performance.
|
||||
* The code is not thread-safe.
|
||||
* Do not use WOLFSSL_FUNC_TIME in production code.
|
||||
*/
|
||||
WOLFSSL_API void WOLFSSL_START(int funcNum);
|
||||
WOLFSSL_API void WOLFSSL_END(int funcNum);
|
||||
WOLFSSL_API void WOLFSSL_TIME(int count);
|
||||
#else
|
||||
#define WOLFSSL_START(n)
|
||||
#define WOLFSSL_END(n)
|
||||
#define WOLFSSL_TIME(n)
|
||||
#endif
|
||||
|
||||
#if defined(DEBUG_WOLFSSL) && !defined(WOLFSSL_DEBUG_ERRORS_ONLY)
|
||||
#if defined(_WIN32)
|
||||
#if defined(INTIME_RTOS)
|
||||
#define __func__ NULL
|
||||
#else
|
||||
#define __func__ __FUNCTION__
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* a is prepended to m and b is appended, creating a log msg a + m + b */
|
||||
#define WOLFSSL_LOG_CAT(a, m, b) #a " " m " " #b
|
||||
|
||||
WOLFSSL_API void WOLFSSL_ENTER(const char* msg);
|
||||
WOLFSSL_API void WOLFSSL_LEAVE(const char* msg, int ret);
|
||||
#define WOLFSSL_STUB(m) \
|
||||
WOLFSSL_MSG(WOLFSSL_LOG_CAT(wolfSSL Stub, m, not implemented))
|
||||
|
||||
WOLFSSL_API void WOLFSSL_MSG(const char* msg);
|
||||
WOLFSSL_API void WOLFSSL_BUFFER(const byte* buffer, word32 length);
|
||||
|
||||
#else
|
||||
|
||||
#define WOLFSSL_ENTER(m)
|
||||
#define WOLFSSL_LEAVE(m, r)
|
||||
#define WOLFSSL_STUB(m)
|
||||
|
||||
#define WOLFSSL_MSG(m)
|
||||
#define WOLFSSL_BUFFER(b, l)
|
||||
|
||||
#endif /* DEBUG_WOLFSSL && !WOLFSSL_DEBUG_ERRORS_ONLY */
|
||||
|
||||
#if defined(DEBUG_WOLFSSL) || defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY)
|
||||
|
||||
#if defined(OPENSSL_EXTRA) || defined(DEBUG_WOLFSSL_VERBOSE)
|
||||
WOLFSSL_API void WOLFSSL_ERROR_LINE(int err, const char* func, unsigned int line,
|
||||
const char* file, void* ctx);
|
||||
#define WOLFSSL_ERROR(x) \
|
||||
WOLFSSL_ERROR_LINE((x), __func__, __LINE__, __FILE__, NULL)
|
||||
#else
|
||||
WOLFSSL_API void WOLFSSL_ERROR(int err);
|
||||
#endif
|
||||
WOLFSSL_API void WOLFSSL_ERROR_MSG(const char* msg);
|
||||
|
||||
#else
|
||||
#define WOLFSSL_ERROR(e)
|
||||
#define WOLFSSL_ERROR_MSG(m)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* WOLFSSL_LOGGING_H */
|
||||
|
114
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/wolfcrypt/md5.h
Normal file
114
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/wolfcrypt/md5.h
Normal file
@ -0,0 +1,114 @@
|
||||
/* md5.h
|
||||
*
|
||||
* Copyright (C) 2006-2018 wolfSSL Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is distributed in binary form as licensed by Espressif Systems.
|
||||
* See README file or contact licensing@wolfssl.com with any questions or comments.
|
||||
*
|
||||
* https://www.wolfssl.com
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/md5.h
|
||||
*/
|
||||
|
||||
|
||||
#ifndef WOLF_CRYPT_MD5_H
|
||||
#define WOLF_CRYPT_MD5_H
|
||||
|
||||
#include <wolfssl/wolfcrypt/types.h>
|
||||
|
||||
#ifndef NO_MD5
|
||||
|
||||
#ifdef HAVE_FIPS
|
||||
#define wc_InitMd5 InitMd5
|
||||
#define wc_Md5Update Md5Update
|
||||
#define wc_Md5Final Md5Final
|
||||
#define wc_Md5Hash Md5Hash
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef NO_OLD_WC_NAMES
|
||||
#define Md5 wc_Md5
|
||||
#define MD5 WC_MD5
|
||||
#define MD5_BLOCK_SIZE WC_MD5_BLOCK_SIZE
|
||||
#define MD5_DIGEST_SIZE WC_MD5_DIGEST_SIZE
|
||||
#define WC_MD5_PAD_SIZE WC_MD5_PAD_SIZE
|
||||
#endif
|
||||
|
||||
/* in bytes */
|
||||
enum {
|
||||
WC_MD5 = WC_HASH_TYPE_MD5,
|
||||
WC_MD5_BLOCK_SIZE = 64,
|
||||
WC_MD5_DIGEST_SIZE = 16,
|
||||
WC_MD5_PAD_SIZE = 56
|
||||
};
|
||||
|
||||
|
||||
#ifdef WOLFSSL_MICROCHIP_PIC32MZ
|
||||
#include <wolfssl/wolfcrypt/port/pic32/pic32mz-crypt.h>
|
||||
#endif
|
||||
#ifdef STM32_HASH
|
||||
#include <wolfssl/wolfcrypt/port/st/stm32.h>
|
||||
#endif
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
#include <wolfssl/wolfcrypt/async.h>
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_TI_HASH
|
||||
#include "wolfssl/wolfcrypt/port/ti/ti-hash.h"
|
||||
#elif defined(WOLFSSL_IMX6_CAAM)
|
||||
#include "wolfssl/wolfcrypt/port/caam/wolfcaam_sha.h"
|
||||
#else
|
||||
|
||||
/* MD5 digest */
|
||||
typedef struct wc_Md5 {
|
||||
#ifdef STM32_HASH
|
||||
STM32_HASH_Context stmCtx;
|
||||
#else
|
||||
word32 buffLen; /* in bytes */
|
||||
word32 loLen; /* length in bytes */
|
||||
word32 hiLen; /* length in bytes */
|
||||
word32 buffer[WC_MD5_BLOCK_SIZE / sizeof(word32)];
|
||||
#ifdef WOLFSSL_PIC32MZ_HASH
|
||||
word32 digest[PIC32_DIGEST_SIZE / sizeof(word32)];
|
||||
#else
|
||||
word32 digest[WC_MD5_DIGEST_SIZE / sizeof(word32)];
|
||||
#endif
|
||||
void* heap;
|
||||
#ifdef WOLFSSL_PIC32MZ_HASH
|
||||
hashUpdCache cache; /* cache for updates */
|
||||
#endif
|
||||
#endif /* STM32_HASH */
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
WC_ASYNC_DEV asyncDev;
|
||||
#endif /* WOLFSSL_ASYNC_CRYPT */
|
||||
} wc_Md5;
|
||||
|
||||
#endif /* WOLFSSL_TI_HASH */
|
||||
|
||||
WOLFSSL_API int wc_InitMd5(wc_Md5*);
|
||||
WOLFSSL_API int wc_InitMd5_ex(wc_Md5*, void*, int);
|
||||
WOLFSSL_API int wc_Md5Update(wc_Md5*, const byte*, word32);
|
||||
WOLFSSL_API int wc_Md5Final(wc_Md5*, byte*);
|
||||
WOLFSSL_API void wc_Md5Free(wc_Md5*);
|
||||
|
||||
WOLFSSL_API int wc_Md5GetHash(wc_Md5*, byte*);
|
||||
WOLFSSL_API int wc_Md5Copy(wc_Md5*, wc_Md5*);
|
||||
|
||||
#ifdef WOLFSSL_PIC32MZ_HASH
|
||||
WOLFSSL_API void wc_Md5SizeSet(wc_Md5* md5, word32 len);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* NO_MD5 */
|
||||
#endif /* WOLF_CRYPT_MD5_H */
|
1011
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/wolfcrypt/mpi_class.h
Normal file
1011
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/wolfcrypt/mpi_class.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,88 @@
|
||||
/* mpi_superclass.h
|
||||
*
|
||||
* Copyright (C) 2006-2018 wolfSSL Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is distributed in binary form as licensed by Espressif Systems.
|
||||
* See README file or contact licensing@wolfssl.com with any questions or comments.
|
||||
*
|
||||
* https://www.wolfssl.com
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/* super class file for PK algos */
|
||||
|
||||
/* default ... include all MPI */
|
||||
#define LTM_ALL
|
||||
|
||||
/* RSA only (does not support DH/DSA/ECC) */
|
||||
/* #define SC_RSA_1 */
|
||||
|
||||
/* For reference.... On an Athlon64 optimizing for speed...
|
||||
|
||||
LTM's mpi.o with all functions [striped] is 142KiB in size.
|
||||
|
||||
*/
|
||||
|
||||
/* Works for RSA only, mpi.o is 68KiB */
|
||||
#ifdef SC_RSA_1
|
||||
#define BN_MP_SHRINK_C
|
||||
#define BN_MP_LCM_C
|
||||
#define BN_MP_PRIME_RANDOM_EX_C
|
||||
#define BN_MP_INVMOD_C
|
||||
#define BN_MP_GCD_C
|
||||
#define BN_MP_MOD_C
|
||||
#define BN_MP_MULMOD_C
|
||||
#define BN_MP_ADDMOD_C
|
||||
#define BN_MP_EXPTMOD_C
|
||||
#define BN_MP_SET_INT_C
|
||||
#define BN_MP_INIT_MULTI_C
|
||||
#define BN_MP_CLEAR_MULTI_C
|
||||
#define BN_MP_UNSIGNED_BIN_SIZE_C
|
||||
#define BN_MP_TO_UNSIGNED_BIN_C
|
||||
#define BN_MP_MOD_D_C
|
||||
#define BN_MP_PRIME_RABIN_MILLER_TRIALS_C
|
||||
#define BN_REVERSE_C
|
||||
#define BN_PRIME_TAB_C
|
||||
|
||||
/* other modifiers */
|
||||
#define BN_MP_DIV_SMALL /* Slower division, not critical */
|
||||
|
||||
/* here we are on the last pass so we turn things off. The functions classes are still there
|
||||
* but we remove them specifically from the build. This also invokes tweaks in functions
|
||||
* like removing support for even moduli, etc...
|
||||
*/
|
||||
#ifdef LTM_LAST
|
||||
#undef BN_MP_TOOM_MUL_C
|
||||
#undef BN_MP_TOOM_SQR_C
|
||||
#undef BN_MP_KARATSUBA_MUL_C
|
||||
#undef BN_MP_KARATSUBA_SQR_C
|
||||
#undef BN_MP_REDUCE_C
|
||||
#undef BN_MP_REDUCE_SETUP_C
|
||||
#undef BN_MP_DR_IS_MODULUS_C
|
||||
#undef BN_MP_DR_SETUP_C
|
||||
#undef BN_MP_DR_REDUCE_C
|
||||
#undef BN_MP_REDUCE_IS_2K_C
|
||||
#undef BN_MP_REDUCE_2K_SETUP_C
|
||||
#undef BN_MP_REDUCE_2K_C
|
||||
#undef BN_S_MP_EXPTMOD_C
|
||||
#undef BN_MP_DIV_3_C
|
||||
#undef BN_S_MP_MUL_HIGH_DIGS_C
|
||||
#undef BN_FAST_S_MP_MUL_HIGH_DIGS_C
|
||||
#undef BN_FAST_MP_INVMOD_C
|
||||
|
||||
/* To safely undefine these you have to make sure your RSA key won't exceed the Comba threshold
|
||||
* which is roughly 255 digits [7140 bits for 32-bit machines, 15300 bits for 64-bit machines]
|
||||
* which means roughly speaking you can handle up to 2536-bit RSA keys with these defined without
|
||||
* trouble.
|
||||
*/
|
||||
#undef BN_S_MP_MUL_DIGS_C
|
||||
#undef BN_S_MP_SQR_C
|
||||
#undef BN_MP_MONTGOMERY_REDUCE_C
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -0,0 +1,63 @@
|
||||
/* pwdbased.h
|
||||
*
|
||||
* Copyright (C) 2006-2018 wolfSSL Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is distributed in binary form as licensed by Espressif Systems.
|
||||
* See README file or contact licensing@wolfssl.com with any questions or comments.
|
||||
*
|
||||
* https://www.wolfssl.com
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/pwdbased.h
|
||||
*/
|
||||
|
||||
#ifndef WOLF_CRYPT_PWDBASED_H
|
||||
#define WOLF_CRYPT_PWDBASED_H
|
||||
|
||||
#include <wolfssl/wolfcrypt/types.h>
|
||||
|
||||
#ifndef NO_PWDBASED
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* hashType renamed to typeH to avoid shadowing global declaration here:
|
||||
* wolfssl/wolfcrypt/asn.h line 173 in enum Oid_Types
|
||||
*/
|
||||
WOLFSSL_API int wc_PBKDF1_ex(byte* key, int keyLen, byte* iv, int ivLen,
|
||||
const byte* passwd, int passwdLen,
|
||||
const byte* salt, int saltLen, int iterations,
|
||||
int hashType, void* heap);
|
||||
WOLFSSL_API int wc_PBKDF1(byte* output, const byte* passwd, int pLen,
|
||||
const byte* salt, int sLen, int iterations, int kLen,
|
||||
int typeH);
|
||||
WOLFSSL_API int wc_PBKDF2(byte* output, const byte* passwd, int pLen,
|
||||
const byte* salt, int sLen, int iterations, int kLen,
|
||||
int typeH);
|
||||
WOLFSSL_API int wc_PKCS12_PBKDF(byte* output, const byte* passwd, int pLen,
|
||||
const byte* salt, int sLen, int iterations,
|
||||
int kLen, int typeH, int purpose);
|
||||
WOLFSSL_API int wc_PKCS12_PBKDF_ex(byte* output, const byte* passwd,int passLen,
|
||||
const byte* salt, int saltLen, int iterations, int kLen,
|
||||
int hashType, int id, void* heap);
|
||||
|
||||
#ifdef HAVE_SCRYPT
|
||||
WOLFSSL_API int wc_scrypt(byte* output, const byte* passwd, int passLen,
|
||||
const byte* salt, int saltLen, int cost,
|
||||
int blockSize, int parallel, int dkLen);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* NO_PWDBASED */
|
||||
#endif /* WOLF_CRYPT_PWDBASED_H */
|
@ -0,0 +1,218 @@
|
||||
/* random.h
|
||||
*
|
||||
* Copyright (C) 2006-2018 wolfSSL Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is distributed in binary form as licensed by Espressif Systems.
|
||||
* See README file or contact licensing@wolfssl.com with any questions or comments.
|
||||
*
|
||||
* https://www.wolfssl.com
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/random.h
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef WOLF_CRYPT_RANDOM_H
|
||||
#define WOLF_CRYPT_RANDOM_H
|
||||
|
||||
#include <wolfssl/wolfcrypt/types.h>
|
||||
|
||||
#if defined(HAVE_FIPS) && \
|
||||
defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)
|
||||
#include <wolfssl/wolfcrypt/fips.h>
|
||||
#endif /* HAVE_FIPS_VERSION >= 2 */
|
||||
|
||||
/* included for fips @wc_fips */
|
||||
#if defined(HAVE_FIPS) && \
|
||||
(!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2))
|
||||
#include <cyassl/ctaocrypt/random.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Maximum generate block length */
|
||||
#ifndef RNG_MAX_BLOCK_LEN
|
||||
#ifdef HAVE_INTEL_QA
|
||||
#define RNG_MAX_BLOCK_LEN (0xFFFF)
|
||||
#else
|
||||
#define RNG_MAX_BLOCK_LEN (0x10000)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Size of the BRBG seed */
|
||||
#ifndef DRBG_SEED_LEN
|
||||
#define DRBG_SEED_LEN (440/8)
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(CUSTOM_RAND_TYPE)
|
||||
/* To maintain compatibility the default is byte */
|
||||
#define CUSTOM_RAND_TYPE byte
|
||||
#endif
|
||||
|
||||
/* make sure Hash DRBG is enabled, unless WC_NO_HASHDRBG is defined
|
||||
or CUSTOM_RAND_GENERATE_BLOCK is defined */
|
||||
#if !defined(WC_NO_HASHDRBG) && !defined(CUSTOM_RAND_GENERATE_BLOCK)
|
||||
#undef HAVE_HASHDRBG
|
||||
#define HAVE_HASHDRBG
|
||||
#ifndef WC_RESEED_INTERVAL
|
||||
#define WC_RESEED_INTERVAL (1000000)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* avoid redefinition of structs */
|
||||
#if !defined(HAVE_FIPS) || \
|
||||
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2))
|
||||
|
||||
/* RNG supports the following sources (in order):
|
||||
* 1. CUSTOM_RAND_GENERATE_BLOCK: Defines name of function as RNG source and
|
||||
* bypasses the options below.
|
||||
* 2. HAVE_INTEL_RDRAND: Uses the Intel RDRAND if supported by CPU.
|
||||
* 3. HAVE_HASHDRBG (requires SHA256 enabled): Uses SHA256 based P-RNG
|
||||
* seeded via wc_GenerateSeed. This is the default source.
|
||||
*/
|
||||
|
||||
/* Seed source can be overriden by defining one of these:
|
||||
CUSTOM_RAND_GENERATE_SEED
|
||||
CUSTOM_RAND_GENERATE_SEED_OS
|
||||
CUSTOM_RAND_GENERATE */
|
||||
|
||||
|
||||
#if defined(CUSTOM_RAND_GENERATE_BLOCK)
|
||||
/* To use define the following:
|
||||
* #define CUSTOM_RAND_GENERATE_BLOCK myRngFunc
|
||||
* extern int myRngFunc(byte* output, word32 sz);
|
||||
*/
|
||||
#elif defined(HAVE_HASHDRBG)
|
||||
#ifdef NO_SHA256
|
||||
#error "Hash DRBG requires SHA-256."
|
||||
#endif /* NO_SHA256 */
|
||||
#include <wolfssl/wolfcrypt/sha256.h>
|
||||
#elif defined(HAVE_WNR)
|
||||
/* allow whitewood as direct RNG source using wc_GenerateSeed directly */
|
||||
#elif defined(HAVE_INTEL_RDRAND)
|
||||
/* Intel RDRAND or RDSEED */
|
||||
#elif !defined(WC_NO_RNG)
|
||||
#error No RNG source defined!
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WNR
|
||||
#include <wnr.h>
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
#include <wolfssl/wolfcrypt/async.h>
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(USE_WINDOWS_API)
|
||||
#if defined(_WIN64)
|
||||
typedef unsigned __int64 ProviderHandle;
|
||||
/* type HCRYPTPROV, avoid #include <windows.h> */
|
||||
#else
|
||||
typedef unsigned long ProviderHandle;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* OS specific seeder */
|
||||
typedef struct OS_Seed {
|
||||
#if defined(USE_WINDOWS_API)
|
||||
ProviderHandle handle;
|
||||
#else
|
||||
int fd;
|
||||
#endif
|
||||
} OS_Seed;
|
||||
|
||||
|
||||
#ifndef WC_RNG_TYPE_DEFINED /* guard on redeclaration */
|
||||
typedef struct WC_RNG WC_RNG;
|
||||
#define WC_RNG_TYPE_DEFINED
|
||||
#endif
|
||||
|
||||
/* RNG context */
|
||||
struct WC_RNG {
|
||||
OS_Seed seed;
|
||||
void* heap;
|
||||
#ifdef HAVE_HASHDRBG
|
||||
/* Hash-based Deterministic Random Bit Generator */
|
||||
struct DRBG* drbg;
|
||||
byte status;
|
||||
#endif
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
WC_ASYNC_DEV asyncDev;
|
||||
int devId;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif /* NO FIPS or have FIPS v2*/
|
||||
|
||||
/* NO_OLD_RNGNAME removes RNG struct name to prevent possible type conflicts,
|
||||
* can't be used with CTaoCrypt FIPS */
|
||||
#if !defined(NO_OLD_RNGNAME) && !defined(HAVE_FIPS)
|
||||
#define RNG WC_RNG
|
||||
#endif
|
||||
|
||||
|
||||
WOLFSSL_LOCAL
|
||||
int wc_GenerateSeed(OS_Seed* os, byte* seed, word32 sz);
|
||||
|
||||
|
||||
#ifdef HAVE_WNR
|
||||
/* Whitewood netRandom client library */
|
||||
WOLFSSL_API int wc_InitNetRandom(const char*, wnr_hmac_key, int);
|
||||
WOLFSSL_API int wc_FreeNetRandom(void);
|
||||
#endif /* HAVE_WNR */
|
||||
|
||||
#ifndef WC_NO_RNG
|
||||
WOLFSSL_API int wc_InitRng(WC_RNG*);
|
||||
WOLFSSL_API int wc_InitRng_ex(WC_RNG* rng, void* heap, int devId);
|
||||
WOLFSSL_API int wc_InitRngNonce(WC_RNG* rng, byte* nonce, word32 nonceSz);
|
||||
WOLFSSL_API int wc_InitRngNonce_ex(WC_RNG* rng, byte* nonce, word32 nonceSz,
|
||||
void* heap, int devId);
|
||||
WOLFSSL_API int wc_RNG_GenerateBlock(WC_RNG*, byte*, word32 sz);
|
||||
WOLFSSL_API int wc_RNG_GenerateByte(WC_RNG*, byte*);
|
||||
WOLFSSL_API int wc_FreeRng(WC_RNG*);
|
||||
#else
|
||||
#include <wolfssl/wolfcrypt/error-crypt.h>
|
||||
#define wc_InitRng(rng) NOT_COMPILED_IN
|
||||
#define wc_InitRng_ex(rng, h, d) NOT_COMPILED_IN
|
||||
#define wc_InitRngNonce(rng, n, s) NOT_COMPILED_IN
|
||||
#define wc_InitRngNonce_ex(rng, n, s, h, d) NOT_COMPILED_IN
|
||||
#define wc_RNG_GenerateBlock(rng, b, s) NOT_COMPILED_IN
|
||||
#define wc_RNG_GenerateByte(rng, b) NOT_COMPILED_IN
|
||||
#define wc_FreeRng(rng) (void)NOT_COMPILED_IN
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef HAVE_HASHDRBG
|
||||
WOLFSSL_LOCAL int wc_RNG_DRBG_Reseed(WC_RNG* rng, const byte* entropy,
|
||||
word32 entropySz);
|
||||
WOLFSSL_API int wc_RNG_TestSeed(const byte* seed, word32 seedSz);
|
||||
WOLFSSL_API int wc_RNG_HealthTest(int reseed,
|
||||
const byte* entropyA, word32 entropyASz,
|
||||
const byte* entropyB, word32 entropyBSz,
|
||||
byte* output, word32 outputSz);
|
||||
WOLFSSL_API int wc_RNG_HealthTest_ex(int reseed,
|
||||
const byte* nonce, word32 nonceSz,
|
||||
const byte* entropyA, word32 entropyASz,
|
||||
const byte* entropyB, word32 entropyBSz,
|
||||
byte* output, word32 outputSz,
|
||||
void* heap, int devId);
|
||||
#endif /* HAVE_HASHDRBG */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* WOLF_CRYPT_RANDOM_H */
|
||||
|
1857
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/wolfcrypt/settings.h
Normal file
1857
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/wolfcrypt/settings.h
Normal file
File diff suppressed because it is too large
Load Diff
143
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/wolfcrypt/sha.h
Normal file
143
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/wolfcrypt/sha.h
Normal file
@ -0,0 +1,143 @@
|
||||
/* sha.h
|
||||
*
|
||||
* Copyright (C) 2006-2018 wolfSSL Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is distributed in binary form as licensed by Espressif Systems.
|
||||
* See README file or contact licensing@wolfssl.com with any questions or comments.
|
||||
*
|
||||
* https://www.wolfssl.com
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/sha.h
|
||||
*/
|
||||
|
||||
|
||||
#ifndef WOLF_CRYPT_SHA_H
|
||||
#define WOLF_CRYPT_SHA_H
|
||||
|
||||
#include <wolfssl/wolfcrypt/types.h>
|
||||
|
||||
#ifndef NO_SHA
|
||||
|
||||
#if defined(HAVE_FIPS) && \
|
||||
defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)
|
||||
#include <wolfssl/wolfcrypt/fips.h>
|
||||
#endif /* HAVE_FIPS_VERSION >= 2 */
|
||||
|
||||
#if defined(HAVE_FIPS) && \
|
||||
(!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2))
|
||||
#define wc_Sha Sha
|
||||
#define WC_SHA SHA
|
||||
#define WC_SHA_BLOCK_SIZE SHA_BLOCK_SIZE
|
||||
#define WC_SHA_DIGEST_SIZE SHA_DIGEST_SIZE
|
||||
#define WC_SHA_PAD_SIZE SHA_PAD_SIZE
|
||||
|
||||
/* for fips @wc_fips */
|
||||
#include <cyassl/ctaocrypt/sha.h>
|
||||
#endif
|
||||
|
||||
#ifdef FREESCALE_LTC_SHA
|
||||
#include "fsl_ltc.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* avoid redefinition of structs */
|
||||
#if !defined(HAVE_FIPS) || \
|
||||
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2))
|
||||
|
||||
#ifdef WOLFSSL_MICROCHIP_PIC32MZ
|
||||
#include <wolfssl/wolfcrypt/port/pic32/pic32mz-crypt.h>
|
||||
#endif
|
||||
#ifdef STM32_HASH
|
||||
#include <wolfssl/wolfcrypt/port/st/stm32.h>
|
||||
#endif
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
#include <wolfssl/wolfcrypt/async.h>
|
||||
#endif
|
||||
|
||||
#if !defined(NO_OLD_SHA_NAMES)
|
||||
#define SHA WC_SHA
|
||||
#endif
|
||||
|
||||
#ifndef NO_OLD_WC_NAMES
|
||||
#define Sha wc_Sha
|
||||
#define SHA_BLOCK_SIZE WC_SHA_BLOCK_SIZE
|
||||
#define SHA_DIGEST_SIZE WC_SHA_DIGEST_SIZE
|
||||
#define SHA_PAD_SIZE WC_SHA_PAD_SIZE
|
||||
#endif
|
||||
|
||||
/* in bytes */
|
||||
enum {
|
||||
WC_SHA = WC_HASH_TYPE_SHA,
|
||||
WC_SHA_BLOCK_SIZE = 64,
|
||||
WC_SHA_DIGEST_SIZE = 20,
|
||||
WC_SHA_PAD_SIZE = 56
|
||||
};
|
||||
|
||||
|
||||
#if defined(WOLFSSL_TI_HASH)
|
||||
#include "wolfssl/wolfcrypt/port/ti/ti-hash.h"
|
||||
|
||||
#elif defined(WOLFSSL_IMX6_CAAM)
|
||||
#include "wolfssl/wolfcrypt/port/caam/wolfcaam_sha.h"
|
||||
|
||||
#else
|
||||
/* Sha digest */
|
||||
typedef struct wc_Sha {
|
||||
#ifdef FREESCALE_LTC_SHA
|
||||
ltc_hash_ctx_t ctx;
|
||||
#elif defined(STM32_HASH)
|
||||
STM32_HASH_Context stmCtx;
|
||||
#else
|
||||
word32 buffLen; /* in bytes */
|
||||
word32 loLen; /* length in bytes */
|
||||
word32 hiLen; /* length in bytes */
|
||||
word32 buffer[WC_SHA_BLOCK_SIZE / sizeof(word32)];
|
||||
#ifdef WOLFSSL_PIC32MZ_HASH
|
||||
word32 digest[PIC32_DIGEST_SIZE / sizeof(word32)];
|
||||
#else
|
||||
word32 digest[WC_SHA_DIGEST_SIZE / sizeof(word32)];
|
||||
#endif
|
||||
void* heap;
|
||||
#ifdef WOLFSSL_PIC32MZ_HASH
|
||||
hashUpdCache cache; /* cache for updates */
|
||||
#endif
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
WC_ASYNC_DEV asyncDev;
|
||||
#endif /* WOLFSSL_ASYNC_CRYPT */
|
||||
#endif
|
||||
} wc_Sha;
|
||||
|
||||
#endif /* WOLFSSL_TI_HASH */
|
||||
|
||||
|
||||
#endif /* HAVE_FIPS */
|
||||
|
||||
WOLFSSL_API int wc_InitSha(wc_Sha*);
|
||||
WOLFSSL_API int wc_InitSha_ex(wc_Sha* sha, void* heap, int devId);
|
||||
WOLFSSL_API int wc_ShaUpdate(wc_Sha*, const byte*, word32);
|
||||
WOLFSSL_API int wc_ShaFinalRaw(wc_Sha*, byte*);
|
||||
WOLFSSL_API int wc_ShaFinal(wc_Sha*, byte*);
|
||||
WOLFSSL_API void wc_ShaFree(wc_Sha*);
|
||||
|
||||
WOLFSSL_API int wc_ShaGetHash(wc_Sha*, byte*);
|
||||
WOLFSSL_API int wc_ShaCopy(wc_Sha*, wc_Sha*);
|
||||
|
||||
#ifdef WOLFSSL_PIC32MZ_HASH
|
||||
WOLFSSL_API void wc_ShaSizeSet(wc_Sha* sha, word32 len);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* NO_SHA */
|
||||
#endif /* WOLF_CRYPT_SHA_H */
|
||||
|
@ -0,0 +1,209 @@
|
||||
/* sha256.h
|
||||
*
|
||||
* Copyright (C) 2006-2018 wolfSSL Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is distributed in binary form as licensed by Espressif Systems.
|
||||
* See README file or contact licensing@wolfssl.com with any questions or comments.
|
||||
*
|
||||
* https://www.wolfssl.com
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/sha256.h
|
||||
*/
|
||||
|
||||
|
||||
/* code submitted by raphael.huck@efixo.com */
|
||||
|
||||
#ifndef WOLF_CRYPT_SHA256_H
|
||||
#define WOLF_CRYPT_SHA256_H
|
||||
|
||||
#include <wolfssl/wolfcrypt/types.h>
|
||||
|
||||
#ifndef NO_SHA256
|
||||
|
||||
#if defined(HAVE_FIPS) && \
|
||||
defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)
|
||||
#include <wolfssl/wolfcrypt/fips.h>
|
||||
#endif /* HAVE_FIPS_VERSION >= 2 */
|
||||
|
||||
#if defined(HAVE_FIPS) && \
|
||||
(!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2))
|
||||
#define wc_Sha256 Sha256
|
||||
#define WC_SHA256 SHA256
|
||||
#define WC_SHA256_BLOCK_SIZE SHA256_BLOCK_SIZE
|
||||
#define WC_SHA256_DIGEST_SIZE SHA256_DIGEST_SIZE
|
||||
#define WC_SHA256_PAD_SIZE SHA256_PAD_SIZE
|
||||
|
||||
#ifdef WOLFSSL_SHA224
|
||||
#define wc_Sha224 Sha224
|
||||
#define WC_SHA224 SHA224
|
||||
#define WC_SHA224_BLOCK_SIZE SHA224_BLOCK_SIZE
|
||||
#define WC_SHA224_DIGEST_SIZE SHA224_DIGEST_SIZE
|
||||
#define WC_SHA224_PAD_SIZE SHA224_PAD_SIZE
|
||||
#endif
|
||||
|
||||
/* for fips @wc_fips */
|
||||
#include <cyassl/ctaocrypt/sha256.h>
|
||||
#endif
|
||||
|
||||
#ifdef FREESCALE_LTC_SHA
|
||||
#include "fsl_ltc.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* avoid redefinition of structs */
|
||||
#if !defined(HAVE_FIPS) || \
|
||||
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2))
|
||||
|
||||
#ifdef WOLFSSL_MICROCHIP_PIC32MZ
|
||||
#include <wolfssl/wolfcrypt/port/pic32/pic32mz-crypt.h>
|
||||
#endif
|
||||
#ifdef STM32_HASH
|
||||
#include <wolfssl/wolfcrypt/port/st/stm32.h>
|
||||
#endif
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
#include <wolfssl/wolfcrypt/async.h>
|
||||
#endif
|
||||
#if defined(WOLFSSL_DEVCRYPTO) && defined(WOLFSSL_DEVCRYPTO_HASH)
|
||||
#include <wolfssl/wolfcrypt/port/devcrypto/wc_devcrypto.h>
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define SHA256_NOINLINE __declspec(noinline)
|
||||
#elif defined(__GNUC__)
|
||||
#define SHA256_NOINLINE __attribute__((noinline))
|
||||
#else
|
||||
#define SHA256_NOINLINE
|
||||
#endif
|
||||
|
||||
#if !defined(NO_OLD_SHA_NAMES)
|
||||
#define SHA256 WC_SHA256
|
||||
#endif
|
||||
|
||||
#ifndef NO_OLD_WC_NAMES
|
||||
#define Sha256 wc_Sha256
|
||||
#define SHA256_BLOCK_SIZE WC_SHA256_BLOCK_SIZE
|
||||
#define SHA256_DIGEST_SIZE WC_SHA256_DIGEST_SIZE
|
||||
#define SHA256_PAD_SIZE WC_SHA256_PAD_SIZE
|
||||
#endif
|
||||
|
||||
/* in bytes */
|
||||
enum {
|
||||
WC_SHA256 = WC_HASH_TYPE_SHA256,
|
||||
WC_SHA256_BLOCK_SIZE = 64,
|
||||
WC_SHA256_DIGEST_SIZE = 32,
|
||||
WC_SHA256_PAD_SIZE = 56
|
||||
};
|
||||
|
||||
|
||||
#ifdef WOLFSSL_TI_HASH
|
||||
#include "wolfssl/wolfcrypt/port/ti/ti-hash.h"
|
||||
#elif defined(WOLFSSL_IMX6_CAAM)
|
||||
#include "wolfssl/wolfcrypt/port/caam/wolfcaam_sha.h"
|
||||
#elif defined(WOLFSSL_AFALG_HASH)
|
||||
#include "wolfssl/wolfcrypt/port/af_alg/afalg_hash.h"
|
||||
#else
|
||||
/* wc_Sha256 digest */
|
||||
typedef struct wc_Sha256 {
|
||||
#ifdef FREESCALE_LTC_SHA
|
||||
ltc_hash_ctx_t ctx;
|
||||
#elif defined(STM32_HASH)
|
||||
STM32_HASH_Context stmCtx;
|
||||
#else
|
||||
/* alignment on digest and buffer speeds up ARMv8 crypto operations */
|
||||
ALIGN16 word32 digest[WC_SHA256_DIGEST_SIZE / sizeof(word32)];
|
||||
ALIGN16 word32 buffer[WC_SHA256_BLOCK_SIZE / sizeof(word32)];
|
||||
word32 buffLen; /* in bytes */
|
||||
word32 loLen; /* length in bytes */
|
||||
word32 hiLen; /* length in bytes */
|
||||
void* heap;
|
||||
#ifdef USE_INTEL_SPEEDUP
|
||||
const byte* data;
|
||||
#endif
|
||||
#ifdef WOLFSSL_PIC32MZ_HASH
|
||||
hashUpdCache cache; /* cache for updates */
|
||||
#endif
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
WC_ASYNC_DEV asyncDev;
|
||||
#endif /* WOLFSSL_ASYNC_CRYPT */
|
||||
#ifdef WOLFSSL_SMALL_STACK_CACHE
|
||||
word32* W;
|
||||
#endif
|
||||
#ifdef WOLFSSL_DEVCRYPTO_HASH
|
||||
WC_CRYPTODEV ctx;
|
||||
byte* msg;
|
||||
word32 used;
|
||||
word32 len;
|
||||
#endif
|
||||
#endif
|
||||
} wc_Sha256;
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* HAVE_FIPS */
|
||||
|
||||
WOLFSSL_API int wc_InitSha256(wc_Sha256*);
|
||||
WOLFSSL_API int wc_InitSha256_ex(wc_Sha256*, void*, int);
|
||||
WOLFSSL_API int wc_Sha256Update(wc_Sha256*, const byte*, word32);
|
||||
WOLFSSL_API int wc_Sha256FinalRaw(wc_Sha256*, byte*);
|
||||
WOLFSSL_API int wc_Sha256Final(wc_Sha256*, byte*);
|
||||
WOLFSSL_API void wc_Sha256Free(wc_Sha256*);
|
||||
|
||||
WOLFSSL_API int wc_Sha256GetHash(wc_Sha256*, byte*);
|
||||
WOLFSSL_API int wc_Sha256Copy(wc_Sha256* src, wc_Sha256* dst);
|
||||
|
||||
#ifdef WOLFSSL_PIC32MZ_HASH
|
||||
WOLFSSL_API void wc_Sha256SizeSet(wc_Sha256*, word32);
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_SHA224
|
||||
/* avoid redefinition of structs */
|
||||
#if !defined(HAVE_FIPS) || \
|
||||
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2))
|
||||
|
||||
#ifndef NO_OLD_WC_NAMES
|
||||
#define Sha224 wc_Sha224
|
||||
#define SHA224 WC_SHA224
|
||||
#define SHA224_BLOCK_SIZE WC_SHA224_BLOCK_SIZE
|
||||
#define SHA224_DIGEST_SIZE WC_SHA224_DIGEST_SIZE
|
||||
#define SHA224_PAD_SIZE WC_SHA224_PAD_SIZE
|
||||
#endif
|
||||
|
||||
/* in bytes */
|
||||
enum {
|
||||
WC_SHA224 = WC_HASH_TYPE_SHA224,
|
||||
WC_SHA224_BLOCK_SIZE = WC_SHA256_BLOCK_SIZE,
|
||||
WC_SHA224_DIGEST_SIZE = 28,
|
||||
WC_SHA224_PAD_SIZE = WC_SHA256_PAD_SIZE
|
||||
};
|
||||
|
||||
|
||||
typedef wc_Sha256 wc_Sha224;
|
||||
#endif /* HAVE_FIPS */
|
||||
|
||||
WOLFSSL_API int wc_InitSha224(wc_Sha224*);
|
||||
WOLFSSL_API int wc_InitSha224_ex(wc_Sha224*, void*, int);
|
||||
WOLFSSL_API int wc_Sha224Update(wc_Sha224*, const byte*, word32);
|
||||
WOLFSSL_API int wc_Sha224Final(wc_Sha224*, byte*);
|
||||
WOLFSSL_API void wc_Sha224Free(wc_Sha224*);
|
||||
|
||||
WOLFSSL_API int wc_Sha224GetHash(wc_Sha224*, byte*);
|
||||
WOLFSSL_API int wc_Sha224Copy(wc_Sha224* src, wc_Sha224* dst);
|
||||
|
||||
#endif /* WOLFSSL_SHA224 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* NO_SHA256 */
|
||||
#endif /* WOLF_CRYPT_SHA256_H */
|
||||
|
758
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/wolfcrypt/types.h
Normal file
758
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/wolfcrypt/types.h
Normal file
@ -0,0 +1,758 @@
|
||||
/* types.h
|
||||
*
|
||||
* Copyright (C) 2006-2018 wolfSSL Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is distributed in binary form as licensed by Espressif Systems.
|
||||
* See README file or contact licensing@wolfssl.com with any questions or comments.
|
||||
*
|
||||
* https://www.wolfssl.com
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/types.h
|
||||
*/
|
||||
|
||||
#ifndef WOLF_CRYPT_TYPES_H
|
||||
#define WOLF_CRYPT_TYPES_H
|
||||
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
#include <wolfssl/wolfcrypt/wc_port.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(WORDS_BIGENDIAN)
|
||||
#define BIG_ENDIAN_ORDER
|
||||
#endif
|
||||
|
||||
#ifndef BIG_ENDIAN_ORDER
|
||||
#define LITTLE_ENDIAN_ORDER
|
||||
#endif
|
||||
|
||||
#ifndef WOLFSSL_TYPES
|
||||
#ifndef byte
|
||||
typedef unsigned char byte;
|
||||
#endif
|
||||
typedef unsigned short word16;
|
||||
typedef unsigned int word32;
|
||||
typedef byte word24[3];
|
||||
#endif
|
||||
|
||||
|
||||
/* try to set SIZEOF_LONG or LONG_LONG if user didn't */
|
||||
#if !defined(_MSC_VER) && !defined(__BCPLUSPLUS__) && !defined(__EMSCRIPTEN__)
|
||||
#if !defined(SIZEOF_LONG_LONG) && !defined(SIZEOF_LONG)
|
||||
#if (defined(__alpha__) || defined(__ia64__) || \
|
||||
defined(_ARCH_PPC64) || defined(__mips64) || \
|
||||
defined(__x86_64__) || \
|
||||
((defined(sun) || defined(__sun)) && \
|
||||
(defined(LP64) || defined(_LP64))))
|
||||
/* long should be 64bit */
|
||||
#define SIZEOF_LONG 8
|
||||
#elif defined(__i386__) || defined(__CORTEX_M3__)
|
||||
/* long long should be 64bit */
|
||||
#define SIZEOF_LONG_LONG 8
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) || defined(__BCPLUSPLUS__)
|
||||
#define WORD64_AVAILABLE
|
||||
#define W64LIT(x) x##ui64
|
||||
typedef unsigned __int64 word64;
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
#define WORD64_AVAILABLE
|
||||
#define W64LIT(x) x##ull
|
||||
typedef unsigned long long word64;
|
||||
#elif defined(SIZEOF_LONG) && SIZEOF_LONG == 8
|
||||
#define WORD64_AVAILABLE
|
||||
#define W64LIT(x) x##LL
|
||||
typedef unsigned long word64;
|
||||
#elif defined(SIZEOF_LONG_LONG) && SIZEOF_LONG_LONG == 8
|
||||
#define WORD64_AVAILABLE
|
||||
#define W64LIT(x) x##LL
|
||||
typedef unsigned long long word64;
|
||||
#elif defined(__SIZEOF_LONG_LONG__) && __SIZEOF_LONG_LONG__ == 8
|
||||
#define WORD64_AVAILABLE
|
||||
#define W64LIT(x) x##LL
|
||||
typedef unsigned long long word64;
|
||||
#endif
|
||||
|
||||
#if !defined(NO_64BIT) && defined(WORD64_AVAILABLE)
|
||||
/* These platforms have 64-bit CPU registers. */
|
||||
#if (defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) || \
|
||||
defined(__mips64) || defined(__x86_64__) || defined(_M_X64)) || \
|
||||
defined(__aarch64__) || defined(__sparc64__)
|
||||
typedef word64 wolfssl_word;
|
||||
#define WC_64BIT_CPU
|
||||
#elif (defined(sun) || defined(__sun)) && \
|
||||
(defined(LP64) || defined(_LP64))
|
||||
/* LP64 with GNU GCC compiler is reserved for when long int is 64 bits
|
||||
* and int uses 32 bits. When using Solaris Studio sparc and __sparc are
|
||||
* available for 32 bit detection but __sparc64__ could be missed. This
|
||||
* uses LP64 for checking 64 bit CPU arch. */
|
||||
typedef word64 wolfssl_word;
|
||||
#define WC_64BIT_CPU
|
||||
#else
|
||||
typedef word32 wolfssl_word;
|
||||
#ifdef WORD64_AVAILABLE
|
||||
#define WOLFCRYPT_SLOW_WORD64
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#undef WORD64_AVAILABLE
|
||||
typedef word32 wolfssl_word;
|
||||
#define MP_16BIT /* for mp_int, mp_word needs to be twice as big as
|
||||
mp_digit, no 64 bit type so make mp_digit 16 bit */
|
||||
#endif
|
||||
|
||||
enum {
|
||||
WOLFSSL_WORD_SIZE = sizeof(wolfssl_word),
|
||||
WOLFSSL_BIT_SIZE = 8,
|
||||
WOLFSSL_WORD_BITS = WOLFSSL_WORD_SIZE * WOLFSSL_BIT_SIZE
|
||||
};
|
||||
|
||||
#define WOLFSSL_MAX_16BIT 0xffffU
|
||||
|
||||
/* use inlining if compiler allows */
|
||||
#ifndef WC_INLINE
|
||||
#ifndef NO_INLINE
|
||||
#ifdef _MSC_VER
|
||||
#define WC_INLINE __inline
|
||||
#elif defined(__GNUC__)
|
||||
#ifdef WOLFSSL_VXWORKS
|
||||
#define WC_INLINE __inline__
|
||||
#else
|
||||
#define WC_INLINE inline
|
||||
#endif
|
||||
#elif defined(__IAR_SYSTEMS_ICC__)
|
||||
#define WC_INLINE inline
|
||||
#elif defined(THREADX)
|
||||
#define WC_INLINE _Inline
|
||||
#else
|
||||
#define WC_INLINE
|
||||
#endif
|
||||
#else
|
||||
#define WC_INLINE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_FIPS) || defined(HAVE_SELFTEST)
|
||||
#define INLINE WC_INLINE
|
||||
#endif
|
||||
|
||||
|
||||
/* set up rotate style */
|
||||
#if (defined(_MSC_VER) || defined(__BCPLUSPLUS__)) && \
|
||||
!defined(WOLFSSL_SGX) && !defined(INTIME_RTOS)
|
||||
#define INTEL_INTRINSICS
|
||||
#define FAST_ROTATE
|
||||
#elif defined(__MWERKS__) && TARGET_CPU_PPC
|
||||
#define PPC_INTRINSICS
|
||||
#define FAST_ROTATE
|
||||
#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
|
||||
/* GCC does peephole optimizations which should result in using rotate
|
||||
instructions */
|
||||
#define FAST_ROTATE
|
||||
#endif
|
||||
|
||||
|
||||
/* set up thread local storage if available */
|
||||
#ifdef HAVE_THREAD_LS
|
||||
#if defined(_MSC_VER)
|
||||
#define THREAD_LS_T __declspec(thread)
|
||||
/* Thread local storage only in FreeRTOS v8.2.1 and higher */
|
||||
#elif defined(FREERTOS) || defined(FREERTOS_TCP)
|
||||
#define THREAD_LS_T
|
||||
#else
|
||||
#define THREAD_LS_T __thread
|
||||
#endif
|
||||
#else
|
||||
#define THREAD_LS_T
|
||||
#endif
|
||||
|
||||
/* GCC 7 has new switch() fall-through detection */
|
||||
#if defined(__GNUC__)
|
||||
#if ((__GNUC__ > 7) || ((__GNUC__ == 7) && (__GNUC_MINOR__ >= 1)))
|
||||
#define FALL_THROUGH __attribute__ ((fallthrough))
|
||||
#endif
|
||||
#endif
|
||||
#ifndef FALL_THROUGH
|
||||
#define FALL_THROUGH
|
||||
#endif
|
||||
|
||||
/* Micrium will use Visual Studio for compilation but not the Win32 API */
|
||||
#if defined(_WIN32) && !defined(MICRIUM) && !defined(FREERTOS) && \
|
||||
!defined(FREERTOS_TCP) && !defined(EBSNET) && \
|
||||
!defined(WOLFSSL_UTASKER) && !defined(INTIME_RTOS)
|
||||
#define USE_WINDOWS_API
|
||||
#endif
|
||||
|
||||
|
||||
/* idea to add global alloc override by Moises Guimaraes */
|
||||
/* default to libc stuff */
|
||||
/* XREALLOC is used once in normal math lib, not in fast math lib */
|
||||
/* XFREE on some embedded systems doesn't like free(0) so test */
|
||||
#if defined(HAVE_IO_POOL)
|
||||
WOLFSSL_API void* XMALLOC(size_t n, void* heap, int type);
|
||||
WOLFSSL_API void* XREALLOC(void *p, size_t n, void* heap, int type);
|
||||
WOLFSSL_API void XFREE(void *p, void* heap, int type);
|
||||
#elif defined(WOLFSSL_ASYNC_CRYPT) && defined(HAVE_INTEL_QA)
|
||||
#include <wolfssl/wolfcrypt/port/intel/quickassist_mem.h>
|
||||
#undef USE_WOLFSSL_MEMORY
|
||||
#ifdef WOLFSSL_DEBUG_MEMORY
|
||||
#define XMALLOC(s, h, t) IntelQaMalloc((s), (h), (t), __func__, __LINE__)
|
||||
#define XFREE(p, h, t) IntelQaFree((p), (h), (t), __func__, __LINE__)
|
||||
#define XREALLOC(p, n, h, t) IntelQaRealloc((p), (n), (h), (t), __func__, __LINE__)
|
||||
#else
|
||||
#define XMALLOC(s, h, t) IntelQaMalloc((s), (h), (t))
|
||||
#define XFREE(p, h, t) IntelQaFree((p), (h), (t))
|
||||
#define XREALLOC(p, n, h, t) IntelQaRealloc((p), (n), (h), (t))
|
||||
#endif /* WOLFSSL_DEBUG_MEMORY */
|
||||
#elif defined(XMALLOC_USER)
|
||||
/* prototypes for user heap override functions */
|
||||
#include <stddef.h> /* for size_t */
|
||||
extern void *XMALLOC(size_t n, void* heap, int type);
|
||||
extern void *XREALLOC(void *p, size_t n, void* heap, int type);
|
||||
extern void XFREE(void *p, void* heap, int type);
|
||||
#elif defined(WOLFSSL_MEMORY_LOG)
|
||||
#define XMALLOC(n, h, t) xmalloc(n, h, t, __func__, __FILE__, __LINE__)
|
||||
#define XREALLOC(p, n, h, t) xrealloc(p, n, h, t, __func__, __FILE__, __LINE__)
|
||||
#define XFREE(p, h, t) xfree(p, h, t, __func__, __FILE__, __LINE__)
|
||||
|
||||
/* prototypes for user heap override functions */
|
||||
#include <stddef.h> /* for size_t */
|
||||
#include <stdlib.h>
|
||||
extern void *xmalloc(size_t n, void* heap, int type, const char* func,
|
||||
const char* file, unsigned int line);
|
||||
extern void *xrealloc(void *p, size_t n, void* heap, int type,
|
||||
const char* func, const char* file, unsigned int line);
|
||||
extern void xfree(void *p, void* heap, int type, const char* func,
|
||||
const char* file, unsigned int line);
|
||||
#elif defined(XMALLOC_OVERRIDE)
|
||||
/* override the XMALLOC, XFREE and XREALLOC macros */
|
||||
#elif defined(NO_WOLFSSL_MEMORY)
|
||||
/* just use plain C stdlib stuff if desired */
|
||||
#include <stdlib.h>
|
||||
#define XMALLOC(s, h, t) ((void)h, (void)t, malloc((s)))
|
||||
#define XFREE(p, h, t) {void* xp = (p); if((xp)) free((xp));}
|
||||
#define XREALLOC(p, n, h, t) realloc((p), (n))
|
||||
#elif !defined(MICRIUM_MALLOC) && !defined(EBSNET) \
|
||||
&& !defined(WOLFSSL_SAFERTOS) && !defined(FREESCALE_MQX) \
|
||||
&& !defined(FREESCALE_KSDK_MQX) && !defined(FREESCALE_FREE_RTOS) \
|
||||
&& !defined(WOLFSSL_LEANPSK) && !defined(WOLFSSL_uITRON4)
|
||||
/* default C runtime, can install different routines at runtime via cbs */
|
||||
#include <wolfssl/wolfcrypt/memory.h>
|
||||
#ifdef WOLFSSL_STATIC_MEMORY
|
||||
#ifdef WOLFSSL_DEBUG_MEMORY
|
||||
#define XMALLOC(s, h, t) wolfSSL_Malloc((s), (h), (t), __func__, __LINE__)
|
||||
#define XFREE(p, h, t) {void* xp = (p); if((xp)) wolfSSL_Free((xp), (h), (t), __func__, __LINE__);}
|
||||
#define XREALLOC(p, n, h, t) wolfSSL_Realloc((p), (n), (h), (t), __func__, __LINE__)
|
||||
#else
|
||||
#define XMALLOC(s, h, t) wolfSSL_Malloc((s), (h), (t))
|
||||
#define XFREE(p, h, t) {void* xp = (p); if((xp)) wolfSSL_Free((xp), (h), (t));}
|
||||
#define XREALLOC(p, n, h, t) wolfSSL_Realloc((p), (n), (h), (t))
|
||||
#endif /* WOLFSSL_DEBUG_MEMORY */
|
||||
#elif !defined(FREERTOS) && !defined(FREERTOS_TCP)
|
||||
#ifdef WOLFSSL_DEBUG_MEMORY
|
||||
#define XMALLOC(s, h, t) ((void)h, (void)t, wolfSSL_Malloc((s), __func__, __LINE__))
|
||||
#define XFREE(p, h, t) {void* xp = (p); if((xp)) wolfSSL_Free((xp), __func__, __LINE__);}
|
||||
#define XREALLOC(p, n, h, t) wolfSSL_Realloc((p), (n), __func__, __LINE__)
|
||||
#else
|
||||
#define XMALLOC(s, h, t) ((void)h, (void)t, wolfSSL_Malloc((s)))
|
||||
#define XFREE(p, h, t) {void* xp = (p); if((xp)) wolfSSL_Free((xp));}
|
||||
#define XREALLOC(p, n, h, t) wolfSSL_Realloc((p), (n))
|
||||
#endif /* WOLFSSL_DEBUG_MEMORY */
|
||||
#endif /* WOLFSSL_STATIC_MEMORY */
|
||||
#endif
|
||||
|
||||
/* declare/free variable handling for async */
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
#define DECLARE_VAR(VAR_NAME, VAR_TYPE, VAR_SIZE, HEAP) \
|
||||
VAR_TYPE* VAR_NAME = (VAR_TYPE*)XMALLOC(sizeof(VAR_TYPE) * VAR_SIZE, (HEAP), DYNAMIC_TYPE_WOLF_BIGINT);
|
||||
#define DECLARE_VAR_INIT(VAR_NAME, VAR_TYPE, VAR_SIZE, INIT_VALUE, HEAP) \
|
||||
VAR_TYPE* VAR_NAME = ({ \
|
||||
VAR_TYPE* ptr = (VAR_TYPE*)XMALLOC(sizeof(VAR_TYPE) * VAR_SIZE, (HEAP), DYNAMIC_TYPE_WOLF_BIGINT); \
|
||||
if (ptr && INIT_VALUE) { \
|
||||
XMEMCPY(ptr, INIT_VALUE, sizeof(VAR_TYPE) * VAR_SIZE); \
|
||||
} \
|
||||
ptr; \
|
||||
})
|
||||
#define DECLARE_ARRAY(VAR_NAME, VAR_TYPE, VAR_ITEMS, VAR_SIZE, HEAP) \
|
||||
VAR_TYPE* VAR_NAME[VAR_ITEMS]; \
|
||||
int idx##VAR_NAME; \
|
||||
for (idx##VAR_NAME=0; idx##VAR_NAME<VAR_ITEMS; idx##VAR_NAME++) { \
|
||||
VAR_NAME[idx##VAR_NAME] = (VAR_TYPE*)XMALLOC(VAR_SIZE, (HEAP), DYNAMIC_TYPE_WOLF_BIGINT); \
|
||||
}
|
||||
#define FREE_VAR(VAR_NAME, HEAP) \
|
||||
XFREE(VAR_NAME, (HEAP), DYNAMIC_TYPE_WOLF_BIGINT);
|
||||
#define FREE_ARRAY(VAR_NAME, VAR_ITEMS, HEAP) \
|
||||
for (idx##VAR_NAME=0; idx##VAR_NAME<VAR_ITEMS; idx##VAR_NAME++) { \
|
||||
XFREE(VAR_NAME[idx##VAR_NAME], (HEAP), DYNAMIC_TYPE_WOLF_BIGINT); \
|
||||
}
|
||||
#else
|
||||
#define DECLARE_VAR(VAR_NAME, VAR_TYPE, VAR_SIZE, HEAP) \
|
||||
VAR_TYPE VAR_NAME[VAR_SIZE]
|
||||
#define DECLARE_VAR_INIT(VAR_NAME, VAR_TYPE, VAR_SIZE, INIT_VALUE, HEAP) \
|
||||
VAR_TYPE* VAR_NAME = (VAR_TYPE*)INIT_VALUE
|
||||
#define DECLARE_ARRAY(VAR_NAME, VAR_TYPE, VAR_ITEMS, VAR_SIZE, HEAP) \
|
||||
VAR_TYPE VAR_NAME[VAR_ITEMS][VAR_SIZE]
|
||||
#define FREE_VAR(VAR_NAME, HEAP) /* nothing to free, its stack */
|
||||
#define FREE_ARRAY(VAR_NAME, VAR_ITEMS, HEAP) /* nothing to free, its stack */
|
||||
#endif
|
||||
|
||||
#if !defined(USE_WOLF_STRTOK) && \
|
||||
((defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)) || \
|
||||
defined(WOLFSSL_TIRTOS) || defined(WOLF_C99))
|
||||
#define USE_WOLF_STRTOK
|
||||
#endif
|
||||
#if !defined(USE_WOLF_STRSEP) && (defined(WOLF_C99))
|
||||
#define USE_WOLF_STRSEP
|
||||
#endif
|
||||
|
||||
#ifndef STRING_USER
|
||||
#include <string.h>
|
||||
#define XMEMCPY(d,s,l) memcpy((d),(s),(l))
|
||||
#define XMEMSET(b,c,l) memset((b),(c),(l))
|
||||
#define XMEMCMP(s1,s2,n) memcmp((s1),(s2),(n))
|
||||
#define XMEMMOVE(d,s,l) memmove((d),(s),(l))
|
||||
|
||||
#define XSTRLEN(s1) strlen((s1))
|
||||
#define XSTRNCPY(s1,s2,n) strncpy((s1),(s2),(n))
|
||||
/* strstr, strncmp, and strncat only used by wolfSSL proper,
|
||||
* not required for wolfCrypt only */
|
||||
#define XSTRSTR(s1,s2) strstr((s1),(s2))
|
||||
#define XSTRNSTR(s1,s2,n) mystrnstr((s1),(s2),(n))
|
||||
#define XSTRNCMP(s1,s2,n) strncmp((s1),(s2),(n))
|
||||
#define XSTRNCAT(s1,s2,n) strncat((s1),(s2),(n))
|
||||
|
||||
#ifdef USE_WOLF_STRSEP
|
||||
#define XSTRSEP(s1,d) wc_strsep((s1),(d))
|
||||
#else
|
||||
#define XSTRSEP(s1,d) strsep((s1),(d))
|
||||
#endif
|
||||
|
||||
#if defined(MICROCHIP_PIC32) || defined(WOLFSSL_TIRTOS)
|
||||
/* XC32 does not support strncasecmp, so use case sensitive one */
|
||||
#define XSTRNCASECMP(s1,s2,n) strncmp((s1),(s2),(n))
|
||||
#elif defined(USE_WINDOWS_API) || defined(FREERTOS_TCP_WINSIM)
|
||||
#define XSTRNCASECMP(s1,s2,n) _strnicmp((s1),(s2),(n))
|
||||
#else
|
||||
#if defined(HAVE_STRINGS_H) && defined(WOLF_C99) && \
|
||||
!defined(WOLFSSL_SGX)
|
||||
#include <strings.h>
|
||||
#endif
|
||||
#define XSTRNCASECMP(s1,s2,n) strncasecmp((s1),(s2),(n))
|
||||
#endif
|
||||
|
||||
/* snprintf is used in asn.c for GetTimeString, PKCS7 test, and when
|
||||
debugging is turned on */
|
||||
#ifndef USE_WINDOWS_API
|
||||
#if defined(NO_FILESYSTEM) && (defined(OPENSSL_EXTRA) || \
|
||||
defined(HAVE_PKCS7)) && !defined(NO_STDIO_FILESYSTEM)
|
||||
/* case where stdio is not included else where but is needed for
|
||||
* snprintf */
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
#define XSNPRINTF snprintf
|
||||
#else
|
||||
#define XSNPRINTF _snprintf
|
||||
#endif
|
||||
|
||||
#if defined(WOLFSSL_CERT_EXT) || defined(HAVE_ALPN)
|
||||
/* use only Thread Safe version of strtok */
|
||||
#if defined(USE_WOLF_STRTOK)
|
||||
#define XSTRTOK(s1,d,ptr) wc_strtok((s1),(d),(ptr))
|
||||
#elif defined(USE_WINDOWS_API) || defined(INTIME_RTOS)
|
||||
#define XSTRTOK(s1,d,ptr) strtok_s((s1),(d),(ptr))
|
||||
#else
|
||||
#define XSTRTOK(s1,d,ptr) strtok_r((s1),(d),(ptr))
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef USE_WOLF_STRTOK
|
||||
WOLFSSL_API char* wc_strtok(char *str, const char *delim, char **nextp);
|
||||
#endif
|
||||
#ifdef USE_WOLF_STRSEP
|
||||
WOLFSSL_API char* wc_strsep(char **stringp, const char *delim);
|
||||
#endif
|
||||
|
||||
#if !defined(NO_FILESYSTEM) && defined(OPENSSL_EXTRA) && \
|
||||
!defined(NO_STDIO_FILESYSTEM)
|
||||
#ifndef XGETENV
|
||||
#include <stdlib.h>
|
||||
#define XGETENV getenv
|
||||
#endif
|
||||
#endif /* OPENSSL_EXTRA */
|
||||
|
||||
#ifndef CTYPE_USER
|
||||
#include <ctype.h>
|
||||
#if defined(HAVE_ECC) || defined(HAVE_OCSP) || \
|
||||
defined(WOLFSSL_KEY_GEN) || !defined(NO_DSA)
|
||||
#define XTOUPPER(c) toupper((c))
|
||||
#define XISALPHA(c) isalpha((c))
|
||||
#endif
|
||||
/* needed by wolfSSL_check_domain_name() */
|
||||
#define XTOLOWER(c) tolower((c))
|
||||
#endif
|
||||
|
||||
|
||||
/* memory allocation types for user hints */
|
||||
enum {
|
||||
DYNAMIC_TYPE_CA = 1,
|
||||
DYNAMIC_TYPE_CERT = 2,
|
||||
DYNAMIC_TYPE_KEY = 3,
|
||||
DYNAMIC_TYPE_FILE = 4,
|
||||
DYNAMIC_TYPE_SUBJECT_CN = 5,
|
||||
DYNAMIC_TYPE_PUBLIC_KEY = 6,
|
||||
DYNAMIC_TYPE_SIGNER = 7,
|
||||
DYNAMIC_TYPE_NONE = 8,
|
||||
DYNAMIC_TYPE_BIGINT = 9,
|
||||
DYNAMIC_TYPE_RSA = 10,
|
||||
DYNAMIC_TYPE_METHOD = 11,
|
||||
DYNAMIC_TYPE_OUT_BUFFER = 12,
|
||||
DYNAMIC_TYPE_IN_BUFFER = 13,
|
||||
DYNAMIC_TYPE_INFO = 14,
|
||||
DYNAMIC_TYPE_DH = 15,
|
||||
DYNAMIC_TYPE_DOMAIN = 16,
|
||||
DYNAMIC_TYPE_SSL = 17,
|
||||
DYNAMIC_TYPE_CTX = 18,
|
||||
DYNAMIC_TYPE_WRITEV = 19,
|
||||
DYNAMIC_TYPE_OPENSSL = 20,
|
||||
DYNAMIC_TYPE_DSA = 21,
|
||||
DYNAMIC_TYPE_CRL = 22,
|
||||
DYNAMIC_TYPE_REVOKED = 23,
|
||||
DYNAMIC_TYPE_CRL_ENTRY = 24,
|
||||
DYNAMIC_TYPE_CERT_MANAGER = 25,
|
||||
DYNAMIC_TYPE_CRL_MONITOR = 26,
|
||||
DYNAMIC_TYPE_OCSP_STATUS = 27,
|
||||
DYNAMIC_TYPE_OCSP_ENTRY = 28,
|
||||
DYNAMIC_TYPE_ALTNAME = 29,
|
||||
DYNAMIC_TYPE_SUITES = 30,
|
||||
DYNAMIC_TYPE_CIPHER = 31,
|
||||
DYNAMIC_TYPE_RNG = 32,
|
||||
DYNAMIC_TYPE_ARRAYS = 33,
|
||||
DYNAMIC_TYPE_DTLS_POOL = 34,
|
||||
DYNAMIC_TYPE_SOCKADDR = 35,
|
||||
DYNAMIC_TYPE_LIBZ = 36,
|
||||
DYNAMIC_TYPE_ECC = 37,
|
||||
DYNAMIC_TYPE_TMP_BUFFER = 38,
|
||||
DYNAMIC_TYPE_DTLS_MSG = 39,
|
||||
DYNAMIC_TYPE_X509 = 40,
|
||||
DYNAMIC_TYPE_TLSX = 41,
|
||||
DYNAMIC_TYPE_OCSP = 42,
|
||||
DYNAMIC_TYPE_SIGNATURE = 43,
|
||||
DYNAMIC_TYPE_HASHES = 44,
|
||||
DYNAMIC_TYPE_SRP = 45,
|
||||
DYNAMIC_TYPE_COOKIE_PWD = 46,
|
||||
DYNAMIC_TYPE_USER_CRYPTO = 47,
|
||||
DYNAMIC_TYPE_OCSP_REQUEST = 48,
|
||||
DYNAMIC_TYPE_X509_EXT = 49,
|
||||
DYNAMIC_TYPE_X509_STORE = 50,
|
||||
DYNAMIC_TYPE_X509_CTX = 51,
|
||||
DYNAMIC_TYPE_URL = 52,
|
||||
DYNAMIC_TYPE_DTLS_FRAG = 53,
|
||||
DYNAMIC_TYPE_DTLS_BUFFER = 54,
|
||||
DYNAMIC_TYPE_SESSION_TICK = 55,
|
||||
DYNAMIC_TYPE_PKCS = 56,
|
||||
DYNAMIC_TYPE_MUTEX = 57,
|
||||
DYNAMIC_TYPE_PKCS7 = 58,
|
||||
DYNAMIC_TYPE_AES_BUFFER = 59,
|
||||
DYNAMIC_TYPE_WOLF_BIGINT = 60,
|
||||
DYNAMIC_TYPE_ASN1 = 61,
|
||||
DYNAMIC_TYPE_LOG = 62,
|
||||
DYNAMIC_TYPE_WRITEDUP = 63,
|
||||
DYNAMIC_TYPE_PRIVATE_KEY = 64,
|
||||
DYNAMIC_TYPE_HMAC = 65,
|
||||
DYNAMIC_TYPE_ASYNC = 66,
|
||||
DYNAMIC_TYPE_ASYNC_NUMA = 67,
|
||||
DYNAMIC_TYPE_ASYNC_NUMA64 = 68,
|
||||
DYNAMIC_TYPE_CURVE25519 = 69,
|
||||
DYNAMIC_TYPE_ED25519 = 70,
|
||||
DYNAMIC_TYPE_SECRET = 71,
|
||||
DYNAMIC_TYPE_DIGEST = 72,
|
||||
DYNAMIC_TYPE_RSA_BUFFER = 73,
|
||||
DYNAMIC_TYPE_DCERT = 74,
|
||||
DYNAMIC_TYPE_STRING = 75,
|
||||
DYNAMIC_TYPE_PEM = 76,
|
||||
DYNAMIC_TYPE_DER = 77,
|
||||
DYNAMIC_TYPE_CERT_EXT = 78,
|
||||
DYNAMIC_TYPE_ALPN = 79,
|
||||
DYNAMIC_TYPE_ENCRYPTEDINFO= 80,
|
||||
DYNAMIC_TYPE_DIRCTX = 81,
|
||||
DYNAMIC_TYPE_HASHCTX = 82,
|
||||
DYNAMIC_TYPE_SEED = 83,
|
||||
DYNAMIC_TYPE_SYMMETRIC_KEY= 84,
|
||||
DYNAMIC_TYPE_ECC_BUFFER = 85,
|
||||
DYNAMIC_TYPE_QSH = 86,
|
||||
DYNAMIC_TYPE_SALT = 87,
|
||||
DYNAMIC_TYPE_HASH_TMP = 88,
|
||||
DYNAMIC_TYPE_BLOB = 89,
|
||||
DYNAMIC_TYPE_NAME_ENTRY = 90,
|
||||
};
|
||||
|
||||
/* max error buffer string size */
|
||||
#ifndef WOLFSSL_MAX_ERROR_SZ
|
||||
#define WOLFSSL_MAX_ERROR_SZ 80
|
||||
#endif
|
||||
|
||||
/* stack protection */
|
||||
enum {
|
||||
MIN_STACK_BUFFER = 8
|
||||
};
|
||||
|
||||
|
||||
/* Algorithm Types */
|
||||
enum wc_AlgoType {
|
||||
WC_ALGO_TYPE_NONE = 0,
|
||||
WC_ALGO_TYPE_HASH = 1,
|
||||
WC_ALGO_TYPE_CIPHER = 2,
|
||||
WC_ALGO_TYPE_PK = 3,
|
||||
|
||||
WC_ALGO_TYPE_MAX = WC_ALGO_TYPE_PK
|
||||
};
|
||||
|
||||
/* hash types */
|
||||
enum wc_HashType {
|
||||
#if defined(HAVE_SELFTEST) || defined(HAVE_FIPS)
|
||||
/* In selftest build, WC_* types are not mapped to WC_HASH_TYPE types.
|
||||
* Values here are based on old selftest hmac.h enum, with additions */
|
||||
WC_HASH_TYPE_NONE = 15,
|
||||
WC_HASH_TYPE_MD2 = 16,
|
||||
WC_HASH_TYPE_MD4 = 17,
|
||||
WC_HASH_TYPE_MD5 = 0,
|
||||
WC_HASH_TYPE_SHA = 1, /* SHA-1 (not old SHA-0) */
|
||||
WC_HASH_TYPE_SHA224 = 8,
|
||||
WC_HASH_TYPE_SHA256 = 2,
|
||||
WC_HASH_TYPE_SHA384 = 5,
|
||||
WC_HASH_TYPE_SHA512 = 4,
|
||||
WC_HASH_TYPE_MD5_SHA = 18,
|
||||
WC_HASH_TYPE_SHA3_224 = 10,
|
||||
WC_HASH_TYPE_SHA3_256 = 11,
|
||||
WC_HASH_TYPE_SHA3_384 = 12,
|
||||
WC_HASH_TYPE_SHA3_512 = 13,
|
||||
WC_HASH_TYPE_BLAKE2B = 14,
|
||||
|
||||
WC_HASH_TYPE_MAX = WC_HASH_TYPE_MD5_SHA
|
||||
#else
|
||||
WC_HASH_TYPE_NONE = 0,
|
||||
WC_HASH_TYPE_MD2 = 1,
|
||||
WC_HASH_TYPE_MD4 = 2,
|
||||
WC_HASH_TYPE_MD5 = 3,
|
||||
WC_HASH_TYPE_SHA = 4, /* SHA-1 (not old SHA-0) */
|
||||
WC_HASH_TYPE_SHA224 = 5,
|
||||
WC_HASH_TYPE_SHA256 = 6,
|
||||
WC_HASH_TYPE_SHA384 = 7,
|
||||
WC_HASH_TYPE_SHA512 = 8,
|
||||
WC_HASH_TYPE_MD5_SHA = 9,
|
||||
WC_HASH_TYPE_SHA3_224 = 10,
|
||||
WC_HASH_TYPE_SHA3_256 = 11,
|
||||
WC_HASH_TYPE_SHA3_384 = 12,
|
||||
WC_HASH_TYPE_SHA3_512 = 13,
|
||||
WC_HASH_TYPE_BLAKE2B = 14,
|
||||
|
||||
WC_HASH_TYPE_MAX = WC_HASH_TYPE_BLAKE2B
|
||||
#endif /* HAVE_SELFTEST */
|
||||
};
|
||||
|
||||
/* cipher types */
|
||||
enum wc_CipherType {
|
||||
WC_CIPHER_NONE = 0,
|
||||
WC_CIPHER_AES = 1,
|
||||
WC_CIPHER_AES_CBC = 2,
|
||||
WC_CIPHER_AES_GCM = 3,
|
||||
WC_CIPHER_AES_CTR = 4,
|
||||
WC_CIPHER_AES_XTS = 5,
|
||||
WC_CIPHER_AES_CFB = 6,
|
||||
WC_CIPHER_DES3 = 7,
|
||||
WC_CIPHER_DES = 8,
|
||||
WC_CIPHER_CHACHA = 9,
|
||||
WC_CIPHER_HC128 = 10,
|
||||
WC_CIPHER_IDEA = 11,
|
||||
|
||||
WC_CIPHER_MAX = WC_CIPHER_HC128
|
||||
};
|
||||
|
||||
/* PK=public key (asymmetric) based algorithms */
|
||||
enum wc_PkType {
|
||||
WC_PK_TYPE_NONE = 0,
|
||||
WC_PK_TYPE_RSA = 1,
|
||||
WC_PK_TYPE_DH = 2,
|
||||
WC_PK_TYPE_ECDH = 3,
|
||||
WC_PK_TYPE_ECDSA_SIGN = 4,
|
||||
WC_PK_TYPE_ECDSA_VERIFY = 5,
|
||||
WC_PK_TYPE_ED25519 = 6,
|
||||
WC_PK_TYPE_CURVE25519 = 7,
|
||||
WC_PK_TYPE_RSA_KEYGEN = 8,
|
||||
WC_PK_TYPE_EC_KEYGEN = 9,
|
||||
|
||||
WC_PK_TYPE_MAX = WC_PK_TYPE_EC_KEYGEN
|
||||
};
|
||||
|
||||
|
||||
/* settings detection for compile vs runtime math incompatibilities */
|
||||
enum {
|
||||
#if !defined(USE_FAST_MATH) && !defined(SIZEOF_LONG) && !defined(SIZEOF_LONG_LONG)
|
||||
CTC_SETTINGS = 0x0
|
||||
#elif !defined(USE_FAST_MATH) && defined(SIZEOF_LONG) && (SIZEOF_LONG == 8)
|
||||
CTC_SETTINGS = 0x1
|
||||
#elif !defined(USE_FAST_MATH) && defined(SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG == 8)
|
||||
CTC_SETTINGS = 0x2
|
||||
#elif !defined(USE_FAST_MATH) && defined(SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG == 4)
|
||||
CTC_SETTINGS = 0x4
|
||||
#elif defined(USE_FAST_MATH) && !defined(SIZEOF_LONG) && !defined(SIZEOF_LONG_LONG)
|
||||
CTC_SETTINGS = 0x8
|
||||
#elif defined(USE_FAST_MATH) && defined(SIZEOF_LONG) && (SIZEOF_LONG == 8)
|
||||
CTC_SETTINGS = 0x10
|
||||
#elif defined(USE_FAST_MATH) && defined(SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG == 8)
|
||||
CTC_SETTINGS = 0x20
|
||||
#elif defined(USE_FAST_MATH) && defined(SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG == 4)
|
||||
CTC_SETTINGS = 0x40
|
||||
#else
|
||||
#error "bad math long / long long settings"
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
WOLFSSL_API word32 CheckRunTimeSettings(void);
|
||||
|
||||
/* If user uses RSA, DH, DSA, or ECC math lib directly then fast math and long
|
||||
types need to match at compile time and run time, CheckCtcSettings will
|
||||
return 1 if a match otherwise 0 */
|
||||
#define CheckCtcSettings() (CTC_SETTINGS == CheckRunTimeSettings())
|
||||
|
||||
/* invalid device id */
|
||||
#define INVALID_DEVID -2
|
||||
|
||||
|
||||
/* AESNI requires alignment and ARMASM gains some performance from it */
|
||||
#if defined(WOLFSSL_AESNI) || defined(WOLFSSL_ARMASM) || defined(USE_INTEL_SPEEDUP)
|
||||
#if !defined(ALIGN16)
|
||||
#if defined(__GNUC__)
|
||||
#define ALIGN16 __attribute__ ( (aligned (16)))
|
||||
#elif defined(_MSC_VER)
|
||||
/* disable align warning, we want alignment ! */
|
||||
#pragma warning(disable: 4324)
|
||||
#define ALIGN16 __declspec (align (16))
|
||||
#else
|
||||
#define ALIGN16
|
||||
#endif
|
||||
#endif /* !ALIGN16 */
|
||||
|
||||
#if !defined (ALIGN32)
|
||||
#if defined (__GNUC__)
|
||||
#define ALIGN32 __attribute__ ( (aligned (32)))
|
||||
#elif defined(_MSC_VER)
|
||||
/* disable align warning, we want alignment ! */
|
||||
#pragma warning(disable: 4324)
|
||||
#define ALIGN32 __declspec (align (32))
|
||||
#else
|
||||
#define ALIGN32
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(ALIGN32)
|
||||
#if defined(__GNUC__)
|
||||
#define ALIGN32 __attribute__ ( (aligned (32)))
|
||||
#elif defined(_MSC_VER)
|
||||
/* disable align warning, we want alignment ! */
|
||||
#pragma warning(disable: 4324)
|
||||
#define ALIGN32 __declspec (align (32))
|
||||
#else
|
||||
#define ALIGN32
|
||||
#endif
|
||||
#endif /* !ALIGN32 */
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define ALIGN128 __attribute__ ( (aligned (128)))
|
||||
#elif defined(_MSC_VER)
|
||||
/* disable align warning, we want alignment ! */
|
||||
#pragma warning(disable: 4324)
|
||||
#define ALIGN128 __declspec (align (128))
|
||||
#else
|
||||
#define ALIGN128
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define ALIGN256 __attribute__ ( (aligned (256)))
|
||||
#elif defined(_MSC_VER)
|
||||
/* disable align warning, we want alignment ! */
|
||||
#pragma warning(disable: 4324)
|
||||
#define ALIGN256 __declspec (align (256))
|
||||
#else
|
||||
#define ALIGN256
|
||||
#endif
|
||||
|
||||
#else
|
||||
#ifndef ALIGN16
|
||||
#define ALIGN16
|
||||
#endif
|
||||
#ifndef ALIGN32
|
||||
#define ALIGN32
|
||||
#endif
|
||||
#ifndef ALIGN128
|
||||
#define ALIGN128
|
||||
#endif
|
||||
#ifndef ALIGN256
|
||||
#define ALIGN256
|
||||
#endif
|
||||
#endif /* WOLFSSL_AESNI || WOLFSSL_ARMASM */
|
||||
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef WOLFSSL_RIOT_OS
|
||||
#define EXIT_TEST(ret) exit(ret)
|
||||
#elif defined(HAVE_STACK_SIZE)
|
||||
#define EXIT_TEST(ret) return (void*)((size_t)(ret))
|
||||
#else
|
||||
#define EXIT_TEST(ret) return ret
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define WOLFSSL_PACK __attribute__ ((packed))
|
||||
#else
|
||||
#define WOLFSSL_PACK
|
||||
#endif
|
||||
|
||||
#ifndef __GNUC_PREREQ
|
||||
#if defined(__GNUC__) && defined(__GNUC_MINOR__)
|
||||
#define __GNUC_PREREQ(maj, min) \
|
||||
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
|
||||
#else
|
||||
#define __GNUC_PREREQ(maj, min) (0) /* not GNUC */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define WC_NORETURN __attribute__((noreturn))
|
||||
#else
|
||||
#define WC_NORETURN
|
||||
#endif
|
||||
|
||||
#if defined(WOLFSSL_KEY_GEN) || defined(HAVE_COMP_KEY) || \
|
||||
defined(WOLFSSL_DEBUG_MATH) || defined(DEBUG_WOLFSSL) || \
|
||||
defined(WOLFSSL_PUBLIC_MP) || defined(OPENSSL_EXTRA) || \
|
||||
(defined(HAVE_ECC) && defined(HAVE_ECC_KEY_EXPORT))
|
||||
#undef WC_MP_TO_RADIX
|
||||
#define WC_MP_TO_RADIX
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* WOLF_CRYPT_TYPES_H */
|
@ -0,0 +1,71 @@
|
||||
/* visibility.h
|
||||
*
|
||||
* Copyright (C) 2006-2018 wolfSSL Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is distributed in binary form as licensed by Espressif Systems.
|
||||
* See README file or contact licensing@wolfssl.com with any questions or comments.
|
||||
*
|
||||
* https://www.wolfssl.com
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* Visibility control macros */
|
||||
|
||||
#ifndef WOLF_CRYPT_VISIBILITY_H
|
||||
#define WOLF_CRYPT_VISIBILITY_H
|
||||
|
||||
|
||||
/* for compatibility and so that fips is using same name of macro @wc_fips */
|
||||
/* The following visibility wrappers are for old FIPS. New FIPS should use
|
||||
* the same as a non-FIPS build. */
|
||||
#if defined(HAVE_FIPS) && \
|
||||
(!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2))
|
||||
#include <cyassl/ctaocrypt/visibility.h>
|
||||
#define WOLFSSL_API CYASSL_API
|
||||
#define WOLFSSL_LOCAL CYASSL_LOCAL
|
||||
#else
|
||||
|
||||
/* WOLFSSL_API is used for the public API symbols.
|
||||
It either imports or exports (or does nothing for static builds)
|
||||
|
||||
WOLFSSL_LOCAL is used for non-API symbols (private).
|
||||
*/
|
||||
|
||||
#if defined(BUILDING_WOLFSSL)
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
#if defined(WOLFSSL_DLL)
|
||||
#define WOLFSSL_API __declspec(dllexport)
|
||||
#else
|
||||
#define WOLFSSL_API
|
||||
#endif
|
||||
#define WOLFSSL_LOCAL
|
||||
#elif defined(HAVE_VISIBILITY) && HAVE_VISIBILITY
|
||||
#define WOLFSSL_API __attribute__ ((visibility("default")))
|
||||
#define WOLFSSL_LOCAL __attribute__ ((visibility("hidden")))
|
||||
#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
|
||||
#define WOLFSSL_API __global
|
||||
#define WOLFSSL_LOCAL __hidden
|
||||
#else
|
||||
#define WOLFSSL_API
|
||||
#define WOLFSSL_LOCAL
|
||||
#endif /* HAVE_VISIBILITY */
|
||||
#else /* BUILDING_WOLFSSL */
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
#if defined(WOLFSSL_DLL)
|
||||
#define WOLFSSL_API __declspec(dllimport)
|
||||
#else
|
||||
#define WOLFSSL_API
|
||||
#endif
|
||||
#define WOLFSSL_LOCAL
|
||||
#else
|
||||
#define WOLFSSL_API
|
||||
#define WOLFSSL_LOCAL
|
||||
#endif
|
||||
#endif /* BUILDING_WOLFSSL */
|
||||
|
||||
#endif /* HAVE_FIPS */
|
||||
#endif /* WOLF_CRYPT_VISIBILITY_H */
|
||||
|
@ -0,0 +1,572 @@
|
||||
/* wc_port.h
|
||||
*
|
||||
* Copyright (C) 2006-2018 wolfSSL Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is distributed in binary form as licensed by Espressif Systems.
|
||||
* See README file or contact licensing@wolfssl.com with any questions or comments.
|
||||
*
|
||||
* https://www.wolfssl.com
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/wc_port.h
|
||||
*/
|
||||
|
||||
#ifndef WOLF_CRYPT_PORT_H
|
||||
#define WOLF_CRYPT_PORT_H
|
||||
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
#include <wolfssl/wolfcrypt/visibility.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Detect if compiler supports C99. "NO_WOLF_C99" can be defined in
|
||||
* user_settings.h to disable checking for C99 support. */
|
||||
#if !defined(WOLF_C99) && defined(__STDC_VERSION__) && \
|
||||
!defined(WOLFSSL_ARDUINO) && !defined(NO_WOLF_C99)
|
||||
#if __STDC_VERSION__ >= 199901L
|
||||
#define WOLF_C99
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef USE_WINDOWS_API
|
||||
#ifdef WOLFSSL_GAME_BUILD
|
||||
#include "system/xtl.h"
|
||||
#else
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#ifndef WOLFSSL_SGX
|
||||
#if defined(_WIN32_WCE) || defined(WIN32_LEAN_AND_MEAN)
|
||||
/* On WinCE winsock2.h must be included before windows.h */
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#endif /* WOLFSSL_SGX */
|
||||
#endif
|
||||
#elif defined(THREADX)
|
||||
#ifndef SINGLE_THREADED
|
||||
#ifdef NEED_THREADX_TYPES
|
||||
#include <types.h>
|
||||
#endif
|
||||
#include <tx_api.h>
|
||||
#endif
|
||||
#elif defined(MICRIUM)
|
||||
/* do nothing, just don't pick Unix */
|
||||
#elif defined(FREERTOS) || defined(FREERTOS_TCP) || defined(WOLFSSL_SAFERTOS)
|
||||
/* do nothing */
|
||||
#elif defined(EBSNET)
|
||||
/* do nothing */
|
||||
#elif defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX)
|
||||
/* do nothing */
|
||||
#elif defined(FREESCALE_FREE_RTOS)
|
||||
#include "fsl_os_abstraction.h"
|
||||
#elif defined(WOLFSSL_VXWORKS)
|
||||
#include <semLib.h>
|
||||
#elif defined(WOLFSSL_uITRON4)
|
||||
#include "stddef.h"
|
||||
#include "kernel.h"
|
||||
#elif defined(WOLFSSL_uTKERNEL2)
|
||||
#include "tk/tkernel.h"
|
||||
#elif defined(WOLFSSL_CMSIS_RTOS)
|
||||
#include "cmsis_os.h"
|
||||
#elif defined(WOLFSSL_MDK_ARM)
|
||||
#if defined(WOLFSSL_MDK5)
|
||||
#include "cmsis_os.h"
|
||||
#else
|
||||
#include <rtl.h>
|
||||
#endif
|
||||
#elif defined(WOLFSSL_CMSIS_RTOS)
|
||||
#include "cmsis_os.h"
|
||||
#elif defined(WOLFSSL_TIRTOS)
|
||||
#include <ti/sysbios/BIOS.h>
|
||||
#include <ti/sysbios/knl/Semaphore.h>
|
||||
#elif defined(WOLFSSL_FROSTED)
|
||||
#include <semaphore.h>
|
||||
#elif defined(INTIME_RTOS)
|
||||
#include <rt.h>
|
||||
#include <io.h>
|
||||
#elif defined(WOLFSSL_NUCLEUS_1_2)
|
||||
/* NU_DEBUG needed struct access in nucleus_realloc */
|
||||
#define NU_DEBUG
|
||||
#include "plus/nucleus.h"
|
||||
#include "nucleus.h"
|
||||
#elif defined(WOLFSSL_APACHE_MYNEWT)
|
||||
/* do nothing */
|
||||
#else
|
||||
#ifndef SINGLE_THREADED
|
||||
#define WOLFSSL_PTHREADS
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
#if defined(OPENSSL_EXTRA) || defined(GOAHEAD_WS)
|
||||
#include <unistd.h> /* for close of BIO */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* For FIPS keep the function names the same */
|
||||
#ifdef HAVE_FIPS
|
||||
#define wc_InitMutex InitMutex
|
||||
#define wc_FreeMutex FreeMutex
|
||||
#define wc_LockMutex LockMutex
|
||||
#define wc_UnLockMutex UnLockMutex
|
||||
#endif /* HAVE_FIPS */
|
||||
|
||||
#ifdef SINGLE_THREADED
|
||||
typedef int wolfSSL_Mutex;
|
||||
#else /* MULTI_THREADED */
|
||||
/* FREERTOS comes first to enable use of FreeRTOS Windows simulator only */
|
||||
#if defined(FREERTOS)
|
||||
typedef xSemaphoreHandle wolfSSL_Mutex;
|
||||
#elif defined(FREERTOS_TCP)
|
||||
#include "FreeRTOS.h"
|
||||
#include "semphr.h"
|
||||
typedef SemaphoreHandle_t wolfSSL_Mutex;
|
||||
#elif defined(WOLFSSL_SAFERTOS)
|
||||
typedef struct wolfSSL_Mutex {
|
||||
signed char mutexBuffer[portQUEUE_OVERHEAD_BYTES];
|
||||
xSemaphoreHandle mutex;
|
||||
} wolfSSL_Mutex;
|
||||
#elif defined(USE_WINDOWS_API)
|
||||
typedef CRITICAL_SECTION wolfSSL_Mutex;
|
||||
#elif defined(WOLFSSL_PTHREADS)
|
||||
typedef pthread_mutex_t wolfSSL_Mutex;
|
||||
#elif defined(THREADX)
|
||||
typedef TX_MUTEX wolfSSL_Mutex;
|
||||
#elif defined(MICRIUM)
|
||||
typedef OS_MUTEX wolfSSL_Mutex;
|
||||
#elif defined(EBSNET)
|
||||
typedef RTP_MUTEX wolfSSL_Mutex;
|
||||
#elif defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX)
|
||||
typedef MUTEX_STRUCT wolfSSL_Mutex;
|
||||
#elif defined(FREESCALE_FREE_RTOS)
|
||||
typedef mutex_t wolfSSL_Mutex;
|
||||
#elif defined(WOLFSSL_VXWORKS)
|
||||
typedef SEM_ID wolfSSL_Mutex;
|
||||
#elif defined(WOLFSSL_uITRON4)
|
||||
typedef struct wolfSSL_Mutex {
|
||||
T_CSEM sem ;
|
||||
ID id ;
|
||||
} wolfSSL_Mutex;
|
||||
#elif defined(WOLFSSL_uTKERNEL2)
|
||||
typedef struct wolfSSL_Mutex {
|
||||
T_CSEM sem ;
|
||||
ID id ;
|
||||
} wolfSSL_Mutex;
|
||||
#elif defined(WOLFSSL_MDK_ARM)
|
||||
#if defined(WOLFSSL_CMSIS_RTOS)
|
||||
typedef osMutexId wolfSSL_Mutex;
|
||||
#else
|
||||
typedef OS_MUT wolfSSL_Mutex;
|
||||
#endif
|
||||
#elif defined(WOLFSSL_CMSIS_RTOS)
|
||||
typedef osMutexId wolfSSL_Mutex;
|
||||
#elif defined(WOLFSSL_TIRTOS)
|
||||
typedef ti_sysbios_knl_Semaphore_Handle wolfSSL_Mutex;
|
||||
#elif defined(WOLFSSL_FROSTED)
|
||||
typedef mutex_t * wolfSSL_Mutex;
|
||||
#elif defined(INTIME_RTOS)
|
||||
typedef RTHANDLE wolfSSL_Mutex;
|
||||
#elif defined(WOLFSSL_NUCLEUS_1_2)
|
||||
typedef NU_SEMAPHORE wolfSSL_Mutex;
|
||||
#else
|
||||
#error Need a mutex type in multithreaded mode
|
||||
#endif /* USE_WINDOWS_API */
|
||||
#endif /* SINGLE_THREADED */
|
||||
|
||||
/* Enable crypt HW mutex for Freescale MMCAU or PIC32MZ */
|
||||
#if defined(FREESCALE_MMCAU) || defined(WOLFSSL_MICROCHIP_PIC32MZ)
|
||||
#ifndef WOLFSSL_CRYPT_HW_MUTEX
|
||||
#define WOLFSSL_CRYPT_HW_MUTEX 1
|
||||
#endif
|
||||
#endif /* FREESCALE_MMCAU */
|
||||
|
||||
#ifndef WOLFSSL_CRYPT_HW_MUTEX
|
||||
#define WOLFSSL_CRYPT_HW_MUTEX 0
|
||||
#endif
|
||||
|
||||
#if WOLFSSL_CRYPT_HW_MUTEX
|
||||
/* wolfSSL_CryptHwMutexInit is called on first wolfSSL_CryptHwMutexLock,
|
||||
however it's recommended to call this directly on Hw init to avoid possible
|
||||
race condition where two calls to wolfSSL_CryptHwMutexLock are made at
|
||||
the same time. */
|
||||
int wolfSSL_CryptHwMutexInit(void);
|
||||
int wolfSSL_CryptHwMutexLock(void);
|
||||
int wolfSSL_CryptHwMutexUnLock(void);
|
||||
#else
|
||||
/* Define stubs, since HW mutex is disabled */
|
||||
#define wolfSSL_CryptHwMutexInit() 0 /* Success */
|
||||
#define wolfSSL_CryptHwMutexLock() 0 /* Success */
|
||||
#define wolfSSL_CryptHwMutexUnLock() (void)0 /* Success */
|
||||
#endif /* WOLFSSL_CRYPT_HW_MUTEX */
|
||||
|
||||
/* Mutex functions */
|
||||
WOLFSSL_API int wc_InitMutex(wolfSSL_Mutex*);
|
||||
WOLFSSL_API wolfSSL_Mutex* wc_InitAndAllocMutex(void);
|
||||
WOLFSSL_API int wc_FreeMutex(wolfSSL_Mutex*);
|
||||
WOLFSSL_API int wc_LockMutex(wolfSSL_Mutex*);
|
||||
WOLFSSL_API int wc_UnLockMutex(wolfSSL_Mutex*);
|
||||
#if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER)
|
||||
/* dynamiclly set which mutex to use. unlock / lock is controlled by flag */
|
||||
typedef void (mutex_cb)(int flag, int type, const char* file, int line);
|
||||
|
||||
WOLFSSL_API int wc_LockMutex_ex(int flag, int type, const char* file, int line);
|
||||
WOLFSSL_API int wc_SetMutexCb(mutex_cb* cb);
|
||||
#endif
|
||||
|
||||
/* main crypto initialization function */
|
||||
WOLFSSL_API int wolfCrypt_Init(void);
|
||||
WOLFSSL_API int wolfCrypt_Cleanup(void);
|
||||
|
||||
/* filesystem abstraction layer, used by ssl.c */
|
||||
#ifndef NO_FILESYSTEM
|
||||
|
||||
#if defined(EBSNET)
|
||||
#include "vfapi.h"
|
||||
#include "vfile.h"
|
||||
|
||||
#define XFILE int
|
||||
#define XFOPEN(NAME, MODE) vf_open((const char *)NAME, VO_RDONLY, 0);
|
||||
#define XFSEEK vf_lseek
|
||||
#define XFTELL vf_tell
|
||||
#define XREWIND vf_rewind
|
||||
#define XFREAD(BUF, SZ, AMT, FD) vf_read(FD, BUF, SZ*AMT)
|
||||
#define XFWRITE(BUF, SZ, AMT, FD) vf_write(FD, BUF, SZ*AMT)
|
||||
#define XFCLOSE vf_close
|
||||
#define XSEEK_END VSEEK_END
|
||||
#define XBADFILE -1
|
||||
#define XFGETS(b,s,f) -2 /* Not ported yet */
|
||||
#elif defined(LSR_FS)
|
||||
#include <fs.h>
|
||||
#define XFILE struct fs_file*
|
||||
#define XFOPEN(NAME, MODE) fs_open((char*)NAME);
|
||||
#define XFSEEK(F, O, W) (void)F
|
||||
#define XFTELL(F) (F)->len
|
||||
#define XREWIND(F) (void)F
|
||||
#define XFREAD(BUF, SZ, AMT, F) fs_read(F, (char*)BUF, SZ*AMT)
|
||||
#define XFWRITE(BUF, SZ, AMT, F) fs_write(F, (char*)BUF, SZ*AMT)
|
||||
#define XFCLOSE fs_close
|
||||
#define XSEEK_END 0
|
||||
#define XBADFILE NULL
|
||||
#define XFGETS(b,s,f) -2 /* Not ported yet */
|
||||
#elif defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX)
|
||||
#define XFILE MQX_FILE_PTR
|
||||
#define XFOPEN fopen
|
||||
#define XFSEEK fseek
|
||||
#define XFTELL ftell
|
||||
#define XREWIND(F) fseek(F, 0, IO_SEEK_SET)
|
||||
#define XFREAD fread
|
||||
#define XFWRITE fwrite
|
||||
#define XFCLOSE fclose
|
||||
#define XSEEK_END IO_SEEK_END
|
||||
#define XBADFILE NULL
|
||||
#define XFGETS fgets
|
||||
#elif defined(MICRIUM)
|
||||
#include <fs_api.h>
|
||||
#define XFILE FS_FILE*
|
||||
#define XFOPEN fs_fopen
|
||||
#define XFSEEK fs_fseek
|
||||
#define XFTELL fs_ftell
|
||||
#define XREWIND fs_rewind
|
||||
#define XFREAD fs_fread
|
||||
#define XFWRITE fs_fwrite
|
||||
#define XFCLOSE fs_fclose
|
||||
#define XSEEK_END FS_SEEK_END
|
||||
#define XBADFILE NULL
|
||||
#define XFGETS(b,s,f) -2 /* Not ported yet */
|
||||
#elif defined(WOLFSSL_NUCLEUS_1_2)
|
||||
#include "fal/inc/fal.h"
|
||||
#define XFILE FILE*
|
||||
#define XFOPEN fopen
|
||||
#define XFSEEK fseek
|
||||
#define XFTELL ftell
|
||||
#define XREWIND rewind
|
||||
#define XFREAD fread
|
||||
#define XFWRITE fwrite
|
||||
#define XFCLOSE fclose
|
||||
#define XSEEK_END PSEEK_END
|
||||
#define XBADFILE NULL
|
||||
#elif defined(WOLFSSL_APACHE_MYNEWT)
|
||||
#include <fs/fs.h>
|
||||
#define XFILE struct fs_file*
|
||||
|
||||
#define XFOPEN mynewt_fopen
|
||||
#define XFSEEK mynewt_fseek
|
||||
#define XFTELL mynewt_ftell
|
||||
#define XREWIND mynewt_rewind
|
||||
#define XFREAD mynewt_fread
|
||||
#define XFWRITE mynewt_fwrite
|
||||
#define XFCLOSE mynewt_fclose
|
||||
#define XSEEK_END 2
|
||||
#define XBADFILE NULL
|
||||
#define XFGETS(b,s,f) -2 /* Not ported yet */
|
||||
#elif defined(WOLFSSL_USER_FILESYSTEM)
|
||||
/* To be defined in user_settings.h */
|
||||
#else
|
||||
/* stdio, default case */
|
||||
#include <stdio.h>
|
||||
#define XFILE FILE*
|
||||
#if defined(WOLFSSL_MDK_ARM)
|
||||
extern FILE * wolfSSL_fopen(const char *name, const char *mode) ;
|
||||
#define XFOPEN wolfSSL_fopen
|
||||
#else
|
||||
#define XFOPEN fopen
|
||||
#endif
|
||||
#define XFSEEK fseek
|
||||
#define XFTELL ftell
|
||||
#define XREWIND rewind
|
||||
#define XFREAD fread
|
||||
#define XFWRITE fwrite
|
||||
#define XFCLOSE fclose
|
||||
#define XSEEK_END SEEK_END
|
||||
#define XBADFILE NULL
|
||||
#define XFGETS fgets
|
||||
|
||||
#if !defined(USE_WINDOWS_API) && !defined(NO_WOLFSSL_DIR)\
|
||||
&& !defined(WOLFSSL_NUCLEUS) && !defined(WOLFSSL_NUCLEUS_1_2)
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef MAX_FILENAME_SZ
|
||||
#define MAX_FILENAME_SZ 256 /* max file name length */
|
||||
#endif
|
||||
#ifndef MAX_PATH
|
||||
#define MAX_PATH 256
|
||||
#endif
|
||||
|
||||
#if !defined(NO_WOLFSSL_DIR) && !defined(WOLFSSL_NUCLEUS) && \
|
||||
!defined(WOLFSSL_NUCLEUS_1_2)
|
||||
typedef struct ReadDirCtx {
|
||||
#ifdef USE_WINDOWS_API
|
||||
WIN32_FIND_DATAA FindFileData;
|
||||
HANDLE hFind;
|
||||
#else
|
||||
struct dirent* entry;
|
||||
DIR* dir;
|
||||
struct stat s;
|
||||
#endif
|
||||
char name[MAX_FILENAME_SZ];
|
||||
} ReadDirCtx;
|
||||
|
||||
#define WC_READDIR_NOFILE -1
|
||||
|
||||
WOLFSSL_API int wc_ReadDirFirst(ReadDirCtx* ctx, const char* path, char** name);
|
||||
WOLFSSL_API int wc_ReadDirNext(ReadDirCtx* ctx, const char* path, char** name);
|
||||
WOLFSSL_API void wc_ReadDirClose(ReadDirCtx* ctx);
|
||||
#endif /* !NO_WOLFSSL_DIR */
|
||||
|
||||
#endif /* !NO_FILESYSTEM */
|
||||
|
||||
/* Windows API defines its own min() macro. */
|
||||
#if defined(USE_WINDOWS_API)
|
||||
#if defined(min) || defined(WOLFSSL_MYSQL_COMPATIBLE)
|
||||
#define WOLFSSL_HAVE_MIN
|
||||
#endif /* min */
|
||||
#if defined(max) || defined(WOLFSSL_MYSQL_COMPATIBLE)
|
||||
#define WOLFSSL_HAVE_MAX
|
||||
#endif /* max */
|
||||
#endif /* USE_WINDOWS_API */
|
||||
|
||||
/* Time functions */
|
||||
#ifndef NO_ASN_TIME
|
||||
#if defined(USER_TIME)
|
||||
/* Use our gmtime and time_t/struct tm types.
|
||||
Only needs seconds since EPOCH using XTIME function.
|
||||
time_t XTIME(time_t * timer) {}
|
||||
*/
|
||||
#define WOLFSSL_GMTIME
|
||||
#define USE_WOLF_TM
|
||||
#define USE_WOLF_TIME_T
|
||||
|
||||
#elif defined(TIME_OVERRIDES)
|
||||
/* Override XTIME() and XGMTIME() functionality.
|
||||
Requires user to provide these functions:
|
||||
time_t XTIME(time_t * timer) {}
|
||||
struct tm* XGMTIME(const time_t* timer, struct tm* tmp) {}
|
||||
*/
|
||||
#ifndef HAVE_TIME_T_TYPE
|
||||
#define USE_WOLF_TIME_T
|
||||
#endif
|
||||
#ifndef HAVE_TM_TYPE
|
||||
#define USE_WOLF_TM
|
||||
#endif
|
||||
#define NEED_TMP_TIME
|
||||
|
||||
#elif defined(HAVE_RTP_SYS)
|
||||
#include "os.h" /* dc_rtc_api needs */
|
||||
#include "dc_rtc_api.h" /* to get current time */
|
||||
|
||||
/* uses parital <time.h> structures */
|
||||
#define XTIME(tl) (0)
|
||||
#define XGMTIME(c, t) rtpsys_gmtime((c))
|
||||
|
||||
#elif defined(MICRIUM)
|
||||
#include <clk.h>
|
||||
#include <time.h>
|
||||
#define XTIME(t1) micrium_time((t1))
|
||||
#define WOLFSSL_GMTIME
|
||||
|
||||
#elif defined(MICROCHIP_TCPIP_V5) || defined(MICROCHIP_TCPIP)
|
||||
#include <time.h>
|
||||
#define XTIME(t1) pic32_time((t1))
|
||||
#define XGMTIME(c, t) gmtime((c))
|
||||
|
||||
#elif defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX)
|
||||
#ifdef FREESCALE_MQX_4_0
|
||||
#include <time.h>
|
||||
extern time_t mqx_time(time_t* timer);
|
||||
#else
|
||||
#define HAVE_GMTIME_R
|
||||
#endif
|
||||
#define XTIME(t1) mqx_time((t1))
|
||||
|
||||
#elif defined(FREESCALE_KSDK_BM) || defined(FREESCALE_FREE_RTOS) || defined(FREESCALE_KSDK_FREERTOS)
|
||||
#include <time.h>
|
||||
#ifndef XTIME
|
||||
/*extern time_t ksdk_time(time_t* timer);*/
|
||||
#define XTIME(t1) ksdk_time((t1))
|
||||
#endif
|
||||
#define XGMTIME(c, t) gmtime((c))
|
||||
|
||||
#elif defined(WOLFSSL_ATMEL) && defined(WOLFSSL_ATMEL_TIME)
|
||||
#define XTIME(t1) atmel_get_curr_time_and_date((t1))
|
||||
#define WOLFSSL_GMTIME
|
||||
#define USE_WOLF_TM
|
||||
#define USE_WOLF_TIME_T
|
||||
|
||||
#elif defined(IDIRECT_DEV_TIME)
|
||||
/*Gets the timestamp from cloak software owned by VT iDirect
|
||||
in place of time() from <time.h> */
|
||||
#include <time.h>
|
||||
#define XTIME(t1) idirect_time((t1))
|
||||
#define XGMTIME(c, t) gmtime((c))
|
||||
|
||||
#elif defined(_WIN32_WCE)
|
||||
#include <windows.h>
|
||||
#define XTIME(t1) windows_time((t1))
|
||||
#define WOLFSSL_GMTIME
|
||||
|
||||
#elif defined(WOLFSSL_APACHE_MYNEWT)
|
||||
#include "os/os_time.h"
|
||||
#define XTIME(t1) mynewt_time((t1))
|
||||
#define WOLFSSL_GMTIME
|
||||
#define USE_WOLF_TM
|
||||
#define USE_WOLF_TIME_T
|
||||
#else
|
||||
/* default */
|
||||
/* uses complete <time.h> facility */
|
||||
#include <time.h>
|
||||
#if defined(HAVE_SYS_TIME_H)
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
/* PowerPC time_t is int */
|
||||
#ifdef __PPC__
|
||||
#define TIME_T_NOT_64BIT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef SIZEOF_TIME_T
|
||||
/* check if size of time_t from autoconf is less than 8 bytes (64bits) */
|
||||
#if SIZEOF_TIME_T < 8
|
||||
#undef TIME_T_NOT_64BIT
|
||||
#define TIME_T_NOT_64BIT
|
||||
#endif
|
||||
#endif
|
||||
#ifdef TIME_T_NOT_LONG
|
||||
/* one old reference to TIME_T_NOT_LONG in GCC-ARM example README
|
||||
* this keeps support for the old macro name */
|
||||
#undef TIME_T_NOT_64BIT
|
||||
#define TIME_T_NOT_64BIT
|
||||
#endif
|
||||
|
||||
/* Map default time functions */
|
||||
#if !defined(XTIME) && !defined(TIME_OVERRIDES) && !defined(USER_TIME)
|
||||
#define XTIME(tl) time((tl))
|
||||
#endif
|
||||
#if !defined(XGMTIME) && !defined(TIME_OVERRIDES)
|
||||
#if defined(WOLFSSL_GMTIME) || !defined(HAVE_GMTIME_R) || defined(WOLF_C99)
|
||||
#define XGMTIME(c, t) gmtime((c))
|
||||
#else
|
||||
#define XGMTIME(c, t) gmtime_r((c), (t))
|
||||
#define NEED_TMP_TIME
|
||||
#endif
|
||||
#endif
|
||||
#if !defined(XVALIDATE_DATE) && !defined(HAVE_VALIDATE_DATE)
|
||||
#define USE_WOLF_VALIDDATE
|
||||
#define XVALIDATE_DATE(d, f, t) ValidateDate((d), (f), (t))
|
||||
#endif
|
||||
|
||||
/* wolf struct tm and time_t */
|
||||
#if defined(USE_WOLF_TM)
|
||||
struct tm {
|
||||
int tm_sec; /* seconds after the minute [0-60] */
|
||||
int tm_min; /* minutes after the hour [0-59] */
|
||||
int tm_hour; /* hours since midnight [0-23] */
|
||||
int tm_mday; /* day of the month [1-31] */
|
||||
int tm_mon; /* months since January [0-11] */
|
||||
int tm_year; /* years since 1900 */
|
||||
int tm_wday; /* days since Sunday [0-6] */
|
||||
int tm_yday; /* days since January 1 [0-365] */
|
||||
int tm_isdst; /* Daylight Savings Time flag */
|
||||
long tm_gmtoff; /* offset from CUT in seconds */
|
||||
char *tm_zone; /* timezone abbreviation */
|
||||
};
|
||||
#endif /* USE_WOLF_TM */
|
||||
#if defined(USE_WOLF_TIME_T)
|
||||
typedef long time_t;
|
||||
#endif
|
||||
#if defined(USE_WOLF_SUSECONDS_T)
|
||||
typedef long suseconds_t;
|
||||
#endif
|
||||
#if defined(USE_WOLF_TIMEVAL_T)
|
||||
struct timeval
|
||||
{
|
||||
time_t tv_sec;
|
||||
suseconds_t tv_usec;
|
||||
};
|
||||
#endif
|
||||
|
||||
/* forward declarations */
|
||||
#if defined(USER_TIME)
|
||||
struct tm* gmtime(const time_t* timer);
|
||||
extern time_t XTIME(time_t * timer);
|
||||
|
||||
#ifdef STACK_TRAP
|
||||
/* for stack trap tracking, don't call os gmtime on OS X/linux,
|
||||
uses a lot of stack spce */
|
||||
extern time_t time(time_t * timer);
|
||||
#define XTIME(tl) time((tl))
|
||||
#endif /* STACK_TRAP */
|
||||
|
||||
#elif defined(TIME_OVERRIDES)
|
||||
extern time_t XTIME(time_t * timer);
|
||||
extern struct tm* XGMTIME(const time_t* timer, struct tm* tmp);
|
||||
#elif defined(WOLFSSL_GMTIME)
|
||||
struct tm* gmtime(const time_t* timer);
|
||||
#endif
|
||||
#endif /* NO_ASN_TIME */
|
||||
|
||||
#ifndef WOLFSSL_LEANPSK
|
||||
char* mystrnstr(const char* s1, const char* s2, unsigned int n);
|
||||
#endif
|
||||
|
||||
#ifndef FILE_BUFFER_SIZE
|
||||
#define FILE_BUFFER_SIZE 1024 /* default static file buffer size for input,
|
||||
will use dynamic buffer if not big enough */
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* WOLF_CRYPT_PORT_H */
|
||||
|
@ -0,0 +1,70 @@
|
||||
/* wolfmath.h
|
||||
*
|
||||
* Copyright (C) 2006-2018 wolfSSL Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is distributed in binary form as licensed by Espressif Systems.
|
||||
* See README file or contact licensing@wolfssl.com with any questions or comments.
|
||||
*
|
||||
* https://www.wolfssl.com
|
||||
*/
|
||||
|
||||
|
||||
#if defined(HAVE_WOLF_BIGINT) && !defined(WOLF_BIGINT_DEFINED)
|
||||
/* raw big integer */
|
||||
typedef struct WC_BIGINT {
|
||||
byte* buf;
|
||||
word32 len;
|
||||
void* heap;
|
||||
} WC_BIGINT;
|
||||
|
||||
#define WOLF_BIGINT_DEFINED
|
||||
#endif
|
||||
|
||||
|
||||
/* only define functions if mp_int has been declared */
|
||||
#ifdef MP_INT_DEFINED
|
||||
|
||||
#ifndef __WOLFMATH_H__
|
||||
#define __WOLFMATH_H__
|
||||
|
||||
/* timing resistance array */
|
||||
#if !defined(WC_NO_CACHE_RESISTANT) && \
|
||||
((defined(HAVE_ECC) && defined(ECC_TIMING_RESISTANT)) || \
|
||||
(defined(USE_FAST_MATH) && defined(TFM_TIMING_RESISTANT)))
|
||||
|
||||
extern const wolfssl_word wc_off_on_addr[2];
|
||||
#endif
|
||||
|
||||
/* common math functions */
|
||||
int get_digit_count(mp_int* a);
|
||||
mp_digit get_digit(mp_int* a, int n);
|
||||
int get_rand_digit(WC_RNG* rng, mp_digit* d);
|
||||
int mp_rand(mp_int* a, int digits, WC_RNG* rng);
|
||||
|
||||
enum {
|
||||
/* format type */
|
||||
WC_TYPE_HEX_STR = 1,
|
||||
WC_TYPE_UNSIGNED_BIN = 2,
|
||||
};
|
||||
|
||||
WOLFSSL_API int wc_export_int(mp_int* mp, byte* buf, word32* len,
|
||||
word32 keySz, int encType);
|
||||
|
||||
#ifdef HAVE_WOLF_BIGINT
|
||||
void wc_bigint_init(WC_BIGINT* a);
|
||||
int wc_bigint_alloc(WC_BIGINT* a, word32 sz);
|
||||
int wc_bigint_from_unsigned_bin(WC_BIGINT* a, const byte* in, word32 inlen);
|
||||
int wc_bigint_to_unsigned_bin(WC_BIGINT* a, byte* out, word32* outlen);
|
||||
void wc_bigint_zero(WC_BIGINT* a);
|
||||
void wc_bigint_free(WC_BIGINT* a);
|
||||
|
||||
int wc_mp_to_bigint(mp_int* src, WC_BIGINT* dst);
|
||||
int wc_mp_to_bigint_sz(mp_int* src, WC_BIGINT* dst, word32 sz);
|
||||
int wc_bigint_to_mp(WC_BIGINT* src, mp_int* dst);
|
||||
#endif /* HAVE_WOLF_BIGINT */
|
||||
|
||||
#endif /* __WOLFMATH_H__ */
|
||||
|
||||
#endif /* MP_INT_DEFINED */
|
514
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/wolfio.h
Normal file
514
components/esp-wolfssl/wolfssl/wolfssl/wolfssl/wolfio.h
Normal file
@ -0,0 +1,514 @@
|
||||
/* io.h
|
||||
*
|
||||
* Copyright (C) 2006-2018 wolfSSL Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL is distributed in binary form as licensed by Espressif Systems.
|
||||
* See README file or contact licensing@wolfssl.com with any questions or comments.
|
||||
*
|
||||
* https://www.wolfssl.com
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfio.h
|
||||
*/
|
||||
|
||||
#ifndef WOLFSSL_IO_H
|
||||
#define WOLFSSL_IO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Micrium uses NetSock I/O callbacks in wolfio.c */
|
||||
#if !defined(WOLFSSL_USER_IO)
|
||||
/* OCSP and CRL_IO require HTTP client */
|
||||
#if defined(HAVE_OCSP) || defined(HAVE_CRL_IO)
|
||||
#ifndef HAVE_HTTP_CLIENT
|
||||
#define HAVE_HTTP_CLIENT
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(WOLFSSL_USER_IO)
|
||||
/* Micrium uses NetSock I/O callbacks in wolfio.c */
|
||||
#if !defined(USE_WOLFSSL_IO) && !defined(MICRIUM) && !defined(WOLFSSL_CONTIKI)
|
||||
#define USE_WOLFSSL_IO
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(USE_WOLFSSL_IO) || defined(HAVE_HTTP_CLIENT)
|
||||
|
||||
#ifdef HAVE_LIBZ
|
||||
#include "zlib.h"
|
||||
#endif
|
||||
|
||||
#ifndef USE_WINDOWS_API
|
||||
#if defined(WOLFSSL_LWIP) && !defined(WOLFSSL_APACHE_MYNEWT)
|
||||
/* lwIP needs to be configured to use sockets API in this mode */
|
||||
/* LWIP_SOCKET 1 in lwip/opt.h or in build */
|
||||
#include "lwip/sockets.h"
|
||||
#ifndef LWIP_PROVIDE_ERRNO
|
||||
#include <errno.h>
|
||||
#define LWIP_PROVIDE_ERRNO 1
|
||||
#endif
|
||||
#elif defined(FREESCALE_MQX)
|
||||
#include <posix.h>
|
||||
#include <rtcs.h>
|
||||
#elif defined(FREESCALE_KSDK_MQX)
|
||||
#include <rtcs.h>
|
||||
#elif (defined(WOLFSSL_MDK_ARM) || defined(WOLFSSL_KEIL_TCP_NET))
|
||||
#include "cmsis_os.h"
|
||||
#include "rl_net.h"
|
||||
#include "errno.h"
|
||||
#elif defined(WOLFSSL_CMSIS_RTOS)
|
||||
#include "cmsis_os.h"
|
||||
#elif defined(WOLFSSL_TIRTOS)
|
||||
#include <sys/socket.h>
|
||||
#elif defined(FREERTOS_TCP)
|
||||
#include "FreeRTOS_Sockets.h"
|
||||
#elif defined(WOLFSSL_IAR_ARM)
|
||||
/* nothing */
|
||||
#elif defined(WOLFSSL_VXWORKS)
|
||||
#include <sockLib.h>
|
||||
#include <errno.h>
|
||||
#elif defined(WOLFSSL_NUCLEUS_1_2)
|
||||
#include <externs.h>
|
||||
#include <errno.h>
|
||||
#elif defined(WOLFSSL_ATMEL)
|
||||
#include "socket/include/socket.h"
|
||||
#elif defined(INTIME_RTOS)
|
||||
#undef MIN
|
||||
#undef MAX
|
||||
#include <rt.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#include <io.h>
|
||||
/* <sys/socket.h> defines these, to avoid conflict, do undef */
|
||||
#undef SOCKADDR
|
||||
#undef SOCKADDR_IN
|
||||
#elif defined(WOLFSSL_PRCONNECT_PRO)
|
||||
#include <prconnect_pro/prconnect_pro.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <netdb.h>
|
||||
#include <sys/ioctl.h>
|
||||
#elif defined(WOLFSSL_SGX)
|
||||
#include <errno.h>
|
||||
#elif defined(WOLFSSL_APACHE_MYNEWT) && !defined(WOLFSSL_LWIP)
|
||||
#include <mn_socket/mn_socket.h>
|
||||
#elif !defined(WOLFSSL_NO_SOCK)
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#ifndef EBSNET
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
|
||||
#if defined(HAVE_RTP_SYS)
|
||||
#include <socket.h>
|
||||
#elif defined(EBSNET)
|
||||
#include "rtipapi.h" /* errno */
|
||||
#include "socket.h"
|
||||
#elif !defined(DEVKITPRO) && !defined(WOLFSSL_PICOTCP) && !defined(WOLFSSL_CONTIKI)
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#ifdef __PPU
|
||||
#include <netex/errno.h>
|
||||
#else
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif /* USE_WINDOWS_API */
|
||||
|
||||
#ifdef __sun
|
||||
#include <sys/filio.h>
|
||||
#endif
|
||||
|
||||
#ifdef USE_WINDOWS_API
|
||||
/* no epipe yet */
|
||||
#ifndef WSAEPIPE
|
||||
#define WSAEPIPE -12345
|
||||
#endif
|
||||
#define SOCKET_EWOULDBLOCK WSAEWOULDBLOCK
|
||||
#define SOCKET_EAGAIN WSAETIMEDOUT
|
||||
#define SOCKET_ECONNRESET WSAECONNRESET
|
||||
#define SOCKET_EINTR WSAEINTR
|
||||
#define SOCKET_EPIPE WSAEPIPE
|
||||
#define SOCKET_ECONNREFUSED WSAENOTCONN
|
||||
#define SOCKET_ECONNABORTED WSAECONNABORTED
|
||||
#elif defined(__PPU)
|
||||
#define SOCKET_EWOULDBLOCK SYS_NET_EWOULDBLOCK
|
||||
#define SOCKET_EAGAIN SYS_NET_EAGAIN
|
||||
#define SOCKET_ECONNRESET SYS_NET_ECONNRESET
|
||||
#define SOCKET_EINTR SYS_NET_EINTR
|
||||
#define SOCKET_EPIPE SYS_NET_EPIPE
|
||||
#define SOCKET_ECONNREFUSED SYS_NET_ECONNREFUSED
|
||||
#define SOCKET_ECONNABORTED SYS_NET_ECONNABORTED
|
||||
#elif defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX)
|
||||
#if MQX_USE_IO_OLD
|
||||
/* RTCS old I/O doesn't have an EWOULDBLOCK */
|
||||
#define SOCKET_EWOULDBLOCK EAGAIN
|
||||
#define SOCKET_EAGAIN EAGAIN
|
||||
#define SOCKET_ECONNRESET RTCSERR_TCP_CONN_RESET
|
||||
#define SOCKET_EINTR EINTR
|
||||
#define SOCKET_EPIPE EPIPE
|
||||
#define SOCKET_ECONNREFUSED RTCSERR_TCP_CONN_REFUSED
|
||||
#define SOCKET_ECONNABORTED RTCSERR_TCP_CONN_ABORTED
|
||||
#else
|
||||
#define SOCKET_EWOULDBLOCK NIO_EWOULDBLOCK
|
||||
#define SOCKET_EAGAIN NIO_EAGAIN
|
||||
#define SOCKET_ECONNRESET NIO_ECONNRESET
|
||||
#define SOCKET_EINTR NIO_EINTR
|
||||
#define SOCKET_EPIPE NIO_EPIPE
|
||||
#define SOCKET_ECONNREFUSED NIO_ECONNREFUSED
|
||||
#define SOCKET_ECONNABORTED NIO_ECONNABORTED
|
||||
#endif
|
||||
#elif defined(WOLFSSL_MDK_ARM)|| defined(WOLFSSL_KEIL_TCP_NET)
|
||||
#define SOCKET_EWOULDBLOCK BSD_ERROR_WOULDBLOCK
|
||||
#define SOCKET_EAGAIN BSD_ERROR_LOCKED
|
||||
#define SOCKET_ECONNRESET BSD_ERROR_CLOSED
|
||||
#define SOCKET_EINTR BSD_ERROR
|
||||
#define SOCKET_EPIPE BSD_ERROR
|
||||
#define SOCKET_ECONNREFUSED BSD_ERROR
|
||||
#define SOCKET_ECONNABORTED BSD_ERROR
|
||||
#elif defined(WOLFSSL_PICOTCP)
|
||||
#define SOCKET_EWOULDBLOCK PICO_ERR_EAGAIN
|
||||
#define SOCKET_EAGAIN PICO_ERR_EAGAIN
|
||||
#define SOCKET_ECONNRESET PICO_ERR_ECONNRESET
|
||||
#define SOCKET_EINTR PICO_ERR_EINTR
|
||||
#define SOCKET_EPIPE PICO_ERR_EIO
|
||||
#define SOCKET_ECONNREFUSED PICO_ERR_ECONNREFUSED
|
||||
#define SOCKET_ECONNABORTED PICO_ERR_ESHUTDOWN
|
||||
#elif defined(FREERTOS_TCP)
|
||||
#define SOCKET_EWOULDBLOCK FREERTOS_EWOULDBLOCK
|
||||
#define SOCKET_EAGAIN FREERTOS_EWOULDBLOCK
|
||||
#define SOCKET_ECONNRESET FREERTOS_SOCKET_ERROR
|
||||
#define SOCKET_EINTR FREERTOS_SOCKET_ERROR
|
||||
#define SOCKET_EPIPE FREERTOS_SOCKET_ERROR
|
||||
#define SOCKET_ECONNREFUSED FREERTOS_SOCKET_ERROR
|
||||
#define SOCKET_ECONNABORTED FREERTOS_SOCKET_ERROR
|
||||
#elif defined(WOLFSSL_NUCLEUS_1_2)
|
||||
#define SOCKET_EWOULDBLOCK NU_WOULD_BLOCK
|
||||
#define SOCKET_EAGAIN NU_WOULD_BLOCK
|
||||
#define SOCKET_ECONNRESET NU_NOT_CONNECTED
|
||||
#define SOCKET_EINTR NU_NOT_CONNECTED
|
||||
#define SOCKET_EPIPE NU_NOT_CONNECTED
|
||||
#define SOCKET_ECONNREFUSED NU_CONNECTION_REFUSED
|
||||
#define SOCKET_ECONNABORTED NU_NOT_CONNECTED
|
||||
#else
|
||||
#define SOCKET_EWOULDBLOCK EWOULDBLOCK
|
||||
#define SOCKET_EAGAIN EAGAIN
|
||||
#define SOCKET_ECONNRESET ECONNRESET
|
||||
#define SOCKET_EINTR EINTR
|
||||
#define SOCKET_EPIPE EPIPE
|
||||
#define SOCKET_ECONNREFUSED ECONNREFUSED
|
||||
#define SOCKET_ECONNABORTED ECONNABORTED
|
||||
#endif /* USE_WINDOWS_API */
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef DEVKITPRO
|
||||
/* from network.h */
|
||||
int net_send(int, const void*, int, unsigned int);
|
||||
int net_recv(int, void*, int, unsigned int);
|
||||
#define SEND_FUNCTION net_send
|
||||
#define RECV_FUNCTION net_recv
|
||||
#elif defined(WOLFSSL_LWIP) && !defined(WOLFSSL_APACHE_MYNEWT)
|
||||
#define SEND_FUNCTION lwip_send
|
||||
#define RECV_FUNCTION lwip_recv
|
||||
#elif defined(WOLFSSL_PICOTCP)
|
||||
#define SEND_FUNCTION pico_send
|
||||
#define RECV_FUNCTION pico_recv
|
||||
#elif defined(FREERTOS_TCP)
|
||||
#define RECV_FUNCTION(a,b,c,d) FreeRTOS_recv((Socket_t)(a),(void*)(b), (size_t)(c), (BaseType_t)(d))
|
||||
#define SEND_FUNCTION(a,b,c,d) FreeRTOS_send((Socket_t)(a),(void*)(b), (size_t)(c), (BaseType_t)(d))
|
||||
#elif defined(WOLFSSL_VXWORKS)
|
||||
#define SEND_FUNCTION send
|
||||
#define RECV_FUNCTION recv
|
||||
#elif defined(WOLFSSL_NUCLEUS_1_2)
|
||||
#define SEND_FUNCTION NU_Send
|
||||
#define RECV_FUNCTION NU_Recv
|
||||
#else
|
||||
#define SEND_FUNCTION send
|
||||
#define RECV_FUNCTION recv
|
||||
#if !defined(HAVE_SOCKADDR) && !defined(WOLFSSL_NO_SOCK)
|
||||
#define HAVE_SOCKADDR
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef USE_WINDOWS_API
|
||||
typedef unsigned int SOCKET_T;
|
||||
#else
|
||||
typedef int SOCKET_T;
|
||||
#endif
|
||||
|
||||
#ifndef WOLFSSL_NO_SOCK
|
||||
#ifndef XSOCKLENT
|
||||
#ifdef USE_WINDOWS_API
|
||||
#define XSOCKLENT int
|
||||
#else
|
||||
#define XSOCKLENT socklen_t
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Socket Addr Support */
|
||||
#ifdef HAVE_SOCKADDR
|
||||
typedef struct sockaddr SOCKADDR;
|
||||
typedef struct sockaddr_storage SOCKADDR_S;
|
||||
typedef struct sockaddr_in SOCKADDR_IN;
|
||||
#ifdef WOLFSSL_IPV6
|
||||
typedef struct sockaddr_in6 SOCKADDR_IN6;
|
||||
#endif
|
||||
typedef struct hostent HOSTENT;
|
||||
#endif /* HAVE_SOCKADDR */
|
||||
|
||||
/* use gethostbyname for c99 */
|
||||
#ifdef WOLF_C99
|
||||
#undef HAVE_GETADDRINFO
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GETADDRINFO
|
||||
typedef struct addrinfo ADDRINFO;
|
||||
#endif
|
||||
#endif /* WOLFSSL_NO_SOCK */
|
||||
|
||||
|
||||
/* IO API's */
|
||||
#ifdef HAVE_IO_TIMEOUT
|
||||
WOLFSSL_API int wolfIO_SetBlockingMode(SOCKET_T sockfd, int non_blocking);
|
||||
WOLFSSL_API void wolfIO_SetTimeout(int to_sec);
|
||||
WOLFSSL_API int wolfIO_Select(SOCKET_T sockfd, int to_sec);
|
||||
#endif
|
||||
WOLFSSL_API int wolfIO_TcpConnect(SOCKET_T* sockfd, const char* ip,
|
||||
unsigned short port, int to_sec);
|
||||
WOLFSSL_API int wolfIO_Send(SOCKET_T sd, char *buf, int sz, int wrFlags);
|
||||
WOLFSSL_API int wolfIO_Recv(SOCKET_T sd, char *buf, int sz, int rdFlags);
|
||||
|
||||
#endif /* USE_WOLFSSL_IO || HAVE_HTTP_CLIENT */
|
||||
|
||||
|
||||
#ifdef USE_WINDOWS_API
|
||||
#ifndef CloseSocket
|
||||
#define CloseSocket(s) closesocket(s)
|
||||
#endif
|
||||
#define StartTCP() { WSADATA wsd; WSAStartup(0x0002, &wsd); }
|
||||
#elif defined(WOLFSSL_MDK_ARM) || defined(WOLFSSL_KEIL_TCP_NET)
|
||||
#ifndef CloseSocket
|
||||
extern int closesocket(int);
|
||||
#define CloseSocket(s) closesocket(s)
|
||||
#endif
|
||||
#define StartTCP()
|
||||
#else
|
||||
#ifndef CloseSocket
|
||||
#define CloseSocket(s) close(s)
|
||||
#endif
|
||||
#define StartTCP()
|
||||
#ifdef FREERTOS_TCP_WINSIM
|
||||
extern int close(int);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
WOLFSSL_API int BioSend(WOLFSSL* ssl, char *buf, int sz, void *ctx);
|
||||
WOLFSSL_API int BioReceive(WOLFSSL* ssl, char* buf, int sz, void* ctx);
|
||||
#if defined(USE_WOLFSSL_IO)
|
||||
/* default IO callbacks */
|
||||
WOLFSSL_API int EmbedReceive(WOLFSSL* ssl, char* buf, int sz, void* ctx);
|
||||
WOLFSSL_API int EmbedSend(WOLFSSL* ssl, char* buf, int sz, void* ctx);
|
||||
|
||||
#ifdef WOLFSSL_DTLS
|
||||
WOLFSSL_API int EmbedReceiveFrom(WOLFSSL* ssl, char* buf, int sz, void*);
|
||||
WOLFSSL_API int EmbedSendTo(WOLFSSL* ssl, char* buf, int sz, void* ctx);
|
||||
WOLFSSL_API int EmbedGenerateCookie(WOLFSSL* ssl, unsigned char* buf,
|
||||
int sz, void*);
|
||||
#ifdef WOLFSSL_MULTICAST
|
||||
WOLFSSL_API int EmbedReceiveFromMcast(WOLFSSL* ssl,
|
||||
char* buf, int sz, void*);
|
||||
#endif /* WOLFSSL_MULTICAST */
|
||||
#ifdef WOLFSSL_SESSION_EXPORT
|
||||
WOLFSSL_API int EmbedGetPeer(WOLFSSL* ssl, char* ip, int* ipSz,
|
||||
unsigned short* port, int* fam);
|
||||
WOLFSSL_API int EmbedSetPeer(WOLFSSL* ssl, char* ip, int ipSz,
|
||||
unsigned short port, int fam);
|
||||
#endif /* WOLFSSL_SESSION_EXPORT */
|
||||
#endif /* WOLFSSL_DTLS */
|
||||
#endif /* USE_WOLFSSL_IO */
|
||||
|
||||
#ifdef HAVE_OCSP
|
||||
WOLFSSL_API int wolfIO_HttpBuildRequestOcsp(const char* domainName,
|
||||
const char* path, int ocspReqSz, unsigned char* buf, int bufSize);
|
||||
WOLFSSL_API int wolfIO_HttpProcessResponseOcsp(int sfd,
|
||||
unsigned char** respBuf, unsigned char* httpBuf, int httpBufSz,
|
||||
void* heap);
|
||||
|
||||
WOLFSSL_API int EmbedOcspLookup(void*, const char*, int, unsigned char*,
|
||||
int, unsigned char**);
|
||||
WOLFSSL_API void EmbedOcspRespFree(void*, unsigned char*);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CRL_IO
|
||||
WOLFSSL_API int wolfIO_HttpBuildRequestCrl(const char* url, int urlSz,
|
||||
const char* domainName, unsigned char* buf, int bufSize);
|
||||
WOLFSSL_API int wolfIO_HttpProcessResponseCrl(WOLFSSL_CRL* crl, int sfd,
|
||||
unsigned char* httpBuf, int httpBufSz);
|
||||
|
||||
WOLFSSL_API int EmbedCrlLookup(WOLFSSL_CRL* crl, const char* url,
|
||||
int urlSz);
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(HAVE_HTTP_CLIENT)
|
||||
WOLFSSL_API int wolfIO_DecodeUrl(const char* url, int urlSz, char* outName,
|
||||
char* outPath, unsigned short* outPort);
|
||||
|
||||
WOLFSSL_API int wolfIO_HttpBuildRequest(const char* reqType,
|
||||
const char* domainName, const char* path, int pathLen, int reqSz,
|
||||
const char* contentType, unsigned char* buf, int bufSize);
|
||||
WOLFSSL_API int wolfIO_HttpProcessResponse(int sfd, const char** appStrList,
|
||||
unsigned char** respBuf, unsigned char* httpBuf, int httpBufSz,
|
||||
int dynType, void* heap);
|
||||
#endif /* HAVE_HTTP_CLIENT */
|
||||
|
||||
|
||||
/* I/O callbacks */
|
||||
typedef int (*CallbackIORecv)(WOLFSSL *ssl, char *buf, int sz, void *ctx);
|
||||
typedef int (*CallbackIOSend)(WOLFSSL *ssl, char *buf, int sz, void *ctx);
|
||||
WOLFSSL_API void wolfSSL_CTX_SetIORecv(WOLFSSL_CTX*, CallbackIORecv);
|
||||
WOLFSSL_API void wolfSSL_CTX_SetIOSend(WOLFSSL_CTX*, CallbackIOSend);
|
||||
/* deprecated old name */
|
||||
#define wolfSSL_SetIORecv wolfSSL_CTX_SetIORecv
|
||||
#define wolfSSL_SetIOSend wolfSSL_CTX_SetIOSend
|
||||
|
||||
WOLFSSL_API void wolfSSL_SetIOReadCtx( WOLFSSL* ssl, void *ctx);
|
||||
WOLFSSL_API void wolfSSL_SetIOWriteCtx(WOLFSSL* ssl, void *ctx);
|
||||
|
||||
WOLFSSL_API void* wolfSSL_GetIOReadCtx( WOLFSSL* ssl);
|
||||
WOLFSSL_API void* wolfSSL_GetIOWriteCtx(WOLFSSL* ssl);
|
||||
|
||||
WOLFSSL_API void wolfSSL_SetIOReadFlags( WOLFSSL* ssl, int flags);
|
||||
WOLFSSL_API void wolfSSL_SetIOWriteFlags(WOLFSSL* ssl, int flags);
|
||||
|
||||
|
||||
#ifdef HAVE_NETX
|
||||
WOLFSSL_LOCAL int NetX_Receive(WOLFSSL *ssl, char *buf, int sz, void *ctx);
|
||||
WOLFSSL_LOCAL int NetX_Send(WOLFSSL *ssl, char *buf, int sz, void *ctx);
|
||||
|
||||
WOLFSSL_API void wolfSSL_SetIO_NetX(WOLFSSL* ssl, NX_TCP_SOCKET* nxsocket,
|
||||
ULONG waitoption);
|
||||
#endif /* HAVE_NETX */
|
||||
|
||||
#ifdef MICRIUM
|
||||
WOLFSSL_LOCAL int MicriumSend(WOLFSSL* ssl, char* buf, int sz, void* ctx);
|
||||
WOLFSSL_LOCAL int MicriumReceive(WOLFSSL* ssl, char* buf, int sz,
|
||||
void* ctx);
|
||||
WOLFSSL_LOCAL int MicriumReceiveFrom(WOLFSSL* ssl, char* buf, int sz,
|
||||
void* ctx);
|
||||
WOLFSSL_LOCAL int MicriumSendTo(WOLFSSL* ssl, char* buf, int sz, void* ctx);
|
||||
#endif /* MICRIUM */
|
||||
|
||||
#if defined(WOLFSSL_APACHE_MYNEWT) && !defined(WOLFSSL_LWIP)
|
||||
WOLFSSL_LOCAL int Mynewt_Receive(WOLFSSL *ssl, char *buf, int sz, void *ctx);
|
||||
WOLFSSL_LOCAL int Mynewt_Send(WOLFSSL* ssl, char *buf, int sz, void *ctx);
|
||||
WOLFSSL_API void wolfSSL_SetIO_Mynewt(WOLFSSL* ssl, struct mn_socket* mnSocket,
|
||||
struct mn_sockaddr_in* mnSockAddrIn);
|
||||
#endif /* defined(WOLFSSL_APACHE_MYNEWT) && !defined(WOLFSSL_LWIP) */
|
||||
|
||||
#ifdef WOLFSSL_UIP
|
||||
|
||||
struct uip_wolfssl_ctx {
|
||||
union socket_connector {
|
||||
struct tcp_socket tcp;
|
||||
struct udp_socket udp;
|
||||
} conn;
|
||||
WOLFSSL_CTX *ctx;
|
||||
WOLFSSL *ssl;
|
||||
uint8_t *input_databuf;
|
||||
uint8_t *output_databuf;
|
||||
uint8_t *ssl_rx_databuf;
|
||||
int ssl_rb_len;
|
||||
int ssl_rb_off;
|
||||
struct process *process;
|
||||
tcp_socket_data_callback_t input_callback;
|
||||
tcp_socket_event_callback_t event_callback;
|
||||
int closing;
|
||||
uip_ipaddr_t peer_addr;
|
||||
uint16_t peer_port;
|
||||
};
|
||||
|
||||
typedef struct uip_wolfssl_ctx uip_wolfssl_ctx;
|
||||
|
||||
WOLFSSL_LOCAL int uIPSend(WOLFSSL* ssl, char* buf, int sz, void* ctx);
|
||||
WOLFSSL_LOCAL int uIPReceive(WOLFSSL* ssl, char* buf, int sz,
|
||||
void* ctx);
|
||||
WOLFSSL_LOCAL int uIPReceiveFrom(WOLFSSL* ssl, char* buf, int sz,
|
||||
void* ctx);
|
||||
WOLFSSL_LOCAL int uIPSendTo(WOLFSSL* ssl, char* buf, int sz, void* ctx);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_DTLS
|
||||
typedef int (*CallbackGenCookie)(WOLFSSL* ssl, unsigned char* buf, int sz,
|
||||
void* ctx);
|
||||
WOLFSSL_API void wolfSSL_CTX_SetGenCookie(WOLFSSL_CTX*, CallbackGenCookie);
|
||||
WOLFSSL_API void wolfSSL_SetCookieCtx(WOLFSSL* ssl, void *ctx);
|
||||
WOLFSSL_API void* wolfSSL_GetCookieCtx(WOLFSSL* ssl);
|
||||
|
||||
#ifdef WOLFSSL_SESSION_EXPORT
|
||||
typedef int (*CallbackGetPeer)(WOLFSSL* ssl, char* ip, int* ipSz,
|
||||
unsigned short* port, int* fam);
|
||||
typedef int (*CallbackSetPeer)(WOLFSSL* ssl, char* ip, int ipSz,
|
||||
unsigned short port, int fam);
|
||||
|
||||
WOLFSSL_API void wolfSSL_CTX_SetIOGetPeer(WOLFSSL_CTX*, CallbackGetPeer);
|
||||
WOLFSSL_API void wolfSSL_CTX_SetIOSetPeer(WOLFSSL_CTX*, CallbackSetPeer);
|
||||
#endif /* WOLFSSL_SESSION_EXPORT */
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifndef XINET_NTOP
|
||||
#define XINET_NTOP(a,b,c,d) inet_ntop((a),(b),(c),(d))
|
||||
#ifdef USE_WINDOWS_API /* Windows-friendly definition */
|
||||
#undef XINET_NTOP
|
||||
#define XINET_NTOP(a,b,c,d) InetNtop((a),(b),(c),(d))
|
||||
#endif
|
||||
#endif
|
||||
#ifndef XINET_PTON
|
||||
#define XINET_PTON(a,b,c) inet_pton((a),(b),(c))
|
||||
#ifdef USE_WINDOWS_API /* Windows-friendly definition */
|
||||
#undef XINET_PTON
|
||||
#define XINET_PTON(a,b,c) InetPton((a),(b),(c))
|
||||
#endif
|
||||
#endif
|
||||
#ifndef XHTONS
|
||||
#define XHTONS(a) htons((a))
|
||||
#endif
|
||||
#ifndef XNTOHS
|
||||
#define XNTOHS(a) ntohs((a))
|
||||
#endif
|
||||
|
||||
#ifndef WOLFSSL_IP4
|
||||
#define WOLFSSL_IP4 AF_INET
|
||||
#endif
|
||||
#ifndef WOLFSSL_IP6
|
||||
#define WOLFSSL_IP6 AF_INET6
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* WOLFSSL_IO_H */
|
@ -376,7 +376,7 @@ int NetworkConnectSSL(Network *n, char *addr, int port, ssl_ca_crt_key_t *ssl_cc
|
||||
goto exit;
|
||||
}
|
||||
|
||||
n->ctx = SSL_CTX_new(method);
|
||||
n->ctx = SSL_CTX_new((SSL_METHOD *)method);
|
||||
|
||||
if (!n->ctx) {
|
||||
goto exit;
|
||||
|
Reference in New Issue
Block a user