]> git.saurik.com Git - apple/security.git/blob - keychain/ot/proto/source/OTPrivateKey.m
Security-58286.51.6.tar.gz
[apple/security.git] / keychain / ot / proto / source / OTPrivateKey.m
1 // This file was automatically generated by protocompiler
2 // DO NOT EDIT!
3 // Compiled from OTPrivateKey.proto
4
5 #import "OTPrivateKey.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 OTPrivateKey
15
16 @synthesize keyType = _keyType;
17 - (NSString *)keyTypeAsString:(OTPrivateKey_KeyType)value
18 {
19 return OTPrivateKey_KeyTypeAsString(value);
20 }
21 - (OTPrivateKey_KeyType)StringAsKeyType:(NSString *)str
22 {
23 return StringAsOTPrivateKey_KeyType(str);
24 }
25 @synthesize keyData = _keyData;
26
27 - (NSString *)description
28 {
29 return [NSString stringWithFormat:@"%@ %@", [super description], [self dictionaryRepresentation]];
30 }
31
32 - (NSDictionary *)dictionaryRepresentation
33 {
34 NSMutableDictionary *dict = [NSMutableDictionary dictionary];
35 [dict setObject:OTPrivateKey_KeyTypeAsString(self->_keyType) forKey:@"keyType"];
36 if (self->_keyData)
37 {
38 [dict setObject:self->_keyData forKey:@"keyData"];
39 }
40 return dict;
41 }
42
43 BOOL OTPrivateKeyReadFrom(__unsafe_unretained OTPrivateKey *self, __unsafe_unretained PBDataReader *reader) {
44 while (PBReaderHasMoreData(reader)) {
45 uint32_t tag = 0;
46 uint8_t aType = 0;
47
48 PBReaderReadTag32AndType(reader, &tag, &aType);
49
50 if (PBReaderHasError(reader))
51 break;
52
53 if (aType == TYPE_END_GROUP) {
54 break;
55 }
56
57 switch (tag) {
58
59 case 1 /* keyType */:
60 {
61 self->_keyType = PBReaderReadInt32(reader);
62 }
63 break;
64 case 2 /* keyData */:
65 {
66 NSData *new_keyData = PBReaderReadData(reader);
67 self->_keyData = new_keyData;
68 }
69 break;
70 default:
71 if (!PBReaderSkipValueWithTag(reader, tag, aType))
72 return NO;
73 break;
74 }
75 }
76 return !PBReaderHasError(reader);
77 }
78
79 - (BOOL)readFrom:(PBDataReader *)reader
80 {
81 return OTPrivateKeyReadFrom(self, reader);
82 }
83 - (void)writeTo:(PBDataWriter *)writer
84 {
85 /* keyType */
86 {
87 PBDataWriterWriteInt32Field(writer, self->_keyType, 1);
88 }
89 /* keyData */
90 {
91 assert(nil != self->_keyData);
92 PBDataWriterWriteDataField(writer, self->_keyData, 2);
93 }
94 }
95
96 - (void)copyTo:(OTPrivateKey *)other
97 {
98 other->_keyType = _keyType;
99 other.keyData = _keyData;
100 }
101
102 - (id)copyWithZone:(NSZone *)zone
103 {
104 OTPrivateKey *copy = [[[self class] allocWithZone:zone] init];
105 copy->_keyType = _keyType;
106 copy->_keyData = [_keyData copyWithZone:zone];
107 return copy;
108 }
109
110 - (BOOL)isEqual:(id)object
111 {
112 OTPrivateKey *other = (OTPrivateKey *)object;
113 return [other isMemberOfClass:[self class]]
114 &&
115 self->_keyType == other->_keyType
116 &&
117 ((!self->_keyData && !other->_keyData) || [self->_keyData isEqual:other->_keyData])
118 ;
119 }
120
121 - (NSUInteger)hash
122 {
123 return 0
124 ^
125 PBHashInt((NSUInteger)_keyType)
126 ^
127 [self->_keyData hash]
128 ;
129 }
130
131 - (void)mergeFrom:(OTPrivateKey *)other
132 {
133 self->_keyType = other->_keyType;
134 if (other->_keyData)
135 {
136 [self setKeyData:other->_keyData];
137 }
138 }
139
140 @end
141