Add support of encrypted payload for Cloud Device API#1867
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request implements end-to-end encryption for the Cloud Device API, introducing models and logic for Nexo-compliant secured messages. Key additions include the NexoSecurityManager for AES-256-CBC encryption and HMAC-SHA256 integrity checks, along with new CloudDeviceApi methods for synchronous and asynchronous encrypted requests. Feedback highlights a security risk in the 'Decrypt-then-MAC' implementation, performance concerns regarding repeated key derivation and ObjectMapper instantiation, and the use of weak PBKDF2 parameters for key generation.
src/main/java/com/adyen/service/clouddevice/CloudDeviceApi.java
Outdated
Show resolved
Hide resolved
src/main/java/com/adyen/service/clouddevice/CloudDeviceApi.java
Outdated
Show resolved
Hide resolved
src/main/java/com/adyen/security/clouddevice/NexoDerivedKeyGenerator.java
Show resolved
Hide resolved
59e8a7f to
66385bd
Compare
jeandersonbc
approved these changes
Apr 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for encrypted payloads in the Cloud Device API, enabling end-to-end encryption for terminal communication.
Changes
New service
EncryptedCloudDeviceApi— support sending and receiving encrypted payloadsNew models
CloudDeviceApiSecuredRequest/CloudDeviceApiSecuredResponse— wrappers for encrypted request/response payloadsSaleToPOISecuredMessage— represents a secured (encrypted) Sale-to-POI messageclouddevice/security/NexoDerivedKey— derived key model used in the encryption schemeclouddevice/security/SecurityTrailer— security trailer attached to encrypted messagesNew security utilities
EncryptionCredentialDetails— holds the encryption credential configurationNexoCryptoPrimitives— low-level crypto primitives (AES, HMAC, etc.)NexoDerivedKeyGenerator— derives session keys from a master keyNexoSecurityException— dedicated exception for security/encryption errorsNexoSecurityManager— orchestrates encryption and decryption of Cloud Device API messagesTests
NexoSecurityManagerTest— unit tests for the encryption/decryption logicEncryptedCloudDeviceApiTest— integration-style tests for the full encrypted request/response flow, backed by fixture JSON files