chiark / gitweb /
Version bump.
[catacomb] / pkcs1.h
1 /* -*-c-*-
2  *
3  * $Id: pkcs1.h,v 1.1 2000/07/01 11:17:38 mdw Exp $
4  *
5  * PKCS#1 1.5 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: pkcs1.h,v $
33  * Revision 1.1  2000/07/01 11:17:38  mdw
34  * New support for PKCS#1 message encoding.
35  *
36  */
37
38 #ifndef CATACOMB_PKCS1_H
39 #define CATACOMB_PKCS1_H
40
41 #ifdef __cplusplus
42   extern "C" {
43 #endif
44
45 /*----- Header files ------------------------------------------------------*/
46
47 #include <mLib/bits.h>
48 #include <mLib/dstr.h>
49
50 #ifndef CATACOMB_GRAND_H
51 #  include "grand.h"
52 #endif
53
54 /*----- Data structures ---------------------------------------------------*/
55
56 typedef struct pkcs1 {
57   grand *r;                             /* Random number source */
58   const void *ep;                       /* Encoding parameters block */
59   size_t epsz;                          /* Size of the parameter block */
60 } pkcs1;
61
62 /*----- Functions provided ------------------------------------------------*/
63
64 /* --- @pkcs1_cryptencode@ --- *
65  *
66  * Arguments:   @const void *msg@ = pointer to message data
67  *              @size_t msz@ = size of message data
68  *              @void *buf@ = pointer to output buffer
69  *              @size_t sz@ = size of the output buffer
70  *              @void *p@ = pointer to PKCS1 parameter block
71  *
72  * Returns:     Zero if all went well, negative on failure.
73  *
74  * Use:         Implements the operation @EME-PKCS1-V1_5-ENCODE@, as defined
75  *              in PKCS#1 v. 2.0 (RFC2437).
76  */
77
78 extern int pkcs1_cryptencode(const void */*msg*/, size_t /*msz*/,
79                              void */*buf*/, size_t /*sz*/, void */*p*/);
80
81 /* --- @pkcs1_cryptdecode@ --- *
82  *
83  * Arguments:   @const void *buf@ = pointer to encoded buffer)
84  *              @size_t sz@ = size of the encoded buffer
85  *              @dstr *d@ = pointer to destination string
86  *              @void *p@ = pointer to PKCS1 parameter block
87  *
88  * Returns:     The length of the output string if successful, negative on
89  *              failure.
90  *
91  * Use:         Implements the operation @EME-PKCS1-V1_5-DECODE@, as defined
92  *              in PKCS#1 v. 2.0 (RFC2437).
93  */
94
95 extern int pkcs1_cryptdecode(const void */*buf*/, size_t /*sz*/,
96                              dstr */*d*/, void */*p*/);
97
98 /* --- @pkcs1_sigencode@ --- *
99  *
100  * Arguments:   @const void *msg@ = pointer to message data
101  *              @size_t msz@ = size of message data
102  *              @void *buf@ = pointer to output buffer
103  *              @size_t sz@ = size of the output buffer
104  *              @void *p@ = pointer to PKCS1 parameter block
105  *
106  * Returns:     Zero if all went well, negative on failure.
107  *
108  * Use:         Implements the operation @EMSA-PKCS1-V1_5-ENCODE@, as defined
109  *              in PKCS#1 v. 2.0 (RFC2437).
110  */
111
112 extern int pkcs1_sigencode(const void */*msg*/, size_t /*msz*/,
113                            void */*buf*/, size_t /*sz*/, void */*p*/);
114
115 /* --- @pkcs1_sigdecode@ --- *
116  *
117  * Arguments:   @const void *buf@ = pointer to encoded buffer
118  *              @size_t sz@ = size of the encoded buffer
119  *              @dstr *d@ = pointer to destination string
120  *              @void *p@ = pointer to PKCS1 parameter block
121  *
122  * Returns:     The length of the output string if successful, negative on
123  *              failure.
124  *
125  * Use:         Implements the operation @EMSA-PKCS1-V1_5-DECODE@, as defined
126  *              in PKCS#1 v. 2.0 (RFC2437).
127  */
128
129 extern int pkcs1_sigdecode(const void */*buf*/, size_t /*sz*/,
130                            dstr */*d*/, void */*p*/);
131
132 /*----- That's all, folks -------------------------------------------------*/
133
134 #ifdef __cplusplus
135   }
136 #endif
137
138 #endif