]> git.ozlabs.org Git - ppp.git/blob - pppd/plugins/radius/md5.c
5a3903dad30b888f306901c4e01b37f7324ecc0d
[ppp.git] / pppd / plugins / radius / md5.c
1 /*
2  * $Id: md5.c,v 1.1 2004/11/14 07:26:26 paulus Exp $
3  */
4 #include <stddef.h>
5
6 #include <pppd/ppp-crypto.h>
7
8 int rc_md5_calc(unsigned char *out, const unsigned char *in, unsigned int inl)
9 {
10     int retval = 0;
11     int outl = MD5_DIGEST_LENGTH;
12
13     PPP_MD_CTX *ctx = PPP_MD_CTX_new();
14     if (ctx) {
15
16         if (PPP_DigestInit(ctx, PPP_md5())) {
17
18             if (PPP_DigestUpdate(ctx, in, inl)) {
19
20                 if (PPP_DigestFinal(ctx, out, &outl)) {
21
22                     retval = 1;
23                 }
24             }
25         }
26
27         PPP_MD_CTX_free(ctx);
28     }
29     return retval;
30 }