Annotation of libwww/Library/src/HTDigest.c, revision 2.1
2.1 ! kahan 1: /* HTDigest.c
! 2: ** GENERIC INTERFACE TO MESSAGE DIGEST ALGORITHMS
! 3: **
! 4: ** (c) COPYRIGHT W3C/INRIA 1998.
! 5: ** Please first read the full copyright statement in the file COPYRIGHT.
! 6: ** @(#) $Id: HTDigest.c,v 1.1 1998/12/15 12:50:20 cvs Exp $
! 7: **
! 8: ** Contains a generic interface to the message digest algorithms,
! 9: ** inspired from the RSA-Euro toolkit. For the moment, it only
! 10: ** covers MD5.
! 11: ** SHA and other algorithms could be added later on. This code
! 12: ** is only used during message digest authentication.
! 13: **
! 14: ** AUTHORS:
! 15: ** JKO Jose Kahan jose@w3.org
! 16: **
! 17: ** HISTORY:
! 18: ** Dec 98 JKO Created the module from scratch
! 19: */
! 20:
! 21: /* Library include files */
! 22: #include "wwwsys.h"
! 23: #include "WWWLib.h"
! 24: #include "HTDigest.h" /* Implemented here */
! 25:
! 26: PUBLIC BOOL HTDigest_init (HTDigestContext *context, int digesttype)
! 27: {
! 28: context->algorithm = digesttype;
! 29:
! 30: switch (digesttype) {
! 31: case HTDaMD5:
! 32: MD5Init (&context->context.md5);
! 33: break;
! 34: default:
! 35: return NO;
! 36: break;
! 37: }
! 38: return YES;
! 39: }
! 40:
! 41: PUBLIC BOOL HTDigest_update (HTDigestContext *context, char *input, unsigned int inputLen)
! 42: {
! 43: switch (context->algorithm) {
! 44: case HTDaMD5:
! 45: MD5Update (&context->context.md5, (unsigned char *) input,
! 46: inputLen);
! 47: break;
! 48: default:
! 49: return NO;
! 50: break;
! 51: }
! 52: }
! 53:
! 54: PUBLIC BOOL HTDigest_final (unsigned char *digest, HTDigestContext *context)
! 55: {
! 56: switch (context->algorithm) {
! 57: case HTDaMD5:
! 58: MD5Final (digest, &context->context.md5);
! 59: break;
! 60: default:
! 61: return NO;
! 62: break;
! 63: }
! 64: }
! 65:
! 66:
! 67:
! 68:
! 69:
Webmaster