]> git.saurik.com Git - apple/security.git/blob - keychain/ot/proto/source/OTBottleContents.m
Security-58286.270.3.0.1.tar.gz
[apple/security.git] / keychain / ot / proto / source / OTBottleContents.m
1 // This file was automatically generated by protocompiler
2 // DO NOT EDIT!
3 // Compiled from OTBottleContents.proto
4
5 #import "OTBottleContents.h"
6 #import <ProtocolBuffer/PBConstants.h>
7 #import <ProtocolBuffer/PBHashUtil.h>
8 #import <ProtocolBuffer/PBDataReader.h>
9
10 #import "OTPrivateKey.h"
11
12 #if !__has_feature(objc_arc)
13 # error This generated file depends on ARC but it is not enabled; turn on ARC, or use 'objc_use_arc' option to generate non-ARC code.
14 #endif
15
16 @implementation OTBottleContents
17
18 - (BOOL)hasReserved1
19 {
20 return _reserved1 != nil;
21 }
22 @synthesize reserved1 = _reserved1;
23 - (BOOL)hasReserved2
24 {
25 return _reserved2 != nil;
26 }
27 @synthesize reserved2 = _reserved2;
28 - (BOOL)hasPeerSigningPrivKey
29 {
30 return _peerSigningPrivKey != nil;
31 }
32 @synthesize peerSigningPrivKey = _peerSigningPrivKey;
33 - (BOOL)hasPeerEncryptionPrivKey
34 {
35 return _peerEncryptionPrivKey != nil;
36 }
37 @synthesize peerEncryptionPrivKey = _peerEncryptionPrivKey;
38
39 - (NSString *)description
40 {
41 return [NSString stringWithFormat:@"%@ %@", [super description], [self dictionaryRepresentation]];
42 }
43
44 - (NSDictionary *)dictionaryRepresentation
45 {
46 NSMutableDictionary *dict = [NSMutableDictionary dictionary];
47 if (self->_reserved1)
48 {
49 [dict setObject:self->_reserved1 forKey:@"reserved1"];
50 }
51 if (self->_reserved2)
52 {
53 [dict setObject:self->_reserved2 forKey:@"reserved2"];
54 }
55 if (self->_peerSigningPrivKey)
56 {
57 [dict setObject:[_peerSigningPrivKey dictionaryRepresentation] forKey:@"peerSigningPrivKey"];
58 }
59 if (self->_peerEncryptionPrivKey)
60 {
61 [dict setObject:[_peerEncryptionPrivKey dictionaryRepresentation] forKey:@"peerEncryptionPrivKey"];
62 }
63 return dict;
64 }
65
66 BOOL OTBottleContentsReadFrom(__unsafe_unretained OTBottleContents *self, __unsafe_unretained PBDataReader *reader) {
67 while (PBReaderHasMoreData(reader)) {
68 uint32_t tag = 0;
69 uint8_t aType = 0;
70
71 PBReaderReadTag32AndType(reader, &tag, &aType);
72
73 if (PBReaderHasError(reader))
74 break;
75
76 if (aType == TYPE_END_GROUP) {
77 break;
78 }
79
80 switch (tag) {
81
82 case 1 /* reserved1 */:
83 {
84 NSData *new_reserved1 = PBReaderReadData(reader);
85 self->_reserved1 = new_reserved1;
86 }
87 break;
88 case 2 /* reserved2 */:
89 {
90 NSData *new_reserved2 = PBReaderReadData(reader);
91 self->_reserved2 = new_reserved2;
92 }
93 break;
94 case 3 /* peerSigningPrivKey */:
95 {
96 OTPrivateKey *new_peerSigningPrivKey = [[OTPrivateKey alloc] init];
97 self->_peerSigningPrivKey = new_peerSigningPrivKey;
98 PBDataReaderMark mark_peerSigningPrivKey;
99 BOOL markError = !PBReaderPlaceMark(reader, &mark_peerSigningPrivKey);
100 if (markError)
101 {
102 return NO;
103 }
104 BOOL inError = !OTPrivateKeyReadFrom(new_peerSigningPrivKey, reader);
105 if (inError)
106 {
107 return NO;
108 }
109 PBReaderRecallMark(reader, &mark_peerSigningPrivKey);
110 }
111 break;
112 case 4 /* peerEncryptionPrivKey */:
113 {
114 OTPrivateKey *new_peerEncryptionPrivKey = [[OTPrivateKey alloc] init];
115 self->_peerEncryptionPrivKey = new_peerEncryptionPrivKey;
116 PBDataReaderMark mark_peerEncryptionPrivKey;
117 BOOL markError = !PBReaderPlaceMark(reader, &mark_peerEncryptionPrivKey);
118 if (markError)
119 {
120 return NO;
121 }
122 BOOL inError = !OTPrivateKeyReadFrom(new_peerEncryptionPrivKey, reader);
123 if (inError)
124 {
125 return NO;
126 }
127 PBReaderRecallMark(reader, &mark_peerEncryptionPrivKey);
128 }
129 break;
130 default:
131 if (!PBReaderSkipValueWithTag(reader, tag, aType))
132 return NO;
133 break;
134 }
135 }
136 return !PBReaderHasError(reader);
137 }
138
139 - (BOOL)readFrom:(PBDataReader *)reader
140 {
141 return OTBottleContentsReadFrom(self, reader);
142 }
143 - (void)writeTo:(PBDataWriter *)writer
144 {
145 /* reserved1 */
146 {
147 if (self->_reserved1)
148 {
149 PBDataWriterWriteDataField(writer, self->_reserved1, 1);
150 }
151 }
152 /* reserved2 */
153 {
154 if (self->_reserved2)
155 {
156 PBDataWriterWriteDataField(writer, self->_reserved2, 2);
157 }
158 }
159 /* peerSigningPrivKey */
160 {
161 if (self->_peerSigningPrivKey != nil)
162 {
163 PBDataWriterWriteSubmessage(writer, self->_peerSigningPrivKey, 3);
164 }
165 }
166 /* peerEncryptionPrivKey */
167 {
168 if (self->_peerEncryptionPrivKey != nil)
169 {
170 PBDataWriterWriteSubmessage(writer, self->_peerEncryptionPrivKey, 4);
171 }
172 }
173 }
174
175 - (void)copyTo:(OTBottleContents *)other
176 {
177 if (_reserved1)
178 {
179 other.reserved1 = _reserved1;
180 }
181 if (_reserved2)
182 {
183 other.reserved2 = _reserved2;
184 }
185 if (_peerSigningPrivKey)
186 {
187 other.peerSigningPrivKey = _peerSigningPrivKey;
188 }
189 if (_peerEncryptionPrivKey)
190 {
191 other.peerEncryptionPrivKey = _peerEncryptionPrivKey;
192 }
193 }
194
195 - (id)copyWithZone:(NSZone *)zone
196 {
197 OTBottleContents *copy = [[[self class] allocWithZone:zone] init];
198 copy->_reserved1 = [_reserved1 copyWithZone:zone];
199 copy->_reserved2 = [_reserved2 copyWithZone:zone];
200 copy->_peerSigningPrivKey = [_peerSigningPrivKey copyWithZone:zone];
201 copy->_peerEncryptionPrivKey = [_peerEncryptionPrivKey copyWithZone:zone];
202 return copy;
203 }
204
205 - (BOOL)isEqual:(id)object
206 {
207 OTBottleContents *other = (OTBottleContents *)object;
208 return [other isMemberOfClass:[self class]]
209 &&
210 ((!self->_reserved1 && !other->_reserved1) || [self->_reserved1 isEqual:other->_reserved1])
211 &&
212 ((!self->_reserved2 && !other->_reserved2) || [self->_reserved2 isEqual:other->_reserved2])
213 &&
214 ((!self->_peerSigningPrivKey && !other->_peerSigningPrivKey) || [self->_peerSigningPrivKey isEqual:other->_peerSigningPrivKey])
215 &&
216 ((!self->_peerEncryptionPrivKey && !other->_peerEncryptionPrivKey) || [self->_peerEncryptionPrivKey isEqual:other->_peerEncryptionPrivKey])
217 ;
218 }
219
220 - (NSUInteger)hash
221 {
222 return 0
223 ^
224 [self->_reserved1 hash]
225 ^
226 [self->_reserved2 hash]
227 ^
228 [self->_peerSigningPrivKey hash]
229 ^
230 [self->_peerEncryptionPrivKey hash]
231 ;
232 }
233
234 - (void)mergeFrom:(OTBottleContents *)other
235 {
236 if (other->_reserved1)
237 {
238 [self setReserved1:other->_reserved1];
239 }
240 if (other->_reserved2)
241 {
242 [self setReserved2:other->_reserved2];
243 }
244 if (self->_peerSigningPrivKey && other->_peerSigningPrivKey)
245 {
246 [self->_peerSigningPrivKey mergeFrom:other->_peerSigningPrivKey];
247 }
248 else if (!self->_peerSigningPrivKey && other->_peerSigningPrivKey)
249 {
250 [self setPeerSigningPrivKey:other->_peerSigningPrivKey];
251 }
252 if (self->_peerEncryptionPrivKey && other->_peerEncryptionPrivKey)
253 {
254 [self->_peerEncryptionPrivKey mergeFrom:other->_peerEncryptionPrivKey];
255 }
256 else if (!self->_peerEncryptionPrivKey && other->_peerEncryptionPrivKey)
257 {
258 [self setPeerEncryptionPrivKey:other->_peerEncryptionPrivKey];
259 }
260 }
261
262 @end
263