pppd/plugins/radius/md5.c
raw| 1 | #include <stddef.h> |
| 2 | |
| 3 | #include <pppd/crypto.h> |
| 4 | |
| 5 | int rc_md5_calc(unsigned char *out, const unsigned char *in, unsigned int inl) |
| 6 | { |
| 7 | int retval = 0; |
| 8 | int outl = MD5_DIGEST_LENGTH; |
| 9 | |
| 10 | PPP_MD_CTX *ctx = PPP_MD_CTX_new(); |
| 11 | if (ctx) { |
| 12 | |
| 13 | if (PPP_DigestInit(ctx, PPP_md5())) { |
| 14 | |
| 15 | if (PPP_DigestUpdate(ctx, in, inl)) { |
| 16 | |
| 17 | if (PPP_DigestFinal(ctx, out, &outl)) { |
| 18 | |
| 19 | retval = 1; |
| 20 | } |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | PPP_MD_CTX_free(ctx); |
| 25 | } |
| 26 | return retval; |
| 27 | } |