File tree Expand file tree Collapse file tree
elliptic-curve/src/hash2curve/hash2field Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -68,15 +68,16 @@ where
6868 where
6969 X : Default + ExtendableOutput + Update ,
7070 {
71- if dst. is_empty ( ) {
71+ // https://www.rfc-editor.org/rfc/rfc9380.html#section-3.1-4.2
72+ if dst. iter ( ) . map ( |slice| slice. len ( ) ) . sum :: < usize > ( ) == 0 {
7273 Err ( Error )
73- } else if dst. iter ( ) . map ( |dst| dst . len ( ) ) . sum :: < usize > ( ) > MAX_DST_LEN {
74+ } else if dst. iter ( ) . map ( |slice| slice . len ( ) ) . sum :: < usize > ( ) > MAX_DST_LEN {
7475 let mut data = Array :: < u8 , L > :: default ( ) ;
7576 let mut hash = X :: default ( ) ;
7677 hash. update ( OVERSIZE_DST_SALT ) ;
7778
78- for dst in dst {
79- hash. update ( dst ) ;
79+ for slice in dst {
80+ hash. update ( slice ) ;
8081 }
8182
8283 hash. finalize_xof ( ) . read ( & mut data) ;
@@ -91,15 +92,16 @@ where
9192 where
9293 X : Digest < OutputSize = L > ,
9394 {
94- if dst. is_empty ( ) {
95+ // https://www.rfc-editor.org/rfc/rfc9380.html#section-3.1-4.2
96+ if dst. iter ( ) . map ( |slice| slice. len ( ) ) . sum :: < usize > ( ) == 0 {
9597 Err ( Error )
96- } else if dst. iter ( ) . map ( |dst| dst . len ( ) ) . sum :: < usize > ( ) > MAX_DST_LEN {
98+ } else if dst. iter ( ) . map ( |slice| slice . len ( ) ) . sum :: < usize > ( ) > MAX_DST_LEN {
9799 Ok ( Self :: Hashed ( {
98100 let mut hash = X :: new ( ) ;
99101 hash. update ( OVERSIZE_DST_SALT ) ;
100102
101- for dst in dst {
102- hash. update ( dst ) ;
103+ for slice in dst {
104+ hash. update ( slice ) ;
103105 }
104106
105107 hash. finalize ( )
You can’t perform that action at this time.
0 commit comments