X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/8dd8c294e9f330eb6b975c2b96cf9bbfcd087e5e..a6864ad907239985bd1f6eab414cec6171930d46:/twofish.h diff --git a/twofish.h b/twofish.h index c941bc5..65007db 100644 --- a/twofish.h +++ b/twofish.h @@ -1,13 +1,13 @@ /* -*-c-*- * - * $Id: twofish.h,v 1.1 2000/06/17 12:10:17 mdw Exp $ + * $Id: twofish.h,v 1.5 2004/04/08 01:36:15 mdw Exp $ * * The Twofish block cipher * * (c) 2000 Straylight/Edgeware */ -/*----- Licensing notice --------------------------------------------------* +/*----- Licensing notice --------------------------------------------------* * * This file is part of Catacomb. * @@ -15,32 +15,23 @@ * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. - * + * * Catacomb is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. - * + * * You should have received a copy of the GNU Library General Public * License along with Catacomb; if not, write to the Free * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. */ -/*----- Revision history --------------------------------------------------* - * - * $Log: twofish.h,v $ - * Revision 1.1 2000/06/17 12:10:17 mdw - * New cipher. - * - */ - /*----- Notes on the Twofish block cipher ---------------------------------* * * Twofish was designed by Bruce Schneier, John Kelsey, Doug Whiting, David * Wagner, Chris Hall and Niels Ferguson. The algorithm is unpatented and - * free for anyone to use. It is one of the five AES finalist algorithms. - * At the time of writing, the AES competition is still underway. + * free for anyone to use. It was one of the five AES finalist algorithms. * * Twofish is a complex cipher offering various space and time tradeoffs. * This implementation has a heavy key schedule and fast bulk encryption. @@ -74,8 +65,30 @@ typedef struct twofish_ctx { uint32 g[4][256]; } twofish_ctx; +typedef struct twofish_fk { + uint32 t0[8], t23[8], t4[2]; + octet t1[32]; +} twofish_fk; + /*----- Functions provided ------------------------------------------------*/ +/* --- @twofish_initfk@ --- * + * + * Arguments: @twofish_ctx *k@ = pointer to key block to fill in + * @const void *buf@ = pointer to buffer of key material + * @size_t sz@ = size of key material + * @const twofish_fk *fk@ = family-key information + * + * Returns: --- + * + * Use: Does the underlying Twofish key initialization with family + * key. Pass in a family-key structure initialized to + * all-bits-zero for a standard key schedule. + */ + +extern void twofish_initfk(twofish_ctx */*k*/, const void */*buf*/, + size_t /*sz*/, const twofish_fk */*fk*/); + /* --- @twofish_init@ --- * * * Arguments: @twofish_ctx *k@ = pointer to key block to fill in @@ -91,6 +104,21 @@ typedef struct twofish_ctx { extern void twofish_init(twofish_ctx */*k*/, const void */*buf*/, size_t /*sz*/); +/* --- @twofish_fkinit@ --- * + * + * Arguments: @twofish_fk *fk@ = pointer to family key block + * @const void *buf@ = pointer to buffer of key material + * @size_t sz@ = size of key material + * + * Returns: --- + * + * Use: Initializes a family-key buffer. This implementation allows + * family keys of any size acceptable to the Twofish algorithm. + */ + +extern void twofish_fkinit(twofish_fk */*fk*/, + const void */*buf*/, size_t /*sz*/); + /* --- @twofish_eblk@, @twofish_dblk@ --- * * * Arguments: @const twofish_ctx *k@ = pointer to key block @@ -106,7 +134,7 @@ extern void twofish_eblk(const twofish_ctx */*k*/, const uint32 */*s*/, uint32 */*d*/); extern void twofish_dblk(const twofish_ctx */*k*/, - const uint32 */*s*/, uint32 */*d*/); + const uint32 */*s*/, uint32 */*d*/); /*----- That's all, folks -------------------------------------------------*/