supla-device
Loading...
Searching...
No Matches
crypto.h
1// SPDX-FileCopyrightText: AC SOFTWARE SP. Z O.O.
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#ifndef SRC_SUPLA_CRYPTO_H_
5#define SRC_SUPLA_CRYPTO_H_
6
7/*
8 * Simple wrapper for cryptographic functions.
9 */
10
11#include <stdint.h>
12#include <stddef.h>
13
14namespace Supla {
15
16namespace Crypto {
17
18// Compares all size bytes without stopping at the first difference.
19// Both buffers must contain at least size bytes; NULL is rejected.
20// Timing may depend on size, which must not depend on secret contents.
21bool constantTimeEqual(const void *left, const void *right, size_t size);
22
35bool pbkdf2Sha256(const char *password,
36 const uint8_t *salt, size_t saltLen, uint32_t iterations,
37 uint8_t *derivedKey, size_t derivedKeyLen);
38
39bool hmacSha256Hex(const char *key, size_t keyLen,
40 const char *data, size_t dataLen,
41 char *output, size_t outputLen);
42
43}; // namespace Crypto
44}; // namespace Supla
45
46
47
48#endif // SRC_SUPLA_CRYPTO_H_