cryptnox-sdk-cpp 1.0.0
Platform-independent C++ core SDK for Cryptnox Hardware Wallet
Loading...
Searching...
No Matches
CW_Utils.h
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: LGPL-3.0-or-later
3 * Copyright (c) 2026 Cryptnox SA
4 */
5
20
21#ifndef CW_UTILS_H
22#define CW_UTILS_H
23
24/******************************************************************
25 * 1. Included files
26 ******************************************************************/
27
28#include "platform_compat.h"
29
30/******************************************************************
31 * 2. Class declaration
32 ******************************************************************/
33
45class CW_Utils {
46public:
59 static bool secure_compare(const uint8_t* a, const uint8_t* b, size_t len);
60
70 static void secure_wipe(uint8_t* buf, size_t len);
71
81 static bool safe_memcpy(uint8_t* dst, size_t dstSize,
82 const uint8_t* src, size_t count);
83
95 static bool fill_secure_random(uint8_t* dest, size_t len);
96};
97
98#endif // CW_UTILS_H
Portable utility functions for cryptographic and security operations.
Definition CW_Utils.h:45
static bool safe_memcpy(uint8_t *dst, size_t dstSize, const uint8_t *src, size_t count)
Safe memcpy — validates pointers, sizes, and checks for overlap.
Definition CW_Utils.cpp:50
static bool fill_secure_random(uint8_t *dest, size_t len)
Fill len bytes at dest with cryptographically random data.
static bool secure_compare(const uint8_t *a, const uint8_t *b, size_t len)
Constant-time buffer comparison, resistant to timing side-channel attacks.
Definition CW_Utils.cpp:22
static void secure_wipe(uint8_t *buf, size_t len)
Securely zero a buffer, guaranteed not to be optimised away.
Definition CW_Utils.cpp:37
Arduino compatibility shims for non-Arduino (plain C++) builds.