Skip to content

Commit 92f6288

Browse files
authored
Merge pull request #48 from mathstuf/fix-dh-compute
keyctl_dh_compute: use the syscall API
2 parents ea94d0d + 620cef6 commit 92f6288

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

keyutils-raw/src/functions.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,21 +359,32 @@ pub fn keyctl_session_to_parent() -> Result<()> {
359359
unsafe { keyctl!(libc::KEYCTL_SESSION_TO_PARENT,) }.map(ignore)
360360
}
361361

362+
#[repr(C)]
363+
struct DhComputeParamsKernel {
364+
priv_: i32,
365+
prime: i32,
366+
base: i32,
367+
}
368+
362369
pub fn keyctl_dh_compute(
363370
private: KeyringSerial,
364371
prime: KeyringSerial,
365372
base: KeyringSerial,
366373
mut buffer: Option<Out<[u8]>>,
367374
) -> Result<usize> {
375+
let params = DhComputeParamsKernel {
376+
priv_: private.get(),
377+
prime: prime.get(),
378+
base: base.get(),
379+
};
368380
let capacity = buffer.as_mut().map_or(0, |b| b.len());
369381
unsafe {
370382
keyctl!(
371383
libc::KEYCTL_DH_COMPUTE,
372-
private.get(),
373-
prime.get(),
374-
base.get(),
384+
&params as *const DhComputeParamsKernel,
375385
buffer.as_mut().map_or(ptr::null(), |b| b.as_mut_ptr()),
376386
capacity,
387+
0,
377388
)
378389
}
379390
.map(size)

0 commit comments

Comments
 (0)