c080c887 |
1 | /* -*-c-*- |
2 | * |
3 | * $Id: pss.h,v 1.1 2000/07/20 20:13:38 mdw Exp $ |
4 | * |
5 | * Probabistic signature scheme |
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: pss.h,v $ |
33 | * Revision 1.1 2000/07/20 20:13:38 mdw |
34 | * Added Bellare and Rogaway's PSS encoding for RSA signatures. |
35 | * |
36 | */ |
37 | |
38 | /*----- Notes on PSS ------------------------------------------------------* |
39 | * |
40 | * Applying PSS before RSA signing renders the construction provably secure, |
41 | * in that the difficulty of forging a signature is directly related to the |
42 | * difficulty of inverting the RSA function, in the random oracle model. |
43 | * This is a good thing. PSS was designed by Bellare and Rogaway. This |
44 | * particular variant is the one specified in draft 1 of PKCS#1 version 2.1. |
45 | * |
46 | * Stanford University have a patent claim on PSS, although if (as seems |
47 | * likely) PSS is included in IEEE P1363, they'll grant a free world-wide |
48 | * licence to use the scheme for signatures with appendix (rather than |
49 | * signatures with message recovery). |
50 | */ |
51 | |
52 | #ifndef CATACOMB_PSS_H |
53 | #define CATACOMB_PSS_H |
54 | |
55 | #ifdef __cplusplus |
56 | extern "C" { |
57 | #endif |
58 | |
59 | /*----- Header files ------------------------------------------------------*/ |
60 | |
61 | #include <mLib/bits.h> |
62 | #include <mLib/dstr.h> |
63 | |
64 | #ifndef CATACOMB_GCIPHER_H |
65 | # include "gcipher.h" |
66 | #endif |
67 | |
68 | #ifndef CATACOMB_GHASH_H |
69 | # include "ghash.h" |
70 | #endif |
71 | |
72 | #ifndef CATACOMB_GRAND_H |
73 | # include "grand.h" |
74 | #endif |
75 | |
76 | /*----- Data structures ---------------------------------------------------*/ |
77 | |
78 | typedef struct pss { |
79 | const gccipher *cc; /* Cipher class for masking */ |
80 | const gchash *ch; /* Hash class for choosing a seed */ |
81 | grand *r; /* Random number source */ |
82 | void *salt; /* Pointer to the salt */ |
83 | } pss; |
84 | |
85 | /*----- Functions provided ------------------------------------------------*/ |
86 | |
87 | /* --- @pss_presign@ --- * |
88 | * |
89 | * Arguments: @pss *pp@ = pointer to PSS parameter block |
90 | * |
91 | * Returns: An initialized generic hash context. |
92 | * |
93 | * Use: Initializes a hash function for signing with PSS. A salt is |
94 | * chosen and written into the parameter block. |
95 | */ |
96 | |
97 | extern ghash *pss_presign(pss */*pp*/); |
98 | |
99 | /* --- @pss_encode@ --- * |
100 | * |
101 | * Arguments: @const void *msg@ = pointer to message (hash) data |
102 | * @size_t msz@ = size of message data |
103 | * @void *buf@ = pointer to output buffer |
104 | * @size_t sz@ = size of the output buffer |
105 | * @void *p@ = pointer to PSS parameter block |
106 | * |
107 | * Returns: Zero of all went well, negative on failure. |
108 | * |
109 | * Use: Implements the operation @EMSA-PSS-ENCODE@, as defined in |
110 | * PKCS#1 v. 2.1 draft 1. |
111 | */ |
112 | |
113 | extern int pss_encode(const void */*msg*/, size_t /*msz*/, |
114 | void */*buf*/, size_t /*sz*/, void */*p*/); |
115 | |
116 | /* --- @pss_decode@ --- * |
117 | * |
118 | * Arguments: @const void *buf@ = pointer to encoded buffer |
119 | * @size_t sz@ = size of the encoded byffer |
120 | * @dstr *d@ = pointer to destination string |
121 | * @void *p@ = pointer to PSS parameter block |
122 | * |
123 | * Returns: The length of the output string (hash) if successful, |
124 | * negative on failure. |
125 | * |
126 | * Use: Implements most of the operation @EMSA_PSS_VERIFY@, as |
127 | * defined in PCSK#1 v. 2.1 draft 1. The salt value is filled |
128 | * in ready for hashing of the data to start. |
129 | */ |
130 | |
131 | extern int pss_decode(const void */*buf*/, size_t /*sz*/, |
132 | dstr */*d*/, void */*p*/); |
133 | |
134 | /* --- @pss_preverify@ --- * |
135 | * |
136 | * Arguments: @pss *pp@ = pointer to PSS parameter block |
137 | * |
138 | * Returns: An initialized generic hash context. |
139 | * |
140 | * Use: Initializes a hash function for use with PSS. A salt is |
141 | * read from the parameter block, where @pss_decode@ should have |
142 | * left it. |
143 | */ |
144 | |
145 | extern ghash *pss_presign(pss */*pp*/); |
146 | |
147 | /* --- @pss_done@ --- * |
148 | * |
149 | * Arguments: @pss *pp@ = pointer to PSS parameter block |
150 | * |
151 | * Returns: --- |
152 | * |
153 | * Use: Disposes of a PSS parameter block once it's finished with. |
154 | */ |
155 | |
156 | extern void pss_done(pss */*pp*/); |
157 | |
158 | /*----- That's all, folks -------------------------------------------------*/ |
159 | |
160 | #ifdef __cplusplus |
161 | } |
162 | #endif |
163 | |
164 | #endif |