@@ -128,10 +128,11 @@ state[7] += new[7]; } @implementation OFSHA384Or512Hash @synthesize calculated = _calculated; +@synthesize allowsSwappableMemory = _allowsSwappableMemory; + (size_t)digestSize { OF_UNRECOGNIZED_SELECTOR } @@ -139,23 +140,26 @@ + (size_t)blockSize { return BLOCK_SIZE; } -+ (instancetype)cryptoHash ++ (instancetype)cryptoHashWithAllowsSwappableMemory: (bool)allowsSwappableMemory { - return [[[self alloc] init] autorelease]; + return [[[self alloc] initWithAllowsSwappableMemory: + allowsSwappableMemory] autorelease]; } -- (instancetype)init +- (instancetype)initWithAllowsSwappableMemory: (bool)allowsSwappableMemory { self = [super init]; @try { _iVarsData = [[OFSecureData alloc] - initWithCount: sizeof(*_iVars)]; + initWithCount: sizeof(*_iVars) + allowsSwappableMemory: allowsSwappableMemory]; _iVars = _iVarsData.mutableItems; + _allowsSwappableMemory = allowsSwappableMemory; if (self.class == [OFSHA384Or512Hash class]) { [self doesNotRecognizeSelector: _cmd]; abort(); } @@ -166,10 +170,15 @@ @throw e; } return self; } + +- (instancetype)init +{ + OF_INVALID_INIT_METHOD +} - (instancetype)of_init { return [super init]; } @@ -195,10 +204,11 @@ { OFSHA384Or512Hash *copy = [[[self class] alloc] of_init]; copy->_iVarsData = [_iVarsData copy]; copy->_iVars = copy->_iVarsData.mutableItems; + copy->_allowsSwappableMemory = _allowsSwappableMemory; copy->_calculated = _calculated; return copy; }