Skip to main content

ace_uds/message/services/authentication/
response.rs

1use ace_macros::FrameCodec;
2
3use crate::UdsError;
4
5#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, FrameCodec)]
6#[frame(error = UdsError)]
7pub enum AuthenticationResponse<'a> {
8    #[frame(id = 0x00)]
9    DeAuthenticateResponse(DeAuthenticateResponse),
10    #[frame(id = 0x01)]
11    VerifyCertificateUnidirectionalResponse(VerifyCertificateUnidirectionalResponse<'a>),
12    #[frame(id = 0x02)]
13    VerifyCertificateBidirectionalResponse(VerifyCertificateBidirectionalResponse<'a>),
14    #[frame(id = 0x03)]
15    ProofOfOwnershipResponse(ProofOfOwnershipResponse<'a>),
16    #[frame(id = 0x04)]
17    TransmitCertificateResponse(TransmitCertificateResponse),
18    #[frame(id = 0x05)]
19    RequestChallengeForAuthenticationResponse(RequestChallengeForAuthenticationResponse<'a>),
20    #[frame(id = 0x06)]
21    VerifyProofOfOwnershipUnidirectionalResponse(VerifyProofOfOwnershipUnidirectionalResponse<'a>),
22    #[frame(id = 0x07)]
23    VerifyProofOfOwnershipBidirectionalResponse(VerifyProofOfOwnershipBidirectionalResponse<'a>),
24    #[frame(id = 0x08)]
25    AuthenticationConfigurationResponse(AuthenticationConfigurationResponse),
26}
27
28#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, FrameCodec)]
29#[frame(error = UdsError)]
30pub enum AuthenticationReturnParameter {
31    #[frame(id = 0x00)]
32    RequestAccepted,
33    #[frame(id = 0x01)]
34    GeneralReject,
35    #[frame(id = 0x02)]
36    AuthenticationConfigurationAPCE,
37    #[frame(id = 0x03)]
38    AuthenticationConfigurationACRAsymmetric,
39    #[frame(id = 0x04)]
40    AuthenticationConfigurationACRSymmetric,
41    #[frame(id_pat = "0x05..=0x0F | 0x14..=0x9F | 0xFF")]
42    IsoSaeReserved(u8),
43    #[frame(id = 0x10)]
44    DeAuthenticationSuccessful,
45    #[frame(id = 0x11)]
46    CertificateVerifiedOwnershipVerificationNecessary,
47    #[frame(id = 0x12)]
48    OwnershipVerified,
49    #[frame(id = 0x13)]
50    CertificateVerified,
51    #[frame(id_pat = "0xA0..=0xCF")]
52    VehicleManufacturerSpecific(u8),
53    #[frame(id_pat = "0xD0..=0xFE")]
54    SystemSupplierSpecific(u8),
55}
56
57#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, FrameCodec)]
58#[frame(error = UdsError)]
59pub struct DeAuthenticateResponse {
60    pub authentication_return_parameter: AuthenticationReturnParameter,
61}
62
63#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, FrameCodec)]
64#[frame(error = UdsError)]
65pub struct VerifyCertificateUnidirectionalResponse<'a> {
66    pub authentication_return_parameter: AuthenticationReturnParameter,
67    pub length_of_challenge_server: u16,
68    #[frame(length = "length_of_challenge_server as usize")]
69    pub challenge_server: &'a [u8],
70    pub length_of_ephemeral_public_key_server: u16,
71    #[frame(length = "length_of_ephemeral_public_key_server as usize")]
72    pub ephemeral_public_key_server: &'a [u8],
73}
74
75#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, FrameCodec)]
76#[frame(error = UdsError)]
77pub struct VerifyCertificateBidirectionalResponse<'a> {
78    pub authentication_return_parameter: AuthenticationReturnParameter,
79    pub length_of_challenge_server: u16,
80    #[frame(length = "length_of_challenge_server as usize")]
81    pub challenge_server: &'a [u8],
82    pub length_of_certificate_server: u16,
83    #[frame(length = "length_of_certificate_server as usize")]
84    pub certificate_server: &'a [u8],
85    pub length_of_proof_of_ownership_server: u16,
86    #[frame(length = "length_of_proof_of_ownership_server as usize")]
87    pub proof_of_ownership_server: &'a [u8],
88    pub length_of_ephemeral_public_key_server: u16,
89    #[frame(length = "length_of_ephemeral_public_key_server as usize")]
90    pub ephemeral_public_key_server: &'a [u8],
91}
92
93#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, FrameCodec)]
94#[frame(error = UdsError)]
95pub struct ProofOfOwnershipResponse<'a> {
96    pub authentication_return_parameter: AuthenticationReturnParameter,
97    pub length_of_session_key_info: u16,
98    #[frame(length = "length_of_session_key_info as usize")]
99    pub session_key_info: &'a [u8],
100}
101
102#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, FrameCodec)]
103#[frame(error = UdsError)]
104pub struct TransmitCertificateResponse {
105    pub authentication_return_parameter: AuthenticationReturnParameter,
106}
107
108#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, FrameCodec)]
109#[frame(error = UdsError)]
110pub struct RequestChallengeForAuthenticationResponse<'a> {
111    pub authentication_return_parameter: AuthenticationReturnParameter,
112    pub algorithm_indicator: [u8; 16],
113    pub length_of_challenge_server: u16,
114    #[frame(length = "length_of_challenge_server as usize")]
115    pub challenge_server: &'a [u8],
116    pub length_of_needed_additional_parameter: u16,
117    #[frame(length = "length_of_needed_additional_parameter as usize")]
118    pub needed_additional_parameter: &'a [u8],
119}
120
121#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, FrameCodec)]
122#[frame(error = UdsError)]
123pub struct VerifyProofOfOwnershipUnidirectionalResponse<'a> {
124    pub authentication_return_parameter: AuthenticationReturnParameter,
125    pub algorithm_indicator: [u8; 16],
126    pub length_of_session_key_info: u16,
127    #[frame(length = "length_of_session_key_info as usize")]
128    pub session_key_info: &'a [u8],
129}
130
131#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, FrameCodec)]
132#[frame(error = UdsError)]
133pub struct VerifyProofOfOwnershipBidirectionalResponse<'a> {
134    pub authentication_return_parameter: AuthenticationReturnParameter,
135    pub algorithm_indicator: [u8; 16],
136    pub length_of_proof_of_ownership_server: u16,
137    #[frame(length = "length_of_proof_of_ownership_server as usize")]
138    pub proof_of_ownership_server: &'a [u8],
139    pub length_of_session_key_info: u16,
140    #[frame(length = "length_of_session_key_info as usize")]
141    pub session_key_info: &'a [u8],
142}
143
144#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, FrameCodec)]
145#[frame(error = UdsError)]
146pub struct AuthenticationConfigurationResponse {
147    pub authentication_return_parameter: AuthenticationReturnParameter,
148}