Makes block print usable in embedded applications if this repo is submodule
This commit is contained in:
parent
beef2d0ee9
commit
2e2e4951c5
14
block.c
14
block.c
|
@ -8,18 +8,21 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#if __has_include("config.h")
|
||||
#include "config.h"
|
||||
#endif
|
||||
#include "block.h"
|
||||
|
||||
void block_print(char const *const label, uint8_t const *const b) {
|
||||
#if defined (HOST_BUILD) || defined (DEBUG_UART)
|
||||
void block_print(char const *const label, void const *const b) {
|
||||
block_print_bytes(label, b, 16);
|
||||
return;
|
||||
}
|
||||
|
||||
void block_print_bytes(char const *const label, uint8_t const *const b,
|
||||
void block_print_bytes(char const *const label, void const *const v,
|
||||
uint32_t num_bytes) {
|
||||
#if defined (HOST_BUILD) || defined (DEBUG_UART)
|
||||
printf("%s: ", label);
|
||||
const uint8_t *b = v;
|
||||
printf("%s: ", label);
|
||||
for (int i = 0; i < num_bytes; i++) {
|
||||
printf("%.2x", b[i]);
|
||||
if (!((i + 1) % 4)) {
|
||||
|
@ -27,9 +30,8 @@ void block_print_bytes(char const *const label, uint8_t const *const b,
|
|||
}
|
||||
}
|
||||
printf("\r\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void block_xor(uint8_t *dest, uint8_t *const a, uint8_t *const b) {
|
||||
for (uint_fast8_t i = 0; i < 4; i++) {
|
||||
|
|
4
block.h
4
block.h
|
@ -8,8 +8,8 @@
|
|||
|
||||
void block_decr(uint8_t *);
|
||||
void block_incr(uint8_t *);
|
||||
void block_print(char const *const, uint8_t const *const);
|
||||
void block_print_bytes(char const *const, uint8_t const *const, uint32_t);
|
||||
void block_print(char const *const, void const *const);
|
||||
void block_print_bytes(char const *const, void const *const, uint32_t);
|
||||
void block_shiftl(uint8_t *, uint8_t *const, uint_fast8_t);
|
||||
void block_shiftr(uint8_t *, uint8_t *const, uint_fast8_t);
|
||||
void block_xor(uint8_t *, uint8_t *const, uint8_t *const);
|
||||
|
|
|
@ -78,7 +78,7 @@ debug-gdbinit:
|
|||
|
||||
.PHONY: flash flash-softdevice erase-all startdebug
|
||||
|
||||
TEST_CFLAGS=-std=gnu99 -g -Wall -Werror -I.. -DHOST_BUILD -Os
|
||||
TEST_CFLAGS=-std=gnu99 -g -Wall -Werror -I.. -I . -DHOST_BUILD -Os
|
||||
|
||||
test:
|
||||
$(HOST_CC) $(TEST_CFLAGS) -lcrypto block.c aes.c cmac.c tests/test_cmac.c -o tests/test_cmac
|
||||
|
|
Loading…
Reference in New Issue