@@ -23,9 +23,7 @@ pub enum Endianness {
23
23
/// This structure wraps a `CK_SP800_108_COUNTER_FORMAT` structure.
24
24
#[ derive( Debug , Clone , Copy ) ]
25
25
#[ repr( transparent) ]
26
- pub struct KbkdfCounterFormat {
27
- inner : cryptoki_sys:: CK_SP800_108_COUNTER_FORMAT ,
28
- }
26
+ pub struct KbkdfCounterFormat ( cryptoki_sys:: CK_SP800_108_COUNTER_FORMAT ) ;
29
27
30
28
impl KbkdfCounterFormat {
31
29
/// Construct encoding format for KDF's internal counter variable.
@@ -36,14 +34,12 @@ impl KbkdfCounterFormat {
36
34
///
37
35
/// * `width_in_bits` - The number of bits used to represent the counter value.
38
36
pub fn new ( endianness : Endianness , width_in_bits : usize ) -> Self {
39
- Self {
40
- inner : cryptoki_sys:: CK_SP800_108_COUNTER_FORMAT {
41
- bLittleEndian : ( endianness == Endianness :: Little ) . into ( ) ,
42
- ulWidthInBits : width_in_bits
37
+ Self ( cryptoki_sys:: CK_SP800_108_COUNTER_FORMAT {
38
+ bLittleEndian : ( endianness == Endianness :: Little ) . into ( ) ,
39
+ ulWidthInBits : width_in_bits
43
40
. try_into ( )
44
41
. expect ( "bit width of KBKDF internal counter does not fit in CK_ULONG" ) ,
45
- } ,
46
- }
42
+ } )
47
43
}
48
44
}
49
45
@@ -63,9 +59,7 @@ pub enum DkmLengthMethod {
63
59
/// This structure wraps a `CK_SP800_108_DKM_LENGTH_FORMAT` structure.
64
60
#[ derive( Debug , Clone , Copy ) ]
65
61
#[ repr( transparent) ]
66
- pub struct KbkdfDkmLengthFormat {
67
- inner : cryptoki_sys:: CK_SP800_108_DKM_LENGTH_FORMAT ,
68
- }
62
+ pub struct KbkdfDkmLengthFormat ( cryptoki_sys:: CK_SP800_108_DKM_LENGTH_FORMAT ) ;
69
63
70
64
impl KbkdfDkmLengthFormat {
71
65
/// Construct encoding format for length value of DKM (derived key material) from KDF.
@@ -78,24 +72,22 @@ impl KbkdfDkmLengthFormat {
78
72
///
79
73
/// * `width_in_bits` - The number of bits used to represent the DKM length value.
80
74
pub fn new (
81
- dkm_length_method : DkmLengthMethod ,
82
- endianness : Endianness ,
83
- width_in_bits : usize ,
75
+ dkm_length_method : DkmLengthMethod ,
76
+ endianness : Endianness ,
77
+ width_in_bits : usize ,
84
78
) -> Self {
85
- Self {
86
- inner : cryptoki_sys:: CK_SP800_108_DKM_LENGTH_FORMAT {
87
- dkmLengthMethod : match dkm_length_method {
88
- DkmLengthMethod :: SumOfKeys => cryptoki_sys:: CK_SP800_108_DKM_LENGTH_SUM_OF_KEYS ,
89
- DkmLengthMethod :: SumOfSegments => {
90
- cryptoki_sys:: CK_SP800_108_DKM_LENGTH_SUM_OF_SEGMENTS
91
- }
92
- } ,
93
- bLittleEndian : ( endianness == Endianness :: Little ) . into ( ) ,
94
- ulWidthInBits : width_in_bits. try_into ( ) . expect (
95
- "bit width of KBKDF derived key material length value does not fit in CK_ULONG" ,
96
- ) ,
79
+ Self ( cryptoki_sys:: CK_SP800_108_DKM_LENGTH_FORMAT {
80
+ dkmLengthMethod : match dkm_length_method {
81
+ DkmLengthMethod :: SumOfKeys => cryptoki_sys:: CK_SP800_108_DKM_LENGTH_SUM_OF_KEYS ,
82
+ DkmLengthMethod :: SumOfSegments => {
83
+ cryptoki_sys:: CK_SP800_108_DKM_LENGTH_SUM_OF_SEGMENTS
84
+ }
97
85
} ,
98
- }
86
+ bLittleEndian : ( endianness == Endianness :: Little ) . into ( ) ,
87
+ ulWidthInBits : width_in_bits. try_into ( ) . expect (
88
+ "bit width of KBKDF derived key material length value does not fit in CK_ULONG" ,
89
+ ) ,
90
+ } )
99
91
}
100
92
}
101
93
@@ -139,13 +131,13 @@ impl<'a> PrfDataParam<'a> {
139
131
} ,
140
132
PrfDataParamType :: Counter ( counter_format) => cryptoki_sys:: CK_PRF_DATA_PARAM {
141
133
type_ : cryptoki_sys:: CK_SP800_108_COUNTER ,
142
- pValue : & counter_format. inner as * const _ as * mut _ ,
134
+ pValue : counter_format as * const _ as * mut _ ,
143
135
ulValueLen : size_of :: < cryptoki_sys:: CK_SP800_108_COUNTER_FORMAT > ( )
144
136
as cryptoki_sys:: CK_ULONG ,
145
137
} ,
146
138
PrfDataParamType :: DkmLength ( dkm_length_format) => cryptoki_sys:: CK_PRF_DATA_PARAM {
147
139
type_ : cryptoki_sys:: CK_SP800_108_DKM_LENGTH ,
148
- pValue : & dkm_length_format. inner as * const _ as * mut _ ,
140
+ pValue : dkm_length_format as * const _ as * mut _ ,
149
141
ulValueLen : size_of :: < cryptoki_sys:: CK_SP800_108_DKM_LENGTH_FORMAT > ( )
150
142
as cryptoki_sys:: CK_ULONG ,
151
143
} ,
@@ -197,15 +189,15 @@ impl<'a> PrfCounterDataParam<'a> {
197
189
PrfCounterDataParamType :: IterationVariable ( counter_format) => {
198
190
cryptoki_sys:: CK_PRF_DATA_PARAM {
199
191
type_ : cryptoki_sys:: CK_SP800_108_ITERATION_VARIABLE ,
200
- pValue : & counter_format. inner as * const _ as * mut _ ,
192
+ pValue : counter_format as * const _ as * mut _ ,
201
193
ulValueLen : size_of :: < cryptoki_sys:: CK_SP800_108_COUNTER_FORMAT > ( )
202
194
as cryptoki_sys:: CK_ULONG ,
203
195
}
204
196
}
205
197
PrfCounterDataParamType :: DkmLength ( dkm_length_format) => {
206
198
cryptoki_sys:: CK_PRF_DATA_PARAM {
207
199
type_ : cryptoki_sys:: CK_SP800_108_DKM_LENGTH ,
208
- pValue : & dkm_length_format. inner as * const _ as * mut _ ,
200
+ pValue : dkm_length_format as * const _ as * mut _ ,
209
201
ulValueLen : size_of :: < cryptoki_sys:: CK_SP800_108_DKM_LENGTH_FORMAT > ( )
210
202
as cryptoki_sys:: CK_ULONG ,
211
203
}
0 commit comments