-
Notifications
You must be signed in to change notification settings - Fork 4
/
GPGRemoteKey.h
208 lines (185 loc) · 6.67 KB
/
GPGRemoteKey.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
//
// GPGRemoteKey.h
// MacGPGME
//
// Created by Robert Goldsmith ([email protected]) on Sat July 9 2005.
//
//
// 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 GPGREMOTEKEY_H
#define GPGREMOTEKEY_H
#include <MacGPGME/GPGObject.h>
#include <MacGPGME/GPGEngine.h>
#include <MacGPGME/GPGContext.h>
#include <MacGPGME/GPGKeyDefines.h>
#ifdef __cplusplus
extern "C" {
#if 0 /* just to make Emacs auto-indent happy */
}
#endif
#endif
/*!
* @class GPGRemoteKey
* @abstract Represents a key on a key server but not in the key ring.
* @discussion Rather than returning actual keys from a remote key match, a key
* server will reply with token representations of the keys, in the
* form of GPGRemoteKey objects. GPGRemoteKey objects are not real
* keys, and cannot be treated as such. However, they can be
* compared against actual keys by checking the <i>short key ID</i>
* of two keys.
*
* GPGRemoteKey objects are returned by
* <code>@link //macgpg/occ/instm/GPGContext(GPGExtendedKeyManagement)/asyncSearchForKeysMatchingPatterns:serverOptions: asyncSearchForKeysMatchingPatterns:serverOptions:@/link</code>
* (GPGContext), or <code>@link //macgpg/occ/instm/GPGContext/operationResults operationResults@/link</code>
* (GPGContext).
*
* GPGRemoteKey objects can be passed (in any combination with
* normal keys) to
* <code>@link //macgpg/occ/instm/GPGContext(GPGExtendedKeyManagement)/asyncDownloadKeys:serverOptions asyncDownloadKeys:serverOptions@/link</code>
* (GPGContext).
*
* GPGRemoteKey objects are immutable and should never be created
* manually.
*/
@interface GPGRemoteKey : GPGObject <NSCopying>
{
NSArray *_userIDs; // Array containing GPGRemoteUserID objects
NSArray *_colonFormatStrings;
int _version;
}
/*!
* @method copyWithZone:
* @abstract Implementation of <code>@link //apple_ref/occ/intf/NSCopying NSCopying@/link</code>
* protocol. Returns itself, retained.
* @discussion GPGRemoteKey objects are immutable.
* @param zone Memory zone (unused)
*/
- (id) copyWithZone:(NSZone *)zone;
/*!
* @method hash
* @abstract Returns hash value based on <i>key ID</i>.
*/
- (unsigned) hash;
/*!
* @method isEqual:
* @abstract Returns <code>YES</code> if both the receiver and <i>anObject</i>
* have the same <i>key ID</i> and of the same class.
*/
- (BOOL) isEqual:(id)anObject;
/*!
* @method dictionaryRepresentation
* @abstract Returns a dictionary containing all key attributes.
* @discussion Returns a dictionary that looks something like this:
* <pre>@textblock {
algo = 17;
created = "2003-05-29 00:33:31 +0100";
expired = 0;
keyid = 2E92F423;
len = 1024;
revoked = 0;
userids = (
"Robert Scott Goldsmith <[email protected]>",
"Robert Scott Goldsmith <[email protected]>"
);
}@/textblock </pre>
*/
- (NSDictionary *) dictionaryRepresentation;
/*!
* @method shortKeyID
* @abstract Returns short (32 bit) <i>key ID</i> using hexadecimal digits.
* @discussion Convenience method. Always returns 8 hexadecimal digits, e.g.
* <code>0A124C58</code>.
* @seealso //macgpg/occ/instm/GPGRemoteKey/keyID keyID
*/
- (NSString *) shortKeyID;
/*!
* @method keyID
* @abstract Returns the key ID in hexadecimal digits.
* @discussion Always returns 16 hexadecimal digits, e.g.
* <code>8CED0ABE0A124C58</code>.
* @seealso //macgpg/occ/instm/GPGRemoteKey/shortKeyID shortKeyID
*/
- (NSString *) keyID;
/*!
* @method algorithm
* @abstract Returns <i>key algorithm</i>.
* @discussion The algorithm is the crypto algorithm for which the <i>key</i>
* (once downloaded) can be used. The value corresponds to the
* <code>@link //macgpg/c/tdef/GPGPublicKeyAlgorithm GPGPublicKeyAlgorithm@/link</code>
* enum values.
*/
- (GPGPublicKeyAlgorithm) algorithm;
/*!
* @method algorithmDescription
* @abstract Returns a non-localized description of the algorithm.
* @discussion Convenience method.
*
* Not always available.
*/
- (NSString *) algorithmDescription;
/*!
* @method length
* @abstract Returns <i>key</i> length, in bits.
*/
- (unsigned int) length;
/*!
* @method creationDate
* @abstract Returns <i>key</i> creation date.
* @discussion Returns nil when not available or invalid.
*/
- (NSCalendarDate *) creationDate;
/*!
* @method expirationDate
* @abstract Returns <i>key</i> expiration date.
* @discussion Returns nil when there is none or is not available or is
* invalid.
*/
- (NSCalendarDate *) expirationDate;
/*!
* @method isKeyRevoked
* @abstract Returns whether key is revoked.
*/
- (BOOL) isKeyRevoked;
/*!
* @method hasKeyExpired
* @abstract Returns whether key is expired.
* @discussion It doesn't compare to current date. Information is computed only
* once when key is retrieved.
*/
- (BOOL) hasKeyExpired;
/*!
* @method userID
* @abstract Returns the <i>primary user ID</i> in a user-presentable
* description using format "Name (Comment) <Email>".
* @discussion Convenience method. Can return nil.
*/
- (NSString *) userID;
/*!
* @method userIDs
* @abstract Returns the <i>user IDs</i>, as <code>@link //macgpg/occ/cl/GPGRemoteUserID GPGRemoteUserID@/link</code> objects.
* @discussion Never returns nil, but can return an empty array.
*/
- (NSArray *) userIDs;
@end
#ifdef __cplusplus
}
#endif
#endif /* GPGREMOTEKEY_H */