1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
|
/*____________________________________________________________________________
pgpPublicKey.h
Copyright (C) 1997 Network Associates Inc. and affiliated companies.
All rights reserved.
$Id: pgpPublicKey.h,v 1.10 1999/03/10 02:54:43 heller Exp $
____________________________________________________________________________*/
#ifndef Included_pgpPublicKey_h /* [ */
#define Included_pgpPublicKey_h
#include "pgpPubTypes.h"
#include "pgpOptionList.h"
/*____________________________________________________________________________
Encryption/Signature Message Formats
____________________________________________________________________________*/
enum PGPPublicKeyMessageFormat_
{
kPGPPublicKeyMessageFormat_PGP = 1,
kPGPPublicKeyMessageFormat_PKCS1 = 2,
kPGPPublicKeyMessageFormat_X509 = 3,
kPGPPublicKeyMessageFormat_IKE = 4,
PGP_ENUM_FORCE( PGPPublicKeyMessageFormat_ )
};
PGPENUM_TYPEDEF( PGPPublicKeyMessageFormat_, PGPPublicKeyMessageFormat );
PGP_BEGIN_C_DECLARATIONS
#if PRAGMA_IMPORT_SUPPORTED
#pragma import on
#endif
/*____________________________________________________________________________
Public-key operations
____________________________________________________________________________*/
/*____________________________________________________________________________
Return a context for public-key operations based on the specified key.
The specified message format is used for all operations with this
context.
____________________________________________________________________________*/
PGPError PGPNewPublicKeyContext( PGPKeyRef publicKeyRef,
PGPPublicKeyMessageFormat messageFormat,
PGPPublicKeyContextRef *outRef );
/*____________________________________________________________________________
Dispose of a public-key context.
____________________________________________________________________________*/
PGPError PGPFreePublicKeyContext( PGPPublicKeyContextRef ref );
/*____________________________________________________________________________
Determine maximum sizes for inputs and outputs.
____________________________________________________________________________*/
PGPError PGPGetPublicKeyOperationSizes( PGPPublicKeyContextRef ref,
PGPSize *maxDecryptedBufferSize,
PGPSize *maxEncryptedBufferSize,
PGPSize *maxSignatureSize );
/*____________________________________________________________________________
Encrypt one block of data, using PKCS-1 padding. Output buffer must
be of size maxEncryptedBufferSize from PGPGetPublicKeyEncryptionSize.
outSize is a return parameter. For some formatting modes the actual
output size may be less than the maximum possible.
____________________________________________________________________________*/
PGPError PGPPublicKeyEncrypt( PGPPublicKeyContextRef ref,
void const *in, PGPSize inSize, void *out,
PGPSize *outSize );
/*____________________________________________________________________________
Verify a signature on a message hash. Returns kPGPError_NoErr on
correct verification, else an error code. The message hash is
finalized and freed by this call (and should not have been finalized
prior to the call).
____________________________________________________________________________*/
PGPError PGPPublicKeyVerifySignature( PGPPublicKeyContextRef ref,
PGPHashContextRef hashContext,
void const *signature, PGPSize signatureSize );
/*____________________________________________________________________________
Verify a signature on a low-level buffer. Returns kPGPError_NOErr
correct verification, else an error code. Not valid with
kPGPPublicKeyMessageFormat_PGP contexts.
____________________________________________________________________________*/
PGPError PGPPublicKeyVerifyRaw( PGPPublicKeyContextRef ref,
void const *signedData, PGPSize signedDataSize,
void const *signature, PGPSize signatureSize );
/*____________________________________________________________________________
Private-key operations
____________________________________________________________________________*/
/*____________________________________________________________________________
Return a context for private-key operations based on the specified
key (which must have a private part). The specified message
format is used for all operations with this context. Unlocks key
data using passphrase.
____________________________________________________________________________*/
PGPError PGPNewPrivateKeyContext( PGPKeyRef privateKeyRef,
PGPPublicKeyMessageFormat messageFormat,
PGPPrivateKeyContextRef *outRef,
PGPOptionListRef firstOption, ...);
/*____________________________________________________________________________
Dispose of a private-key context. All sensitive data is wiped before
being deleted.
____________________________________________________________________________*/
PGPError PGPFreePrivateKeyContext( PGPPrivateKeyContextRef ref );
/*____________________________________________________________________________
Determine maximum sizes for inputs and outputs.
____________________________________________________________________________*/
PGPError PGPGetPrivateKeyOperationSizes( PGPPrivateKeyContextRef ref,
PGPSize *maxDecryptedBufferSize,
PGPSize *maxEncryptedBufferSize,
PGPSize *maxSignatureSize);
/*____________________________________________________________________________
Decrypt one block of data. Output buffer must be of size at least
maxDecryptedBufferSize from PGPGetPrivateKeyDecryptionSize.
outSize is a return parameter. For some formatting modes the actual
output size may be less than the maximum possible.
____________________________________________________________________________*/
PGPError PGPPrivateKeyDecrypt( PGPPrivateKeyContextRef ref,
void const *in, PGPSize inSize, void *out,
PGPSize *outSize );
/*____________________________________________________________________________
Sign a message hash. Output signature buffer must be of size at
least maxSignatureSize from PGPGetPrivateKeyDecryptionSize.
signatureSize is a return parameter. For some formatting modes
the actual signature size may be less than the maximum possible.
The message hash is finalized and freed by this call (and should
not have been finalized prior to the call).
____________________________________________________________________________*/
PGPError PGPPrivateKeySign( PGPPrivateKeyContextRef ref,
PGPHashContextRef hashContext,
void *signature, PGPSize *signatureSize );
/*____________________________________________________________________________
Sign a low level signedData buffer. Output signature buffer must be
of size at least maxSignatureSize from PGPGetPrivateKeyDecryptionSize.
signatureSize is a return parameter. Not valid with
kPGPPublicKeyMessageFormat_PGP contexts.
____________________________________________________________________________*/
PGPError PGPPrivateKeySignRaw( PGPPrivateKeyContextRef ref,
void const *signedData, PGPSize signedDataSize,
void const *signature, PGPSize *signatureSize );
/*____________________________________________________________________________
Miscellaneous operations
____________________________________________________________________________*/
/*____________________________________________________________________________
Given the size of a prime modulus in bits, this returns an appropriate
size for an exponent in bits, such that the work factor to find a
discrete log modulo the modulus is approximately equal to half the
length of the exponent. This makes the exponent an appropriate size
for a subgroup in a discrete log signature scheme. For encryption
schemes, where decryption attacks can be stealthy and undetected, we
use 3/2 times the returned exponent size.
____________________________________________________________________________*/
PGPError PGPDiscreteLogExponentBits( PGPUInt32 modulusBits,
PGPUInt32 *exponentBits );
#if PRAGMA_IMPORT_SUPPORTED
#pragma import reset
#endif
PGP_END_C_DECLARATIONS
#endif /* ] Included_pgpPublicKey_h */
/*__Editor_settings____
Local Variables:
tab-width: 4
End:
vi: ts=4 sw=4
vim: si
_____________________*/
|