However, the "random-with length-extension on collision" algorithm has
some other (non-BR) shortcomings:
- It is sailing very close to the edge of compliance for little or no
good reason.
- If the collision case is ever triggered, chances are high that other
parts of the CA system have not been tested with different length
serial numbers from the same issuing CA, thus causing larger failures,
such as OCSP responders returning incorrect results for the colliding
certificates.
Another algorithm that would produce occasional <= 64 bit serial numbers
while remaining compliant is:
- Generate 64 random bits.
- Append a 15 bit counter resulting in a 15 to 79 bit serial number (up
to 10 bytes).
- Rotate issuing CAs before the counter wraps.
Here a small fraction (1 in 65536 certificates thus about one per two
issuing CAs if all 32768 counter values are used) will randomly be 64
bits or shorter due to the first 16 random bits being zero.
So
- 63-bit serial numbers are highly suspicious (the algorithm you
provided would produce them for half the certificates, other algorithms
much less frequently, if at all).
- 64-bit serial numbers would be cause for concern, but would require
more thorough analysis, perhaps even a code audit.
- >= 65-bit serial numbers are a lot less likely to be violating the
entropy requirement BR.
So perhaps:
- Generate an informational warning for 64-bit serial numbers.
- Generate a stronger warning for 33 to 63-bit serial numbers.
- In a separate tool check if an issuing CA produces shorter-than-64-bit
serial numbers more frequently than a random distribution (with some
margin).
- One simple test could be to dump the serial numbers from an issuing CA
(without DER formatting, leading zeroes etc.) as bare unsigned numbers
with no fomatting, pipe this into gzip -9 or zlib and check if the
resulting output is less than 8 bytes per certificate.
- A more sophisticated whole-CA test could first sort the serials
numerically, then do pairwise subtracts of all but the first before
converting to bare (signed) binary numbers and compressing. This would
reduce false entropy from pure counter bits.