mirror of
https://github.com/savoirfairelinux/opendht.git
synced 2026-11-08 12:28:42 +00:00
RevocationList::sign() always overwrote the CRL Number extension: random on the first signature, incremented afterwards. This leaves no way for a certificate authority replicated over several devices to keep numbers unique, since every device branching from the same list mints the same number for a different content. Add an optional `number` parameter, used verbatim when non-zero, so callers can partition the number space (RFC 5280 5.2.3 requires monotonicity for a given CRL scope and issuer, not globally). Also fix the default increment path: the extension holds a DER integer with leading zeros stripped, so reading it straight into an uint64_t only worked for numbers wide enough to occupy all 8 bytes. Signing a list numbered 5 produced 0x0500000000000001 instead of 6. Read and write the number as a big-endian byte string instead, which makes the `endian()` helper unnecessary. Add tests covering the default numbering, explicit numbers (including values with leading zero bytes and the largest positive 8-byte integer), pack/unpack round-trips, and a device-partitioned numbering scheme.