Skip to content

Commit

Permalink
Fixed problems found in review
Browse files Browse the repository at this point in the history
  • Loading branch information
hvge committed Sep 12, 2024
1 parent de55475 commit 001dc87
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion include/PowerAuth/Session.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ namespace powerAuth

/**
Resets session into its initial state. The existing session's setup and the external encryption
key is preserved by this call. If |full_reset\ parameter is true, then also resets data not relevant
key is preserved by this call. If |full_reset| parameter is true, then also resets data not relevant
to the activation state. For example, ECIES public key for application scope.
*/
void resetSession(bool full_reset = true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class EciesMetadata {

/**
* @param applicationKey Base64 string with an application key cryptographic constant
* @param temporaryKeyId Temporary encryption key identifier
* @param activationIdentifier String with an activation identifier
*/
public EciesMetadata(@NonNull String applicationKey, @NonNull String temporaryKeyId, @Nullable String activationIdentifier) {
Expand All @@ -43,21 +44,21 @@ public EciesMetadata(@NonNull String applicationKey, @NonNull String temporaryKe
// Getters

/**
* @return Base64 string with an application key cryptographic constant
* @return Base64 string with an application key cryptographic constant.
*/
public @NonNull String getActivationKey() {
return applicationKey;
}

/**
* @return Temporary key identifier
* @return Application key identifier.
*/
public @NonNull String getApplicationKey() {
return applicationKey;
}

/**
* @return Base64 String with an activation identifier
* @return Base64 String with an activation identifier.
*/
public @Nullable String getActivationIdentifier() {
return activationIdentifier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ private Pair<GetTemporaryKeyRequest, JwtObject> prepareRequestJwt() {
final String jwtHeaderPlusPayload = jwtHeader + jwtPayload;
final SignedData dataToSign = new SignedData(jwtHeaderPlusPayload.getBytes(StandardCharsets.US_ASCII), null, signingKey, SignatureFormat.DEFAULT);
if (ErrorCode.OK != session.signDataWithHmacKey(dataToSign, unlockKeys)) {
this.complete(new PowerAuthErrorException(PowerAuthErrorCodes.ENCRYPTION_ERROR));
this.complete(new PowerAuthErrorException(PowerAuthErrorCodes.ENCRYPTION_ERROR, "Failed to calculate JWT signature"));
return null;
}
final String jwtSignature = Base64.encodeToString(dataToSign.signature, Base64.NO_WRAP | Base64.NO_PADDING | Base64.URL_SAFE);
Expand Down
2 changes: 1 addition & 1 deletion proj-xcode/PowerAuth2/private/PA2GetTemporaryKeyRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

@interface PA2GetTemporaryKeyRequest : NSObject<PA2Encodable>

@property (nonatomic, strong) NSString * appKey;
@property (nonatomic, strong) NSString * applicationKey;
@property (nonatomic, strong) NSString * activationId;
@property (nonatomic, strong) NSString * challenge;

Expand Down
4 changes: 2 additions & 2 deletions proj-xcode/PowerAuth2/private/PA2GetTemporaryKeyRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ @implementation PA2GetTemporaryKeyRequest
- (NSDictionary<NSString *,NSObject *> *)toDictionary
{
if (_activationId) {
return @{ @"applicationKey" : _appKey, @"activationId": _activationId, @"challenge" : _challenge };
return @{ @"applicationKey" : _applicationKey, @"activationId": _activationId, @"challenge" : _challenge };
} else {
return @{ @"applicationKey" : _appKey, @"challenge" : _challenge };
return @{ @"applicationKey" : _applicationKey, @"challenge" : _challenge };
}
}

Expand Down
2 changes: 1 addition & 1 deletion proj-xcode/PowerAuth2/private/PA2GetTemporaryKeyResponse.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

@interface PA2GetTemporaryKeyResponse : NSObject<PA2Decodable>

@property (nonatomic, strong) NSString * appKey;
@property (nonatomic, strong) NSString * applicationKey;
@property (nonatomic, strong) NSString * activationId;
@property (nonatomic, strong) NSString * challenge;
@property (nonatomic, strong) NSString * keyId;
Expand Down
2 changes: 1 addition & 1 deletion proj-xcode/PowerAuth2/private/PA2GetTemporaryKeyResponse.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ - (instancetype) initWithDictionary:(NSDictionary<NSString *,NSObject *> *)dicti
{
self = [super init];
if (self) {
_appKey = PA2ObjectAs(dictionary[@"applicationKey"], NSString);
_applicationKey = PA2ObjectAs(dictionary[@"applicationKey"], NSString);
_activationId = PA2ObjectAs(dictionary[@"activationId"], NSString);
_challenge = PA2ObjectAs(dictionary[@"challenge"], NSString);
_publicKey = PA2ObjectAs(dictionary[@"publicKey"], NSString);
Expand Down
4 changes: 2 additions & 2 deletions proj-xcode/PowerAuth2/private/PA2GetTemporaryKeyTask.m
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ - (PA2JwtObject*) prepareRequestJwt:(PA2GetTemporaryKeyRequest*)request
}
}
// Update input request object
request.appKey = _applicationKey;
request.applicationKey = _applicationKey;
request.activationId = activationId;
request.challenge = [[PowerAuthCoreCryptoUtils randomBytes:18] base64EncodedStringWithOptions:0];
// Prepare JWT string
Expand Down Expand Up @@ -187,7 +187,7 @@ - (PA2GetTemporaryKeyResponse*) processResponseJwt:(PA2JwtObject*)responseJwt er
- (BOOL) validateResponse:(PA2GetTemporaryKeyResponse*)response withRequest:(PA2GetTemporaryKeyRequest*)request
{
BOOL match = [response.challenge isEqualToString:request.challenge];
match = match && [response.appKey isEqualToString:request.appKey];
match = match && [response.applicationKey isEqualToString:request.applicationKey];
if (!_isApplicationScope) {
match = match && [response.activationId isEqualToString:request.activationId];
}
Expand Down

0 comments on commit 001dc87

Please sign in to comment.