SecDbBackupKeyClassSigningKey.m   [plain text]

// This file was automatically generated by protocompiler
// DO NOT EDIT!
// Compiled from SecDbBackupRecoverySet.proto

#import "SecDbBackupKeyClassSigningKey.h"
#import <ProtocolBuffer/PBConstants.h>
#import <ProtocolBuffer/PBHashUtil.h>
#import <ProtocolBuffer/PBDataReader.h>

#if !__has_feature(objc_arc)
# 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.
#endif

@implementation SecDbBackupKeyClassSigningKey

@synthesize keyClass = _keyClass;
- (void)setKeyClass:(int32_t)v
{
_has.keyClass = YES;
_keyClass = v;
}
- (void)setHasKeyClass:(BOOL)f
{
_has.keyClass = f;
}
- (BOOL)hasKeyClass
{
return _has.keyClass != 0;
}
- (BOOL)hasPublicKey
{
return _publicKey != nil;
}
@synthesize publicKey = _publicKey;
- (BOOL)hasAksRefKey
{
return _aksRefKey != nil;
}
@synthesize aksRefKey = _aksRefKey;
- (BOOL)hasAksWrappedKey
{
return _aksWrappedKey != nil;
}
@synthesize aksWrappedKey = _aksWrappedKey;
- (BOOL)hasBackupWrappedKey
{
return _backupWrappedKey != nil;
}
@synthesize backupWrappedKey = _backupWrappedKey;

- (NSString *)description
{
return [NSString stringWithFormat:@"%@ %@", [super description], [self dictionaryRepresentation]];
}

- (NSDictionary *)dictionaryRepresentation
{
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
if (self->_has.keyClass)
{
[dict setObject:[NSNumber numberWithInt:self->_keyClass] forKey:@"keyClass"];
}
if (self->_publicKey)
{
[dict setObject:self->_publicKey forKey:@"publicKey"];
}
if (self->_aksRefKey)
{
[dict setObject:self->_aksRefKey forKey:@"aksRefKey"];
}
if (self->_aksWrappedKey)
{
[dict setObject:self->_aksWrappedKey forKey:@"aksWrappedKey"];
}
if (self->_backupWrappedKey)
{
[dict setObject:self->_backupWrappedKey forKey:@"backupWrappedKey"];
}
return dict;
}

BOOL SecDbBackupKeyClassSigningKeyReadFrom(__unsafe_unretained SecDbBackupKeyClassSigningKey *self, __unsafe_unretained PBDataReader *reader) {
while (PBReaderHasMoreData(reader)) {
uint32_t tag = 0;
uint8_t aType = 0;

PBReaderReadTag32AndType(reader, &tag, &aType);

if (PBReaderHasError(reader))
break;

if (aType == TYPE_END_GROUP) {
break;
}

switch (tag) {

case 1 /* keyClass */:
{
self->_has.keyClass = YES;
self->_keyClass = PBReaderReadInt32(reader);
}
break;
case 3 /* publicKey */:
{
NSData *new_publicKey = PBReaderReadData(reader);
self->_publicKey = new_publicKey;
}
break;
case 4 /* aksRefKey */:
{
NSData *new_aksRefKey = PBReaderReadData(reader);
self->_aksRefKey = new_aksRefKey;
}
break;
case 5 /* aksWrappedKey */:
{
NSData *new_aksWrappedKey = PBReaderReadData(reader);
self->_aksWrappedKey = new_aksWrappedKey;
}
break;
case 6 /* backupWrappedKey */:
{
NSData *new_backupWrappedKey = PBReaderReadData(reader);
self->_backupWrappedKey = new_backupWrappedKey;
}
break;
default:
if (!PBReaderSkipValueWithTag(reader, tag, aType))
return NO;
break;
}
}
return !PBReaderHasError(reader);
}

- (BOOL)readFrom:(PBDataReader *)reader
{
return SecDbBackupKeyClassSigningKeyReadFrom(self, reader);
}
- (void)writeTo:(PBDataWriter *)writer
{
/* keyClass */
{
if (self->_has.keyClass)
{
PBDataWriterWriteInt32Field(writer, self->_keyClass, 1);
}
}
/* publicKey */
{
if (self->_publicKey)
{
PBDataWriterWriteDataField(writer, self->_publicKey, 3);
}
}
/* aksRefKey */
{
if (self->_aksRefKey)
{
PBDataWriterWriteDataField(writer, self->_aksRefKey, 4);
}
}
/* aksWrappedKey */
{
if (self->_aksWrappedKey)
{
PBDataWriterWriteDataField(writer, self->_aksWrappedKey, 5);
}
}
/* backupWrappedKey */
{
if (self->_backupWrappedKey)
{
PBDataWriterWriteDataField(writer, self->_backupWrappedKey, 6);
}
}
}

- (void)copyTo:(SecDbBackupKeyClassSigningKey *)other
{
if (self->_has.keyClass)
{
other->_keyClass = _keyClass;
other->_has.keyClass = YES;
}
if (_publicKey)
{
other.publicKey = _publicKey;
}
if (_aksRefKey)
{
other.aksRefKey = _aksRefKey;
}
if (_aksWrappedKey)
{
other.aksWrappedKey = _aksWrappedKey;
}
if (_backupWrappedKey)
{
other.backupWrappedKey = _backupWrappedKey;
}
}

- (id)copyWithZone:(NSZone *)zone
{
SecDbBackupKeyClassSigningKey *copy = [[[self class] allocWithZone:zone] init];
if (self->_has.keyClass)
{
copy->_keyClass = _keyClass;
copy->_has.keyClass = YES;
}
copy->_publicKey = [_publicKey copyWithZone:zone];
copy->_aksRefKey = [_aksRefKey copyWithZone:zone];
copy->_aksWrappedKey = [_aksWrappedKey copyWithZone:zone];
copy->_backupWrappedKey = [_backupWrappedKey copyWithZone:zone];
return copy;
}

- (BOOL)isEqual:(id)object
{
SecDbBackupKeyClassSigningKey *other = (SecDbBackupKeyClassSigningKey *)object;
return [other isMemberOfClass:[self class]]
&&
((self->_has.keyClass && other->_has.keyClass && self->_keyClass == other->_keyClass) || (!self->_has.keyClass && !other->_has.keyClass))
&&
((!self->_publicKey && !other->_publicKey) || [self->_publicKey isEqual:other->_publicKey])
&&
((!self->_aksRefKey && !other->_aksRefKey) || [self->_aksRefKey isEqual:other->_aksRefKey])
&&
((!self->_aksWrappedKey && !other->_aksWrappedKey) || [self->_aksWrappedKey isEqual:other->_aksWrappedKey])
&&
((!self->_backupWrappedKey && !other->_backupWrappedKey) || [self->_backupWrappedKey isEqual:other->_backupWrappedKey])
;
}

- (NSUInteger)hash
{
return 0
^
(self->_has.keyClass ? PBHashInt((NSUInteger)self->_keyClass) : 0)
^
[self->_publicKey hash]
^
[self->_aksRefKey hash]
^
[self->_aksWrappedKey hash]
^
[self->_backupWrappedKey hash]
;
}

- (void)mergeFrom:(SecDbBackupKeyClassSigningKey *)other
{
if (other->_has.keyClass)
{
self->_keyClass = other->_keyClass;
self->_has.keyClass = YES;
}
if (other->_publicKey)
{
[self setPublicKey:other->_publicKey];
}
if (other->_aksRefKey)
{
[self setAksRefKey:other->_aksRefKey];
}
if (other->_aksWrappedKey)
{
[self setAksWrappedKey:other->_aksWrappedKey];
}
if (other->_backupWrappedKey)
{
[self setBackupWrappedKey:other->_backupWrappedKey];
}
}

@end