Drop overheadLength, only used in one place

This commit is contained in:
Davide De Rosa 2018-09-19 14:45:40 +02:00
parent dd02c92aa5
commit 600c93be55
2 changed files with 2 additions and 6 deletions

View File

@ -50,7 +50,6 @@ const NSInteger CryptoAEADTagLength = 16;
@property (nonatomic, unsafe_unretained) const EVP_CIPHER *cipher;
@property (nonatomic, assign) int cipherKeyLength;
@property (nonatomic, assign) int cipherIVLength; // 12 (AD packetId + HMAC key)
@property (nonatomic, assign) int overheadLength;
@property (nonatomic, assign) int extraPacketIdOffset;
@property (nonatomic, unsafe_unretained) EVP_CIPHER_CTX *cipherCtxEnc;
@ -73,7 +72,6 @@ const NSInteger CryptoAEADTagLength = 16;
self.cipherKeyLength = EVP_CIPHER_key_length(self.cipher);
self.cipherIVLength = EVP_CIPHER_iv_length(self.cipher);
self.overheadLength = CryptoAEADTagLength;
self.extraLength = PacketIdLength;
self.extraPacketIdOffset = 0;
@ -104,7 +102,7 @@ const NSInteger CryptoAEADTagLength = 16;
- (NSInteger)encryptionCapacityWithLength:(NSInteger)length
{
return safe_crypto_capacity(length, self.overheadLength);
return safe_crypto_capacity(length, CryptoAEADTagLength);
}
#pragma mark Encrypter

View File

@ -54,7 +54,6 @@ const NSInteger CryptoCBCMaxHMACLength = 100;
@property (nonatomic, assign) int cipherIVLength;
@property (nonatomic, assign) int hmacKeyLength;
@property (nonatomic, assign) int digestLength;
@property (nonatomic, assign) int overheadLength;
@property (nonatomic, unsafe_unretained) EVP_CIPHER_CTX *cipherCtxEnc;
@property (nonatomic, unsafe_unretained) EVP_CIPHER_CTX *cipherCtxDec;
@ -87,7 +86,6 @@ const NSInteger CryptoCBCMaxHMACLength = 100;
// as seen in OpenVPN's crypto_openssl.c:md_kt_size()
self.hmacKeyLength = EVP_MD_size(self.digest);
self.digestLength = EVP_MD_size(self.digest);
self.overheadLength = self.cipherIVLength + self.digestLength;
if (cipherName) {
self.cipherCtxEnc = EVP_CIPHER_CTX_new();
@ -122,7 +120,7 @@ const NSInteger CryptoCBCMaxHMACLength = 100;
- (NSInteger)encryptionCapacityWithLength:(NSInteger)length
{
return safe_crypto_capacity(length, self.overheadLength);
return safe_crypto_capacity(length, self.digestLength + self.cipherIVLength);
}
#pragma mark Encrypter