Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /* cast128.h
0002 
0003    The CAST-128 block cipher.
0004 
0005    Copyright (C) 2001, 2014 Niels Möller
0006 
0007    This file is part of GNU Nettle.
0008 
0009    GNU Nettle is free software: you can redistribute it and/or
0010    modify it under the terms of either:
0011 
0012      * the GNU Lesser General Public License as published by the Free
0013        Software Foundation; either version 3 of the License, or (at your
0014        option) any later version.
0015 
0016    or
0017 
0018      * the GNU General Public License as published by the Free
0019        Software Foundation; either version 2 of the License, or (at your
0020        option) any later version.
0021 
0022    or both in parallel, as here.
0023 
0024    GNU Nettle is distributed in the hope that it will be useful,
0025    but WITHOUT ANY WARRANTY; without even the implied warranty of
0026    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0027    General Public License for more details.
0028 
0029    You should have received copies of the GNU General Public License and
0030    the GNU Lesser General Public License along with this program.  If
0031    not, see http://www.gnu.org/licenses/.
0032 */
0033  
0034 #ifndef NETTLE_CAST128_H_INCLUDED
0035 #define NETTLE_CAST128_H_INCLUDED
0036 
0037 #include "nettle-types.h"
0038 
0039 #ifdef __cplusplus
0040 extern "C" {
0041 #endif
0042 
0043 /* Name mangling */
0044 #define cast5_set_key nettle_cast5_set_key
0045 #define cast128_set_key nettle_cast128_set_key
0046 #define cast128_encrypt nettle_cast128_encrypt
0047 #define cast128_decrypt nettle_cast128_decrypt
0048 
0049 #define CAST128_BLOCK_SIZE 8
0050 
0051 /* Variable key size between 40 and 128. */
0052 #define CAST5_MIN_KEY_SIZE 5
0053 #define CAST5_MAX_KEY_SIZE 16
0054 
0055 #define CAST128_KEY_SIZE 16
0056 
0057 struct cast128_ctx
0058 {
0059   unsigned rounds;  /* Number of rounds to use, 12 or 16 */
0060   /* Expanded key, rotations (5 bits only) and 32-bit masks. */
0061   unsigned char Kr[16];
0062   uint32_t Km[16];
0063 };
0064 
0065 /* Using variable key size. */
0066 void
0067 cast5_set_key(struct cast128_ctx *ctx,
0068           size_t length, const uint8_t *key);
0069 
0070 void
0071 cast128_set_key(struct cast128_ctx *ctx, const uint8_t *key);
0072 
0073 void
0074 cast128_encrypt(const struct cast128_ctx *ctx,
0075         size_t length, uint8_t *dst,
0076         const uint8_t *src);
0077 void
0078 cast128_decrypt(const struct cast128_ctx *ctx,
0079         size_t length, uint8_t *dst,
0080         const uint8_t *src);
0081 
0082 #ifdef __cplusplus
0083 }
0084 #endif
0085 
0086 #endif /* NETTLE_CAST128_H_INCLUDED */