Skip to content

Commit 2768406

Browse files
committed
Fix hashlib for espressif
due to mbedtls version skew, some macros need to be provided. The espressif common-hal implementation is no longer needed. The copyright of hashlib/__init__.h comes from micropython extmod/modhashlib.c where I found the macro definitions.
1 parent 080cc54 commit 2768406

File tree

6 files changed

+36
-138
lines changed

6 files changed

+36
-138
lines changed

ports/espressif/common-hal/hashlib/Hash.c

Lines changed: 0 additions & 57 deletions
This file was deleted.

ports/espressif/common-hal/hashlib/Hash.h

Lines changed: 0 additions & 41 deletions
This file was deleted.

ports/espressif/common-hal/hashlib/__init__.c

Lines changed: 0 additions & 40 deletions
This file was deleted.

shared-module/hashlib/Hash.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
*/
2626

2727
#include "shared-bindings/hashlib/Hash.h"
28+
#include "shared-module/hashlib/__init__.h"
2829

2930
#include "mbedtls/ssl.h"
3031

shared-module/hashlib/__init__.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
*/
2626

2727
#include "shared-bindings/hashlib/__init__.h"
28+
#include "shared-module/hashlib/__init__.h"
2829

2930
#include "mbedtls/ssl.h"
3031

shared-module/hashlib/__init__.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2022 Scott Shawcroft for Adafruit Industries
7+
* Copyright (c) 2014 Paul Sokolovsky
8+
*
9+
* Permission is hereby granted, free of charge, to any person obtaining a copy
10+
* of this software and associated documentation files (the "Software"), to deal
11+
* in the Software without restriction, including without limitation the rights
12+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
* copies of the Software, and to permit persons to whom the Software is
14+
* furnished to do so, subject to the following conditions:
15+
*
16+
* The above copyright notice and this permission notice shall be included in
17+
* all copies or substantial portions of the Software.
18+
*
19+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+
* THE SOFTWARE.
26+
*/
27+
28+
#pragma once
29+
30+
#if MBEDTLS_VERSION_NUMBER < 0x02070000 || MBEDTLS_VERSION_NUMBER >= 0x03000000
31+
#define mbedtls_sha1_starts_ret mbedtls_sha1_starts
32+
#define mbedtls_sha1_update_ret mbedtls_sha1_update
33+
#define mbedtls_sha1_finish_ret mbedtls_sha1_finish
34+
#endif

0 commit comments

Comments
 (0)