Skip to content

Commit b509c0c

Browse files
committed
Fix
1 parent dac29ff commit b509c0c

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

src/aead.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -708,15 +708,20 @@ mod recprot {
708708
pTag: tag.as_mut_ptr(),
709709
ulTagBits: super::TAG_BITS_UL,
710710
};
711-
eprintln!(
712-
"params: pIv={:?} ulIvLen={} ulIvFixedBits={} ivGenerator={} pTag={:?} ulTagBits={}",
711+
// Copy fields to locals first: eprintln! takes references, which is
712+
// a hard error (E0793) on packed structs on Windows.
713+
let (p_iv, ul_iv_len, ul_iv_fixed, iv_gen, p_tag, ul_tag_bits) = (
713714
params.pIv,
714715
params.ulIvLen,
715716
params.ulIvFixedBits,
716717
params.ivGenerator,
717718
params.pTag,
718719
params.ulTagBits,
719720
);
721+
eprintln!(
722+
"params: pIv={p_iv:?} ulIvLen={ul_iv_len} ulIvFixedBits={ul_iv_fixed} \
723+
ivGenerator={iv_gen} pTag={p_tag:?} ulTagBits={ul_tag_bits}"
724+
);
720725
// Show the raw bytes NSS will receive so we can spot any layout mismatch.
721726
let params_bytes: &[u8] = unsafe {
722727
std::slice::from_raw_parts(

src/freebl.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@ pub type ChaCha20Poly1305Context = ChaCha20Poly1305ContextStr;
3737
// tag to verify. ulTagBits = TAG_LEN * 8 = 128.
3838
//
3939
// NSS's pkcs11t.h pulls in pkcs11p.h which applies `#pragma pack(push,
40-
// cryptoki, 1)` on Windows. With that packing in effect and CK_ULONG = 4
41-
// bytes (MSVC LLP64), the natural 4-byte padding before `pTag` is removed and
42-
// sizeof = 32. On LP64 all fields are 8 bytes wide so packing is a no-op and
43-
// sizeof = 48. `#[repr(C, packed)]` matches both.
40+
// cryptoki, 1)` on all platforms. On LP64 all six fields are 8 bytes wide so
41+
// packing is a no-op (sizeof = 48). On Windows LLP64 (CK_ULONG = 4 bytes)
42+
// packing removes the natural 4-byte padding before `pTag` (sizeof = 32).
4443
#[repr(C, packed)]
4544
#[derive(Copy, Clone)]
4645
#[expect(non_snake_case, reason = "PKCS#11 naming conventions.")]
@@ -75,6 +74,7 @@ unsafe extern "C" {
7574
pub fn AES_DestroyContext(cx: *mut AESContext, freeit: c_int);
7675

7776
/// AES ECB/CBC encrypt — used in tests to verify the AES context works.
77+
#[cfg(test)]
7878
pub fn AES_Encrypt(
7979
cx: *mut AESContext,
8080
output: *mut c_uchar,

0 commit comments

Comments
 (0)