components/openssl: add more interface for application

This commit is contained in:
dongheng 2016-09-21 09:23:29 +08:00
parent 44c466c0ea
commit 5adc661d05
11 changed files with 92 additions and 152 deletions

View File

@ -1,50 +0,0 @@
#############################################################
# Required variables for each makefile
# Discard this section from all parent makefiles
# Expected variables (with automatic defaults):
# CSRCS (all "C" files in the dir)
# SUBDIRS (all subdirs with a Makefile)
# GEN_LIBS - list of libs to be generated ()
# GEN_IMAGES - list of images to be generated ()
# COMPONENTS_xxx - a list of libs/objs in the form
# subdir/lib to be extracted and rolled up into
# a generated lib/image xxx.a ()
#
ifndef PDIR
UP_EXTRACT_DIR = ..
GEN_LIBS = libopenssl.a
COMPONENTS_libopenssl = library/liblibrary.a platform/libplatform.a
endif
#############################################################
# Configuration i.e. compile options etc.
# Target specific stuff (defines etc.) goes in here!
# Generally values applying to a tree are captured in the
# makefile at its root level - these are then overridden
# for a subtree within the makefile rooted therein
#
#DEFINES +=
#############################################################
# Recursion Magic - Don't touch this!!
#
# Each subtree potentially has an include directory
# corresponding to the common APIs applicable to modules
# rooted at that subtree. Accordingly, the INCLUDE PATH
# of a module can only contain the include directories up
# its parent path, and not its siblings
#
# Required for each makefile to inherit from the parent
#
INCLUDES := $(INCLUDES) -I $(PDIR)include -I $(PDIR)include/platform -I $(PDIR)include/internal
INCLUDES += -I ./inlcude
INCLUDES += -I $(SDK_PATH)/include/openssl/internal
INCLUDES += -I ./
PDIR := ../$(PDIR)
sinclude $(PDIR)Makefile

View File

@ -0,0 +1,4 @@
# Anyone compiling mbedTLS code needs the name of the
# alternative config file
CFLAGS += -DMBEDTLS_CONFIG_FILE='"mbedtls/esp_config.h"'

View File

@ -0,0 +1,9 @@
#
# Component Makefile
#
COMPONENT_ADD_INCLUDEDIRS := include include/internal include/platform include/oepnssl
COMPONENT_SRCDIRS := library platform
include $(IDF_PATH)/make/component_common.mk

View File

@ -3,9 +3,4 @@
#include "ssl_types.h"
#define SSL_want_nothing(s) (SSL_want(s) == SSL_NOTHING)
#define SSL_want_read(s) (SSL_want(s) == SSL_READING)
#define SSL_want_write(s) (SSL_want(s) == SSL_WRITING)
#define SSL_want_x509_lookup(s) (SSL_want(s) == SSL_WRITING)
#endif

View File

@ -8,4 +8,6 @@ EVP_PKEY *d2i_PrivateKey(int type,
const unsigned char **pp,
long length);
void EVP_PKEY_free(EVP_PKEY *x);
#endif

View File

@ -2,7 +2,8 @@
#define _SSL_PM_H_
#include "ssl_types.h"
#include "esp_common.h"
#include "esp_types.h"
#include "esp_system.h"
void* ssl_zalloc(size_t size);
void *ssl_malloc(size_t size);

View File

@ -1,46 +0,0 @@
#############################################################
# Required variables for each makefile
# Discard this section from all parent makefiles
# Expected variables (with automatic defaults):
# CSRCS (all "C" files in the dir)
# SUBDIRS (all subdirs with a Makefile)
# GEN_LIBS - list of libs to be generated ()
# GEN_IMAGES - list of images to be generated ()
# COMPONENTS_xxx - a list of libs/objs in the form
# subdir/lib to be extracted and rolled up into
# a generated lib/image xxx.a ()
#
ifndef PDIR
GEN_LIBS = liblibrary.a
endif
#############################################################
# Configuration i.e. compile options etc.
# Target specific stuff (defines etc.) goes in here!
# Generally values applying to a tree are captured in the
# makefile at its root level - these are then overridden
# for a subtree within the makefile rooted therein
#
#DEFINES +=
#############################################################
# Recursion Magic - Don't touch this!!
#
# Each subtree potentially has an include directory
# corresponding to the common APIs applicable to modules
# rooted at that subtree. Accordingly, the INCLUDE PATH
# of a module can only contain the include directories up
# its parent path, and not its siblings
#
# Required for each makefile to inherit from the parent
#
INCLUDES := $(INCLUDES) -I $(PDIR)include
INCLUDES += -I ./
PDIR := ../$(PDIR)
sinclude $(PDIR)Makefile

View File

@ -1,4 +1,5 @@
#include "ssl_cert.h"
#include "ssl_dbg.h"
#include "ssl_pm.h"
CERT *ssl_cert_new(void)

View File

@ -6,7 +6,7 @@
#define SSL_SEND_DATA_MAX_LENGTH 1460
static int ossl_statem_in_error(const SSL *ssl)
int ossl_statem_in_error(const SSL *ssl)
{
if (ssl->statem.state == MSG_FLOW_ERROR)
return 1;
@ -14,6 +14,74 @@ static int ossl_statem_in_error(const SSL *ssl)
return 0;
}
/*
* SSL_want - get the SSL specifical statement
*
* @param ssl - SSL point
*
* @return specifical statement
*/
int SSL_want(const SSL *ssl)
{
return 0;
}
/*
* SSL_want_nothing - check if SSL want nothing
*
* @param ssl - SSL point
*
* @return
* 1 : yes
* 0 : no
*/
int SSL_want_nothing(const SSL *ssl)
{
return (SSL_want(ssl) == SSL_NOTHING);
}
/*
* SSL_want_read - check if SSL want to read
*
* @param ssl - SSL point
*
* @return
* 1 : yes
* 0 : no
*/
int SSL_want_read(const SSL *ssl)
{
return (SSL_want(ssl) == SSL_READING);
}
/*
* SSL_want_read - check if SSL want to write
*
* @param ssl - SSL point
*
* @return
* 1 : yes
* 0 : no
*/
int SSL_want_write(const SSL *ssl)
{
return (SSL_want(ssl) == SSL_WRITING);
}
/*
* SSL_want_read - check if SSL want to lookup X509 certification
*
* @param ssl - SSL point
*
* @return
* 1 : yes
* 0 : no
*/
int SSL_want_x509_lookup(const SSL *ssl)
{
return (SSL_want(ssl) == SSL_WRITING);
}
/*
* SSL_get_error - get SSL error code
*
@ -1153,7 +1221,7 @@ char *SSL_state_string(const SSL *ssl)
SSL_ASSERT(ssl);
if (ossl_state_in_error(ssl))
if (ossl_statem_in_error(ssl))
str = "SSLERR";
else
{

View File

@ -1,46 +0,0 @@
#############################################################
# Required variables for each makefile
# Discard this section from all parent makefiles
# Expected variables (with automatic defaults):
# CSRCS (all "C" files in the dir)
# SUBDIRS (all subdirs with a Makefile)
# GEN_LIBS - list of libs to be generated ()
# GEN_IMAGES - list of images to be generated ()
# COMPONENTS_xxx - a list of libs/objs in the form
# subdir/lib to be extracted and rolled up into
# a generated lib/image xxx.a ()
#
ifndef PDIR
GEN_LIBS = libplatform.a
endif
#############################################################
# Configuration i.e. compile options etc.
# Target specific stuff (defines etc.) goes in here!
# Generally values applying to a tree are captured in the
# makefile at its root level - these are then overridden
# for a subtree within the makefile rooted therein
#
#DEFINES +=
#############################################################
# Recursion Magic - Don't touch this!!
#
# Each subtree potentially has an include directory
# corresponding to the common APIs applicable to modules
# rooted at that subtree. Accordingly, the INCLUDE PATH
# of a module can only contain the include directories up
# its parent path, and not its siblings
#
# Required for each makefile to inherit from the parent
#
INCLUDES := $(INCLUDES) -I $(PDIR)include
INCLUDES += -I ./
PDIR := ../$(PDIR)
sinclude $(PDIR)Makefile

View File

@ -1,6 +1,8 @@
#include "ssl_pm.h"
#include "ssl_dbg.h"
#include <string.h>
/* mbedtls include */
#include "mbedtls/platform.h"
#include "mbedtls/net.h"
@ -55,7 +57,7 @@ void* ssl_zalloc(size_t size)
void *ssl_malloc(size_t size)
{
return zalloc(size);
return ssl_zalloc(size);
}
void ssl_free(void *p)
@ -140,7 +142,7 @@ int ssl_pm_new(SSL *ssl)
ret = mbedtls_ssl_conf_own_cert(&ssl_pm->conf, &x509_pm->x509_crt, &pkey_pm->pkey);
if (ret)
SSL_ERR(ret, failed4, "mbedtls_ssl_conf_own_cert:[%d]\n", ret);
SSL_ERR(ret, failed3, "mbedtls_ssl_conf_own_cert:[%d]\n", ret);
}
ret = mbedtls_ssl_setup(&ssl_pm->ssl, &ssl_pm->conf);