1 // This file was automatically generated by protocompiler
3 // Compiled from SecDbKeychainSerializedSecretData.proto
5 #import "SecDbKeychainSerializedSecretData.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 SecDbKeychainSerializedSecretData
16 @synthesize ciphertext = _ciphertext;
17 @synthesize wrappedKey = _wrappedKey;
18 @synthesize tamperCheck = _tamperCheck;
19 - (BOOL)hasSecDbBackupWrappedItemKey
21 return _secDbBackupWrappedItemKey != nil;
23 @synthesize secDbBackupWrappedItemKey = _secDbBackupWrappedItemKey;
25 - (NSString *)description
27 return [NSString stringWithFormat:@"%@ %@", [super description], [self dictionaryRepresentation]];
30 - (NSDictionary *)dictionaryRepresentation
32 NSMutableDictionary *dict = [NSMutableDictionary dictionary];
33 if (self->_ciphertext)
35 [dict setObject:self->_ciphertext forKey:@"ciphertext"];
37 if (self->_wrappedKey)
39 [dict setObject:self->_wrappedKey forKey:@"wrappedKey"];
41 if (self->_tamperCheck)
43 [dict setObject:self->_tamperCheck forKey:@"tamperCheck"];
45 if (self->_secDbBackupWrappedItemKey)
47 [dict setObject:self->_secDbBackupWrappedItemKey forKey:@"SecDbBackupWrappedItemKey"];
52 BOOL SecDbKeychainSerializedSecretDataReadFrom(__unsafe_unretained SecDbKeychainSerializedSecretData *self, __unsafe_unretained PBDataReader *reader) {
53 while (PBReaderHasMoreData(reader)) {
57 PBReaderReadTag32AndType(reader, &tag, &aType);
59 if (PBReaderHasError(reader))
62 if (aType == TYPE_END_GROUP) {
68 case 1 /* ciphertext */:
70 NSData *new_ciphertext = PBReaderReadData(reader);
71 self->_ciphertext = new_ciphertext;
74 case 2 /* wrappedKey */:
76 NSData *new_wrappedKey = PBReaderReadData(reader);
77 self->_wrappedKey = new_wrappedKey;
80 case 3 /* tamperCheck */:
82 NSString *new_tamperCheck = PBReaderReadString(reader);
83 self->_tamperCheck = new_tamperCheck;
86 case 4 /* secDbBackupWrappedItemKey */:
88 NSData *new_secDbBackupWrappedItemKey = PBReaderReadData(reader);
89 self->_secDbBackupWrappedItemKey = new_secDbBackupWrappedItemKey;
93 if (!PBReaderSkipValueWithTag(reader, tag, aType))
98 return !PBReaderHasError(reader);
101 - (BOOL)readFrom:(PBDataReader *)reader
103 return SecDbKeychainSerializedSecretDataReadFrom(self, reader);
105 - (void)writeTo:(PBDataWriter *)writer
109 assert(nil != self->_ciphertext);
110 PBDataWriterWriteDataField(writer, self->_ciphertext, 1);
114 assert(nil != self->_wrappedKey);
115 PBDataWriterWriteDataField(writer, self->_wrappedKey, 2);
119 assert(nil != self->_tamperCheck);
120 PBDataWriterWriteStringField(writer, self->_tamperCheck, 3);
122 /* secDbBackupWrappedItemKey */
124 if (self->_secDbBackupWrappedItemKey)
126 PBDataWriterWriteDataField(writer, self->_secDbBackupWrappedItemKey, 4);
131 - (void)copyTo:(SecDbKeychainSerializedSecretData *)other
133 other.ciphertext = _ciphertext;
134 other.wrappedKey = _wrappedKey;
135 other.tamperCheck = _tamperCheck;
136 if (_secDbBackupWrappedItemKey)
138 other.secDbBackupWrappedItemKey = _secDbBackupWrappedItemKey;
142 - (id)copyWithZone:(NSZone *)zone
144 SecDbKeychainSerializedSecretData *copy = [[[self class] allocWithZone:zone] init];
145 copy->_ciphertext = [_ciphertext copyWithZone:zone];
146 copy->_wrappedKey = [_wrappedKey copyWithZone:zone];
147 copy->_tamperCheck = [_tamperCheck copyWithZone:zone];
148 copy->_secDbBackupWrappedItemKey = [_secDbBackupWrappedItemKey copyWithZone:zone];
152 - (BOOL)isEqual:(id)object
154 SecDbKeychainSerializedSecretData *other = (SecDbKeychainSerializedSecretData *)object;
155 return [other isMemberOfClass:[self class]]
157 ((!self->_ciphertext && !other->_ciphertext) || [self->_ciphertext isEqual:other->_ciphertext])
159 ((!self->_wrappedKey && !other->_wrappedKey) || [self->_wrappedKey isEqual:other->_wrappedKey])
161 ((!self->_tamperCheck && !other->_tamperCheck) || [self->_tamperCheck isEqual:other->_tamperCheck])
163 ((!self->_secDbBackupWrappedItemKey && !other->_secDbBackupWrappedItemKey) || [self->_secDbBackupWrappedItemKey isEqual:other->_secDbBackupWrappedItemKey])
171 [self->_ciphertext hash]
173 [self->_wrappedKey hash]
175 [self->_tamperCheck hash]
177 [self->_secDbBackupWrappedItemKey hash]
181 - (void)mergeFrom:(SecDbKeychainSerializedSecretData *)other
183 if (other->_ciphertext)
185 [self setCiphertext:other->_ciphertext];
187 if (other->_wrappedKey)
189 [self setWrappedKey:other->_wrappedKey];
191 if (other->_tamperCheck)
193 [self setTamperCheck:other->_tamperCheck];
195 if (other->_secDbBackupWrappedItemKey)
197 [self setSecDbBackupWrappedItemKey:other->_secDbBackupWrappedItemKey];