mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-25 11:46:31 +00:00
Berry fix MD5 compilation for idf4
This commit is contained in:
parent
dd089f80c9
commit
36eb62ab94
@ -21,7 +21,7 @@
|
|||||||
#ifdef USE_BERRY
|
#ifdef USE_BERRY
|
||||||
|
|
||||||
#include <berry.h>
|
#include <berry.h>
|
||||||
#include "mbedtls/md5.h"
|
#include "MD5Builder.h"
|
||||||
#include "be_mem.h"
|
#include "be_mem.h"
|
||||||
|
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
@ -33,7 +33,7 @@ extern "C" {
|
|||||||
int free_ctx(bvm* vm) {
|
int free_ctx(bvm* vm) {
|
||||||
int argc = be_top(vm);
|
int argc = be_top(vm);
|
||||||
if (argc > 0) {
|
if (argc > 0) {
|
||||||
mbedtls_md5_context * ctx = (mbedtls_md5_context*) be_tocomptr(vm, 1);
|
struct MD5Context * ctx = (struct MD5Context *) be_tocomptr(vm, 1);
|
||||||
if (ctx != NULL) {
|
if (ctx != NULL) {
|
||||||
be_os_free(ctx);
|
be_os_free(ctx);
|
||||||
}
|
}
|
||||||
@ -45,12 +45,11 @@ extern "C" {
|
|||||||
int32_t m_md5_init(struct bvm *vm);
|
int32_t m_md5_init(struct bvm *vm);
|
||||||
int32_t m_md5_init(struct bvm *vm) {
|
int32_t m_md5_init(struct bvm *vm) {
|
||||||
|
|
||||||
mbedtls_md5_context * ctx = (mbedtls_md5_context*) be_os_malloc(sizeof(mbedtls_md5_context));
|
struct MD5Context * ctx = (struct MD5Context *) be_os_malloc(sizeof(struct MD5Context));
|
||||||
if (!ctx) {
|
if (!ctx) {
|
||||||
be_throw(vm, BE_MALLOC_FAIL);
|
be_throw(vm, BE_MALLOC_FAIL);
|
||||||
}
|
}
|
||||||
mbedtls_md5_init(ctx);
|
MD5Init(ctx);
|
||||||
mbedtls_md5_starts_ret(ctx);
|
|
||||||
|
|
||||||
be_newcomobj(vm, ctx, &free_ctx);
|
be_newcomobj(vm, ctx, &free_ctx);
|
||||||
be_setmember(vm, 1, ".p");
|
be_setmember(vm, 1, ".p");
|
||||||
@ -72,12 +71,12 @@ extern "C" {
|
|||||||
if (!bytes) break;
|
if (!bytes) break;
|
||||||
|
|
||||||
be_getmember(vm, 1, ".p");
|
be_getmember(vm, 1, ".p");
|
||||||
mbedtls_md5_context * ctx;
|
struct MD5Context * ctx;
|
||||||
ctx = (mbedtls_md5_context*) be_tocomptr(vm, -1);
|
ctx = (struct MD5Context *) be_tocomptr(vm, -1);
|
||||||
if (!ctx) break;
|
if (!ctx) break;
|
||||||
|
|
||||||
if (length > 0) {
|
if (length > 0) {
|
||||||
mbedtls_md5_update_ret(ctx, (const uint8_t*) bytes, length);
|
MD5Update(ctx, (const uint8_t*) bytes, length);
|
||||||
}
|
}
|
||||||
be_return_nil(vm);
|
be_return_nil(vm);
|
||||||
// success
|
// success
|
||||||
@ -92,11 +91,11 @@ extern "C" {
|
|||||||
int32_t m_md5_finish(struct bvm *vm);
|
int32_t m_md5_finish(struct bvm *vm);
|
||||||
int32_t m_md5_finish(struct bvm *vm) {
|
int32_t m_md5_finish(struct bvm *vm) {
|
||||||
be_getmember(vm, 1, ".p");
|
be_getmember(vm, 1, ".p");
|
||||||
mbedtls_md5_context * ctx;
|
struct MD5Context * ctx;
|
||||||
ctx = (mbedtls_md5_context*) be_tocomptr(vm, -1);
|
ctx = (struct MD5Context *) be_tocomptr(vm, -1);
|
||||||
|
|
||||||
uint8_t output[16];
|
uint8_t output[16];
|
||||||
mbedtls_md5_finish_ret(ctx, output);
|
MD5Final(output, ctx);
|
||||||
be_pushbytes(vm, output, sizeof(output));
|
be_pushbytes(vm, output, sizeof(output));
|
||||||
be_return(vm);
|
be_return(vm);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user