X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=pppd%2Fplugins%2Fradius%2Fmd5.c;h=5a3903dad30b888f306901c4e01b37f7324ecc0d;hb=4cb90c1fb141ae3cca08c2ac9c663c14a4d2473e;hp=8acfb38c49a3a9e791f87ceccb9eedcabd067cbc;hpb=774440c7f0a2b633bae02980927e36ad371604dc;p=ppp.git diff --git a/pppd/plugins/radius/md5.c b/pppd/plugins/radius/md5.c index 8acfb38..5a3903d 100644 --- a/pppd/plugins/radius/md5.c +++ b/pppd/plugins/radius/md5.c @@ -1,13 +1,30 @@ /* * $Id: md5.c,v 1.1 2004/11/14 07:26:26 paulus Exp $ */ -#include +#include -void rc_md5_calc (unsigned char *output, unsigned char *input, unsigned int inlen) +#include + +int rc_md5_calc(unsigned char *out, const unsigned char *in, unsigned int inl) { - MD5_CTX context; + int retval = 0; + int outl = MD5_DIGEST_LENGTH; + + PPP_MD_CTX *ctx = PPP_MD_CTX_new(); + if (ctx) { + + if (PPP_DigestInit(ctx, PPP_md5())) { + + if (PPP_DigestUpdate(ctx, in, inl)) { + + if (PPP_DigestFinal(ctx, out, &outl)) { + + retval = 1; + } + } + } - MD5_Init (&context); - MD5_Update (&context, input, inlen); - MD5_Final (output, &context); + PPP_MD_CTX_free(ctx); + } + return retval; }