/* -*-c-*-
*
- * $Id: rc4.h,v 1.1 1999/09/03 08:41:12 mdw Exp $
+ * $Id: rc4.h,v 1.4 2004/04/08 01:36:15 mdw Exp $
*
* The alleged RC4 stream cipher
*
* (c) 1999 Straylight/Edgeware
*/
-/*----- Licensing notice --------------------------------------------------*
+/*----- Licensing notice --------------------------------------------------*
*
* This file is part of Catacomb.
*
* 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: rc4.h,v $
- * Revision 1.1 1999/09/03 08:41:12 mdw
- * Initial import.
- *
- */
-
/*----- Notes on RC4 ------------------------------------------------------*
*
* RC4 is a stream cipher desgigned by Ron Rivest. For a while RC4 was a
* list.
*/
-#ifndef RC4_H
-#define RC4_H
+#ifndef CATACOMB_RC4_H
+#define CATACOMB_RC4_H
#ifdef __cplusplus
extern "C" {
#include <mLib/bits.h>
+#ifndef CATACOMB_GCIPHER_H
+# include "gcipher.h"
+#endif
+
+#ifndef CATACOMB_GRAND_H
+# include "grand.h"
+#endif
+
/*----- Data structures ---------------------------------------------------*/
typedef struct rc4_ctx {
/*----- Functions provided ------------------------------------------------*/
+/* --- @rc4_addkey@ --- *
+ *
+ * Arguments: @rc4_ctx *ctx@ = pointer to context to key
+ * @const void *k@ = pointer to key data to use
+ * @size_t sz@ = size of the key data
+ *
+ * Returns: ---
+ *
+ * Use: Mixes key data with an RC4 context. The RC4 context is not
+ * reset before mixing. This may be used to mix new key
+ * material with an existing RC4 context.
+ */
+
+extern void rc4_addkey(rc4_ctx */*ctx*/, const void */*k*/, size_t /*sz*/);
+
/* --- @rc4_init@ --- *
*
* Arguments: @rc4_ctx *ctx@ = pointer to context to initialize
const void */*src*/, void */*dest*/,
size_t /*sz*/);
+/*----- Generic cipher interface ------------------------------------------*/
+
+#define RC4_KEYSZ 16
+extern const octet rc4_keysz[];
+
+extern const gccipher rc4;
+
+/*----- Generic random number generator interface -------------------------*/
+
+/* --- @rc4_rand@ --- *
+ *
+ * Arguments: @const void *k@ = pointer to key material
+ * @size_t sz@ = size of key material
+ *
+ * Returns: Pointer to generic random number generator interface.
+ *
+ * Use: Creates a random number interface wrapper around an
+ * OFB-mode block cipher.
+ */
+
+extern grand *rc4_rand(const void */*k*/, size_t /*sz*/);
+
/*----- That's all, folks -------------------------------------------------*/
#ifdef __cplusplus