]> git.saurik.com Git - apple/security.git/blob - OSX/sec/securityd/SecDbKeychainV7-protobufs/SecDbKeychainSerializedAKSWrappedKey.m
Security-58286.270.3.0.1.tar.gz
[apple/security.git] / OSX / sec / securityd / SecDbKeychainV7-protobufs / SecDbKeychainSerializedAKSWrappedKey.m
1 // This file was automatically generated by protocompiler
2 // DO NOT EDIT!
3 // Compiled from foo.proto
4
5 #import "SecDbKeychainSerializedAKSWrappedKey.h"
6 #import <ProtocolBuffer/PBConstants.h>
7 #import <ProtocolBuffer/PBHashUtil.h>
8 #import <ProtocolBuffer/PBDataReader.h>
9
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.
12 #endif
13
14 @implementation SecDbKeychainSerializedAKSWrappedKey
15
16 @synthesize wrappedKey = _wrappedKey;
17 - (BOOL)hasRefKeyBlob
18 {
19 return _refKeyBlob != nil;
20 }
21 @synthesize refKeyBlob = _refKeyBlob;
22 @synthesize type = _type;
23
24 - (NSString *)description
25 {
26 return [NSString stringWithFormat:@"%@ %@", [super description], [self dictionaryRepresentation]];
27 }
28
29 - (NSDictionary *)dictionaryRepresentation
30 {
31 NSMutableDictionary *dict = [NSMutableDictionary dictionary];
32 if (self->_wrappedKey)
33 {
34 [dict setObject:self->_wrappedKey forKey:@"wrappedKey"];
35 }
36 if (self->_refKeyBlob)
37 {
38 [dict setObject:self->_refKeyBlob forKey:@"refKeyBlob"];
39 }
40 [dict setObject:[NSNumber numberWithUnsignedInt:self->_type] forKey:@"type"];
41 return dict;
42 }
43
44 BOOL SecDbKeychainSerializedAKSWrappedKeyReadFrom(__unsafe_unretained SecDbKeychainSerializedAKSWrappedKey *self, __unsafe_unretained PBDataReader *reader) {
45 while (PBReaderHasMoreData(reader)) {
46 uint32_t tag = 0;
47 uint8_t aType = 0;
48
49 PBReaderReadTag32AndType(reader, &tag, &aType);
50
51 if (PBReaderHasError(reader))
52 break;
53
54 if (aType == TYPE_END_GROUP) {
55 break;
56 }
57
58 switch (tag) {
59
60 case 1 /* wrappedKey */:
61 {
62 NSData *new_wrappedKey = PBReaderReadData(reader);
63 self->_wrappedKey = new_wrappedKey;
64 }
65 break;
66 case 2 /* refKeyBlob */:
67 {
68 NSData *new_refKeyBlob = PBReaderReadData(reader);
69 self->_refKeyBlob = new_refKeyBlob;
70 }
71 break;
72 case 3 /* type */:
73 {
74 self->_type = PBReaderReadUint32(reader);
75 }
76 break;
77 default:
78 if (!PBReaderSkipValueWithTag(reader, tag, aType))
79 return NO;
80 break;
81 }
82 }
83 return !PBReaderHasError(reader);
84 }
85
86 - (BOOL)readFrom:(PBDataReader *)reader
87 {
88 return SecDbKeychainSerializedAKSWrappedKeyReadFrom(self, reader);
89 }
90 - (void)writeTo:(PBDataWriter *)writer
91 {
92 /* wrappedKey */
93 {
94 assert(nil != self->_wrappedKey);
95 PBDataWriterWriteDataField(writer, self->_wrappedKey, 1);
96 }
97 /* refKeyBlob */
98 {
99 if (self->_refKeyBlob)
100 {
101 PBDataWriterWriteDataField(writer, self->_refKeyBlob, 2);
102 }
103 }
104 /* type */
105 {
106 PBDataWriterWriteUint32Field(writer, self->_type, 3);
107 }
108 }
109
110 - (void)copyTo:(SecDbKeychainSerializedAKSWrappedKey *)other
111 {
112 other.wrappedKey = _wrappedKey;
113 if (_refKeyBlob)
114 {
115 other.refKeyBlob = _refKeyBlob;
116 }
117 other->_type = _type;
118 }
119
120 - (id)copyWithZone:(NSZone *)zone
121 {
122 SecDbKeychainSerializedAKSWrappedKey *copy = [[[self class] allocWithZone:zone] init];
123 copy->_wrappedKey = [_wrappedKey copyWithZone:zone];
124 copy->_refKeyBlob = [_refKeyBlob copyWithZone:zone];
125 copy->_type = _type;
126 return copy;
127 }
128
129 - (BOOL)isEqual:(id)object
130 {
131 SecDbKeychainSerializedAKSWrappedKey *other = (SecDbKeychainSerializedAKSWrappedKey *)object;
132 return [other isMemberOfClass:[self class]]
133 &&
134 ((!self->_wrappedKey && !other->_wrappedKey) || [self->_wrappedKey isEqual:other->_wrappedKey])
135 &&
136 ((!self->_refKeyBlob && !other->_refKeyBlob) || [self->_refKeyBlob isEqual:other->_refKeyBlob])
137 &&
138 self->_type == other->_type
139 ;
140 }
141
142 - (NSUInteger)hash
143 {
144 return 0
145 ^
146 [self->_wrappedKey hash]
147 ^
148 [self->_refKeyBlob hash]
149 ^
150 PBHashInt((NSUInteger)_type)
151 ;
152 }
153
154 - (void)mergeFrom:(SecDbKeychainSerializedAKSWrappedKey *)other
155 {
156 if (other->_wrappedKey)
157 {
158 [self setWrappedKey:other->_wrappedKey];
159 }
160 if (other->_refKeyBlob)
161 {
162 [self setRefKeyBlob:other->_refKeyBlob];
163 }
164 self->_type = other->_type;
165 }
166
167 @end
168