1313// self-test gate. This is intentional for neqo (non-FIPS) and saves ~7.6%
1414// CPU on the PK11_AEADOp hot path (sftk_SessionFromHandle + mutex overhead).
1515
16- use std:: os:: raw:: { c_int, c_uchar, c_uint, c_ulong , c_void} ;
16+ use std:: os:: raw:: { c_int, c_uchar, c_uint, c_void} ;
1717
1818// NSS_AES_GCM = 4 (from blapit.h)
1919pub const NSS_AES_GCM : c_int = 4 ;
@@ -35,23 +35,22 @@ pub type ChaCha20Poly1305Context = ChaCha20Poly1305ContextStr;
3535// For CKG_NO_GENERATE (ivGenerator = 0), pIv/ulIvLen supply the full nonce.
3636// For encrypt, pTag is the output tag buffer; for decrypt, pTag is the input
3737// tag to verify. ulTagBits = TAG_LEN * 8 = 128.
38+ //
39+ // CK_ULONG is `unsigned long` in C, i.e, 64 bit on NSS platforms.
3840#[ repr( C ) ]
3941#[ derive( Copy , Clone ) ]
4042#[ expect( non_snake_case, reason = "PKCS#11 naming conventions." ) ]
4143pub struct CK_GCM_MESSAGE_PARAMS {
4244 pub pIv : * mut c_uchar ,
43- pub ulIvLen : c_ulong ,
44- pub ulIvFixedBits : c_ulong ,
45- pub ivGenerator : c_ulong , // CK_GENERATOR_FUNCTION; 0 = CKG_NO_GENERATE
45+ pub ulIvLen : u64 ,
46+ pub ulIvFixedBits : u64 ,
47+ pub ivGenerator : u64 , // CK_GENERATOR_FUNCTION; 0 = CKG_NO_GENERATE
4648 pub pTag : * mut c_uchar ,
47- pub ulTagBits : c_ulong ,
49+ pub ulTagBits : u64 ,
4850}
4951
50- // On LP64 (Linux/macOS) pointer == c_ulong == 8 bytes, so all 6 fields are
51- // the same width. On Windows LLP64, c_ulong is 4 bytes but pointers are 8,
52- // so the layout differs and the check would be wrong — skip it there.
53- #[ cfg( not( target_os = "windows" ) ) ]
54- const _: ( ) = assert ! ( size_of:: <CK_GCM_MESSAGE_PARAMS >( ) == 6 * size_of:: <c_ulong>( ) ) ;
52+ // All six fields are 8 bytes (two pointers + four u64s).
53+ const _: ( ) = assert ! ( size_of:: <CK_GCM_MESSAGE_PARAMS >( ) == 48 ) ;
5554
5655unsafe extern "C" {
5756 /// Allocate and initialise an AES context. Pass `NULL` for `iv` when
0 commit comments