@@ -27,10 +27,11 @@ pub mod tests {
2727 private:: SigningKey ,
2828 } ,
2929 } ;
30+ use core:: convert:: Infallible ;
3031 use digest:: { Digest , OutputSizeUser } ;
3132 use hex_literal:: hex;
3233 use hybrid_array:: { Array , ArraySize } ;
33- use rand_core:: { CryptoRng , RngCore , TryRngCore } ;
34+ use rand_core:: { TryCryptoRng , TryRngCore } ;
3435 use signature:: { RandomizedSignerMut , Verifier } ;
3536 use std:: { matches, ops:: Add } ;
3637 use typenum:: { Sum , U2 } ;
@@ -128,28 +129,31 @@ pub mod tests {
128129 /// Constant RNG for testing purposes only.
129130 pub struct ConstantRng < ' a > ( pub & ' a [ u8 ] ) ;
130131
131- impl RngCore for ConstantRng < ' _ > {
132- fn next_u32 ( & mut self ) -> u32 {
132+ impl TryRngCore for ConstantRng < ' _ > {
133+ type Error = Infallible ;
134+
135+ fn try_next_u32 ( & mut self ) -> Result < u32 , Self :: Error > {
133136 let ( head, tail) = self . 0 . split_at ( 4 ) ;
134137 self . 0 = tail;
135- u32:: from_be_bytes ( head. try_into ( ) . unwrap ( ) )
138+ Ok ( u32:: from_be_bytes ( head. try_into ( ) . unwrap ( ) ) )
136139 }
137140
138- fn next_u64 ( & mut self ) -> u64 {
141+ fn try_next_u64 ( & mut self ) -> Result < u64 , Self :: Error > {
139142 let ( head, tail) = self . 0 . split_at ( 8 ) ;
140143 self . 0 = tail;
141- u64:: from_be_bytes ( head. try_into ( ) . unwrap ( ) )
144+ Ok ( u64:: from_be_bytes ( head. try_into ( ) . unwrap ( ) ) )
142145 }
143146
144- fn fill_bytes ( & mut self , dest : & mut [ u8 ] ) {
147+ fn try_fill_bytes ( & mut self , dest : & mut [ u8 ] ) -> Result < ( ) , Self :: Error > {
145148 let ( hd, tl) = self . 0 . split_at ( dest. len ( ) ) ;
146149 dest. copy_from_slice ( hd) ;
147150 self . 0 = tl;
151+ Ok ( ( ) )
148152 }
149153 }
150154
151155 /// WARNING: This is not a secure cryptographic RNG. It is only used for testing.
152- impl CryptoRng for ConstantRng < ' _ > { }
156+ impl TryCryptoRng for ConstantRng < ' _ > { }
153157
154158 #[ test]
155159 /// Test Case 2, Appendix F. LMS level 2. https://datatracker.ietf.org/doc/html/rfc8554#appendix-F
0 commit comments