summaryrefslogtreecommitdiff
path: root/crypt-sunmd5.c
diff options
context:
space:
mode:
authorBjörn Esser <besser82@fedoraproject.org>2018-10-22 13:48:34 +0200
committerBjörn Esser <besser82@fedoraproject.org>2018-10-22 13:55:23 +0200
commit4964877dbf96d951b3f45b2dba97459404d1dff8 (patch)
tree822fc8f0e649351d8683191249f56bae818504e1 /crypt-sunmd5.c
parent323e5e097f643641f41f24969227b073470e186e (diff)
downloadlibxcrypt-4964877dbf96d951b3f45b2dba97459404d1dff8.tar.gz
libxcrypt-4964877dbf96d951b3f45b2dba97459404d1dff8.tar.bz2
libxcrypt-4964877dbf96d951b3f45b2dba97459404d1dff8.zip
Use md5 implementation from Alexander Peslyak.
Thus we now have a md5 implementation in the public domain.
Diffstat (limited to 'crypt-sunmd5.c')
-rw-r--r--crypt-sunmd5.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/crypt-sunmd5.c b/crypt-sunmd5.c
index 9f76ed1..7a30aae 100644
--- a/crypt-sunmd5.c
+++ b/crypt-sunmd5.c
@@ -165,7 +165,7 @@ crypt_sunmd5_rn (const char *phrase, size_t phr_size,
{
struct crypt_sunmd5_scratch
{
- struct md5_ctx ctx;
+ MD5_CTX ctx;
uint8_t dg[16];
char rn[16];
};
@@ -238,27 +238,27 @@ crypt_sunmd5_rn (const char *phrase, size_t phr_size,
struct crypt_sunmd5_scratch *s = scratch;
/* Initial round. */
- md5_init_ctx (&s->ctx);
- md5_process_bytes (phrase, phr_size, &s->ctx);
- md5_process_bytes (setting, saltlen, &s->ctx);
- md5_finish_ctx (&s->ctx, s->dg);
+ MD5_Init (&s->ctx);
+ MD5_Update (&s->ctx, phrase, phr_size);
+ MD5_Update (&s->ctx, setting, saltlen);
+ MD5_Final (s->dg, &s->ctx);
/* Stretching rounds. */
for (unsigned int i = 0; i < nrounds; i++)
{
- md5_init_ctx (&s->ctx);
+ MD5_Init (&s->ctx);
- md5_process_bytes (s->dg, sizeof s->dg, &s->ctx);
+ MD5_Update (&s->ctx, s->dg, sizeof s->dg);
/* The trailing nul is intentionally included. */
if (muffet_coin_toss (s->dg, i))
- md5_process_bytes (hamlet_quotation, sizeof hamlet_quotation, &s->ctx);
+ MD5_Update (&s->ctx, hamlet_quotation, sizeof hamlet_quotation);
int nwritten = snprintf (s->rn, sizeof s->rn, "%u", i);
assert (nwritten >= 1 && (unsigned int)nwritten + 1 <= sizeof s->rn);
- md5_process_bytes (s->rn, (unsigned int)nwritten, &s->ctx);
+ MD5_Update (&s->ctx, s->rn, (unsigned int)nwritten);
- md5_finish_ctx (&s->ctx, s->dg);
+ MD5_Final (s->dg, &s->ctx);
}
memcpy (output, setting, saltlen);