mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2025-01-29 08:43:33 -05:00
fw: use bool as return type for memeq
This commit is contained in:
parent
80a155a1c2
commit
26045bfcd1
@ -5,8 +5,10 @@
|
||||
|
||||
#include "lib.h"
|
||||
#include "assert.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
void *memset(void *dest, int c, unsigned n)
|
||||
{
|
||||
@ -52,15 +54,15 @@ void wordcpy_s(void *dest, size_t destsize, const void *src, size_t n)
|
||||
}
|
||||
}
|
||||
|
||||
int memeq(void *dest, const void *src, size_t n)
|
||||
bool memeq(void *dest, const void *src, size_t n)
|
||||
{
|
||||
uint8_t *src_byte = (uint8_t *)src;
|
||||
uint8_t *dest_byte = (uint8_t *)dest;
|
||||
int res = -1;
|
||||
bool res = true;
|
||||
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
if (dest_byte[i] != src_byte[i]) {
|
||||
res = 0;
|
||||
res = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,11 +8,12 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
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);
|
||||
bool memeq(void *dest, const void *src, size_t n);
|
||||
void secure_wipe(void *v, size_t n);
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user