11use bouncycastle_core:: errors:: SerializedStateError ;
22use bouncycastle_core:: serializable_state:: { LIB_VERSION , SemVer } ;
3- use bouncycastle_core:: traits:: { SerializableKeyedState , SerializableState } ;
3+ use bouncycastle_core:: traits:: { Suspendable , SuspendableKeyed } ;
44
5- pub struct TestFrameworkSerializableState { }
5+ pub struct TestFrameworkSuspendableState { }
66
7- impl TestFrameworkSerializableState {
7+ impl TestFrameworkSuspendableState {
88 pub fn new ( ) -> Self {
99 Self { }
1010 }
1111
1212 /// Test all the members of trait SerializableState.
1313 ///
1414 /// Expects ta be handed an instance of the object that has some in-progress state to be serialized.
15- pub fn test <
16- const SERIALIZED_STATE_LEN : usize ,
17- S : SerializableState < SERIALIZED_STATE_LEN > + Clone ,
18- > (
15+ pub fn test < const SERIALIZED_STATE_LEN : usize , S : Suspendable < SERIALIZED_STATE_LEN > + Clone > (
1916 & self ,
2017 instance : & S ,
2118 ) {
@@ -27,10 +24,10 @@ impl TestFrameworkSerializableState {
2724 let instance_clone = instance. clone ( ) ;
2825
2926 // You can serialize and then deserialize the state.
30- let serialized_state = instance_clone. serialize_state ( ) ;
27+ let serialized_state = instance_clone. suspend ( ) ;
3128 assert_eq ! ( serialized_state. len( ) , SERIALIZED_STATE_LEN ) ;
3229
33- let _deserialized_state = S :: from_serialized_state ( serialized_state) . unwrap ( ) ;
30+ let _deserialized_state = S :: from_suspended ( serialized_state) . unwrap ( ) ;
3431
3532 // The serialized state MUST include a prefix indicating the current version of the library.
3633 let state_sized: [ u8 ; 3 ] = serialized_state[ ..3 ] . try_into ( ) . unwrap ( ) ;
@@ -41,7 +38,7 @@ impl TestFrameworkSerializableState {
4138 // used the helper functions.
4239 let mut ver0_serialized_state = serialized_state. clone ( ) ;
4340 ver0_serialized_state[ ..3 ] . copy_from_slice ( & [ 0 , 0 , 0 ] ) ;
44- match S :: from_serialized_state ( ver0_serialized_state) {
41+ match S :: from_suspended ( ver0_serialized_state) {
4542 Err ( SerializedStateError :: IncompatibleVersion ) => { /* good */ }
4643 _ => {
4744 panic ! ( "Expected IncompatibleVersion error" )
@@ -54,7 +51,7 @@ impl TestFrameworkSerializableState {
5451 let mut futurever_serialized_state = serialized_state. clone ( ) ;
5552 futurever_serialized_state[ ..3 ]
5653 . copy_from_slice ( & [ future_ver. major , future_ver. minor , future_ver. patch ] ) ;
57- match S :: from_serialized_state ( futurever_serialized_state) {
54+ match S :: from_suspended ( futurever_serialized_state) {
5855 Err ( SerializedStateError :: IncompatibleVersion ) => { /* good */ }
5956 _ => {
6057 panic ! ( "Expected IncompatibleVersion error" )
@@ -63,9 +60,9 @@ impl TestFrameworkSerializableState {
6360 }
6461}
6562
66- pub struct TestFrameworkSerializableKeyedState { }
63+ pub struct TestFrameworkSuspendableKeyedState { }
6764
68- impl TestFrameworkSerializableKeyedState {
65+ impl TestFrameworkSuspendableKeyedState {
6966 pub fn new ( ) -> Self {
7067 Self { }
7168 }
@@ -75,7 +72,7 @@ impl TestFrameworkSerializableKeyedState {
7572 /// Expects ta be handed an instance of the object that has some in-progress state to be serialized.
7673 pub fn test <
7774 const SERIALIZED_STATE_LEN : usize ,
78- S : SerializableKeyedState < SERIALIZED_STATE_LEN > + Clone ,
75+ S : SuspendableKeyed < SERIALIZED_STATE_LEN > + Clone ,
7976 > (
8077 & self ,
8178 instance : & S ,
@@ -89,10 +86,10 @@ impl TestFrameworkSerializableKeyedState {
8986 let instance_clone = instance. clone ( ) ;
9087
9188 // You can serialize and then deserialize the state.
92- let serialized_state = instance_clone. serialize_state ( ) ;
89+ let serialized_state = instance_clone. suspend ( ) ;
9390 assert_eq ! ( serialized_state. len( ) , SERIALIZED_STATE_LEN ) ;
9491
95- let _deserialized_state = S :: from_serialized_state ( serialized_state, key) . unwrap ( ) ;
92+ let _deserialized_state = S :: from_suspended ( serialized_state, key) . unwrap ( ) ;
9693
9794 // The serialized state MUST include a prefix indicating the current version of the library.
9895 let state_sized: [ u8 ; 3 ] = serialized_state[ ..3 ] . try_into ( ) . unwrap ( ) ;
@@ -103,7 +100,7 @@ impl TestFrameworkSerializableKeyedState {
103100 // used the helper functions.
104101 let mut ver0_serialized_state = serialized_state. clone ( ) ;
105102 ver0_serialized_state[ ..3 ] . copy_from_slice ( & [ 0 , 0 , 0 ] ) ;
106- match S :: from_serialized_state ( ver0_serialized_state, key) {
103+ match S :: from_suspended ( ver0_serialized_state, key) {
107104 Err ( SerializedStateError :: IncompatibleVersion ) => { /* good */ }
108105 _ => {
109106 panic ! ( "Expected IncompatibleVersion error" )
@@ -116,7 +113,7 @@ impl TestFrameworkSerializableKeyedState {
116113 let mut futurever_serialized_state = serialized_state. clone ( ) ;
117114 futurever_serialized_state[ ..3 ]
118115 . copy_from_slice ( & [ future_ver. major , future_ver. minor , future_ver. patch ] ) ;
119- match S :: from_serialized_state ( futurever_serialized_state, key) {
116+ match S :: from_suspended ( futurever_serialized_state, key) {
120117 Err ( SerializedStateError :: IncompatibleVersion ) => { /* good */ }
121118 _ => {
122119 panic ! ( "Expected IncompatibleVersion error" )
0 commit comments