Skip to content

Add support of encrypted payload for Cloud Device API#1867

Merged
gcatanese merged 2 commits intomainfrom
support-encryption-cloud-device-api
Apr 3, 2026
Merged

Add support of encrypted payload for Cloud Device API#1867
gcatanese merged 2 commits intomainfrom
support-encryption-cloud-device-api

Conversation

@gcatanese
Copy link
Copy Markdown
Contributor

@gcatanese gcatanese commented Apr 2, 2026

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 payloads

New models

  • CloudDeviceApiSecuredRequest / CloudDeviceApiSecuredResponse — wrappers for encrypted request/response payloads
  • SaleToPOISecuredMessage — represents a secured (encrypted) Sale-to-POI message
  • clouddevice/security/NexoDerivedKey — derived key model used in the encryption scheme
  • clouddevice/security/SecurityTrailer — security trailer attached to encrypted messages

New security utilities

  • EncryptionCredentialDetails — holds the encryption credential configuration
  • NexoCryptoPrimitives — low-level crypto primitives (AES, HMAC, etc.)
  • NexoDerivedKeyGenerator — derives session keys from a master key
  • NexoSecurityException — dedicated exception for security/encryption errors
  • NexoSecurityManager — orchestrates encryption and decryption of Cloud Device API messages

Tests

  • NexoSecurityManagerTest — unit tests for the encryption/decryption logic
  • EncryptedCloudDeviceApiTest — integration-style tests for the full encrypted request/response flow, backed by fixture JSON files

@gcatanese gcatanese requested review from a team as code owners April 2, 2026 13:12
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@gcatanese gcatanese force-pushed the support-encryption-cloud-device-api branch from 59e8a7f to 66385bd Compare April 2, 2026 14:34
@jeandersonbc jeandersonbc self-requested a review April 3, 2026 07:48
@gcatanese gcatanese added this pull request to the merge queue Apr 3, 2026
Merged via the queue into main with commit 2f39f94 Apr 3, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants