Skip to content

Commit

Permalink
Merge pull request #520 from wultra/develop
Browse files Browse the repository at this point in the history
Merge develop into master
  • Loading branch information
romanstrobl authored Sep 4, 2023
2 parents 8336bb4 + c99da11 commit e51333b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@
<maven-jar-plugin.version>3.3.0</maven-jar-plugin.version>
<maven-deploy-plugin.version>3.1.1</maven-deploy-plugin.version>
<maven-javadoc-plugin.version>3.5.0</maven-javadoc-plugin.version>
<maven-source-plugin.version>3.2.1</maven-source-plugin.version>
<maven-source-plugin.version>3.3.0</maven-source-plugin.version>
<maven-surefire-plugin.version>3.1.2</maven-surefire-plugin.version>
<guava.version>32.1.2-jre</guava.version>
<slf4j.version>2.0.7</slf4j.version>
<slf4j.version>2.0.9</slf4j.version>
<junit.version>5.9.2</junit.version>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,17 @@ public EncryptedRequest encryptRequest(byte[] data) throws EncryptorException {
this.envelopeKey = envelopeKey;
this.requestNonce = validator.isUseTimestamp() ? null : requestNonce;

final Base64.Encoder base64Encoder = Base64.getEncoder();
final EciesCryptogram eciesCryptogram = eciesPayload.getCryptogram();
if (eciesCryptogram == null) {
throw new EncryptorException("The cryptogram value is null.");
}

return new EncryptedRequest(
Base64.getEncoder().encodeToString(eciesPayload.getCryptogram().getEphemeralPublicKey()),
Base64.getEncoder().encodeToString(eciesPayload.getCryptogram().getEncryptedData()),
Base64.getEncoder().encodeToString(eciesPayload.getCryptogram().getMac()),
validator.isUseNonceForRequest() ? Base64.getEncoder().encodeToString(requestNonce) : null,
base64Encoder.encodeToString(eciesCryptogram.getEphemeralPublicKey()),
base64Encoder.encodeToString(eciesCryptogram.getEncryptedData()),
base64Encoder.encodeToString(eciesCryptogram.getMac()),
validator.isUseNonceForRequest() && requestNonce != null ? base64Encoder.encodeToString(requestNonce) : null,
requestTimestamp
);
}
Expand All @@ -174,9 +180,10 @@ public byte[] decryptResponse(EncryptedResponse response) throws EncryptorExcept
throw new EncryptorException("Invalid encrypted response object");
}

final byte[] mac = Base64.getDecoder().decode(response.getMac());
final byte[] encryptedData = Base64.getDecoder().decode(response.getEncryptedData());
final byte[] responseNonce = validator.isUseTimestamp() ? Base64.getDecoder().decode(response.getNonce()) : requestNonce;
final Base64.Decoder base64Decoder = Base64.getDecoder();
final byte[] mac = base64Decoder.decode(response.getMac());
final byte[] encryptedData = base64Decoder.decode(response.getEncryptedData());
final byte[] responseNonce = validator.isUseTimestamp() ? base64Decoder.decode(response.getNonce()) : requestNonce;
final Long responseTimestamp = validator.isUseTimestamp() ? response.getTimestamp() : null;

// Build sharedInfo2 with parameters received from the request.
Expand Down

0 comments on commit e51333b

Please sign in to comment.