Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Nadezhda Ivanova
OpenLDAP
Commits
c52dc059
Commit
c52dc059
authored
Oct 27, 1999
by
Kurt Zeilenga
Browse files
In fallback mode, use value of buffer to improve quality of hash.
parent
f804da9b
Changes
1
Hide whitespace changes
Inline
Side-by-side
libraries/liblutil/entropy.c
View file @
c52dc059
...
...
@@ -24,6 +24,10 @@
/*
* lutil_entropy() provides nbytes of entropy in buf.
* Quality offerred is suitable for one-time uses, such as "once" keys.
*
* Note: Callers are encouraged to provide additional bytes of
* of entropy in the buf argument. This information is used in
* fallback mode to improve the quality of bytes returned.
*/
int
lutil_entropy
(
char
*
buf
,
int
nbytes
)
{
...
...
@@ -75,7 +79,7 @@ int lutil_entropy( char *buf, int nbytes )
* MD5 is a strong cryptographic hash, this should
* be fairly resistant to attack
*/
static
in
t
counter
=
0
;
static
sig_atomic_
t
counter
=
0
;
int
n
;
struct
rdata_s
{
...
...
@@ -119,10 +123,14 @@ int lutil_entropy( char *buf, int nbytes )
lutil_MD5Init
(
&
ctx
);
lutil_MD5Update
(
&
ctx
,
(
char
*
)
&
rdata
,
sizeof
(
rdata
)
);
/* use caller to provided information */
lutil_MD5Update
(
&
ctx
,
(
char
*
)
&
buf
,
nbytes
);
lutil_MD5Final
(
digest
,
&
ctx
);
memcpy
(
&
buf
[
n
],
digest
,
nbytes
-
n
>
16
?
16
:
nbytes
-
n
);
nbytes
-
n
>
=
16
?
16
:
nbytes
-
n
);
}
return
0
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment