3 * $Id: oaep.h,v 1.1 2000/07/01 11:18:30 mdw Exp $
5 * Optimal asymmetric encryption packing
7 * (c) 2000 Straylight/Edgeware
10 /*----- Licensing notice --------------------------------------------------*
12 * This file is part of Catacomb.
14 * Catacomb is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU Library General Public License as
16 * published by the Free Software Foundation; either version 2 of the
17 * License, or (at your option) any later version.
19 * Catacomb is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Library General Public License for more details.
24 * You should have received a copy of the GNU Library General Public
25 * License along with Catacomb; if not, write to the Free
26 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
30 /*----- Revision history --------------------------------------------------*
33 * Revision 1.1 2000/07/01 11:18:30 mdw
34 * Support for Optimal Asymmetric Encryption Padding.
38 /*----- Notes on OAEP -----------------------------------------------------*
40 * Applying OAEP before RSA encryption renders the construction plaintext-
41 * aware under the random oracle model. This is probably a good thing. OAEP
42 * was designed by Bellare and Rogaway. This particular variant is the one
43 * specified in PKCS#1 version 2.0. It's apparently not compatible with the
44 * OAEP used in the SET protocols.
47 #ifndef CATACOMB_OAEP_H
48 #define CATACOMB_OAEP_H
54 /*----- Header files ------------------------------------------------------*/
56 #include <mLib/bits.h>
57 #include <mLib/dstr.h>
59 #ifndef CATACOMB_GCIPHER_H
63 #ifndef CATACOMB_GHASH_H
67 #ifndef CATACOMB_GRAND_H
71 /*----- Data structures ---------------------------------------------------*/
74 const gccipher
*cc
; /* Cipher class for masking */
75 const gchash
*ch
; /* Hash class for parameter block */
76 grand
*r
; /* Random number source */
77 const void *ep
; /* Encoding parameters block */
78 size_t epsz
; /* Size of the parameter block */
81 /*----- Functions provided ------------------------------------------------*/
83 /* --- @oaep_encode@ --- *
85 * Arguments: @const void *msg@ = pointer to message data
86 * @size_t msz@ = size of message data
87 * @void *buf@ = pointer to output buffer
88 * @size_t sz@ = size of the output buffer
89 * @void *p@ = pointer to OAEP parameter block
91 * Returns: Zero if all went well, negative on failure.
93 * Use: Implements the operation @EME-OAEP-ENCODE@, as defined in
94 * PKCS#1 v. 2.0 (RFC2437).
97 extern int oaep_encode(const void */
*msg*/
, size_t /*msz*/,
98 void */
*buf*/
, size_t /*sz*/, void */
*p*/
);
100 /* --- @oaep_decode@ --- *
102 * Arguments: @const void *buf@ = pointer to encoded buffer
103 * @size_t sz@ = size of the encoded buffer
104 * @dstr *d@ = pointer to destination string
105 * @void *p@ = pointer to OAEP parameter block
107 * Returns: The length of the output string if successful, negative on
110 * Use: Implements the operation @EME-OAEP-DECODE@, as defined in
111 * PKCS#1 v. 2.0 (RFC2437).
114 extern int oaep_decode(const void */
*buf*/
, size_t /*sz*/,
115 dstr */
*d*/
, void */
*p*/
);
117 /*----- That's all, folks -------------------------------------------------*/