Expose HMAC digestLength where available

This commit is contained in:
Davide De Rosa 2018-09-10 15:18:16 +02:00
parent 9103192513
commit 401d999b3d
4 changed files with 13 additions and 0 deletions

View File

@ -97,6 +97,11 @@ const NSInteger CryptoAEADTagLength = 16;
self.cipher = NULL;
}
- (int)digestLength
{
return 0;
}
#pragma mark Encrypter
- (void)configureEncryptionWithCipherKey:(ZeroingData *)cipherKey hmacKey:(ZeroingData *)hmacKey

View File

@ -68,4 +68,6 @@
- (nonnull id<Encrypter>)encrypter;
- (nonnull id<Decrypter>)decrypter;
- (NSInteger)digestLength;
@end

View File

@ -50,6 +50,7 @@
@property (nonatomic, strong) NSString *cipherAlgorithm;
@property (nonatomic, strong) NSString *digestAlgorithm;
@property (nonatomic, assign) NSInteger digestLength;
@property (nonatomic, strong) id<Encrypter> encrypter;
@property (nonatomic, strong) id<Decrypter> decrypter;
@ -131,6 +132,9 @@
[self.encrypter configureEncryptionWithCipherKey:cipherEncKey hmacKey:hmacEncKey];
[self.decrypter configureDecryptionWithCipherKey:cipherDecKey hmacKey:hmacDecKey];
NSAssert(self.encrypter.digestLength == self.decrypter.digestLength, @"Digest length mismatch in encrypter/decrypter");
self.digestLength = self.encrypter.digestLength;
return YES;
}

View File

@ -45,6 +45,7 @@
@protocol Encrypter
- (void)configureEncryptionWithCipherKey:(nonnull ZeroingData *)cipherKey hmacKey:(nonnull ZeroingData *)hmacKey;
- (int)digestLength;
- (int)overheadLength;
- (int)extraLength;
@ -59,6 +60,7 @@
@protocol Decrypter
- (void)configureDecryptionWithCipherKey:(nonnull ZeroingData *)cipherKey hmacKey:(nonnull ZeroingData *)hmacKey;
- (int)digestLength;
- (int)overheadLength;
- (int)extraLength;