@@ -111,7 +111,6 @@ pub struct ProcessingM2MethodSpecificsC {
111111#[ repr( C ) ]
112112pub struct ProcessingM2C {
113113 pub method_specifics : ProcessingM2MethodSpecificsC ,
114- pub method : EDHOCMethod ,
115114 pub prk_2e : BytesHashLen ,
116115 pub th_2 : BytesHashLen ,
117116 pub x : BytesP256ElemLen ,
@@ -129,7 +128,6 @@ impl Default for ProcessingM2C {
129128 mac_2 : Default :: default ( ) ,
130129 id_cred_r : Default :: default ( ) ,
131130 } ,
132- method : EDHOCMethod :: StatStat ,
133131 prk_2e : Default :: default ( ) ,
134132 th_2 : Default :: default ( ) ,
135133 x : Default :: default ( ) ,
@@ -154,7 +152,6 @@ impl ProcessingM2C {
154152
155153 ProcessingM2 {
156154 method_specifics,
157- method : self . method ,
158155 prk_2e : self . prk_2e ,
159156 th_2 : self . th_2 ,
160157 x : self . x ,
@@ -177,7 +174,6 @@ impl ProcessingM2C {
177174 ( * processing_m2_c) . x = processing_m2. x ;
178175 ( * processing_m2_c) . g_y = processing_m2. g_y ;
179176 ( * processing_m2_c) . plaintext_2 = processing_m2. plaintext_2 ;
180- ( * processing_m2_c) . method = processing_m2. method ;
181177 let c_r = processing_m2. c_r . as_slice ( ) ;
182178 assert_eq ! ( c_r. len( ) , 1 , "C API only supports short C_R" ) ;
183179 ( * processing_m2_c) . c_r = c_r[ 0 ] ;
@@ -224,6 +220,79 @@ impl CredentialC {
224220 }
225221}
226222
223+ #[ derive( Debug ) ]
224+ #[ repr( C ) ]
225+ pub enum ProcessedM2MethodSpecificsKindC {
226+ Prm2StatStat ,
227+ }
228+
229+ #[ derive( Debug ) ]
230+ #[ repr( C ) ]
231+ pub struct ProcessedM2MethodSpecificsC {
232+ pub kind : ProcessedM2MethodSpecificsKindC ,
233+ }
234+
235+ #[ derive( Debug ) ]
236+ #[ repr( C ) ]
237+ pub struct ProcessedM2C {
238+ pub method : EDHOCMethod ,
239+ pub method_specifics : ProcessedM2MethodSpecificsC ,
240+ pub prk_3e2m : BytesHashLen ,
241+ pub prk_4e3m : BytesHashLen ,
242+ pub th_3 : BytesHashLen ,
243+ }
244+
245+ impl Default for ProcessedM2C {
246+ fn default ( ) -> Self {
247+ Self {
248+ method : EDHOCMethod :: StatStat ,
249+ method_specifics : ProcessedM2MethodSpecificsC {
250+ kind : ProcessedM2MethodSpecificsKindC :: Prm2StatStat ,
251+ } ,
252+ prk_3e2m : Default :: default ( ) ,
253+ prk_4e3m : Default :: default ( ) ,
254+ th_3 : Default :: default ( ) ,
255+ }
256+ }
257+ }
258+
259+ impl ProcessedM2C {
260+ pub fn to_rust ( & self ) -> ProcessedM2 {
261+ let method_specifics = match self . method_specifics . kind {
262+ ProcessedM2MethodSpecificsKindC :: Prm2StatStat => {
263+ ProcessedM2MethodSpecifics :: StatStat { }
264+ }
265+ } ;
266+
267+ ProcessedM2 {
268+ method : self . method ,
269+ method_specifics,
270+ prk_3e2m : self . prk_3e2m ,
271+ prk_4e3m : self . prk_4e3m ,
272+ th_3 : self . th_3 ,
273+ }
274+ }
275+
276+ pub unsafe fn copy_into_c ( processed_m2 : ProcessedM2 , processed_m2_c : * mut ProcessedM2C ) {
277+ if processed_m2_c. is_null ( ) {
278+ panic ! ( "processed_m2_c is null" ) ;
279+ }
280+
281+ ( * processed_m2_c) . method = processed_m2. method ;
282+ ( * processed_m2_c) . prk_3e2m = processed_m2. prk_3e2m ;
283+ ( * processed_m2_c) . prk_4e3m = processed_m2. prk_4e3m ;
284+ ( * processed_m2_c) . th_3 = processed_m2. th_3 ;
285+
286+ match processed_m2. method_specifics {
287+ ProcessedM2MethodSpecifics :: StatStat { } => {
288+ ( * processed_m2_c) . method_specifics = ProcessedM2MethodSpecificsC {
289+ kind : ProcessedM2MethodSpecificsKindC :: Prm2StatStat ,
290+ } ;
291+ }
292+ }
293+ }
294+ }
295+
227296#[ no_mangle]
228297pub unsafe extern "C" fn credential_new (
229298 cred : * mut CredentialC ,
0 commit comments