[core] Add MD5 library
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -258,3 +258,4 @@ xml/
|
|||||||
ltapi/
|
ltapi/
|
||||||
ltambz/
|
ltambz/
|
||||||
hashChanges.yaml
|
hashChanges.yaml
|
||||||
|
.piopm
|
||||||
|
|||||||
27
arduino/libretuya/libraries/MD5/MD5.h
Normal file
27
arduino/libretuya/libraries/MD5/MD5.h
Normal 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
|
||||||
29
arduino/libretuya/libraries/MD5/MD5PolarSSLImpl.cpp
Normal file
29
arduino/libretuya/libraries/MD5/MD5PolarSSLImpl.cpp
Normal 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
|
||||||
16
arduino/libretuya/libraries/MD5/MD5PolarSSLImpl.h
Normal file
16
arduino/libretuya/libraries/MD5/MD5PolarSSLImpl.h
Normal 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"
|
||||||
7
arduino/realtek-ambz/libraries/MD5/MD5Impl.h
Normal file
7
arduino/realtek-ambz/libraries/MD5/MD5Impl.h
Normal 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
|
||||||
@@ -180,6 +180,8 @@ env.AddLibrary(
|
|||||||
"+<component/common/mbed/hal_ext>",
|
"+<component/common/mbed/hal_ext>",
|
||||||
"+<component/common/mbed/targets/cmsis>",
|
"+<component/common/mbed/targets/cmsis>",
|
||||||
"+<component/common/mbed/targets/hal/rtl8711b>",
|
"+<component/common/mbed/targets/hal/rtl8711b>",
|
||||||
|
# keep PolarSSL for headers for ROM crypto functions
|
||||||
|
"+<component/common/network/ssl/polarssl-1.3.8/include>",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user