isomdl/presentation/authentication/mod.rs
1use std::collections::BTreeMap;
2
3use crate::presentation::device::RequestedItems;
4use serde::{Deserialize, Serialize};
5use serde_json::Value;
6
7/// Module containing functions to perform mdoc authentication.
8pub mod mdoc;
9
10/// The outcome of the holder device authenticating the device request.
11#[derive(Debug, Serialize, Deserialize, Default, Clone, PartialEq)]
12pub struct RequestAuthenticationOutcome {
13 /// The requested items from the mDL namespace.
14 pub items_request: RequestedItems,
15 /// The common name from the certificate that signed this request, if available.
16 /// This value can be used to display to the user who the reader is, however
17 /// caution should be exercised if reader authentication was not successful.
18 pub common_name: Option<String>,
19 /// Outcome of reader authentication.
20 pub reader_authentication: AuthenticationStatus,
21 /// Errors that occurred during request processing.
22 pub errors: Errors,
23}
24
25/// The outcome of the reader device authenticating the device response.
26#[derive(Debug, Serialize, Deserialize, Default, Clone, PartialEq, Eq)]
27pub struct ResponseAuthenticationOutcome {
28 /// The values sent back from the holder device, serialized as JSON.
29 pub response: BTreeMap<String, Value>,
30 /// Outcome of issuer authentication.
31 pub issuer_authentication: AuthenticationStatus,
32 /// Outcome of device authentication.
33 pub device_authentication: AuthenticationStatus,
34 /// Errors that occurred during response processing.
35 pub errors: Errors,
36}
37
38/// The outcome of authenticity checks.
39#[derive(Debug, Serialize, Deserialize, Default, Clone, Copy, PartialEq, Eq)]
40pub enum AuthenticationStatus {
41 #[default]
42 Unchecked,
43 Invalid,
44 Valid,
45}
46
47/// Errors that occur during request/response processing.
48pub type Errors = BTreeMap<String, serde_json::Value>;