identity_credential/validator/sd_jwt/
error.rs

1// Copyright 2020-2023 IOTA Stiftung
2// SPDX-License-Identifier: Apache-2.0
3
4use crate::validator::JwtValidationError;
5
6/// An error associated with validating KB-JWT.
7#[derive(Debug, thiserror::Error, strum::IntoStaticStr)]
8#[non_exhaustive]
9pub enum KeyBindingJwtError {
10  /// Invalid key binding JWT.
11  #[error("KB-JWT is invalid")]
12  JwtValidationError(#[from] JwtValidationError),
13
14  /// Deserialization failed.
15  #[error("Deserialization error")]
16  DeserializationError(String),
17
18  /// Error from `sd_jwt_payload`.
19  #[error("SdJwt Error {0}")]
20  SdJwtError(#[from] sd_jwt_payload::Error),
21
22  /// Invalid hash value.
23  #[error("the `_sd_hash` value of the KB-JWT does not match the derived value from the provided SD-JWT")]
24  InvalidDigest,
25
26  /// Invalid nonce value.
27  #[error("provided nonce does not match the KB-JWT nonce claim")]
28  InvalidNonce,
29
30  /// Invalid `aud` value.
31  #[error("provided audience value does not match the KB-JWT `aud` claim")]
32  AudienceMismatch,
33
34  /// Issuance date validation error.
35  #[error("KB-JWT `iat` value is invalid, {0}")]
36  IssuanceDate(String),
37
38  /// SD-JWT does not contain a key binding JWT.
39  #[error("the provided SD-JWT does not include a KB-JWT")]
40  MissingKeyBindingJwt,
41
42  /// Header value `typ` is invalid.
43  #[error("header `typ` value is missing or not equal to `kb+jwt`")]
44  InvalidHeaderTypValue,
45}