1 // This file was automatically generated by protocompiler
3 // Compiled from SecDbBackupRecoverySet.proto
5 #import "SecDbBackupKeyClassSigningKey.h"
6 #import <ProtocolBuffer/PBConstants.h>
7 #import <ProtocolBuffer/PBHashUtil.h>
8 #import <ProtocolBuffer/PBDataReader.h>
10 #if !__has_feature(objc_arc)
11 # 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 @implementation SecDbBackupKeyClassSigningKey
16 @synthesize keyClass = _keyClass;
17 - (void)setKeyClass:(int32_t)v
22 - (void)setHasKeyClass:(BOOL)f
28 return _has.keyClass != 0;
32 return _publicKey != nil;
34 @synthesize publicKey = _publicKey;
37 return _aksRefKey != nil;
39 @synthesize aksRefKey = _aksRefKey;
40 - (BOOL)hasAksWrappedKey
42 return _aksWrappedKey != nil;
44 @synthesize aksWrappedKey = _aksWrappedKey;
45 - (BOOL)hasBackupWrappedKey
47 return _backupWrappedKey != nil;
49 @synthesize backupWrappedKey = _backupWrappedKey;
51 - (NSString *)description
53 return [NSString stringWithFormat:@"%@ %@", [super description], [self dictionaryRepresentation]];
56 - (NSDictionary *)dictionaryRepresentation
58 NSMutableDictionary *dict = [NSMutableDictionary dictionary];
59 if (self->_has.keyClass)
61 [dict setObject:[NSNumber numberWithInt:self->_keyClass] forKey:@"keyClass"];
65 [dict setObject:self->_publicKey forKey:@"publicKey"];
69 [dict setObject:self->_aksRefKey forKey:@"aksRefKey"];
71 if (self->_aksWrappedKey)
73 [dict setObject:self->_aksWrappedKey forKey:@"aksWrappedKey"];
75 if (self->_backupWrappedKey)
77 [dict setObject:self->_backupWrappedKey forKey:@"backupWrappedKey"];
82 BOOL SecDbBackupKeyClassSigningKeyReadFrom(__unsafe_unretained SecDbBackupKeyClassSigningKey *self, __unsafe_unretained PBDataReader *reader) {
83 while (PBReaderHasMoreData(reader)) {
87 PBReaderReadTag32AndType(reader, &tag, &aType);
89 if (PBReaderHasError(reader))
92 if (aType == TYPE_END_GROUP) {
98 case 1 /* keyClass */:
100 self->_has.keyClass = YES;
101 self->_keyClass = PBReaderReadInt32(reader);
104 case 3 /* publicKey */:
106 NSData *new_publicKey = PBReaderReadData(reader);
107 self->_publicKey = new_publicKey;
110 case 4 /* aksRefKey */:
112 NSData *new_aksRefKey = PBReaderReadData(reader);
113 self->_aksRefKey = new_aksRefKey;
116 case 5 /* aksWrappedKey */:
118 NSData *new_aksWrappedKey = PBReaderReadData(reader);
119 self->_aksWrappedKey = new_aksWrappedKey;
122 case 6 /* backupWrappedKey */:
124 NSData *new_backupWrappedKey = PBReaderReadData(reader);
125 self->_backupWrappedKey = new_backupWrappedKey;
129 if (!PBReaderSkipValueWithTag(reader, tag, aType))
134 return !PBReaderHasError(reader);
137 - (BOOL)readFrom:(PBDataReader *)reader
139 return SecDbBackupKeyClassSigningKeyReadFrom(self, reader);
141 - (void)writeTo:(PBDataWriter *)writer
145 if (self->_has.keyClass)
147 PBDataWriterWriteInt32Field(writer, self->_keyClass, 1);
152 if (self->_publicKey)
154 PBDataWriterWriteDataField(writer, self->_publicKey, 3);
159 if (self->_aksRefKey)
161 PBDataWriterWriteDataField(writer, self->_aksRefKey, 4);
166 if (self->_aksWrappedKey)
168 PBDataWriterWriteDataField(writer, self->_aksWrappedKey, 5);
171 /* backupWrappedKey */
173 if (self->_backupWrappedKey)
175 PBDataWriterWriteDataField(writer, self->_backupWrappedKey, 6);
180 - (void)copyTo:(SecDbBackupKeyClassSigningKey *)other
182 if (self->_has.keyClass)
184 other->_keyClass = _keyClass;
185 other->_has.keyClass = YES;
189 other.publicKey = _publicKey;
193 other.aksRefKey = _aksRefKey;
197 other.aksWrappedKey = _aksWrappedKey;
199 if (_backupWrappedKey)
201 other.backupWrappedKey = _backupWrappedKey;
205 - (id)copyWithZone:(NSZone *)zone
207 SecDbBackupKeyClassSigningKey *copy = [[[self class] allocWithZone:zone] init];
208 if (self->_has.keyClass)
210 copy->_keyClass = _keyClass;
211 copy->_has.keyClass = YES;
213 copy->_publicKey = [_publicKey copyWithZone:zone];
214 copy->_aksRefKey = [_aksRefKey copyWithZone:zone];
215 copy->_aksWrappedKey = [_aksWrappedKey copyWithZone:zone];
216 copy->_backupWrappedKey = [_backupWrappedKey copyWithZone:zone];
220 - (BOOL)isEqual:(id)object
222 SecDbBackupKeyClassSigningKey *other = (SecDbBackupKeyClassSigningKey *)object;
223 return [other isMemberOfClass:[self class]]
225 ((self->_has.keyClass && other->_has.keyClass && self->_keyClass == other->_keyClass) || (!self->_has.keyClass && !other->_has.keyClass))
227 ((!self->_publicKey && !other->_publicKey) || [self->_publicKey isEqual:other->_publicKey])
229 ((!self->_aksRefKey && !other->_aksRefKey) || [self->_aksRefKey isEqual:other->_aksRefKey])
231 ((!self->_aksWrappedKey && !other->_aksWrappedKey) || [self->_aksWrappedKey isEqual:other->_aksWrappedKey])
233 ((!self->_backupWrappedKey && !other->_backupWrappedKey) || [self->_backupWrappedKey isEqual:other->_backupWrappedKey])
241 (self->_has.keyClass ? PBHashInt((NSUInteger)self->_keyClass) : 0)
243 [self->_publicKey hash]
245 [self->_aksRefKey hash]
247 [self->_aksWrappedKey hash]
249 [self->_backupWrappedKey hash]
253 - (void)mergeFrom:(SecDbBackupKeyClassSigningKey *)other
255 if (other->_has.keyClass)
257 self->_keyClass = other->_keyClass;
258 self->_has.keyClass = YES;
260 if (other->_publicKey)
262 [self setPublicKey:other->_publicKey];
264 if (other->_aksRefKey)
266 [self setAksRefKey:other->_aksRefKey];
268 if (other->_aksWrappedKey)
270 [self setAksWrappedKey:other->_aksWrappedKey];
272 if (other->_backupWrappedKey)
274 [self setBackupWrappedKey:other->_backupWrappedKey];