helper.h
1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* Copyright (C) 2015 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup sys_crypto
* @{
*
* @file helper.h
* @brief helper functions for sys_crypto_modes
*
* @author Freie Universitaet Berlin, Computer Systems & Telematics
* @author Nico von Geyso <nico.geyso@fu-berlin.de>
*/
#ifndef CRYPTO_HELPER_H
#define CRYPTO_HELPER_H
#include <stddef.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Increment a counter encoded in an 16 octet block. The counter is
* encoded from the least significant bit in the following form:
* block[15-L..15])
*
* @param block encoded block
* @param L length of counter
*/
void crypto_block_inc_ctr(uint8_t block[16], int L);
/**
* @brief Compares two blocks of same size in deterministic time.
*
* @param a block a
* @param b block b
* @param len size of both blocks
*
* @returns 0 iff the blocks are non-equal.
*/
int crypto_equals(uint8_t *a, uint8_t *b, size_t len);
#ifdef __cplusplus
}
#endif
#endif /* CRYPTO_HELPER_H */