1 // This file was automatically generated by protocompiler
3 // Compiled from SecDbBackupRecoverySet.proto
5 #import "SecDbBackupRecoverySet.h"
6 #import <ProtocolBuffer/PBConstants.h>
7 #import <ProtocolBuffer/PBHashUtil.h>
8 #import <ProtocolBuffer/PBDataReader.h>
10 #import "SecDbBackupBagIdentity.h"
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.
16 @implementation SecDbBackupRecoverySet
18 @synthesize recoveryType = _recoveryType;
19 - (void)setRecoveryType:(int32_t)v
21 _has.recoveryType = YES;
24 - (void)setHasRecoveryType:(BOOL)f
26 _has.recoveryType = f;
28 - (BOOL)hasRecoveryType
30 return _has.recoveryType;
32 - (BOOL)hasBagIdentity
34 return _bagIdentity != nil;
36 @synthesize bagIdentity = _bagIdentity;
37 - (BOOL)hasWrappedBagSecret
39 return _wrappedBagSecret != nil;
41 @synthesize wrappedBagSecret = _wrappedBagSecret;
42 - (BOOL)hasWrappedKCSKSecret
44 return _wrappedKCSKSecret != nil;
46 @synthesize wrappedKCSKSecret = _wrappedKCSKSecret;
47 - (BOOL)hasWrappedRecoveryKey
49 return _wrappedRecoveryKey != nil;
51 @synthesize wrappedRecoveryKey = _wrappedRecoveryKey;
53 - (NSString *)description
55 return [NSString stringWithFormat:@"%@ %@", [super description], [self dictionaryRepresentation]];
58 - (NSDictionary *)dictionaryRepresentation
60 NSMutableDictionary *dict = [NSMutableDictionary dictionary];
61 if (self->_has.recoveryType)
63 [dict setObject:[NSNumber numberWithInt:self->_recoveryType] forKey:@"recoveryType"];
65 if (self->_bagIdentity)
67 [dict setObject:[_bagIdentity dictionaryRepresentation] forKey:@"bagIdentity"];
69 if (self->_wrappedBagSecret)
71 [dict setObject:self->_wrappedBagSecret forKey:@"wrappedBagSecret"];
73 if (self->_wrappedKCSKSecret)
75 [dict setObject:self->_wrappedKCSKSecret forKey:@"wrappedKCSKSecret"];
77 if (self->_wrappedRecoveryKey)
79 [dict setObject:self->_wrappedRecoveryKey forKey:@"wrappedRecoveryKey"];
84 BOOL SecDbBackupRecoverySetReadFrom(__unsafe_unretained SecDbBackupRecoverySet *self, __unsafe_unretained PBDataReader *reader) {
85 while (PBReaderHasMoreData(reader)) {
89 PBReaderReadTag32AndType(reader, &tag, &aType);
91 if (PBReaderHasError(reader))
94 if (aType == TYPE_END_GROUP) {
100 case 1 /* recoveryType */:
102 self->_has.recoveryType = YES;
103 self->_recoveryType = PBReaderReadInt32(reader);
106 case 2 /* bagIdentity */:
108 SecDbBackupBagIdentity *new_bagIdentity = [[SecDbBackupBagIdentity alloc] init];
109 self->_bagIdentity = new_bagIdentity;
110 PBDataReaderMark mark_bagIdentity;
111 BOOL markError = !PBReaderPlaceMark(reader, &mark_bagIdentity);
116 BOOL inError = !SecDbBackupBagIdentityReadFrom(new_bagIdentity, reader);
121 PBReaderRecallMark(reader, &mark_bagIdentity);
124 case 3 /* wrappedBagSecret */:
126 NSData *new_wrappedBagSecret = PBReaderReadData(reader);
127 self->_wrappedBagSecret = new_wrappedBagSecret;
130 case 4 /* wrappedKCSKSecret */:
132 NSData *new_wrappedKCSKSecret = PBReaderReadData(reader);
133 self->_wrappedKCSKSecret = new_wrappedKCSKSecret;
136 case 5 /* wrappedRecoveryKey */:
138 NSData *new_wrappedRecoveryKey = PBReaderReadData(reader);
139 self->_wrappedRecoveryKey = new_wrappedRecoveryKey;
143 if (!PBReaderSkipValueWithTag(reader, tag, aType))
148 return !PBReaderHasError(reader);
151 - (BOOL)readFrom:(PBDataReader *)reader
153 return SecDbBackupRecoverySetReadFrom(self, reader);
155 - (void)writeTo:(PBDataWriter *)writer
159 if (self->_has.recoveryType)
161 PBDataWriterWriteInt32Field(writer, self->_recoveryType, 1);
166 if (self->_bagIdentity != nil)
168 PBDataWriterWriteSubmessage(writer, self->_bagIdentity, 2);
171 /* wrappedBagSecret */
173 if (self->_wrappedBagSecret)
175 PBDataWriterWriteDataField(writer, self->_wrappedBagSecret, 3);
178 /* wrappedKCSKSecret */
180 if (self->_wrappedKCSKSecret)
182 PBDataWriterWriteDataField(writer, self->_wrappedKCSKSecret, 4);
185 /* wrappedRecoveryKey */
187 if (self->_wrappedRecoveryKey)
189 PBDataWriterWriteDataField(writer, self->_wrappedRecoveryKey, 5);
194 - (void)copyTo:(SecDbBackupRecoverySet *)other
196 if (self->_has.recoveryType)
198 other->_recoveryType = _recoveryType;
199 other->_has.recoveryType = YES;
203 other.bagIdentity = _bagIdentity;
205 if (_wrappedBagSecret)
207 other.wrappedBagSecret = _wrappedBagSecret;
209 if (_wrappedKCSKSecret)
211 other.wrappedKCSKSecret = _wrappedKCSKSecret;
213 if (_wrappedRecoveryKey)
215 other.wrappedRecoveryKey = _wrappedRecoveryKey;
219 - (id)copyWithZone:(NSZone *)zone
221 SecDbBackupRecoverySet *copy = [[[self class] allocWithZone:zone] init];
222 if (self->_has.recoveryType)
224 copy->_recoveryType = _recoveryType;
225 copy->_has.recoveryType = YES;
227 copy->_bagIdentity = [_bagIdentity copyWithZone:zone];
228 copy->_wrappedBagSecret = [_wrappedBagSecret copyWithZone:zone];
229 copy->_wrappedKCSKSecret = [_wrappedKCSKSecret copyWithZone:zone];
230 copy->_wrappedRecoveryKey = [_wrappedRecoveryKey copyWithZone:zone];
234 - (BOOL)isEqual:(id)object
236 SecDbBackupRecoverySet *other = (SecDbBackupRecoverySet *)object;
237 return [other isMemberOfClass:[self class]]
239 ((self->_has.recoveryType && other->_has.recoveryType && self->_recoveryType == other->_recoveryType) || (!self->_has.recoveryType && !other->_has.recoveryType))
241 ((!self->_bagIdentity && !other->_bagIdentity) || [self->_bagIdentity isEqual:other->_bagIdentity])
243 ((!self->_wrappedBagSecret && !other->_wrappedBagSecret) || [self->_wrappedBagSecret isEqual:other->_wrappedBagSecret])
245 ((!self->_wrappedKCSKSecret && !other->_wrappedKCSKSecret) || [self->_wrappedKCSKSecret isEqual:other->_wrappedKCSKSecret])
247 ((!self->_wrappedRecoveryKey && !other->_wrappedRecoveryKey) || [self->_wrappedRecoveryKey isEqual:other->_wrappedRecoveryKey])
255 (self->_has.recoveryType ? PBHashInt((NSUInteger)self->_recoveryType) : 0)
257 [self->_bagIdentity hash]
259 [self->_wrappedBagSecret hash]
261 [self->_wrappedKCSKSecret hash]
263 [self->_wrappedRecoveryKey hash]
267 - (void)mergeFrom:(SecDbBackupRecoverySet *)other
269 if (other->_has.recoveryType)
271 self->_recoveryType = other->_recoveryType;
272 self->_has.recoveryType = YES;
274 if (self->_bagIdentity && other->_bagIdentity)
276 [self->_bagIdentity mergeFrom:other->_bagIdentity];
278 else if (!self->_bagIdentity && other->_bagIdentity)
280 [self setBagIdentity:other->_bagIdentity];
282 if (other->_wrappedBagSecret)
284 [self setWrappedBagSecret:other->_wrappedBagSecret];
286 if (other->_wrappedKCSKSecret)
288 [self setWrappedKCSKSecret:other->_wrappedKCSKSecret];
290 if (other->_wrappedRecoveryKey)
292 [self setWrappedRecoveryKey:other->_wrappedRecoveryKey];