JanssenProject / JanssenProject/jans

fix(jans-fido2): replace magic numbers with CoseRSAAlgorithm and CoseEC2Algorithm enum constants in TPMProcessor

Open
#13,990 0 comments 0 reactions 1 assignee Claimed by @imran-ishaq View on GitHub
comp-jans-fido2 kind-bug
Dominant language
Java
Stars
648
Forks
174
Avg merge
1d 18h
Merged PRs (30d)
110

Description

Describe the bug:

TPMProcessor.java uses raw magic numbers -65535, -257, and -7 in algorithm comparisons at lines 237 and 257 instead of the existing CoseRSAAlgorithm and CoseEC2Algorithm enum constants that already define and document these values. The developer even left TODO comments explicitly flagging this. Using raw integers makes the code unclear, error-prone, and inconsistent with the rest of the module where CoseRSAAlgorithm.RS256.getNumericValue() and CoseEC2Algorithm.ES256.getNumericValue() are already used consistently.

To Reproduce:
Open TPMProcessor.java and inspect lines 237 and 257 — the algorithm values -65535, -257, and -7 carry no readable meaning without cross-referencing the COSE specification or other files.

Expected behavior:
Algorithm comparisons should use the existing enum constants — CoseRSAAlgorithm.RS256, CoseRSAAlgorithm.RS65535, and CoseEC2Algorithm.ES256 — with getNumericValue(), making the intent self-documenting and consistent with AttestationService, CoseService, and DeviceRegistrationService which already follow this pattern.

Additional context:
Both CoseRSAAlgorithm and CoseEC2Algorithm are already imported in TPMProcessor.java at lines 43–45. This is a pure code quality fix — no behavioral change, no logic change, identical compiled output.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.