1 // This file was automatically generated by protocompiler
3 // Compiled from SecDbKeychainSerializedAKSWrappedKey.proto
5 #import "SecDbKeychainSerializedAKSWrappedKey.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 SecDbKeychainSerializedAKSWrappedKey
16 @synthesize wrappedKey = _wrappedKey;
19 return _refKeyBlob != nil;
21 @synthesize refKeyBlob = _refKeyBlob;
22 @synthesize type = _type;
24 - (NSString *)description
26 return [NSString stringWithFormat:@"%@ %@", [super description], [self dictionaryRepresentation]];
29 - (NSDictionary *)dictionaryRepresentation
31 NSMutableDictionary *dict = [NSMutableDictionary dictionary];
32 if (self->_wrappedKey)
34 [dict setObject:self->_wrappedKey forKey:@"wrappedKey"];
36 if (self->_refKeyBlob)
38 [dict setObject:self->_refKeyBlob forKey:@"refKeyBlob"];
40 [dict setObject:[NSNumber numberWithUnsignedInt:self->_type] forKey:@"type"];
44 BOOL SecDbKeychainSerializedAKSWrappedKeyReadFrom(__unsafe_unretained SecDbKeychainSerializedAKSWrappedKey *self, __unsafe_unretained PBDataReader *reader) {
45 while (PBReaderHasMoreData(reader)) {
49 PBReaderReadTag32AndType(reader, &tag, &aType);
51 if (PBReaderHasError(reader))
54 if (aType == TYPE_END_GROUP) {
60 case 1 /* wrappedKey */:
62 NSData *new_wrappedKey = PBReaderReadData(reader);
63 self->_wrappedKey = new_wrappedKey;
66 case 2 /* refKeyBlob */:
68 NSData *new_refKeyBlob = PBReaderReadData(reader);
69 self->_refKeyBlob = new_refKeyBlob;
74 self->_type = PBReaderReadUint32(reader);
78 if (!PBReaderSkipValueWithTag(reader, tag, aType))
83 return !PBReaderHasError(reader);
86 - (BOOL)readFrom:(PBDataReader *)reader
88 return SecDbKeychainSerializedAKSWrappedKeyReadFrom(self, reader);
90 - (void)writeTo:(PBDataWriter *)writer
94 assert(nil != self->_wrappedKey);
95 PBDataWriterWriteDataField(writer, self->_wrappedKey, 1);
99 if (self->_refKeyBlob)
101 PBDataWriterWriteDataField(writer, self->_refKeyBlob, 2);
106 PBDataWriterWriteUint32Field(writer, self->_type, 3);
110 - (void)copyTo:(SecDbKeychainSerializedAKSWrappedKey *)other
112 other.wrappedKey = _wrappedKey;
115 other.refKeyBlob = _refKeyBlob;
117 other->_type = _type;
120 - (id)copyWithZone:(NSZone *)zone
122 SecDbKeychainSerializedAKSWrappedKey *copy = [[[self class] allocWithZone:zone] init];
123 copy->_wrappedKey = [_wrappedKey copyWithZone:zone];
124 copy->_refKeyBlob = [_refKeyBlob copyWithZone:zone];
129 - (BOOL)isEqual:(id)object
131 SecDbKeychainSerializedAKSWrappedKey *other = (SecDbKeychainSerializedAKSWrappedKey *)object;
132 return [other isMemberOfClass:[self class]]
134 ((!self->_wrappedKey && !other->_wrappedKey) || [self->_wrappedKey isEqual:other->_wrappedKey])
136 ((!self->_refKeyBlob && !other->_refKeyBlob) || [self->_refKeyBlob isEqual:other->_refKeyBlob])
138 self->_type == other->_type
146 [self->_wrappedKey hash]
148 [self->_refKeyBlob hash]
150 PBHashInt((NSUInteger)_type)
154 - (void)mergeFrom:(SecDbKeychainSerializedAKSWrappedKey *)other
156 if (other->_wrappedKey)
158 [self setWrappedKey:other->_wrappedKey];
160 if (other->_refKeyBlob)
162 [self setRefKeyBlob:other->_refKeyBlob];
164 self->_type = other->_type;