Repository navigation
Issue certificate serials as positive minimal integers (R74) - #138
LucaCappelletti94 wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (15)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughCertificate serials now use a validated 16-byte type across certificate issuance. CA signing and server enrolment generate serials through random sources, and enrolment retries draws that do not satisfy the serial validation rule. ChangesCertificate serial handling
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant DeviceEnrolment
participant CertificateSerial
participant RandomSource
DeviceEnrolment->>CertificateSerial: Request a random serial using RandomSource
loop Until a valid serial is drawn
CertificateSerial->>RandomSource: Fill a 16-byte candidate
RandomSource-->>CertificateSerial: Candidate bytes or fill error
end
CertificateSerial-->>DeviceEnrolment: Valid serial or fill error
DeviceEnrolment->>DeviceEnrolment: Map errors or store serial bytes
Merge Risk: ⚪ Minimal · up to No concrete issue remains that should block merging after normal checks. 🚥 Pre-merge checks | ✅ 12✅ Passed checks (12 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #138 +/- ##
==========================================
- Coverage 86.40% 86.40% -0.01%
==========================================
Files 163 164 +1
Lines 39726 39754 +28
Branches 39726 39754 +28
==========================================
+ Hits 34325 34348 +23
- Misses 3525 3529 +4
- Partials 1876 1877 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|



Device and issuer certificate serials were sixteen raw random bytes. About one draw in 256 started with a zero byte. The certificate's serial then reads without that byte, while the enrolment record keeps it, so the record and the certificate disagree. This is what made
enrolment::a_signed_in_device_enrols_and_is_recordedfail once on CI. About half of all draws started with a byte of 128 or more, which DER can only encode with an extra leading byte.Serials now come from a small validated type,
CertificateSerial, whose first byte is always between 1 and 127, so every serial is the positive, minimal integer RFC 5280 asks for. It draws again until the first byte fits, which keeps the draw unbiased. Both the server's enrolment andconnetto-caissue through it, and the stored record is unchanged. A new test feeds the server a draw starting with a zero byte. It failed on main exactly as CI did and passes now. The plan's R74 decision 17 states the rule.A random 16-byte serial could begin with zero or have its high bit set. Those values do not meet the required positive, minimal integer encoding and could cause the certificate serial to differ from the serial recorded during enrolment.
The fix validates serials before use and draws again until the first byte is from
0x01through0x7F. Both issuer and device certificate issuance use this validated type, which keeps the certificate and enrolment record serials consistent.