@@ -951,7 +951,7 @@ impl X963Kdf {
951951struct ConcatKdfHash {
952952 algorithm : pyo3:: Py < pyo3:: PyAny > ,
953953 length : usize ,
954- otherinfo : pyo3:: Py < pyo3:: types:: PyBytes > ,
954+ otherinfo : Option < pyo3:: Py < pyo3:: types:: PyBytes > > ,
955955 used : bool ,
956956}
957957
@@ -982,13 +982,10 @@ impl ConcatKdfHash {
982982 ) ) ;
983983 }
984984
985- let otherinfo_bytes =
986- otherinfo. unwrap_or_else ( || pyo3:: types:: PyBytes :: new ( py, b"" ) . into ( ) ) ;
987-
988985 Ok ( ConcatKdfHash {
989986 algorithm,
990987 length,
991- otherinfo : otherinfo_bytes ,
988+ otherinfo,
992989 used : false ,
993990 } )
994991 }
@@ -1016,7 +1013,9 @@ impl ConcatKdfHash {
10161013 let mut hash_obj = hashes:: Hash :: new ( py, algorithm_bound, None ) ?;
10171014 hash_obj. update_bytes ( & counter. to_be_bytes ( ) ) ?;
10181015 hash_obj. update_bytes ( key_material. as_bytes ( ) ) ?;
1019- hash_obj. update_bytes ( self . otherinfo . as_bytes ( py) ) ?;
1016+ if let Some ( ref otherinfo) = self . otherinfo {
1017+ hash_obj. update_bytes ( otherinfo. as_bytes ( py) ) ?;
1018+ }
10201019 let block = hash_obj. finalize ( py) ?;
10211020 let block_bytes = block. as_bytes ( ) ;
10221021
@@ -1060,7 +1059,7 @@ struct ConcatKdfHmac {
10601059 algorithm : pyo3:: Py < pyo3:: PyAny > ,
10611060 length : usize ,
10621061 salt : pyo3:: Py < pyo3:: types:: PyBytes > ,
1063- otherinfo : pyo3:: Py < pyo3:: types:: PyBytes > ,
1062+ otherinfo : Option < pyo3:: Py < pyo3:: types:: PyBytes > > ,
10641063 used : bool ,
10651064}
10661065
@@ -1115,14 +1114,11 @@ impl ConcatKdfHmac {
11151114 pyo3:: types:: PyBytes :: new ( py, & vec ! [ 0u8 ; block_size_val] ) . into ( )
11161115 } ;
11171116
1118- let otherinfo_bytes =
1119- otherinfo. unwrap_or_else ( || pyo3:: types:: PyBytes :: new ( py, b"" ) . into ( ) ) ;
1120-
11211117 Ok ( ConcatKdfHmac {
11221118 algorithm,
11231119 length,
11241120 salt : salt_bytes,
1125- otherinfo : otherinfo_bytes ,
1121+ otherinfo,
11261122 used : false ,
11271123 } )
11281124 }
@@ -1150,7 +1146,9 @@ impl ConcatKdfHmac {
11501146 let mut hmac = Hmac :: new_bytes ( py, self . salt . as_bytes ( py) , algorithm_bound) ?;
11511147 hmac. update_bytes ( & counter. to_be_bytes ( ) ) ?;
11521148 hmac. update_bytes ( key_material. as_bytes ( ) ) ?;
1153- hmac. update_bytes ( self . otherinfo . as_bytes ( py) ) ?;
1149+ if let Some ( ref otherinfo) = self . otherinfo {
1150+ hmac. update_bytes ( otherinfo. as_bytes ( py) ) ?;
1151+ }
11541152 let result = hmac. finalize_bytes ( ) ?;
11551153
11561154 let copy_len = ( self . length - pos) . min ( digest_size) ;
0 commit comments