X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/cd6c3eeba0c396300391d99e8a17558dca5305fd..99a01cb9f0ce9a6aa95f3a60f53c14f4e216158b:/oaep.h diff --git a/oaep.h b/oaep.h new file mode 100644 index 0000000..3f956b6 --- /dev/null +++ b/oaep.h @@ -0,0 +1,123 @@ +/* -*-c-*- + * + * $Id: oaep.h,v 1.1 2000/07/01 11:18:30 mdw Exp $ + * + * Optimal asymmetric encryption packing + * + * (c) 2000 Straylight/Edgeware + */ + +/*----- Licensing notice --------------------------------------------------* + * + * This file is part of Catacomb. + * + * Catacomb is free software; you can redistribute it and/or modify + * 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: oaep.h,v $ + * Revision 1.1 2000/07/01 11:18:30 mdw + * Support for Optimal Asymmetric Encryption Padding. + * + */ + +/*----- Notes on OAEP -----------------------------------------------------* + * + * Applying OAEP before RSA encryption renders the construction plaintext- + * aware under the random oracle model. This is probably a good thing. OAEP + * was designed by Bellare and Rogaway. This particular variant is the one + * specified in PKCS#1 version 2.0. It's apparently not compatible with the + * OAEP used in the SET protocols. + */ + +#ifndef CATACOMB_OAEP_H +#define CATACOMB_OAEP_H + +#ifdef __cplusplus + extern "C" { +#endif + +/*----- Header files ------------------------------------------------------*/ + +#include +#include + +#ifndef CATACOMB_GCIPHER_H +# include "gcipher.h" +#endif + +#ifndef CATACOMB_GHASH_H +# include "ghash.h" +#endif + +#ifndef CATACOMB_GRAND_H +# include "grand.h" +#endif + +/*----- Data structures ---------------------------------------------------*/ + +typedef struct oaep { + const gccipher *cc; /* Cipher class for masking */ + const gchash *ch; /* Hash class for parameter block */ + grand *r; /* Random number source */ + const void *ep; /* Encoding parameters block */ + size_t epsz; /* Size of the parameter block */ +} oaep; + +/*----- Functions provided ------------------------------------------------*/ + +/* --- @oaep_encode@ --- * + * + * Arguments: @const void *msg@ = pointer to message data + * @size_t msz@ = size of message data + * @void *buf@ = pointer to output buffer + * @size_t sz@ = size of the output buffer + * @void *p@ = pointer to OAEP parameter block + * + * Returns: Zero if all went well, negative on failure. + * + * Use: Implements the operation @EME-OAEP-ENCODE@, as defined in + * PKCS#1 v. 2.0 (RFC2437). + */ + +extern int oaep_encode(const void */*msg*/, size_t /*msz*/, + void */*buf*/, size_t /*sz*/, void */*p*/); + +/* --- @oaep_decode@ --- * + * + * Arguments: @const void *buf@ = pointer to encoded buffer + * @size_t sz@ = size of the encoded buffer + * @dstr *d@ = pointer to destination string + * @void *p@ = pointer to OAEP parameter block + * + * Returns: The length of the output string if successful, negative on + * failure. + * + * Use: Implements the operation @EME-OAEP-DECODE@, as defined in + * PKCS#1 v. 2.0 (RFC2437). + */ + +extern int oaep_decode(const void */*buf*/, size_t /*sz*/, + dstr */*d*/, void */*p*/); + +/*----- That's all, folks -------------------------------------------------*/ + +#ifdef __cplusplus + } +#endif + +#endif