-
Notifications
You must be signed in to change notification settings - Fork 4
/
GPGSignature.h
399 lines (358 loc) · 15.1 KB
/
GPGSignature.h
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
//
// GPGSignature.h
// MacGPGME
//
// Created by davelopper at users.sourceforge.net on Sun Jul 14 2002.
//
//
// Copyright (C) 2001-2006 Mac GPG Project.
//
// This code is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License as published by the Free
// Software Foundation; either version 2.1 of the License, or (at your option)
// any later version.
//
// This code is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
// details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, visit <http://www.gnu.org/> or write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
// MA 02111-1307, USA.
//
// More info at <http://macgpg.sourceforge.net/>
//
#ifndef GPGSIGNATURE_H
#define GPGSIGNATURE_H
#include <MacGPGME/GPGObject.h>
#include <MacGPGME/GPGKey.h>
#ifdef __cplusplus
extern "C" {
#if 0 /* just to make Emacs auto-indent happy */
}
#endif
#endif
/*!
* @typedef GPGSignatureSummaryMask
* @abstract Mask values returned by <code>@link summary summary@/link</code>
* (GPGSignature).
* @constant GPGSignatureSummaryValidMask The signature is fully valid.
* @constant GPGSignatureSummaryGreenMask The signature is good but one might
* want to display some extra
* information. Check the other bits.
* @constant GPGSignatureSummaryRedMask The signature is bad. It might be
* useful to check other bits and
* display more information, i.e. a
* revoked certificate might not render
* a signature invalid when the message
* was received prior to the cause for
* the revocation.
* @constant GPGSignatureSummaryKeyRevokedMask The key or at least one
* certificate has been revoked.
* @constant GPGSignatureSummaryKeyExpiredMask The key or one of the
* certificates has expired. It
* is probably a good idea to
* display the date of the
* expiration.
* @constant GPGSignatureSummarySignatureExpiredMask The signature has
* expired.
* @constant GPGSignatureSummaryKeyMissingMask Can't verify due to a missing
* key or certificate.
* @constant GPGSignatureSummaryCRLMissingMask The CRL (or an equivalent
* mechanism) is not available.
* @constant GPGSignatureSummaryCRLTooOldMask Available CRL is too old.
* @constant GPGSignatureSummaryBadPolicyMask A policy requirement was not
* met.
* @constant GPGSignatureSummarySystemErrorMask A system error occured.
*/
typedef enum {
GPGSignatureSummaryValidMask = 0x0001,
GPGSignatureSummaryGreenMask = 0x0002,
GPGSignatureSummaryRedMask = 0x0004,
GPGSignatureSummaryKeyRevokedMask = 0x0010,
GPGSignatureSummaryKeyExpiredMask = 0x0020,
GPGSignatureSummarySignatureExpiredMask = 0x0040,
GPGSignatureSummaryKeyMissingMask = 0x0080,
GPGSignatureSummaryCRLMissingMask = 0x0100,
GPGSignatureSummaryCRLTooOldMask = 0x0200,
GPGSignatureSummaryBadPolicyMask = 0x0400,
GPGSignatureSummarySystemErrorMask = 0x0800
}GPGSignatureSummaryMask;
/*!
* @typedef GPGPKATrust
* @abstract Trust information gained by means of the PKA system.
* @discussion Depending on the configuration of the engine, this metric may
* also be reflected by the validity of the signature.
* @constant GPGPKATrustUnavailable No PKA information available or
* verification not possible.
* @constant GPGPKATrustBad PKA verification failed.
* @constant GPGPKATrustOK PKA verification succeeded.
* @constant GPGPKATrustRFU <i>Reserved for future use.</i>
* @seealso GPGSignature
*/
typedef enum {
GPGPKATrustUnavailable = 0,
GPGPKATrustBad = 1,
GPGPKATrustOK = 2,
GPGPKATrustRFU = 3,
}GPGPKATrust;
/*!
* @class GPGSignature
* @abstract Represents a data signature (not a key signature - see
* <code>@link //macgpg/occ/cl/GPGKeySignature GPGKeySignature@/link</code>
* for that).
* @discussion GPGSignature objects are returned by
* <code>@link //macgpg/occ/instm/GPGContext(GPGSynchronousOperations)/signatures signatures@/link</code>
* (GPGContext); you should never need to instantiate yourself
* objects of that class. Signatures are also returned after a
* signing operation, but in this case, currently, not all
* attributes have significant values: you can count only on
* <code>@link //macgpg/occ/instm/GPGSignature/algorithm algorithm@/link</code>,
* <code>@link hashAlgorithm hashAlgorithm@/link</code>,
* <code>@link signatureClass signatureClass@/link</code>,
* <code>@link //macgpg/occ/instm/GPGSignature/creationDate creationDate@/link</code>
* and <code>@link //macgpg/occ/instm/GPGSignature/fingerprint fingerprint@/link</code>.
*/
@interface GPGSignature : NSObject <NSCopying>
{
NSString *_fingerprint;
NSCalendarDate *_creationDate;
NSCalendarDate *_expirationDate;
GPGValidity _validity;
GPGError _status;
GPGSignatureSummaryMask _summary;
NSDictionary *_notations;
NSArray *_policyURLs;
GPGError _validityError;
BOOL _wrongKeyUsage;
GPGPublicKeyAlgorithm _algorithm;
GPGHashAlgorithm _hashAlgorithm;
unsigned int _signatureClass;
NSArray *_signatureNotations;
GPGPKATrust _pkaTrust;
NSString *_pkaAddress;
}
/*!
* @method copyWithZone:
* @abstract Implementation of <code>@link //apple_ref/occ/intf/NSCopying NSCopying@/link</code>
* protocol. Returns itself, retained.
* @discussion GPGSignature objects are (currently) immutable.
* @param zone Memory zone (unused).
*/
- (id) copyWithZone:(NSZone *)zone;
/*!
* @methodgroup Attributes
*/
/*!
* @method fingerprint
* @abstract Returns signer's key <i>fingerprint</i> or <i>key ID</i>.
* @discussion Never returns nil.
*/
- (NSString *) fingerprint;
/*!
* @method creationDate
* @abstract Returns <i>signature</i> creation date.
* @discussion Returns nil when not available or invalid.
*/
- (NSCalendarDate *) creationDate;
/*!
* @method expirationDate
* @abstract Returns <i>signature</i> expiration date.
* @discussion Returns nil if signature does not expire.
*
* Not used for new signatures.
*/
- (NSCalendarDate *) expirationDate;
/*!
* @method validity
* @abstract Returns <i>signature</i>'s validity.
* @discussion Not used for new signatures.
*
* Note that a signature's validity is never <code>@link //macgpg/c/econst/GPGValidityUltimate GPGValidityUltimate@/link</code>,
* because <code>@link //macgpg/c/econst/GPGValidityUltimate GPGValidityUltimate@/link</code>
* is reserved for key certification, not for signatures.
*/
- (GPGValidity) validity;
/*!
* @method status
* @abstract Returns <i>signature</i> status.
* @discussion In particular, the following status codes are of interest:<dl>
* <dt><code>@link //macgpg/c/econst/GPGErrorNoError GPGErrorNoError@/link</code></dt>
* <dd>This status indicates that the signature is valid. For the
* combined result this status means that all signatures are
* valid.</dd>
* <dt><code>@link //macgpg/c/econst/GPGErrorSignatureExpired GPGErrorSignatureExpired@/link</code></dt>
* <dd>This status indicates that the signature is valid but
* expired. For the combined result this status means that all
* signatures are valid and expired.</dd>
* <dt><code>@link //macgpg/c/econst/GPGErrorKeyExpired GPGErrorKeyExpired@/link</code></dt>
* <dd>This status indicates that the signature is valid but the
* key used to verify the signature has expired. For the combined
* result this status means that all signatures are valid and all
* keys are expired.</dd>
* <dt><code>@link //macgpg/c/econst/GPGErrorCertificateRevoked GPGErrorCertificateRevoked@/link</code></dt>
* <dd>This status indicates that the signature is valid but the
* key used to verify the signature has been revoked. For the
* combined result this status means that all signatures are valid
* and all keys are revoked.</dd>
* <dt><code>@link //macgpg/c/econst/GPGErrorBadSignature GPGErrorBadSignature@/link</code></dt>
* <dd>This status indicates that the signature is invalid. For the
* combined result this status means that all signatures are
* invalid.</dd>
* <dt><code>@link //macgpg/c/econst/GPGErrorNoPublicKey GPGErrorNoPublicKey@/link</code></dt>
* <dd>This status indicates that the signature could not be
* verified due to a missing key. For the combined result this
* status means that all signatures could not be checked due to
* missing keys.</dd>
* <dt><code>@link //macgpg/c/econst/GPGErrorGeneralError GPGErrorGeneralError@/link</code></dt>
* <dd>This status indicates that there was some other error which
* prevented the signature verification.</dd></dl>
* Not used for new signatures.
*/
- (GPGError) status;
/*!
* @method summary
* @abstract Returns a mask giving a summary of the signature status.
* @discussion Not used for new signatures.
*/
- (GPGSignatureSummaryMask) summary;
/*!
* @method algorithm
* @abstract Returns the public key algorithm used to create the signature.
*/
- (GPGPublicKeyAlgorithm) algorithm;
/*!
* @method hashAlgorithm
* @abstract Returns the hash algorithm used for the signature.
*/
- (GPGHashAlgorithm) hashAlgorithm;
/*!
* @method signatureClass
* @abstract Returns the signature class of a <i>key signature</i> or a new
* signature.
* @discussion The meaning is specific to the crypto engine.
*
* This attribute is not (yet?) available for signatures returned
* after a verification operation.
*/
- (unsigned int) signatureClass;
/*!
* @method pkaTrust
* @abstract Returns the PKA status.
*/
- (GPGPKATrust) pkaTrust;
/*!
* @method pkaAddress
* @abstract Returns the mailbox from the PKA information, or
* <code>nil</code>.
*/
- (NSString *) pkaAddress;
/*!
* @methodgroup Notations
*/
/*!
* @method signatureNotations
* @abstract Returns all signature notations (notation data and policy URLs).
* @discussion Never returns nil.
*/
- (NSArray *) signatureNotations;
/*!
* @methodgroup Misc
*/
/*!
* @method validityError
* @abstract Returns error explaining why a signature is invalid.
* @discussion If a signature is not valid, this provides a reason why.
*
* Not used for new signatures.
*/
- (GPGError) validityError;
/*!
* @method wrongKeyUsage
* @abstract Returns <code>YES</code> if the key was not used according to
* its policy.
* @discussion Not used for new signatures.
*/
- (BOOL) wrongKeyUsage;
/*!
* @methodgroup Convenience methods
*/
/*!
* @method validityDescription
* @abstract Returns <i>signature</i>'s validity in localized human readable
* form.
* @discussion Not used for new signatures.
*/
- (NSString *) validityDescription;
/*!
* @method algorithmDescription
* @abstract Returns the localized description of the public key algorithm
* used to create the signature.
*/
- (NSString *) algorithmDescription;
/*!
* @method hashAlgorithmDescription
* @abstract Returns the localized description of the hash algorithm used for
* the signature.
*/
- (NSString *) hashAlgorithmDescription;
/*!
* @method formattedFingerprint
* @abstract Returns signer's key formatted fingerprint or key ID.
* @discussion If <code>@link //macgpg/occ/instm/GPGSignature/fingerprint fingerprint@/link</code> returns a
* <i>fingerprint</i>, returns <i>fingerprint</i> in hex digit
* form, formatted like this:
*
* <tt>XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX</tt>
*
* or
*
* <tt>XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX</tt>.
*
* If <code>@link //macgpg/occ/instm/GPGSignature/fingerprint fingerprint@/link</code> returns a
* <i>key ID</i>, returns <i>key ID</i> with 32 or 40 hexadecimal
* digits, prefixed by <code>0x</code>.
*/
- (NSString *) formattedFingerprint;
@end
/*!
* @category GPGSignature(GPGSignatureDeprecated)
* @abstract Deprecated methods
*/
@interface GPGSignature(GPGSignatureDeprecated)
/*!
* @method notations
* @abstract Returns a dictionary of <i>notation data</i> key-value pairs.
* @discussion Returns a dictionary of <i>notation data</i> key-value pairs. A
* notation is a key/value pair that is added to the content, it
* can be anything. Value is returned as an
* <code>@link //apple_ref/occ/cl/NSString NSString@/link</code>
* object.
*
* Not used for new signatures.
* @deprecated in version 1.1
* @see //macgpg/occ/instm/GPGSignature/signatureNotations signatureNotations
*/
- (NSDictionary *) notations;
/*!
* @method policyURLs
* @abstract Returns an array of <i>policy URLs</i> as
* <code>@link //apple_ref/occ/cl/NSString NSString@/link</code>
* objects.
* @discussion Returns an array of <i>policy URLs</i> as
* <code>@link //apple_ref/occ/cl/NSString NSString@/link</code>
* objects. A policy URL is an URL to a document that documents
* the persons policy in signing other people's keys.
*
* Not used for new signatures.
* @deprecated in version 1.1
* @see //macgpg/occ/instm/GPGSignature/signatureNotations signatureNotations
*/
- (NSArray *) policyURLs;
@end
#ifdef __cplusplus
}
#endif
#endif /* GPGSIGNATURE_H */