@@ -245,7 +245,7 @@ mod recprot {
245245mod recprot {
246246 use std:: {
247247 fmt,
248- os:: raw:: { c_char, c_int, c_uint} ,
248+ os:: raw:: { c_char, c_int, c_uint, c_ulong } ,
249249 ptr:: { null, null_mut} ,
250250 } ;
251251
@@ -271,8 +271,24 @@ mod recprot {
271271 reason = "NONCE_LEN = 12 and TAG_LEN = 16 both fit in u32"
272272 ) ]
273273 const TAG_LEN_C : c_uint = TAG_LEN as c_uint ;
274- const NONCE_LEN_UL : u64 = NONCE_LEN as u64 ;
275- const TAG_BITS_UL : u64 = ( TAG_LEN * 8 ) as u64 ;
274+ // On Windows c_ulong is u32; on other platforms it is u64 (same width as usize),
275+ // so cast_possible_truncation only fires on Windows.
276+ #[ cfg_attr(
277+ target_os = "windows" ,
278+ expect(
279+ clippy:: cast_possible_truncation,
280+ reason = "NONCE_LEN = 12 fits in u32"
281+ )
282+ ) ]
283+ const NONCE_LEN_UL : c_ulong = NONCE_LEN as c_ulong ;
284+ #[ cfg_attr(
285+ target_os = "windows" ,
286+ expect(
287+ clippy:: cast_possible_truncation,
288+ reason = "TAG_LEN * 8 = 128 fits in u32"
289+ )
290+ ) ]
291+ const TAG_BITS_UL : c_ulong = ( TAG_LEN * 8 ) as c_ulong ;
276292 #[ expect(
277293 clippy:: cast_possible_truncation,
278294 reason = "CK_GCM_MESSAGE_PARAMS is a small fixed struct"
@@ -645,10 +661,14 @@ mod recprot {
645661
646662 #[ test]
647663 fn ck_gcm_message_params_size ( ) {
664+ use std:: os:: raw:: c_ulong;
648665 eprintln ! (
649- "size_of::<CK_GCM_MESSAGE_PARAMS>() = {}, GCM_PARAMS_LEN_C = {}" ,
666+ "size_of::<CK_GCM_MESSAGE_PARAMS>()={} GCM_PARAMS_LEN_C={} \
667+ size_of::<c_ulong>()={} size_of::<*mut u8>()={}",
650668 size_of:: <freebl:: CK_GCM_MESSAGE_PARAMS >( ) ,
651669 super :: GCM_PARAMS_LEN_C ,
670+ size_of:: <c_ulong>( ) ,
671+ size_of:: <* mut u8 >( ) ,
652672 ) ;
653673 }
654674
@@ -688,6 +708,21 @@ mod recprot {
688708 pTag : tag. as_mut_ptr ( ) ,
689709 ulTagBits : super :: TAG_BITS_UL ,
690710 } ;
711+ eprintln ! (
712+ "params: pIv={:?} ulIvLen={} ulIvFixedBits={} ivGenerator={} pTag={:?} ulTagBits={}" ,
713+ params. pIv, params. ulIvLen, params. ulIvFixedBits,
714+ params. ivGenerator, params. pTag, params. ulTagBits,
715+ ) ;
716+ // Show the raw bytes NSS will receive so we can spot any layout mismatch.
717+ let params_bytes: & [ u8 ] = unsafe {
718+ std:: slice:: from_raw_parts (
719+ ( & raw const params) . cast :: < u8 > ( ) ,
720+ size_of :: < freebl:: CK_GCM_MESSAGE_PARAMS > ( ) ,
721+ )
722+ } ;
723+ eprintln ! ( "params raw bytes: {params_bytes:02x?}" ) ;
724+ // Clear any stale error so we know exactly what AES_AEAD sets (if anything).
725+ unsafe { crate :: err:: PR_SetError ( 0 , 0 ) } ;
691726 let rv = unsafe {
692727 freebl:: AES_AEAD (
693728 ctx_enc,
0 commit comments