From 178e5c34f25dee31797b26dd00db12896eb34b90 Mon Sep 17 00:00:00 2001 From: Lubos Racansky Date: Mon, 4 Sep 2023 11:13:12 +0200 Subject: [PATCH] Fix #996: Coverity: Dead local store --- .../server/service/behavior/tasks/TokenBehavior.java | 12 +++++------- .../behavior/tasks/UpgradeServiceBehavior.java | 4 ++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/service/behavior/tasks/TokenBehavior.java b/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/service/behavior/tasks/TokenBehavior.java index 8922c9a9a..f9c8df392 100644 --- a/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/service/behavior/tasks/TokenBehavior.java +++ b/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/service/behavior/tasks/TokenBehavior.java @@ -31,18 +31,18 @@ import io.getlime.security.powerauth.app.server.converter.ServerPrivateKeyConverter; import io.getlime.security.powerauth.app.server.converter.SignatureTypeConverter; import io.getlime.security.powerauth.app.server.database.RepositoryCatalogue; -import io.getlime.security.powerauth.app.server.database.model.enumeration.ActivationStatus; -import io.getlime.security.powerauth.app.server.database.model.enumeration.EncryptionMode; import io.getlime.security.powerauth.app.server.database.model.ServerPrivateKey; import io.getlime.security.powerauth.app.server.database.model.entity.ActivationRecordEntity; import io.getlime.security.powerauth.app.server.database.model.entity.ApplicationVersionEntity; import io.getlime.security.powerauth.app.server.database.model.entity.TokenEntity; +import io.getlime.security.powerauth.app.server.database.model.enumeration.ActivationStatus; +import io.getlime.security.powerauth.app.server.database.model.enumeration.EncryptionMode; import io.getlime.security.powerauth.app.server.database.model.enumeration.UniqueValueType; -import io.getlime.security.powerauth.app.server.service.replay.ReplayVerificationService; import io.getlime.security.powerauth.app.server.service.exceptions.GenericServiceException; import io.getlime.security.powerauth.app.server.service.i18n.LocalizationProvider; import io.getlime.security.powerauth.app.server.service.model.ServiceError; import io.getlime.security.powerauth.app.server.service.model.TokenInfo; +import io.getlime.security.powerauth.app.server.service.replay.ReplayVerificationService; import io.getlime.security.powerauth.crypto.lib.encryptor.EncryptorFactory; import io.getlime.security.powerauth.crypto.lib.encryptor.ServerEncryptor; import io.getlime.security.powerauth.crypto.lib.encryptor.exception.EncryptorException; @@ -64,11 +64,9 @@ import org.springframework.stereotype.Component; import javax.crypto.SecretKey; -import java.nio.charset.StandardCharsets; import java.security.InvalidKeyException; import java.security.PrivateKey; import java.security.PublicKey; -import java.security.interfaces.ECPrivateKey; import java.security.spec.InvalidKeySpecException; import java.util.Base64; import java.util.Calendar; @@ -213,8 +211,8 @@ private EncryptedResponse createToken(String activationId, String applicationKey new EncryptorParameters(version, applicationKey, activationId), new ServerEncryptorSecrets(serverPrivateKey, applicationVersion.getApplicationSecret(), transportKeyBytes) ); - // Try to decrypt request data, the data must not be empty. Currently only '{}' is sent in request data. - final byte[] decryptedData = serverEncryptor.decryptRequest(encryptedRequest); + // Try to decrypt request data, the data must not be empty. Currently only '{}' is sent in request data. Ignore result of decryption. + serverEncryptor.decryptRequest(encryptedRequest); // Generate unique token ID. String tokenId = null; diff --git a/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/service/behavior/tasks/UpgradeServiceBehavior.java b/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/service/behavior/tasks/UpgradeServiceBehavior.java index 273457965..8fc8307bf 100644 --- a/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/service/behavior/tasks/UpgradeServiceBehavior.java +++ b/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/service/behavior/tasks/UpgradeServiceBehavior.java @@ -188,8 +188,8 @@ public StartUpgradeResponse startUpgrade(StartUpgradeRequest request) throws Gen new ServerEncryptorSecrets(serverPrivateKey, applicationVersion.getApplicationSecret(), transportKeyBytes) ); - // Try to decrypt request data, the data must not be empty. Currently only '{}' is sent in request data. - final byte[] decryptedData = serverEncryptor.decryptRequest(encryptedRequest); + // Try to decrypt request data, the data must not be empty. Currently only '{}' is sent in request data. Ignore result of decryption. + serverEncryptor.decryptRequest(encryptedRequest); // Request is valid, generate hash based counter if it does not exist yet final String ctrDataBase64;