pub const IN_REPLY_TO: i64 = -70001;
pub const REQUEST_HASH: i64 = -70002;
pub const SENDER_KEY_ID: i64 = -70003;
pub const RESPONSE_KEY_ID: i64 = -70004;
pub const RESPONSE_SUBJECT: i64 = -70005;
pub const SIGNER_CERTIFICATES_JWT: i64 = -70006;
pub(crate) const HDR_ALG: i64 = 1;
pub(crate) const HDR_CRIT: i64 = 2;
pub(crate) const HDR_CONTENT_TYPE: i64 = 3;
pub(crate) const HDR_KID: i64 = 4;
pub(crate) const HDR_IV: i64 = 5;
pub(crate) const HDR_CWT_CLAIMS: i64 = 15;
pub(crate) const HDR_EPHEMERAL_KEY: i64 = -1;
pub(crate) const HDR_PARTY_U_IDENTITY: i64 = -21;
pub(crate) const HDR_PARTY_V_IDENTITY: i64 = -24;
pub(crate) const CWT_ISS: i64 = 1;
pub(crate) const CWT_AUD: i64 = 3;
pub(crate) const CWT_EXP: i64 = 4;
pub(crate) const CWT_IAT: i64 = 6;
pub(crate) const CWT_CTI: i64 = 7;
#[must_use]
#[allow(clippy::cast_sign_loss)]
pub(crate) const fn canonical_sort_key(label: i64) -> (u8, u64) {
if label >= 0 {
(0, label as u64)
} else {
(1, !(label as u64))
}
}
#[cfg(test)]
mod tests {
use super::*;
fn is_canonical_order(labels: &[i64]) -> bool {
labels.is_sorted_by(|a, b| canonical_sort_key(*a) < canonical_sort_key(*b))
}
#[test]
fn sort_key_orders_like_encoded_bytes() {
let order = [0, 1, 23, 24, 256, -1, -24, -25, -70001, -70002];
assert!(is_canonical_order(&order));
assert!(!is_canonical_order(&[-70002, -70001]));
assert!(!is_canonical_order(&[-1, 3]));
assert!(!is_canonical_order(&[3, 3]));
}
}