From 001dc87ff30e4a65011b26b940bed8c77a1496cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20=C4=8Eurech?= Date: Thu, 12 Sep 2024 15:04:49 +0200 Subject: [PATCH] Fixed problems found in review --- include/PowerAuth/Session.h | 2 +- .../io/getlime/security/powerauth/ecies/EciesMetadata.java | 7 ++++--- .../security/powerauth/sdk/impl/GetTemporaryKeyTask.java | 2 +- proj-xcode/PowerAuth2/private/PA2GetTemporaryKeyRequest.h | 2 +- proj-xcode/PowerAuth2/private/PA2GetTemporaryKeyRequest.m | 4 ++-- proj-xcode/PowerAuth2/private/PA2GetTemporaryKeyResponse.h | 2 +- proj-xcode/PowerAuth2/private/PA2GetTemporaryKeyResponse.m | 2 +- proj-xcode/PowerAuth2/private/PA2GetTemporaryKeyTask.m | 4 ++-- 8 files changed, 13 insertions(+), 12 deletions(-) diff --git a/include/PowerAuth/Session.h b/include/PowerAuth/Session.h index 31f1dbc7..05969c9e 100644 --- a/include/PowerAuth/Session.h +++ b/include/PowerAuth/Session.h @@ -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); diff --git a/proj-android/PowerAuthLibrary/src/main/java/io/getlime/security/powerauth/ecies/EciesMetadata.java b/proj-android/PowerAuthLibrary/src/main/java/io/getlime/security/powerauth/ecies/EciesMetadata.java index 25a3c3ae..3fbb75d2 100644 --- a/proj-android/PowerAuthLibrary/src/main/java/io/getlime/security/powerauth/ecies/EciesMetadata.java +++ b/proj-android/PowerAuthLibrary/src/main/java/io/getlime/security/powerauth/ecies/EciesMetadata.java @@ -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) { @@ -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; diff --git a/proj-android/PowerAuthLibrary/src/main/java/io/getlime/security/powerauth/sdk/impl/GetTemporaryKeyTask.java b/proj-android/PowerAuthLibrary/src/main/java/io/getlime/security/powerauth/sdk/impl/GetTemporaryKeyTask.java index 5404d4ea..393b5265 100644 --- a/proj-android/PowerAuthLibrary/src/main/java/io/getlime/security/powerauth/sdk/impl/GetTemporaryKeyTask.java +++ b/proj-android/PowerAuthLibrary/src/main/java/io/getlime/security/powerauth/sdk/impl/GetTemporaryKeyTask.java @@ -176,7 +176,7 @@ private Pair 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); diff --git a/proj-xcode/PowerAuth2/private/PA2GetTemporaryKeyRequest.h b/proj-xcode/PowerAuth2/private/PA2GetTemporaryKeyRequest.h index 77408d33..e2e2785b 100644 --- a/proj-xcode/PowerAuth2/private/PA2GetTemporaryKeyRequest.h +++ b/proj-xcode/PowerAuth2/private/PA2GetTemporaryKeyRequest.h @@ -18,7 +18,7 @@ @interface PA2GetTemporaryKeyRequest : NSObject -@property (nonatomic, strong) NSString * appKey; +@property (nonatomic, strong) NSString * applicationKey; @property (nonatomic, strong) NSString * activationId; @property (nonatomic, strong) NSString * challenge; diff --git a/proj-xcode/PowerAuth2/private/PA2GetTemporaryKeyRequest.m b/proj-xcode/PowerAuth2/private/PA2GetTemporaryKeyRequest.m index f83b0ff9..5f775ade 100644 --- a/proj-xcode/PowerAuth2/private/PA2GetTemporaryKeyRequest.m +++ b/proj-xcode/PowerAuth2/private/PA2GetTemporaryKeyRequest.m @@ -21,9 +21,9 @@ @implementation PA2GetTemporaryKeyRequest - (NSDictionary *)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 }; } } diff --git a/proj-xcode/PowerAuth2/private/PA2GetTemporaryKeyResponse.h b/proj-xcode/PowerAuth2/private/PA2GetTemporaryKeyResponse.h index 86f717bc..593e630d 100644 --- a/proj-xcode/PowerAuth2/private/PA2GetTemporaryKeyResponse.h +++ b/proj-xcode/PowerAuth2/private/PA2GetTemporaryKeyResponse.h @@ -18,7 +18,7 @@ @interface PA2GetTemporaryKeyResponse : NSObject -@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; diff --git a/proj-xcode/PowerAuth2/private/PA2GetTemporaryKeyResponse.m b/proj-xcode/PowerAuth2/private/PA2GetTemporaryKeyResponse.m index 78416dd8..6112933e 100644 --- a/proj-xcode/PowerAuth2/private/PA2GetTemporaryKeyResponse.m +++ b/proj-xcode/PowerAuth2/private/PA2GetTemporaryKeyResponse.m @@ -23,7 +23,7 @@ - (instancetype) initWithDictionary:(NSDictionary *)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); diff --git a/proj-xcode/PowerAuth2/private/PA2GetTemporaryKeyTask.m b/proj-xcode/PowerAuth2/private/PA2GetTemporaryKeyTask.m index fed271a6..fef3629e 100644 --- a/proj-xcode/PowerAuth2/private/PA2GetTemporaryKeyTask.m +++ b/proj-xcode/PowerAuth2/private/PA2GetTemporaryKeyTask.m @@ -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 @@ -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]; }