3 * Counter mode, using an network byte order incremented counter,
4 * matching the testcases of NIST 800-38A.
7 /* nettle, low-level cryptographics library
9 * Copyright (C) 2005 Niels Möller
11 * The nettle library is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License as published by
13 * the Free Software Foundation; either version 2.1 of the License, or (at your
14 * option) any later version.
16 * The nettle library is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
19 * License for more details.
21 * You should have received a copy of the GNU Lesser General Public License
22 * along with the nettle library; see the file COPYING.LIB. If not, write to
23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
27 #ifndef NETTLE_CTR_H_INCLUDED
28 #define NETTLE_CTR_H_INCLUDED
30 #include "nettle-types.h"
37 #define ctr_crypt nettle_ctr_crypt
40 ctr_crypt(void *ctx
, nettle_crypt_func
*f
,
41 unsigned block_size
, uint8_t *ctr
,
42 unsigned length
, uint8_t *dst
,
45 #define CTR_CTX(type, size) \
46 { type ctx; uint8_t ctr[size]; }
48 #define CTR_SET_COUNTER(ctx, data) \
49 memcpy((ctx)->ctr, (data), sizeof((ctx)->ctr))
51 #define CTR_CRYPT(self, f, length, dst, src) \
52 (0 ? ((f)(&(self)->ctx, 0, NULL, NULL)) \
53 : ctr_crypt((void *) &(self)->ctx, \
54 (nettle_crypt_func *) (f), \
55 sizeof((self)->ctr), (self)->ctr, \
56 (length), (dst), (src)))
62 #endif /* NETTLE_CTR_H_INCLUDED */