Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions lakers-c/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl Default for ProcessingM2C {

impl ProcessingM2C {
pub fn to_rust(&self) -> ProcessingM2 {
ProcessingM2 {
ProcessingM2::StatStat(ProcessingM2StatStat {
mac_2: self.mac_2,
prk_2e: self.prk_2e,
th_2: self.th_2,
Expand All @@ -136,7 +136,7 @@ impl ProcessingM2C {
c_r: ConnId::from_int_raw(self.c_r),
id_cred_r: self.id_cred_r.clone(),
ead_2: unsafe { (*self.ead_2).to_rust() },
}
})
}

/// note that it is a shallow copy (ead_2 is handled separately by the caller)
Expand All @@ -145,16 +145,20 @@ impl ProcessingM2C {
panic!("processing_m2_c is null");
}

(*processing_m2_c).mac_2 = processing_m2.mac_2;
(*processing_m2_c).prk_2e = processing_m2.prk_2e;
(*processing_m2_c).th_2 = processing_m2.th_2;
(*processing_m2_c).x = processing_m2.x;
(*processing_m2_c).g_y = processing_m2.g_y;
(*processing_m2_c).plaintext_2 = processing_m2.plaintext_2;
let c_r = processing_m2.c_r.as_slice();
assert_eq!(c_r.len(), 1, "C API only supports short C_R");
(*processing_m2_c).c_r = c_r[0];
(*processing_m2_c).id_cred_r = processing_m2.id_cred_r;
match processing_m2 {
ProcessingM2::StatStat(s) => {
(*processing_m2_c).mac_2 = s.mac_2;
(*processing_m2_c).prk_2e = s.prk_2e;
(*processing_m2_c).th_2 = s.th_2;
(*processing_m2_c).x = s.x;
(*processing_m2_c).g_y = s.g_y;
(*processing_m2_c).plaintext_2 = s.plaintext_2;
let c_r = s.c_r.as_slice();
assert_eq!(c_r.len(), 1, "C API only supports short C_R");
(*processing_m2_c).c_r = c_r[0];
(*processing_m2_c).id_cred_r = s.id_cred_r;
}
}
}
}

Expand Down
Loading
Loading