@@ -122,10 +122,11 @@ state[3] += new[3]; } @implementation OFMD5Hash @synthesize calculated = _calculated; +@synthesize allowsSwappableMemory = _allowsSwappableMemory; + (size_t)digestSize { return DIGEST_SIZE; } @@ -133,32 +134,40 @@ + (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; [self of_resetState]; } @catch (id e) { [self release]; @throw e; } return self; } + +- (instancetype)init +{ + OF_INVALID_INIT_METHOD +} - (instancetype)of_init { return [super init]; } @@ -184,10 +193,11 @@ { OFMD5Hash *copy = [[OFMD5Hash alloc] of_init]; copy->_iVarsData = [_iVarsData copy]; copy->_iVars = copy->_iVarsData.mutableItems; + copy->_allowsSwappableMemory = _allowsSwappableMemory; copy->_calculated = _calculated; return copy; }