@@ -104,14 +104,14 @@ static void read_output(struct space *space, struct file *f, off_t *poff,
104
104
pull_bytes (f , poff , output -> script , output -> script_length );
105
105
}
106
106
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 )
108
108
{
109
109
if (likely (f -> mmap )) {
110
- SHA256_Update (sha256 , f -> mmap + start , len );
110
+ sha256_write (sha256 , f -> mmap + start , len );
111
111
} else {
112
112
u8 * buf = tal_arr (NULL , u8 , len );
113
113
file_read (f , start , len , buf );
114
- SHA256_Update (sha256 , buf , len );
114
+ sha256_write (sha256 , buf , len );
115
115
tal_free (buf );
116
116
}
117
117
}
@@ -156,10 +156,10 @@ void read_bitcoin_transaction(struct space *space,
156
156
size_t i ;
157
157
const off_t start = * poff ;
158
158
off_t hash_start = * poff ;
159
- SHA256_CTX sha256 ;
159
+ sha256_context sha256 ;
160
160
bool segwit = false;
161
161
162
- SHA256_Init (& sha256 );
162
+ sha256_initialize (& sha256 );
163
163
164
164
trans -> version = pull_u32 (f , poff );
165
165
sha_add (& sha256 , f , start , * poff - start );
@@ -211,10 +211,10 @@ void read_bitcoin_transaction(struct space *space,
211
211
len += * poff - hash_start ;
212
212
213
213
/* 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 );
218
218
219
219
trans -> non_swlen = len ;
220
220
trans -> total_len = * poff - start ;
@@ -243,7 +243,7 @@ read_bitcoin_block_header(struct bitcoin_block *block,
243
243
u8 block_md [SHA256_DIGEST_LENGTH ],
244
244
const u32 marker )
245
245
{
246
- SHA256_CTX sha256 ;
246
+ sha256_context sha256 ;
247
247
off_t start ;
248
248
249
249
block -> D9B4BEF9 = pull_u32 (f , off );
@@ -260,20 +260,20 @@ read_bitcoin_block_header(struct bitcoin_block *block,
260
260
block -> nonce = pull_u32 (f , off );
261
261
262
262
/* Bitcoin uses double sha (it's not quite known why...) */
263
- SHA256_Init (& sha256 );
263
+ sha256_initialize (& sha256 );
264
264
if (likely (f -> mmap )) {
265
- SHA256_Update (& sha256 , f -> mmap + start , * off - start );
265
+ sha256_write (& sha256 , f -> mmap + start , * off - start );
266
266
} else {
267
267
u8 * buf = tal_arr (NULL , u8 , * off - start );
268
268
file_read (f , start , * off - start , buf );
269
- SHA256_Update (& sha256 , buf , * off - start );
269
+ sha256_write (& sha256 , buf , * off - start );
270
270
tal_free (buf );
271
271
}
272
- SHA256_Final ( block_md , & sha256 );
272
+ sha256_finalize ( & sha256 , block_md );
273
273
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 );
277
277
278
278
block -> transaction_count = pull_varint (f , off );
279
279
0 commit comments