Respond to code review.

This commit is contained in:
Michael Kirk 2018-07-23 10:35:35 -06:00
parent b42f528713
commit 8c5d6ba9bb
4 changed files with 20 additions and 5 deletions

View file

@ -5,8 +5,8 @@
@interface TSRequest : NSMutableURLRequest
@property (nonatomic) BOOL shouldHaveAuthorizationHeaders;
@property (nullable) NSString *authUsername;
@property (nullable) NSString *authPassword;
@property (atomic, nullable) NSString *authUsername;
@property (atomic, nullable) NSString *authPassword;
@property (nonatomic, readonly) NSDictionary *parameters;

View file

@ -58,8 +58,6 @@
_parameters = parameters ?: @{};
[self setHTTPMethod:method];
self.shouldHaveAuthorizationHeaders = YES;
_authUsername = [TSAccountManager localNumber];
_authPassword = [TSAccountManager serverAuthToken];
return self;
}
@ -71,4 +69,19 @@
return [[TSRequest alloc] initWithURL:url method:method parameters:parameters];
}
#pragma mark - Authorization
- (NSString *)authUsername
{
OWSAssert(self.shouldHaveAuthorizationHeaders);
return (_authUsername ?: [TSAccountManager localNumber]);
}
- (NSString *)authPassword
{
OWSAssert(self.shouldHaveAuthorizationHeaders);
return (_authPassword ?: [TSAccountManager serverAuthToken]);
}
@end

View file

@ -32,6 +32,7 @@ extern const NSUInteger kAES256_KeyByteLength;
@property (nonatomic, readonly) NSData *initializationVector;
@property (nonatomic, readonly) NSData *authTag;
- (instancetype)init NS_UNAVAILABLE;
- (nullable instancetype)initWithCipherText:(NSData *)cipherText
initializationVector:(NSData *)initializationVector
authTag:(NSData *)authTag NS_DESIGNATED_INITIALIZER;

View file

@ -111,7 +111,8 @@ const NSUInteger kAES256_KeyByteLength = 32;
_initializationVector = [initializationVector copy];
_authTag = [authTag copy];
if (_ciphertext == nil || _initializationVector == nil || _authTag == nil) {
if (_ciphertext == nil || _initializationVector.length != kAESGCM256_IVLength
|| _authTag.length != kAESGCM256_TagLength) {
return nil;
}