Skip to content

fix(android): ensure deterministic cipher selection - #795

Open
kewdex wants to merge 4 commits into
oblador:masterfrom
kewdex:fix/cipher-selection-priority
Open

fix(android): ensure deterministic cipher selection#795
kewdex wants to merge 4 commits into
oblador:masterfrom
kewdex:fix/cipher-selection-priority

Conversation

@kewdex

@kewdex kewdex commented May 7, 2026

Copy link
Copy Markdown

Summary

  • Fix non-deterministic cipher selection when AES-GCM and RSA have equal capability levels
  • Use LinkedHashMap to preserve insertion order as tie breaker
  • Reorder ciphers so AES-GCM is preferred over RSA for biometric storage

Problem

Previously, cipher selection used HashMap which has non-deterministic iteration order. When two ciphers had equal capability (AES-GCM and RSA both at 1023), the selected cipher depended on hash bucket ordering, potentially causing inconsistent behavior across devices/installs.

Solution

  • Changed HashMap to LinkedHashMap to preserve insertion order
  • Changed capability comparison from < to <= so first match wins
  • Ordered ciphers by capability descending with preferred ciphers first

Test plan

  • e2e test added to verify AES-GCM is selected over RSA for biometric access control

kewdex added 4 commits May 7, 2026 12:09
Use LinkedHashMap to preserve cipher insertion order and change
capability comparison to prefer first match when equal. This ensures
AES-GCM is consistently selected over RSA for new biometric credentials.
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.

1 participant