Annotation of libwww/Library/src/HTDigest.c, revision 2.2
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.
2.2 ! frystyk 6: ** @(#) $Id: HTDigest.c,v 2.1 1998/12/16 10:59:08 kahan Exp $
2.1 kahan 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: {
2.2 ! frystyk 43: if (context) {
! 44: switch (context->algorithm) {
! 45: case HTDaMD5:
! 46: MD5Update (&context->context.md5, (unsigned char *) input,
! 47: inputLen);
! 48: break;
! 49: default:
! 50: return NO;
! 51: break;
! 52: }
! 53: return YES;
! 54: }
! 55: return NO;
2.1 kahan 56: }
57:
58: PUBLIC BOOL HTDigest_final (unsigned char *digest, HTDigestContext *context)
59: {
2.2 ! frystyk 60: if (context) {
! 61: switch (context->algorithm) {
! 62: case HTDaMD5:
! 63: MD5Final (digest, &context->context.md5);
! 64: break;
! 65: default:
! 66: return NO;
! 67: break;
! 68: }
! 69: return YES;
2.1 kahan 70: }
2.2 ! frystyk 71: return NO;
2.1 kahan 72: }
73:
74:
75:
76:
77:
Webmaster