@@ -134,16 +134,18 @@ void br_sha1_out(const br_sha1_context *cc, void *out)
134134 br_sha1_context ctx = * cc ;
135135 size_t used = (size_t )(ctx .count & 63U );
136136 uint64_t bit_len = (uint64_t )ctx .count << 3 ;
137+ bool first = (ctx .count < 64 );
137138
138139 ctx .buf [used ++ ] = 0x80 ;
139140 if (used > 56 ) {
140141 memset (ctx .buf + used , 0 , 64 - used );
141- sha_hal_process_block (ctx .val , ctx .buf , SHA1 , 5 , 16 , ctx . count <= 64 );
142+ sha_hal_process_block (ctx .val , ctx .buf , SHA1 , 5 , 16 , first );
142143 used = 0 ;
144+ first = false;
143145 }
144146 memset (ctx .buf + used , 0 , 56 - used );
145147 br_enc64be (ctx .buf + 56 , bit_len );
146- sha_hal_process_block (ctx .val , ctx .buf , SHA1 , 5 , 16 , ctx . count <= 64 );
148+ sha_hal_process_block (ctx .val , ctx .buf , SHA1 , 5 , 16 , first );
147149 memcpy (out , ctx .val , 20 );
148150}
149151
@@ -172,7 +174,7 @@ const br_hash_class br_sha1_vtable PROGMEM = {
172174 | BR_HASHDESC_LBLEN (6 )
173175 | BR_HASHDESC_MD_PADDING
174176 | BR_HASHDESC_MD_PADDING_BE
175- | BR_HASHDESC_STATE (32 ),
177+ | BR_HASHDESC_STATE (20 ),
176178 (void (* )(const br_hash_class * * )) & br_sha1_init ,
177179 (void (* )(const br_hash_class * * , const void * , size_t )) & br_sha1_update ,
178180 (void (* )(const br_hash_class * const * , void * )) & br_sha1_out ,
0 commit comments