]> granicus.if.org Git - esp-idf/commitdiff
components/openssl: add more interface for application
authordongheng <dongheng@espressif.com>
Wed, 21 Sep 2016 01:23:29 +0000 (09:23 +0800)
committerdongheng <dongheng@espressif.com>
Wed, 21 Sep 2016 01:23:29 +0000 (09:23 +0800)
components/openssl/Makefile [deleted file]
components/openssl/Makefile.projbuild [new file with mode: 0644]
components/openssl/component.mk [new file with mode: 0644]
components/openssl/include/internal/ssl_lib.h
components/openssl/include/internal/ssl_pkey.h
components/openssl/include/platform/ssl_pm.h
components/openssl/library/Makefile [deleted file]
components/openssl/library/ssl_cert.c
components/openssl/library/ssl_lib.c
components/openssl/platform/Makefile [deleted file]
components/openssl/platform/ssl_pm.c

diff --git a/components/openssl/Makefile b/components/openssl/Makefile
deleted file mode 100644 (file)
index bdd8a0e..0000000
+++ /dev/null
@@ -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
-
diff --git a/components/openssl/Makefile.projbuild b/components/openssl/Makefile.projbuild
new file mode 100644 (file)
index 0000000..51300ef
--- /dev/null
@@ -0,0 +1,4 @@
+# Anyone compiling mbedTLS code needs the name of the
+# alternative config file
+CFLAGS += -DMBEDTLS_CONFIG_FILE='"mbedtls/esp_config.h"'
+
diff --git a/components/openssl/component.mk b/components/openssl/component.mk
new file mode 100644 (file)
index 0000000..97de697
--- /dev/null
@@ -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
index d95d2195560220bf800f7e6004c65c82960bf263..0881fbbfdb8a9f9a03aaf18c054a5b5e48f68440 100644 (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
index cc870e18ede7f9312ef141c032b3d8f491792314..c7170244a69195017f771c614bda7b312a78834e 100644 (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
index c75ae95af545c749b4f2ed8749aab81e09e86f16..a6731cff7fe7f617bc61840ec5ab9ebfe02a3742 100644 (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);
diff --git a/components/openssl/library/Makefile b/components/openssl/library/Makefile
deleted file mode 100644 (file)
index 10f4067..0000000
+++ /dev/null
@@ -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
-
index 10f723bfcbad96aba5a4a0a4e83738f18623c3ab..53325924602dffec8fa2ef468d9c5a35171ba242 100644 (file)
@@ -1,4 +1,5 @@
 #include "ssl_cert.h"
+#include "ssl_dbg.h"
 #include "ssl_pm.h"
 
 CERT *ssl_cert_new(void)
index ad78f3961acac1cf9c8a837112990a0599255074..e1e112cc7b1868f8d693735d1ad2bfb5661f69e3 100644 (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
     {
diff --git a/components/openssl/platform/Makefile b/components/openssl/platform/Makefile
deleted file mode 100644 (file)
index 749b478..0000000
+++ /dev/null
@@ -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
-
index 831420180c06cd8b678ae6cc4480fbe21680999f..9d207b3a0e0f769a16899241f8c81e645c4c46c8 100644 (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);