@@ -17,11 +17,33 @@ pub mod generic_keys {
1717 pub ( crate ) pk : PublicKey < LEN > ,
1818 pub ( crate ) d : [ PrivateKeyByte ; LEN ] ,
1919 }
20+ #[ cfg( feature = "check-secret-independence" ) ]
21+ impl < ' a , const LEN : usize > libcrux_secrets:: DeclassifyRef
22+ for & ' a generic_keys:: PrivateKey < LEN , libcrux_secrets:: U8 >
23+ {
24+ type DeclassifiedRef = & ' a generic_keys:: PrivateKey < LEN , u8 > ;
25+ fn declassify_ref ( self ) -> Self :: DeclassifiedRef {
26+ unsafe { core:: mem:: transmute ( self ) }
27+ }
28+ }
29+
2030 /// An RSA Private Key backed by slices. Use if the length is not known at compile time.
2131 pub struct VarLenPrivateKey < ' a , PrivateKeyByte > {
2232 pub ( crate ) pk : VarLenPublicKey < ' a > ,
2333 pub ( crate ) d : & ' a [ PrivateKeyByte ] ,
2434 }
35+
36+ #[ cfg( feature = "check-secret-independence" ) ]
37+ impl < ' a > libcrux_secrets:: Declassify for generic_keys:: VarLenPrivateKey < ' a , libcrux_secrets:: U8 > {
38+ type Declassified = generic_keys:: VarLenPrivateKey < ' a , u8 > ;
39+ fn declassify ( self ) -> Self :: Declassified {
40+ use libcrux_secrets:: DeclassifyRef ;
41+ generic_keys:: VarLenPrivateKey {
42+ pk : self . pk ,
43+ d : self . d . declassify_ref ( ) ,
44+ }
45+ }
46+ }
2547}
2648
2749/// An RSA Private Key that is `LEN` bytes long.
@@ -134,28 +156,6 @@ fn hacl_hash_alg(alg: crate::DigestAlgorithm) -> libcrux_hacl_rs::streaming_type
134156 }
135157}
136158
137- #[ cfg( feature = "check-secret-independence" ) ]
138- impl < ' a > libcrux_secrets:: Declassify for generic_keys:: VarLenPrivateKey < ' a , libcrux_secrets:: U8 > {
139- type Declassified = generic_keys:: VarLenPrivateKey < ' a , u8 > ;
140- fn declassify ( self ) -> Self :: Declassified {
141- use libcrux_secrets:: DeclassifyRef ;
142- generic_keys:: VarLenPrivateKey {
143- pk : self . pk ,
144- d : self . d . declassify_ref ( ) ,
145- }
146- }
147- }
148-
149- #[ cfg( feature = "check-secret-independence" ) ]
150- impl < ' a , const LEN : usize > libcrux_secrets:: DeclassifyRef
151- for & ' a generic_keys:: PrivateKey < LEN , libcrux_secrets:: U8 >
152- {
153- type DeclassifiedRef = & ' a generic_keys:: PrivateKey < LEN , u8 > ;
154- fn declassify_ref ( self ) -> Self :: DeclassifiedRef {
155- unsafe { core:: mem:: transmute ( self ) }
156- }
157- }
158-
159159// next up: generate these in macros
160160
161161macro_rules! impl_rsapss_base {
0 commit comments