reallyme-jose 0.1.0

JOSE, JWT, JWS, and JWE helpers for ReallyMe identity.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// SPDX-FileCopyrightText: Copyright © 2026 ReallyMe LLC. All rights reserved
//
// SPDX-License-Identifier: Apache-2.0

use super::JwtError;
use crate::Algorithm;

/// Maps a JWT `alg` header value to the corresponding crypto algorithm.
///
/// RFC 7518 + DID alignment
pub fn algorithm_from_jwt_alg(alg: &str) -> Result<Algorithm, JwtError> {
    match alg {
        "ES256" => Ok(Algorithm::P256),
        "ES256K" => Ok(Algorithm::Secp256k1),
        "EdDSA" => Ok(Algorithm::Ed25519),
        _ => Err(JwtError::UnsupportedAlgorithm),
    }
}