99a01cb9 |
1 | /* -*-c-*- |
2 | * |
3 | * $Id: oaep.h,v 1.1 2000/07/01 11:18:30 mdw Exp $ |
4 | * |
5 | * Optimal asymmetric encryption packing |
6 | * |
7 | * (c) 2000 Straylight/Edgeware |
8 | */ |
9 | |
10 | /*----- Licensing notice --------------------------------------------------* |
11 | * |
12 | * This file is part of Catacomb. |
13 | * |
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. |
18 | * |
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. |
23 | * |
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, |
27 | * MA 02111-1307, USA. |
28 | */ |
29 | |
30 | /*----- Revision history --------------------------------------------------* |
31 | * |
32 | * $Log: oaep.h,v $ |
33 | * Revision 1.1 2000/07/01 11:18:30 mdw |
34 | * Support for Optimal Asymmetric Encryption Padding. |
35 | * |
36 | */ |
37 | |
38 | /*----- Notes on OAEP -----------------------------------------------------* |
39 | * |
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. |
45 | */ |
46 | |
47 | #ifndef CATACOMB_OAEP_H |
48 | #define CATACOMB_OAEP_H |
49 | |
50 | #ifdef __cplusplus |
51 | extern "C" { |
52 | #endif |
53 | |
54 | /*----- Header files ------------------------------------------------------*/ |
55 | |
56 | #include <mLib/bits.h> |
57 | #include <mLib/dstr.h> |
58 | |
59 | #ifndef CATACOMB_GCIPHER_H |
60 | # include "gcipher.h" |
61 | #endif |
62 | |
63 | #ifndef CATACOMB_GHASH_H |
64 | # include "ghash.h" |
65 | #endif |
66 | |
67 | #ifndef CATACOMB_GRAND_H |
68 | # include "grand.h" |
69 | #endif |
70 | |
71 | /*----- Data structures ---------------------------------------------------*/ |
72 | |
73 | typedef struct oaep { |
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 */ |
79 | } oaep; |
80 | |
81 | /*----- Functions provided ------------------------------------------------*/ |
82 | |
83 | /* --- @oaep_encode@ --- * |
84 | * |
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 |
90 | * |
91 | * Returns: Zero if all went well, negative on failure. |
92 | * |
93 | * Use: Implements the operation @EME-OAEP-ENCODE@, as defined in |
94 | * PKCS#1 v. 2.0 (RFC2437). |
95 | */ |
96 | |
97 | extern int oaep_encode(const void */*msg*/, size_t /*msz*/, |
98 | void */*buf*/, size_t /*sz*/, void */*p*/); |
99 | |
100 | /* --- @oaep_decode@ --- * |
101 | * |
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 |
106 | * |
107 | * Returns: The length of the output string if successful, negative on |
108 | * failure. |
109 | * |
110 | * Use: Implements the operation @EME-OAEP-DECODE@, as defined in |
111 | * PKCS#1 v. 2.0 (RFC2437). |
112 | */ |
113 | |
114 | extern int oaep_decode(const void */*buf*/, size_t /*sz*/, |
115 | dstr */*d*/, void */*p*/); |
116 | |
117 | /*----- That's all, folks -------------------------------------------------*/ |
118 | |
119 | #ifdef __cplusplus |
120 | } |
121 | #endif |
122 | |
123 | #endif |