mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Respond to code review.
This commit is contained in:
parent
b42f528713
commit
8c5d6ba9bb
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue