|
Packit Service |
4684c1 |
/* cfb.h
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
Cipher feedback mode.
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
Copyright (C) 2015, 2017 Dmitry Eremin-Solenikov
|
|
Packit Service |
4684c1 |
Copyright (C) 2001 Niels Möller
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
This file is part of GNU Nettle.
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
GNU Nettle is free software: you can redistribute it and/or
|
|
Packit Service |
4684c1 |
modify it under the terms of either:
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
* the GNU Lesser General Public License as published by the Free
|
|
Packit Service |
4684c1 |
Software Foundation; either version 3 of the License, or (at your
|
|
Packit Service |
4684c1 |
option) any later version.
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
or
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
* the GNU General Public License as published by the Free
|
|
Packit Service |
4684c1 |
Software Foundation; either version 2 of the License, or (at your
|
|
Packit Service |
4684c1 |
option) any later version.
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
or both in parallel, as here.
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
GNU Nettle is distributed in the hope that it will be useful,
|
|
Packit Service |
4684c1 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
4684c1 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
4684c1 |
General Public License for more details.
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
You should have received copies of the GNU General Public License and
|
|
Packit Service |
4684c1 |
the GNU Lesser General Public License along with this program. If
|
|
Packit Service |
4684c1 |
not, see http://www.gnu.org/licenses/.
|
|
Packit Service |
4684c1 |
*/
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#ifndef GNUTLS_LIB_NETTLE_BACKPORT_NETTLE_CFB_H_INCLUDED
|
|
Packit Service |
4684c1 |
#define GNUTLS_LIB_NETTLE_BACKPORT_NETTLE_CFB_H_INCLUDED
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#include <nettle/nettle-types.h>
|
|
Packit Service |
4684c1 |
#include "block8.h"
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#ifdef __cplusplus
|
|
Packit Service |
4684c1 |
extern "C" {
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
/* Name mangling */
|
|
Packit Service |
4684c1 |
#define cfb_encrypt gnutls_nettle_backport_cfb_encrypt
|
|
Packit Service |
4684c1 |
#define cfb_decrypt gnutls_nettle_backport_cfb_decrypt
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#define cfb8_encrypt gnutls_nettle_backport_cfb8_encrypt
|
|
Packit Service |
4684c1 |
#define cfb8_decrypt gnutls_nettle_backport_cfb8_decrypt
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
void
|
|
Packit Service |
4684c1 |
cfb_encrypt(const void *ctx, nettle_cipher_func *f,
|
|
Packit Service |
4684c1 |
size_t block_size, uint8_t *iv,
|
|
Packit Service |
4684c1 |
size_t length, uint8_t *dst,
|
|
Packit Service |
4684c1 |
const uint8_t *src);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
void
|
|
Packit Service |
4684c1 |
cfb_decrypt(const void *ctx, nettle_cipher_func *f,
|
|
Packit Service |
4684c1 |
size_t block_size, uint8_t *iv,
|
|
Packit Service |
4684c1 |
size_t length, uint8_t *dst,
|
|
Packit Service |
4684c1 |
const uint8_t *src);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
void
|
|
Packit Service |
4684c1 |
cfb8_encrypt(const void *ctx, nettle_cipher_func *f,
|
|
Packit Service |
4684c1 |
size_t block_size, uint8_t *iv,
|
|
Packit Service |
4684c1 |
size_t length, uint8_t *dst,
|
|
Packit Service |
4684c1 |
const uint8_t *src);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
void
|
|
Packit Service |
4684c1 |
cfb8_decrypt(const void *ctx, nettle_cipher_func *f,
|
|
Packit Service |
4684c1 |
size_t block_size, uint8_t *iv,
|
|
Packit Service |
4684c1 |
size_t length, uint8_t *dst,
|
|
Packit Service |
4684c1 |
const uint8_t *src);
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#define CFB_CTX(type, size) \
|
|
Packit Service |
4684c1 |
{ type ctx; uint8_t iv[size]; }
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#define CFB_SET_IV(ctx, data) \
|
|
Packit Service |
4684c1 |
memcpy((ctx)->iv, (data), sizeof((ctx)->iv))
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#define CFB8_CTX CFB_CTX
|
|
Packit Service |
4684c1 |
#define CFB8_SET_IV CFB_SET_IV
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
/* NOTE: Avoid using NULL, as we don't include anything defining it. */
|
|
Packit Service |
4684c1 |
#define CFB_ENCRYPT(self, f, length, dst, src) \
|
|
Packit Service |
4684c1 |
(0 ? ((f)(&(self)->ctx, ~(size_t) 0, \
|
|
Packit Service |
4684c1 |
(uint8_t *) 0, (const uint8_t *) 0)) \
|
|
Packit Service |
4684c1 |
: cfb_encrypt((void *) &(self)->ctx, \
|
|
Packit Service |
4684c1 |
(nettle_cipher_func *) (f), \
|
|
Packit Service |
4684c1 |
sizeof((self)->iv), (self)->iv, \
|
|
Packit Service |
4684c1 |
(length), (dst), (src)))
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#define CFB_DECRYPT(self, f, length, dst, src) \
|
|
Packit Service |
4684c1 |
(0 ? ((f)(&(self)->ctx, ~(size_t) 0, \
|
|
Packit Service |
4684c1 |
(uint8_t *) 0, (const uint8_t *) 0)) \
|
|
Packit Service |
4684c1 |
: cfb_decrypt((void *) &(self)->ctx, \
|
|
Packit Service |
4684c1 |
(nettle_cipher_func *) (f), \
|
|
Packit Service |
4684c1 |
sizeof((self)->iv), (self)->iv, \
|
|
Packit Service |
4684c1 |
(length), (dst), (src)))
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#define CFB8_ENCRYPT(self, f, length, dst, src) \
|
|
Packit Service |
4684c1 |
(0 ? ((f)(&(self)->ctx, ~(size_t) 0, \
|
|
Packit Service |
4684c1 |
(uint8_t *) 0, (const uint8_t *) 0)) \
|
|
Packit Service |
4684c1 |
: cfb8_encrypt((void *) &(self)->ctx, \
|
|
Packit Service |
4684c1 |
(nettle_cipher_func *) (f), \
|
|
Packit Service |
4684c1 |
sizeof((self)->iv), (self)->iv, \
|
|
Packit Service |
4684c1 |
(length), (dst), (src)))
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#define CFB8_DECRYPT(self, f, length, dst, src) \
|
|
Packit Service |
4684c1 |
(0 ? ((f)(&(self)->ctx, ~(size_t) 0, \
|
|
Packit Service |
4684c1 |
(uint8_t *) 0, (const uint8_t *) 0)) \
|
|
Packit Service |
4684c1 |
: cfb8_decrypt((void *) &(self)->ctx, \
|
|
Packit Service |
4684c1 |
(nettle_cipher_func *) (f), \
|
|
Packit Service |
4684c1 |
sizeof((self)->iv), (self)->iv, \
|
|
Packit Service |
4684c1 |
(length), (dst), (src)))
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#ifdef __cplusplus
|
|
Packit Service |
4684c1 |
}
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
#endif /* GNUTLS_LIB_NETTLE_BACKPORT_NETTLE_CFB_H_INCLUDED */
|