@@ -104,14 +104,14 @@ static void read_output(struct space *space, struct file *f, off_t *poff,
104104 pull_bytes (f , poff , output -> script , output -> script_length );
105105}
106106
107- static void sha_add (SHA256_CTX * sha256 , struct file * f , off_t start , off_t len )
107+ static void sha_add (sha256_context * sha256 , struct file * f , off_t start , off_t len )
108108{
109109 if (likely (f -> mmap )) {
110- SHA256_Update (sha256 , f -> mmap + start , len );
110+ sha256_write (sha256 , f -> mmap + start , len );
111111 } else {
112112 u8 * buf = tal_arr (NULL , u8 , len );
113113 file_read (f , start , len , buf );
114- SHA256_Update (sha256 , buf , len );
114+ sha256_write (sha256 , buf , len );
115115 tal_free (buf );
116116 }
117117}
@@ -156,10 +156,10 @@ void read_bitcoin_transaction(struct space *space,
156156 size_t i ;
157157 const off_t start = * poff ;
158158 off_t hash_start = * poff ;
159- SHA256_CTX sha256 ;
159+ sha256_context sha256 ;
160160 bool segwit = false;
161161
162- SHA256_Init (& sha256 );
162+ sha256_initialize (& sha256 );
163163
164164 trans -> version = pull_u32 (f , poff );
165165 sha_add (& sha256 , f , start , * poff - start );
@@ -211,10 +211,10 @@ void read_bitcoin_transaction(struct space *space,
211211 len += * poff - hash_start ;
212212
213213 /* Bitcoin uses double sha (it's not quite known why...) */
214- SHA256_Final ( trans -> sha256 , & sha256 );
215- SHA256_Init (& sha256 );
216- SHA256_Update (& sha256 , trans -> sha256 , sizeof (trans -> sha256 ));
217- SHA256_Final ( trans -> sha256 , & sha256 );
214+ sha256_finalize ( & sha256 , trans -> sha256 );
215+ sha256_initialize (& sha256 );
216+ sha256_write (& sha256 , trans -> sha256 , sizeof (trans -> sha256 ));
217+ sha256_finalize ( & sha256 , trans -> sha256 );
218218
219219 trans -> non_swlen = len ;
220220 trans -> total_len = * poff - start ;
@@ -243,7 +243,7 @@ read_bitcoin_block_header(struct bitcoin_block *block,
243243 u8 block_md [SHA256_DIGEST_LENGTH ],
244244 const u32 marker )
245245{
246- SHA256_CTX sha256 ;
246+ sha256_context sha256 ;
247247 off_t start ;
248248
249249 block -> D9B4BEF9 = pull_u32 (f , off );
@@ -260,20 +260,20 @@ read_bitcoin_block_header(struct bitcoin_block *block,
260260 block -> nonce = pull_u32 (f , off );
261261
262262 /* Bitcoin uses double sha (it's not quite known why...) */
263- SHA256_Init (& sha256 );
263+ sha256_initialize (& sha256 );
264264 if (likely (f -> mmap )) {
265- SHA256_Update (& sha256 , f -> mmap + start , * off - start );
265+ sha256_write (& sha256 , f -> mmap + start , * off - start );
266266 } else {
267267 u8 * buf = tal_arr (NULL , u8 , * off - start );
268268 file_read (f , start , * off - start , buf );
269- SHA256_Update (& sha256 , buf , * off - start );
269+ sha256_write (& sha256 , buf , * off - start );
270270 tal_free (buf );
271271 }
272- SHA256_Final ( block_md , & sha256 );
272+ sha256_finalize ( & sha256 , block_md );
273273
274- SHA256_Init (& sha256 );
275- SHA256_Update (& sha256 , block_md , SHA256_DIGEST_LENGTH );
276- SHA256_Final ( block_md , & sha256 );
274+ sha256_initialize (& sha256 );
275+ sha256_write (& sha256 , block_md , SHA256_DIGEST_LENGTH );
276+ sha256_finalize ( & sha256 , block_md );
277277
278278 block -> transaction_count = pull_varint (f , off );
279279
0 commit comments