diff mbox series

Drop not required inclusion of openSSL

Message ID 20190111090421.25334-1-sbabic@denx.de
State Accepted
Headers show
Series Drop not required inclusion of openSSL | expand

Commit Message

Stefano Babic Jan. 11, 2019, 9:04 a.m. UTC
Just a few files require to include headers from openSSL. Because
openSSL requires a License Exception, the license for these file must be
adjusted to take care that openSSL code is used.

Patch tries to limit the number of files requiring this.

Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 corelib/channel_curl.c               | 6 +++---
 handlers/ubivol_handler.c            | 1 -
 include/channel_curl.h               | 3 +--
 include/sslapi.h                     | 7 -------
 include/util.h                       | 3 +++
 suricatta/server_hawkbit.c           | 2 +-
 suricatta/test/test_server_hawkbit.c | 2 +-
 7 files changed, 9 insertions(+), 15 deletions(-)
diff mbox series

Patch

diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c
index 05fe5fe..fea6c05 100644
--- a/corelib/channel_curl.c
+++ b/corelib/channel_curl.c
@@ -847,7 +847,7 @@  channel_op_res_t channel_get_file(channel_t *this, void *data)
 	channel_data_t *channel_data = (channel_data_t *)data;
 
 	if (channel_data->usessl) {
-		memset(channel_data->sha1hash, 0x0, SHA_DIGEST_LENGTH * 2 + 1);
+		memset(channel_data->sha1hash, 0x0, SWUPDATE_SHA_DIGEST_LENGTH * 2 + 1);
 		channel_data->dgst = swupdate_HASH_init("sha1");
 		if (!channel_data->dgst) {
 			result = CHANNEL_EINIT;
@@ -1000,7 +1000,7 @@  channel_op_res_t channel_get_file(channel_t *this, void *data)
 	}
 
 	if (channel_data->usessl) {
-		unsigned char sha1hash[SHA_DIGEST_LENGTH];
+		unsigned char sha1hash[SWUPDATE_SHA_DIGEST_LENGTH];
 		unsigned int md_len;
 		(void)md_len;
 		if (swupdate_HASH_final(channel_data->dgst, sha1hash, &md_len) != 1) {
@@ -1009,7 +1009,7 @@  channel_op_res_t channel_get_file(channel_t *this, void *data)
 		}
 
 		char sha1hexchar[3];
-		for (int i = 0; i < SHA_DIGEST_LENGTH; i++) {
+		for (int i = 0; i < SWUPDATE_SHA_DIGEST_LENGTH; i++) {
 			sprintf(sha1hexchar, "%02x", sha1hash[i]);
 			strcat(channel_data->sha1hash, sha1hexchar);
 		}
diff --git a/handlers/ubivol_handler.c b/handlers/ubivol_handler.c
index 8b204dd..805e610 100644
--- a/handlers/ubivol_handler.c
+++ b/handlers/ubivol_handler.c
@@ -19,7 +19,6 @@ 
 #include "handler.h"
 #include "flash.h"
 #include "util.h"
-#include "sslapi.h"
 
 void ubi_handler(void);
 
diff --git a/include/channel_curl.h b/include/channel_curl.h
index 0ea3423..0e499c6 100644
--- a/include/channel_curl.h
+++ b/include/channel_curl.h
@@ -11,7 +11,6 @@ 
 #endif
 #include <stdio.h>
 #include <stdbool.h>
-#include "sslapi.h"
 #include "swupdate_status.h"
 
 /* Curl Channel Implementation Private Header File.
@@ -63,7 +62,7 @@  typedef struct {
 	bool nofollow;
 	int (*checkdwl)(void);
 	struct swupdate_digest *dgst;
-	char sha1hash[SHA_DIGEST_LENGTH * 2 + 1];
+	char sha1hash[SWUPDATE_SHA_DIGEST_LENGTH * 2 + 1];
 	sourcetype source;
 	struct dict *headers;
 } channel_data_t;
diff --git a/include/sslapi.h b/include/sslapi.h
index 7bdb2b2..6f03ece 100644
--- a/include/sslapi.h
+++ b/include/sslapi.h
@@ -141,13 +141,6 @@  void swupdate_DECRYPT_cleanup(struct swupdate_digest *dgst);
 #define swupdate_DECRYPT_cleanup(p)
 #endif
 
-/*
- * if openSSL is not selected
- */
-#ifndef SHA_DIGEST_LENGTH
-#define SHA_DIGEST_LENGTH 20
-#endif
-
 #ifndef SSL_PURPOSE_DEFAULT
 #define SSL_PURPOSE_EMAIL_PROT -1
 #define SSL_PURPOSE_CODE_SIGN  -1
diff --git a/include/util.h b/include/util.h
index 4675d89..445e9f2 100644
--- a/include/util.h
+++ b/include/util.h
@@ -20,6 +20,9 @@ 
 #define NOTIFY_BUF_SIZE 	2048
 #define ENOMEM_ASPRINTF		-1
 
+#define SWUPDATE_SHA_DIGEST_LENGTH	20
+#define AES_BLOCK_SIZE	16
+
 extern int loglevel;
 
 typedef enum {
diff --git a/suricatta/server_hawkbit.c b/suricatta/server_hawkbit.c
index 34dc5ac..d02ab61 100644
--- a/suricatta/server_hawkbit.c
+++ b/suricatta/server_hawkbit.c
@@ -1046,7 +1046,7 @@  server_op_res_t server_process_update_artifact(int action_id,
 #ifdef CONFIG_SURICATTA_SSL
 		if (strncmp((char *)&channel_data.sha1hash,
 			    json_object_get_string(json_data_artifact_sha1hash),
-			    SHA_DIGEST_LENGTH) != 0) {
+			    SWUPDATE_SHA_DIGEST_LENGTH) != 0) {
 				ERROR(
 			    "Checksum does not match: Should be '%s', but "
 			    "actually is '%s'.\n",
diff --git a/suricatta/test/test_server_hawkbit.c b/suricatta/test/test_server_hawkbit.c
index fcb81ac..cc98f78 100644
--- a/suricatta/test/test_server_hawkbit.c
+++ b/suricatta/test/test_server_hawkbit.c
@@ -93,7 +93,7 @@  channel_op_res_t __wrap_channel_get_file(channel_t *this, void *data, int file_h
 #ifdef CONFIG_SURICATTA_SSL
 	channel_data_t *channel_data = (channel_data_t *)data;
 	strncpy(channel_data->sha1hash, mock_type(char *),
-		SHA_DIGEST_LENGTH * 2 + 1);
+		SWUPDATE_SHA_DIGEST_LENGTH * 2 + 1);
 #else
 	(void)data;
 #endif