|
1 /* |
|
2 * ============================================================================ |
|
3 * Name : ./accesssec/eapol/eapol_framework/wapi_common/src/ec_cs_compare_reference_id.cpp |
|
4 * Part of : WAPI / WAPI *** Info from the SWAD |
|
5 * Description : WAPI authentication |
|
6 * Version : %version: 2 % << Don't touch! Updated by Synergy at check-out. |
|
7 * |
|
8 * Copyright © 2001-2009 Nokia. All rights reserved. |
|
9 * This material, including documentation and any related computer |
|
10 * programs, is protected by copyright controlled by Nokia. All |
|
11 * rights are reserved. Copying, including reproducing, storing, |
|
12 * adapting or translating, any or all of this material requires the |
|
13 * prior written consent of Nokia. This material also contains |
|
14 * confidential information which may not be disclosed to others |
|
15 * without the prior written consent of Nokia. |
|
16 * ============================================================================ |
|
17 * Template version: 4.1.1 |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 // This is enumeration of WAPI source code. |
|
23 #if defined(USE_EAP_MINIMUM_RELEASE_TRACES) |
|
24 #undef EAP_FILE_NUMBER_ENUM |
|
25 #define EAP_FILE_NUMBER_ENUM 700 |
|
26 #undef EAP_FILE_NUMBER_DATE |
|
27 #define EAP_FILE_NUMBER_DATE 1127594498 |
|
28 #endif //#if defined(USE_EAP_MINIMUM_RELEASE_TRACES) |
|
29 |
|
30 |
|
31 #if defined(USE_WAPI_CORE) |
|
32 |
|
33 #include "eap_automatic_variable.h" |
|
34 #include "ec_cs_types.h" |
|
35 #include "ec_cs_data.h" |
|
36 #include "ec_cs_compare_reference.h" |
|
37 #include "wapi_certificate_asn1_der_parser.h" |
|
38 #include "wapi_asn1_der_parser.h" |
|
39 #include "ec_cs_tlv_header.h" |
|
40 #include "ec_cs_tlv_payloads.h" |
|
41 |
|
42 //---------------------------------------------------------------------------- |
|
43 |
|
44 EAP_FUNC_EXPORT ec_cs_compare_reference_c::~ec_cs_compare_reference_c() |
|
45 { |
|
46 } |
|
47 |
|
48 //---------------------------------------------------------------------------- |
|
49 |
|
50 EAP_FUNC_EXPORT ec_cs_compare_reference_c::ec_cs_compare_reference_c( |
|
51 abs_eap_am_tools_c * const tools) |
|
52 : m_am_tools(tools) |
|
53 { |
|
54 } |
|
55 |
|
56 //---------------------------------------------------------------------------- |
|
57 |
|
58 EAP_FUNC_EXPORT i32_t ec_cs_compare_reference_c::compare( |
|
59 const ec_cs_data_c * const reference_tlv_from_array, |
|
60 const ec_cs_data_c * const reference) const |
|
61 { |
|
62 // reference_tlv_from_array includes ID-Reference TLV which includes ASU-ID TLV and Certificate-reference TLV. |
|
63 // reference includes identity of certificate. Data is concatenation of subject name, issuer name and serial number, each ASN.1/DER encoded. |
|
64 |
|
65 EAP_TRACE_DATA_DEBUG( |
|
66 m_am_tools, |
|
67 TRACE_FLAGS_DEFAULT, |
|
68 (EAPL("ec_cs_compare_reference_c::compare(): reference_tlv_from_array"), |
|
69 reference_tlv_from_array->get_data()->get_data(), |
|
70 reference_tlv_from_array->get_data()->get_data_length())); |
|
71 |
|
72 EAP_TRACE_DATA_DEBUG( |
|
73 m_am_tools, |
|
74 TRACE_FLAGS_DEFAULT, |
|
75 (EAPL("ec_cs_compare_reference_c::compare(): reference"), |
|
76 reference->get_data()->get_data(), |
|
77 reference->get_data()->get_data_length())); |
|
78 |
|
79 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
|
80 |
|
81 ec_cs_tlv_header_c id_reference_tlv( |
|
82 m_am_tools, |
|
83 reference_tlv_from_array->get_data()->get_data(), |
|
84 reference_tlv_from_array->get_data()->get_data_length()); |
|
85 if (id_reference_tlv.get_is_valid() == false) |
|
86 { |
|
87 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
88 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
89 } |
|
90 |
|
91 |
|
92 { |
|
93 ec_cs_tlv_payloads_c parser( |
|
94 m_am_tools, |
|
95 true); |
|
96 if (parser.get_is_valid() == false) |
|
97 { |
|
98 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
99 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
100 } |
|
101 |
|
102 u32_t length(id_reference_tlv.get_data_length()); |
|
103 u32_t padding_length(0ul); |
|
104 |
|
105 eap_status_e status = parser.parse_ec_cs_payloads( |
|
106 id_reference_tlv.get_data(length), ///< This is the start of the message buffer. |
|
107 &length, ///< This is the length of the buffer. This must match with the length of all payloads. |
|
108 &padding_length ///< Length of possible padding is set to this variable. |
|
109 ); |
|
110 if (status != eap_status_ok) |
|
111 { |
|
112 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
113 return EAP_STATUS_RETURN(m_am_tools, status); |
|
114 } |
|
115 |
|
116 const ec_cs_variable_data_c * const asu_id = parser.get_tlv_pointer(ec_cs_tlv_type_CS_certificate_reference); |
|
117 if (asu_id == 0) |
|
118 { |
|
119 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
120 return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter); |
|
121 } |
|
122 |
|
123 return reference->get_data()->compare(asu_id->get_data(asu_id->get_data_length()), asu_id->get_data_length()); |
|
124 } |
|
125 |
|
126 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
|
127 |
|
128 } |
|
129 |
|
130 //---------------------------------------------------------------------------------- |
|
131 |
|
132 #endif //#if defined(USE_WAPI_CORE) |
|
133 |
|
134 // End. |