@@ -21,50 +21,50 @@ pub const AES256CTR_BLOCKBYTES: usize = 64;
21
21
22
22
/// Block size for AES256CTR in bytes.
23
23
#[ cfg( not( feature = "90s" ) ) ]
24
- pub ( crate ) const AES256CTR_BLOCKBYTES : usize = 64 ;
24
+ pub const AES256CTR_BLOCKBYTES : usize = 64 ;
25
25
26
26
/// Block size for XOF (Extendable Output Function) in bytes.
27
27
#[ cfg( feature = "90s" ) ]
28
28
pub const XOF_BLOCKBYTES : usize = AES256CTR_BLOCKBYTES ;
29
29
30
30
/// Block size for XOF (Extendable Output Function) in bytes.
31
31
#[ cfg( not( feature = "90s" ) ) ]
32
- pub ( crate ) const XOF_BLOCKBYTES : usize = SHAKE128_RATE ;
32
+ pub const XOF_BLOCKBYTES : usize = SHAKE128_RATE ;
33
33
34
34
/// Type alias for the XOF (Extendable Output Function) state.
35
35
#[ cfg( not( feature = "90s" ) ) ]
36
- pub ( crate ) type XofState = KeccakState ;
36
+ pub type XofState = KeccakState ;
37
37
38
38
/// Type alias for the XOF (Extendable Output Function) state in 90s mode.
39
39
#[ cfg( feature = "90s" ) ]
40
40
pub type XofState = Aes256CtrCtx ;
41
41
42
42
/// Keccak state for absorbing data
43
- #[ derive( Copy , Clone ) ]
44
- pub ( crate ) struct KeccakState {
45
- pub ( crate ) s : [ u64 ; 25 ] ,
46
- pub ( crate ) pos : usize ,
43
+ #[ derive( Copy , Clone , Debug , Default ) ]
44
+ pub struct KeccakState {
45
+ pub s : [ u64 ; 25 ] ,
46
+ pub pos : usize ,
47
47
}
48
48
49
49
impl KeccakState {
50
50
/// Creates a new KeccakState
51
- pub ( crate ) fn new ( ) -> Self {
51
+ pub fn new ( ) -> Self {
52
52
KeccakState {
53
53
s : [ 0u64 ; 25 ] ,
54
54
pos : 0usize ,
55
55
}
56
56
}
57
57
58
58
/// Resets the KeccakState
59
- pub ( crate ) fn reset ( & mut self ) {
59
+ pub fn reset ( & mut self ) {
60
60
self . s = [ 0u64 ; 25 ] ;
61
61
self . pos = 0 ;
62
62
}
63
63
}
64
64
65
65
/// Computes SHA3-256 hash
66
66
#[ cfg( not( feature = "90s" ) ) ]
67
- pub ( crate ) fn hash_h ( out : & mut [ u8 ] , input : & [ u8 ] , inlen : usize ) {
67
+ pub fn hash_h ( out : & mut [ u8 ] , input : & [ u8 ] , inlen : usize ) {
68
68
sha3_256 ( out, input, inlen) ;
69
69
}
70
70
@@ -79,7 +79,7 @@ pub fn hash_h(out: &mut [u8], input: &[u8], inlen: usize) {
79
79
80
80
/// Computes SHA3-512 hash
81
81
#[ cfg( not( feature = "90s" ) ) ]
82
- pub ( crate ) fn hash_g ( out : & mut [ u8 ] , input : & [ u8 ] , inlen : usize ) {
82
+ pub fn hash_g ( out : & mut [ u8 ] , input : & [ u8 ] , inlen : usize ) {
83
83
sha3_512 ( out, input, inlen) ;
84
84
}
85
85
@@ -94,7 +94,7 @@ pub fn hash_g(out: &mut [u8], input: &[u8], inlen: usize) {
94
94
95
95
/// Absorbs input data into the XOF state in non-90s mode
96
96
#[ cfg( not( feature = "90s" ) ) ]
97
- pub ( crate ) fn xof_absorb ( state : & mut XofState , input : & [ u8 ] , x : u8 , y : u8 ) {
97
+ pub fn xof_absorb ( state : & mut XofState , input : & [ u8 ] , x : u8 , y : u8 ) {
98
98
kyber_shake128_absorb ( state, input, x, y) ;
99
99
}
100
100
@@ -109,7 +109,7 @@ pub fn xof_absorb(state: &mut XofState, input: &[u8], x: u8, y: u8) {
109
109
110
110
/// Squeezes XOF data into output in non-90s mode
111
111
#[ cfg( not( feature = "90s" ) ) ]
112
- pub ( crate ) fn xof_squeezeblocks ( out : & mut [ u8 ] , outblocks : usize , state : & mut XofState ) {
112
+ pub fn xof_squeezeblocks ( out : & mut [ u8 ] , outblocks : usize , state : & mut XofState ) {
113
113
kyber_shake128_squeezeblocks ( out, outblocks, state) ;
114
114
}
115
115
@@ -121,7 +121,7 @@ pub fn xof_squeezeblocks(out: &mut [u8], outblocks: usize, state: &mut XofState)
121
121
122
122
/// Pseudo-random function (PRF) in non-90s mode
123
123
#[ cfg( not( feature = "90s" ) ) ]
124
- pub ( crate ) fn prf ( out : & mut [ u8 ] , outbytes : usize , key : & [ u8 ] , nonce : u8 ) {
124
+ pub fn prf ( out : & mut [ u8 ] , outbytes : usize , key : & [ u8 ] , nonce : u8 ) {
125
125
shake256_prf ( out, outbytes, key, nonce) ;
126
126
}
127
127
@@ -145,7 +145,7 @@ pub fn prf(out: &mut [u8], _outbytes: usize, key: &[u8], nonce: u8) {
145
145
146
146
/// Key derivation function (KDF) in non-90s mode
147
147
#[ cfg( not( feature = "90s" ) ) ]
148
- pub ( crate ) fn kdf ( out : & mut [ u8 ] , input : & [ u8 ] , inlen : usize ) {
148
+ pub fn kdf ( out : & mut [ u8 ] , input : & [ u8 ] , inlen : usize ) {
149
149
shake256 ( out, KYBER_SHARED_SECRET_BYTES , input, inlen) ;
150
150
}
151
151
@@ -160,7 +160,7 @@ pub fn kdf(out: &mut [u8], input: &[u8], inlen: usize) {
160
160
161
161
/// Absorb step of the SHAKE128 specialized for the Kyber context
162
162
#[ cfg( not( feature = "90s" ) ) ]
163
- fn kyber_shake128_absorb ( s : & mut KeccakState , input : & [ u8 ] , x : u8 , y : u8 ) {
163
+ pub fn kyber_shake128_absorb ( s : & mut KeccakState , input : & [ u8 ] , x : u8 , y : u8 ) {
164
164
let mut extseed = [ 0u8 ; KYBER_SYM_BYTES + 2 ] ;
165
165
extseed[ ..KYBER_SYM_BYTES ] . copy_from_slice ( input) ;
166
166
extseed[ KYBER_SYM_BYTES ] = x;
@@ -170,13 +170,13 @@ fn kyber_shake128_absorb(s: &mut KeccakState, input: &[u8], x: u8, y: u8) {
170
170
171
171
/// Squeeze step of SHAKE128 XOF in non-90s mode
172
172
#[ cfg( not( feature = "90s" ) ) ]
173
- fn kyber_shake128_squeezeblocks ( output : & mut [ u8 ] , nblocks : usize , s : & mut KeccakState ) {
173
+ pub fn kyber_shake128_squeezeblocks ( output : & mut [ u8 ] , nblocks : usize , s : & mut KeccakState ) {
174
174
shake128_squeezeblocks ( output, nblocks, s) ;
175
175
}
176
176
177
177
/// Usage of SHAKE256 as a PRF in non-90s mode
178
178
#[ cfg( not( feature = "90s" ) ) ]
179
- fn shake256_prf ( output : & mut [ u8 ] , outlen : usize , key : & [ u8 ] , nonce : u8 ) {
179
+ pub fn shake256_prf ( output : & mut [ u8 ] , outlen : usize , key : & [ u8 ] , nonce : u8 ) {
180
180
let mut extkey = [ 0u8 ; KYBER_SYM_BYTES + 1 ] ;
181
181
extkey[ ..KYBER_SYM_BYTES ] . copy_from_slice ( key) ;
182
182
extkey[ KYBER_SYM_BYTES ] = nonce;
0 commit comments