mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2024-10-01 01:45:38 -04:00
3a6a60ff26
The memset() responsible for the zeroisation of the secure_ctx under the compute_cdi() function in FW's main.c, was optimised away by the compiler. Instead of using memset(), secure_wipe() is introduced which uses a volatile keyword to prevent the compiler to try to optimise it. Secure_wipe() is now used on all locations handling removal of sensitive data.
33 lines
767 B
C
33 lines
767 B
C
/*
|
|
* Copyright (C) 2022 - Tillitis AB
|
|
* SPDX-License-Identifier: GPL-2.0-only
|
|
*/
|
|
|
|
#ifndef LIB_H
|
|
#define LIB_H
|
|
|
|
#include "types.h"
|
|
|
|
#ifdef NOCONSOLE
|
|
#define htif_putc(ch)
|
|
#define htif_lf()
|
|
#define htif_puthex(c)
|
|
#define htif_putinthex(n)
|
|
#define htif_puts(s)
|
|
#define htif_hexdump(buf, len)
|
|
#else
|
|
void htif_putc(char ch);
|
|
void htif_lf();
|
|
void htif_puthex(uint8_t c);
|
|
void htif_putinthex(const uint32_t n);
|
|
void htif_puts(const char *s);
|
|
void htif_hexdump(void *buf, int len);
|
|
#endif
|
|
|
|
void *memset(void *dest, int c, unsigned n);
|
|
void memcpy_s(void *dest, size_t destsize, const void *src, size_t n);
|
|
void wordcpy_s(void *dest, size_t destsize, const void *src, size_t n);
|
|
int memeq(void *dest, const void *src, size_t n);
|
|
void secure_wipe(void *v, size_t n);
|
|
#endif
|