[core] Add MD5 library

This commit is contained in:
Kuba Szczodrzyński
2022-06-03 11:24:27 +02:00
parent a21c07fa03
commit 4c27aa57b1
6 changed files with 82 additions and 0 deletions

1
.gitignore vendored
View File

@@ -258,3 +258,4 @@ xml/
ltapi/
ltambz/
hashChanges.yaml
.piopm

View File

@@ -0,0 +1,27 @@
/* Copyright (c) Kuba Szczodrzyński 2022-06-03. */
#pragma once
#include <MD5Impl.h>
// available built-in implementations
#if LT_MD5_USE_POLARSSL
#include "MD5PolarSSLImpl.h"
#endif
// common API
#ifdef __cplusplus
extern "C" {
#endif
#ifndef LT_MD5_CTX_T
#define LT_MD5_CTX_T void
#endif
void MD5Init(LT_MD5_CTX_T *context);
void MD5Update(LT_MD5_CTX_T *context, const unsigned char *buf, unsigned len);
void MD5Final(unsigned char digest[16], LT_MD5_CTX_T *context);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,29 @@
/* Copyright (c) Kuba Szczodrzyński 2022-06-03. */
// check if impl defines LT_MD5_USE_POLARSSL
extern "C" {
#include <MD5Impl.h>
}
#if LT_MD5_USE_POLARSSL
#include "MD5PolarSSLImpl.h"
extern "C" {
void MD5Init(LT_MD5_CTX_T *context) {
md5_init(context);
md5_starts(context);
}
void MD5Update(LT_MD5_CTX_T *context, const unsigned char *buf, unsigned len) {
md5_update(context, buf, len);
}
void MD5Final(unsigned char digest[16], LT_MD5_CTX_T *context) {
md5_finish(context, digest);
}
} // extern "C"
#endif

View File

@@ -0,0 +1,16 @@
/* Copyright (c) Kuba Szczodrzyński 2022-06-03. */
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <polarssl/md5.h>
#define LT_MD5_CTX_T md5_context
#ifdef __cplusplus
} // extern "C"
#endif
#include "MD5.h"

View File

@@ -0,0 +1,7 @@
/* Copyright (c) Kuba Szczodrzyński 2022-06-03. */
#pragma once
#include <sdk_extern.h>
#define LT_MD5_USE_POLARSSL 1

View File

@@ -180,6 +180,8 @@ env.AddLibrary(
"+<component/common/mbed/hal_ext>",
"+<component/common/mbed/targets/cmsis>",
"+<component/common/mbed/targets/hal/rtl8711b>",
# keep PolarSSL for headers for ROM crypto functions
"+<component/common/network/ssl/polarssl-1.3.8/include>",
],
)