@@ -63,7 +63,7 @@ static unsigned char crpool[64];
63
63
static unsigned char randpool [SHA_DIGESTSIZE ], randout [SHA_DIGESTSIZE ];
64
64
static unsigned long randcnt = 0 ;
65
65
static unsigned int outpos = 0 ;
66
- SHA1_CTX randctxt ;
66
+ SHA512_CTX randctxt ;
67
67
#endif /* OPENSSL */
68
68
69
69
/*
@@ -84,15 +84,15 @@ t_envhash(unsigned char * out)
84
84
{
85
85
char * * ptr ;
86
86
char ebuf [256 ];
87
- SHA1_CTX ctxt ;
87
+ SHA512_CTX ctxt ;
88
88
89
- SHA1Init (& ctxt );
89
+ SHA512Init (& ctxt );
90
90
for (ptr = environ ; * ptr ; ++ ptr ) {
91
91
strncpy (ebuf , * ptr , 255 );
92
92
ebuf [255 ] = '\0' ;
93
- SHA1Update (& ctxt , ebuf , strlen (ebuf ));
93
+ SHA512Update (& ctxt , ebuf , strlen (ebuf ));
94
94
}
95
- SHA1Final (out , & ctxt );
95
+ SHA512Final (out , & ctxt );
96
96
}
97
97
98
98
/*
@@ -118,13 +118,13 @@ t_fshash(unsigned char * out)
118
118
{
119
119
char dotpath [128 ];
120
120
struct stat st ;
121
- SHA1_CTX ctxt ;
121
+ SHA512_CTX ctxt ;
122
122
int i , pinode ;
123
123
dev_t pdev ;
124
124
125
- SHA1Init (& ctxt );
125
+ SHA512Init (& ctxt );
126
126
if (stat ("." , & st ) >= 0 ) {
127
- SHA1Update (& ctxt , (unsigned char * ) & st , sizeof (st ));
127
+ SHA512Update (& ctxt , (unsigned char * ) & st , sizeof (st ));
128
128
pinode = st .st_ino ;
129
129
pdev = st .st_dev ;
130
130
strcpy (dotpath , ".." );
@@ -133,22 +133,22 @@ t_fshash(unsigned char * out)
133
133
break ;
134
134
if (st .st_ino == pinode && st .st_dev == pdev )
135
135
break ;
136
- SHA1Update (& ctxt , (unsigned char * ) & st , sizeof (st ));
136
+ SHA512Update (& ctxt , (unsigned char * ) & st , sizeof (st ));
137
137
pinode = st .st_ino ;
138
138
pdev = st .st_dev ;
139
139
strcat (dotpath , "/.." );
140
140
}
141
141
}
142
142
143
143
if (fstat (0 , & st ) >= 0 )
144
- SHA1Update (& ctxt , (unsigned char * ) & st , sizeof (st ));
144
+ SHA512Update (& ctxt , (unsigned char * ) & st , sizeof (st ));
145
145
146
146
sprintf (dotpath , "/tmp/rnd.%d" , getpid ());
147
147
if (creat (dotpath , 0600 ) >= 0 && stat (dotpath , & st ) >= 0 )
148
- SHA1Update (& ctxt , (unsigned char * ) & st , sizeof (st ));
148
+ SHA512Update (& ctxt , (unsigned char * ) & st , sizeof (st ));
149
149
unlink (dotpath );
150
150
151
- SHA1Final (out , & ctxt );
151
+ SHA512Final (out , & ctxt );
152
152
}
153
153
154
154
/*
@@ -191,7 +191,6 @@ unsigned long raw_truerand();
191
191
static void
192
192
t_initrand ()
193
193
{
194
- SHA1_CTX ctxt ;
195
194
#ifdef USE_FTIME
196
195
struct timeb t ;
197
196
#else
@@ -271,9 +270,10 @@ t_initrand()
271
270
#elif defined(GCRYPT )
272
271
gcry_random_add_bytes ((unsigned char * )& preseed , sizeof (preseed ), -1 );
273
272
#else
274
- SHA1Init (& ctxt );
275
- SHA1Update (& ctxt , (unsigned char * ) & preseed , sizeof (preseed ));
276
- SHA1Final (randpool , & ctxt );
273
+ SHA512_CTX ctxt ;
274
+ SHA512Init (& ctxt );
275
+ SHA512Update (& ctxt , (unsigned char * ) & preseed , sizeof (preseed ));
276
+ SHA512Final (randpool , & ctxt );
277
277
memset ((unsigned char * ) & ctxt , 0 , sizeof (ctxt ));
278
278
outpos = 0 ;
279
279
#endif /* OPENSSL */
@@ -340,13 +340,13 @@ t_random(unsigned char * data, unsigned size)
340
340
}
341
341
342
342
/* Recycle */
343
- SHA1Init (& randctxt );
344
- SHA1Update (& randctxt , randpool , sizeof (randpool ));
345
- SHA1Final (randout , & randctxt );
346
- SHA1Init (& randctxt );
347
- SHA1Update (& randctxt , (unsigned char * ) & randcnt , sizeof (randcnt ));
348
- SHA1Update (& randctxt , randpool , sizeof (randpool ));
349
- SHA1Final (randpool , & randctxt );
343
+ SHA512Init (& randctxt );
344
+ SHA512Update (& randctxt , randpool , sizeof (randpool ));
345
+ SHA512Final (randout , & randctxt );
346
+ SHA512Init (& randctxt );
347
+ SHA512Update (& randctxt , (unsigned char * ) & randcnt , sizeof (randcnt ));
348
+ SHA512Update (& randctxt , randpool , sizeof (randpool ));
349
+ SHA512Final (randpool , & randctxt );
350
350
++ randcnt ;
351
351
outpos = sizeof (randout );
352
352
}
@@ -370,7 +370,7 @@ t_sessionkey(unsigned char * key, unsigned char * sk, unsigned sklen)
370
370
unsigned i , klen ;
371
371
unsigned char * hbuf ;
372
372
unsigned char hout [SHA_DIGESTSIZE ];
373
- SHA1_CTX ctxt ;
373
+ SHA512_CTX ctxt ;
374
374
375
375
while (sklen > 0 && * sk == 0 ) { /* Skip leading 0's */
376
376
-- sklen ;
@@ -383,17 +383,17 @@ t_sessionkey(unsigned char * key, unsigned char * sk, unsigned sklen)
383
383
384
384
for (i = 0 ; i < klen ; ++ i )
385
385
hbuf [i ] = sk [sklen - 2 * i - 1 ];
386
- SHA1Init (& ctxt );
387
- SHA1Update (& ctxt , hbuf , klen );
388
- SHA1Final (hout , & ctxt );
386
+ SHA512Init (& ctxt );
387
+ SHA512Update (& ctxt , hbuf , klen );
388
+ SHA512Final (hout , & ctxt );
389
389
for (i = 0 ; i < sizeof (hout ); ++ i )
390
390
key [2 * i ] = hout [i ];
391
391
392
392
for (i = 0 ; i < klen ; ++ i )
393
393
hbuf [i ] = sk [sklen - 2 * i - 2 ];
394
- SHA1Init (& ctxt );
395
- SHA1Update (& ctxt , hbuf , klen );
396
- SHA1Final (hout , & ctxt );
394
+ SHA512Init (& ctxt );
395
+ SHA512Update (& ctxt , hbuf , klen );
396
+ SHA512Final (hout , & ctxt );
397
397
for (i = 0 ; i < sizeof (hout ); ++ i )
398
398
key [2 * i + 1 ] = hout [i ];
399
399
@@ -406,7 +406,7 @@ t_sessionkey(unsigned char * key, unsigned char * sk, unsigned sklen)
406
406
_TYPE ( void )
407
407
t_mgf1 (unsigned char * mask , unsigned masklen , const unsigned char * seed , unsigned seedlen )
408
408
{
409
- SHA1_CTX ctxt ;
409
+ SHA512_CTX ctxt ;
410
410
unsigned i = 0 ;
411
411
unsigned pos = 0 ;
412
412
unsigned char cnt [4 ];
@@ -417,17 +417,17 @@ t_mgf1(unsigned char * mask, unsigned masklen, const unsigned char * seed, unsig
417
417
cnt [1 ] = (i >> 16 ) & 0xFF ;
418
418
cnt [2 ] = (i >> 8 ) & 0xFF ;
419
419
cnt [3 ] = i & 0xFF ;
420
- SHA1Init (& ctxt );
421
- SHA1Update (& ctxt , seed , seedlen );
422
- SHA1Update (& ctxt , cnt , 4 );
420
+ SHA512Init (& ctxt );
421
+ SHA512Update (& ctxt , seed , seedlen );
422
+ SHA512Update (& ctxt , cnt , 4 );
423
423
424
424
if (pos + SHA_DIGESTSIZE > masklen ) {
425
- SHA1Final (hout , & ctxt );
425
+ SHA512Final (hout , & ctxt );
426
426
memcpy (mask + pos , hout , masklen - pos );
427
427
pos = masklen ;
428
428
}
429
429
else {
430
- SHA1Final (mask + pos , & ctxt );
430
+ SHA512Final (mask + pos , & ctxt );
431
431
pos += SHA_DIGESTSIZE ;
432
432
}
433
433
0 commit comments