MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / kid_from_public_key_der

Function kid_from_public_key_der

crates/openshell-bootstrap/src/jwt.rs:60–63  ·  view source on GitHub ↗

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])

Source from the content-addressed store, hash-verified

58/// signing keys a single deployment ever has, while staying short enough
59/// to keep JWT headers compact.
60fn 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
65fn hex_encode_prefix(bytes: &[u8], n: usize) -> String {
66 use std::fmt::Write as _;

Calls 1

hex_encode_prefixFunction · 0.85