Skip to content

Commit c1bd53d

Browse files
committed
remove CIRCUITPY_HASHLIB_SHA256 ifdef guards
1 parent fabe72b commit c1bd53d

File tree

5 files changed

+4
-26
lines changed

5 files changed

+4
-26
lines changed

py/circuitpy_mpconfig.mk

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,6 @@ CFLAGS += -DCIRCUITPY_HASHLIB_MBEDTLS=$(CIRCUITPY_HASHLIB_MBEDTLS)
343343
CIRCUITPY_HASHLIB_MBEDTLS_ONLY ?= $(call enable-if-all,$(CIRCUITPY_HASHLIB_MBEDTLS) $(call enable-if-not,$(CIRCUITPY_SSL)))
344344
CFLAGS += -DCIRCUITPY_HASHLIB_MBEDTLS_ONLY=$(CIRCUITPY_HASHLIB_MBEDTLS_ONLY)
345345

346-
CIRCUITPY_HASHLIB_SHA256 ?= $(CIRCUITPY_HASHLIB)
347-
CFLAGS += -DCIRCUITPY_HASHLIB_SHA256=$(CIRCUITPY_HASHLIB_SHA256)
348-
349346
CIRCUITPY_I2CTARGET ?= $(CIRCUITPY_FULL_BUILD)
350347
CFLAGS += -DCIRCUITPY_I2CTARGET=$(CIRCUITPY_I2CTARGET)
351348

shared-module/hashlib/Hash.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,10 @@ void common_hal_hashlib_hash_update(hashlib_hash_obj_t *self, const uint8_t *dat
1313
if (self->hash_type == MBEDTLS_SSL_HASH_SHA1) {
1414
mbedtls_sha1_update_ret(&self->sha1, data, datalen);
1515
return;
16-
}
17-
#if CIRCUITPY_HASHLIB_SHA256
18-
else if (self->hash_type == MBEDTLS_SSL_HASH_SHA256) {
16+
} else if (self->hash_type == MBEDTLS_SSL_HASH_SHA256) {
1917
mbedtls_sha256_update_ret(&self->sha256, data, datalen);
2018
return;
2119
}
22-
#endif
2320
}
2421

2522
void common_hal_hashlib_hash_digest(hashlib_hash_obj_t *self, uint8_t *data, size_t datalen) {
@@ -33,26 +30,19 @@ void common_hal_hashlib_hash_digest(hashlib_hash_obj_t *self, uint8_t *data, siz
3330
mbedtls_sha1_clone(&copy, &self->sha1);
3431
mbedtls_sha1_finish_ret(&self->sha1, data);
3532
mbedtls_sha1_clone(&self->sha1, &copy);
36-
}
37-
#if CIRCUITPY_HASHLIB_SHA256
38-
else if (self->hash_type == MBEDTLS_SSL_HASH_SHA256) {
33+
} else if (self->hash_type == MBEDTLS_SSL_HASH_SHA256) {
3934
mbedtls_sha256_context copy;
4035
mbedtls_sha256_clone(&copy, &self->sha256);
4136
mbedtls_sha256_finish_ret(&self->sha256, data);
4237
mbedtls_sha256_clone(&self->sha256, &copy);
4338
}
44-
#endif
4539
}
4640

4741
size_t common_hal_hashlib_hash_get_digest_size(hashlib_hash_obj_t *self) {
4842
if (self->hash_type == MBEDTLS_SSL_HASH_SHA1) {
4943
return 20;
50-
}
51-
#if CIRCUITPY_HASHLIB_SHA256
52-
else if (self->hash_type == MBEDTLS_SSL_HASH_SHA256) {
44+
} else if (self->hash_type == MBEDTLS_SSL_HASH_SHA256) {
5345
return 32;
5446
}
55-
#endif
56-
5747
return 0;
5848
}

shared-module/hashlib/Hash.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,13 @@
77
#pragma once
88

99
#include "mbedtls/sha1.h"
10-
#if CIRCUITPY_HASHLIB_SHA256
1110
#include "mbedtls/sha256.h"
12-
#endif
1311

1412
typedef struct {
1513
mp_obj_base_t base;
1614
union {
1715
mbedtls_sha1_context sha1;
18-
#if CIRCUITPY_HASHLIB_SHA256
1916
mbedtls_sha256_context sha256;
20-
#endif
2117
};
2218
// Of MBEDTLS_SSL_HASH_*
2319
uint8_t hash_type;

shared-module/hashlib/__init__.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,11 @@ bool common_hal_hashlib_new(hashlib_hash_obj_t *self, const char *algorithm) {
1616
mbedtls_sha1_init(&self->sha1);
1717
mbedtls_sha1_starts_ret(&self->sha1);
1818
return true;
19-
}
20-
#if CIRCUITPY_HASHLIB_SHA256
21-
else if (strcmp(algorithm, "sha256") == 0) {
19+
} else if (strcmp(algorithm, "sha256") == 0) {
2220
self->hash_type = MBEDTLS_SSL_HASH_SHA256;
2321
mbedtls_sha256_init(&self->sha256);
2422
mbedtls_sha256_starts_ret(&self->sha256, 0);
2523
return true;
2624
}
27-
#endif
2825
return false;
2926
}

shared-module/hashlib/__init__.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414
#define mbedtls_sha1_update_ret mbedtls_sha1_update
1515
#define mbedtls_sha1_finish_ret mbedtls_sha1_finish
1616

17-
#if CIRCUITPY_HASHLIB_SHA256
1817
#define mbedtls_sha256_starts_ret mbedtls_sha256_starts
1918
#define mbedtls_sha256_update_ret mbedtls_sha256_update
2019
#define mbedtls_sha256_finish_ret mbedtls_sha256_finish
21-
#endif
2220

2321
#endif

0 commit comments

Comments
 (0)