Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:02:15

0001 /* ctr.h
0002 
0003    Counter mode, using an network byte order incremented counter,
0004    matching the testcases of NIST 800-38A.
0005 
0006    Copyright (C) 2005 Niels Möller
0007 
0008    This file is part of GNU Nettle.
0009 
0010    GNU Nettle is free software: you can redistribute it and/or
0011    modify it under the terms of either:
0012 
0013      * the GNU Lesser General Public License as published by the Free
0014        Software Foundation; either version 3 of the License, or (at your
0015        option) any later version.
0016 
0017    or
0018 
0019      * the GNU General Public License as published by the Free
0020        Software Foundation; either version 2 of the License, or (at your
0021        option) any later version.
0022 
0023    or both in parallel, as here.
0024 
0025    GNU Nettle is distributed in the hope that it will be useful,
0026    but WITHOUT ANY WARRANTY; without even the implied warranty of
0027    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0028    General Public License for more details.
0029 
0030    You should have received copies of the GNU General Public License and
0031    the GNU Lesser General Public License along with this program.  If
0032    not, see http://www.gnu.org/licenses/.
0033 */
0034 
0035 #ifndef NETTLE_CTR_H_INCLUDED
0036 #define NETTLE_CTR_H_INCLUDED
0037 
0038 #include "nettle-types.h"
0039 
0040 #ifdef __cplusplus
0041 extern "C" {
0042 #endif
0043 
0044 /* Name mangling */
0045 #define ctr_crypt nettle_ctr_crypt
0046 
0047 void
0048 ctr_crypt(const void *ctx, nettle_cipher_func *f,
0049       size_t block_size, uint8_t *ctr,
0050       size_t length, uint8_t *dst,
0051       const uint8_t *src);
0052 
0053 #define CTR_CTX(type, size) \
0054 { type ctx; uint8_t ctr[size]; }
0055 
0056 #define CTR_SET_COUNTER(ctx, data) \
0057 memcpy((ctx)->ctr, (data), sizeof((ctx)->ctr))
0058 
0059 #define CTR_CRYPT(self, f, length, dst, src)        \
0060   (0 ? ((f)(&(self)->ctx, ~(size_t) 0,          \
0061       (uint8_t *) 0, (const uint8_t *) 0))      \
0062    : ctr_crypt((void *) &(self)->ctx,           \
0063            (nettle_cipher_func *) (f),      \
0064            sizeof((self)->ctr), (self)->ctr,    \
0065            (length), (dst), (src)))
0066 
0067 #ifdef __cplusplus
0068 }
0069 #endif
0070 
0071 #endif /* NETTLE_CTR_H_INCLUDED */