Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/nettle/cfb.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /* cfb.h
0002 
0003    Cipher feedback mode.
0004 
0005    Copyright (C) 2015, 2017 Dmitry Eremin-Solenikov
0006    Copyright (C) 2001 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_CFB_H_INCLUDED
0036 #define NETTLE_CFB_H_INCLUDED
0037 
0038 #include "nettle-types.h"
0039 
0040 #ifdef __cplusplus
0041 extern "C" {
0042 #endif
0043 
0044 /* Name mangling */
0045 #define cfb_encrypt nettle_cfb_encrypt
0046 #define cfb_decrypt nettle_cfb_decrypt
0047 
0048 #define cfb8_encrypt nettle_cfb8_encrypt
0049 #define cfb8_decrypt nettle_cfb8_decrypt
0050 
0051 void
0052 cfb_encrypt(const void *ctx, nettle_cipher_func *f,
0053         size_t block_size, uint8_t *iv,
0054         size_t length, uint8_t *dst,
0055         const uint8_t *src);
0056 
0057 void
0058 cfb_decrypt(const void *ctx, nettle_cipher_func *f,
0059         size_t block_size, uint8_t *iv,
0060         size_t length, uint8_t *dst,
0061         const uint8_t *src);
0062 
0063 void
0064 cfb8_encrypt(const void *ctx, nettle_cipher_func *f,
0065          size_t block_size, uint8_t *iv,
0066          size_t length, uint8_t *dst,
0067          const uint8_t *src);
0068 
0069 void
0070 cfb8_decrypt(const void *ctx, nettle_cipher_func *f,
0071          size_t block_size, uint8_t *iv,
0072          size_t length, uint8_t *dst,
0073          const uint8_t *src);
0074 
0075 
0076 #define CFB_CTX(type, size) \
0077 { type ctx; uint8_t iv[size]; }
0078 
0079 #define CFB_SET_IV(ctx, data) \
0080 memcpy((ctx)->iv, (data), sizeof((ctx)->iv))
0081 
0082 #define CFB8_CTX CFB_CTX
0083 #define CFB8_SET_IV CFB_SET_IV
0084 
0085 /* NOTE: Avoid using NULL, as we don't include anything defining it. */
0086 #define CFB_ENCRYPT(self, f, length, dst, src)      \
0087   (0 ? ((f)(&(self)->ctx, ~(size_t) 0,          \
0088         (uint8_t *) 0, (const uint8_t *) 0))    \
0089    : cfb_encrypt((void *) &(self)->ctx,         \
0090          (nettle_cipher_func *) (f),        \
0091          sizeof((self)->iv), (self)->iv,    \
0092          (length), (dst), (src)))
0093 
0094 #define CFB_DECRYPT(self, f, length, dst, src)      \
0095   (0 ? ((f)(&(self)->ctx, ~(size_t) 0,          \
0096         (uint8_t *) 0, (const uint8_t *) 0))    \
0097    : cfb_decrypt((void *) &(self)->ctx,         \
0098          (nettle_cipher_func *) (f),        \
0099          sizeof((self)->iv), (self)->iv,    \
0100          (length), (dst), (src)))
0101 
0102 #define CFB8_ENCRYPT(self, f, length, dst, src)     \
0103   (0 ? ((f)(&(self)->ctx, ~(size_t) 0,          \
0104         (uint8_t *) 0, (const uint8_t *) 0))    \
0105    : cfb8_encrypt((void *) &(self)->ctx,        \
0106           (nettle_cipher_func *) (f),       \
0107           sizeof((self)->iv), (self)->iv,   \
0108           (length), (dst), (src)))
0109 
0110 #define CFB8_DECRYPT(self, f, length, dst, src)     \
0111   (0 ? ((f)(&(self)->ctx, ~(size_t) 0,          \
0112         (uint8_t *) 0, (const uint8_t *) 0))    \
0113    : cfb8_decrypt((void *) &(self)->ctx,        \
0114           (nettle_cipher_func *) (f),       \
0115           sizeof((self)->iv), (self)->iv,   \
0116           (length), (dst), (src)))
0117 
0118 #ifdef __cplusplus
0119 }
0120 #endif
0121 
0122 #endif /* NETTLE_CFB_H_INCLUDED */