1 // This file was automatically generated by protocompiler
3 // Compiled from SecDbKeychainSerializedMetadata.proto
5 #import "SecDbKeychainSerializedMetadata.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 SecDbKeychainSerializedMetadata
16 @synthesize ciphertext = _ciphertext;
17 @synthesize wrappedKey = _wrappedKey;
18 @synthesize tamperCheck = _tamperCheck;
20 - (NSString *)description
22 return [NSString stringWithFormat:@"%@ %@", [super description], [self dictionaryRepresentation]];
25 - (NSDictionary *)dictionaryRepresentation
27 NSMutableDictionary *dict = [NSMutableDictionary dictionary];
28 if (self->_ciphertext)
30 [dict setObject:self->_ciphertext forKey:@"ciphertext"];
32 if (self->_wrappedKey)
34 [dict setObject:self->_wrappedKey forKey:@"wrappedKey"];
36 if (self->_tamperCheck)
38 [dict setObject:self->_tamperCheck forKey:@"tamperCheck"];
43 BOOL SecDbKeychainSerializedMetadataReadFrom(__unsafe_unretained SecDbKeychainSerializedMetadata *self, __unsafe_unretained PBDataReader *reader) {
44 while (PBReaderHasMoreData(reader)) {
48 PBReaderReadTag32AndType(reader, &tag, &aType);
50 if (PBReaderHasError(reader))
53 if (aType == TYPE_END_GROUP) {
59 case 1 /* ciphertext */:
61 NSData *new_ciphertext = PBReaderReadData(reader);
62 self->_ciphertext = new_ciphertext;
65 case 2 /* wrappedKey */:
67 NSData *new_wrappedKey = PBReaderReadData(reader);
68 self->_wrappedKey = new_wrappedKey;
71 case 3 /* tamperCheck */:
73 NSString *new_tamperCheck = PBReaderReadString(reader);
74 self->_tamperCheck = new_tamperCheck;
78 if (!PBReaderSkipValueWithTag(reader, tag, aType))
83 return !PBReaderHasError(reader);
86 - (BOOL)readFrom:(PBDataReader *)reader
88 return SecDbKeychainSerializedMetadataReadFrom(self, reader);
90 - (void)writeTo:(PBDataWriter *)writer
94 assert(nil != self->_ciphertext);
95 PBDataWriterWriteDataField(writer, self->_ciphertext, 1);
99 assert(nil != self->_wrappedKey);
100 PBDataWriterWriteDataField(writer, self->_wrappedKey, 2);
104 assert(nil != self->_tamperCheck);
105 PBDataWriterWriteStringField(writer, self->_tamperCheck, 3);
109 - (void)copyTo:(SecDbKeychainSerializedMetadata *)other
111 other.ciphertext = _ciphertext;
112 other.wrappedKey = _wrappedKey;
113 other.tamperCheck = _tamperCheck;
116 - (id)copyWithZone:(NSZone *)zone
118 SecDbKeychainSerializedMetadata *copy = [[[self class] allocWithZone:zone] init];
119 copy->_ciphertext = [_ciphertext copyWithZone:zone];
120 copy->_wrappedKey = [_wrappedKey copyWithZone:zone];
121 copy->_tamperCheck = [_tamperCheck copyWithZone:zone];
125 - (BOOL)isEqual:(id)object
127 SecDbKeychainSerializedMetadata *other = (SecDbKeychainSerializedMetadata *)object;
128 return [other isMemberOfClass:[self class]]
130 ((!self->_ciphertext && !other->_ciphertext) || [self->_ciphertext isEqual:other->_ciphertext])
132 ((!self->_wrappedKey && !other->_wrappedKey) || [self->_wrappedKey isEqual:other->_wrappedKey])
134 ((!self->_tamperCheck && !other->_tamperCheck) || [self->_tamperCheck isEqual:other->_tamperCheck])
142 [self->_ciphertext hash]
144 [self->_wrappedKey hash]
146 [self->_tamperCheck hash]
150 - (void)mergeFrom:(SecDbKeychainSerializedMetadata *)other
152 if (other->_ciphertext)
154 [self setCiphertext:other->_ciphertext];
156 if (other->_wrappedKey)
158 [self setWrappedKey:other->_wrappedKey];
160 if (other->_tamperCheck)
162 [self setTamperCheck:other->_tamperCheck];