vlc | branch: master | Marvin Scholz <[email protected]> | Wed Apr 1 16:07:32 2020 +0200| [55fb3007a0dd09aec707523989c937a8c6beb93c] | committer: Marvin Scholz
rand: use new md5 API > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=55fb3007a0dd09aec707523989c937a8c6beb93c --- src/posix/rand.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/posix/rand.c b/src/posix/rand.c index b2b724f771..1c258055b7 100644 --- a/src/posix/rand.c +++ b/src/posix/rand.c @@ -35,7 +35,7 @@ #include <pthread.h> #include <vlc_fs.h> -#include <vlc_md5.h> +#include <vlc_hash.h> /* * Pseudo-random number generator using a HMAC-MD5 in counter mode. @@ -83,33 +83,35 @@ void vlc_rand_bytes (void *buf, size_t len) while (len > 0) { uint64_t val; - struct md5_s mdi, mdo; + vlc_hash_md5_t mdi, mdo; + uint8_t mdi_buf[VLC_HASH_MD5_DIGEST_SIZE]; + uint8_t mdo_buf[VLC_HASH_MD5_DIGEST_SIZE]; - InitMD5 (&mdi); - InitMD5 (&mdo); + vlc_hash_md5_Init (&mdi); + vlc_hash_md5_Init (&mdo); pthread_mutex_lock (&lock); if (counter == 0) vlc_rand_init (); val = counter++; - AddMD5 (&mdi, ikey, sizeof (ikey)); - AddMD5 (&mdo, okey, sizeof (okey)); + vlc_hash_md5_Update (&mdi, ikey, sizeof (ikey)); + vlc_hash_md5_Update (&mdo, okey, sizeof (okey)); pthread_mutex_unlock (&lock); - AddMD5 (&mdi, &stamp, sizeof (stamp)); - AddMD5 (&mdi, &val, sizeof (val)); - EndMD5 (&mdi); - AddMD5 (&mdo, mdi.buf, 16); - EndMD5 (&mdo); + vlc_hash_md5_Update (&mdi, &stamp, sizeof (stamp)); + vlc_hash_md5_Update (&mdi, &val, sizeof (val)); + vlc_hash_md5_Finish (&mdi, mdi_buf, sizeof(mdi_buf)); + vlc_hash_md5_Update (&mdo, mdi_buf, sizeof(mdi_buf)); + vlc_hash_md5_Finish (&mdo, mdo_buf, sizeof(mdo_buf)); - if (len < 16) + if (len < sizeof(mdo_buf)) { - memcpy (buf, mdo.buf, len); + memcpy (buf, mdo_buf, len); break; } - memcpy (buf, mdo.buf, 16); + memcpy (buf, mdo_buf, sizeof(mdo_buf)); len -= 16; buf = ((uint8_t *)buf) + 16; } _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
