Stable `kid` derived from the SHA-256 of the public-key DER. First 16 bytes hex-encoded — collision-resistant for the small N of signing keys a single deployment ever has, while staying short enough to keep JWT headers compact.
(public_key_der: &[u8])
| 58 | /// signing keys a single deployment ever has, while staying short enough |
| 59 | /// to keep JWT headers compact. |
| 60 | fn kid_from_public_key_der(public_key_der: &[u8]) -> String { |
| 61 | let digest = Sha256::digest(public_key_der); |
| 62 | hex_encode_prefix(&digest, 16) |
| 63 | } |
| 64 | |
| 65 | fn hex_encode_prefix(bytes: &[u8], n: usize) -> String { |
| 66 | use std::fmt::Write as _; |