NetBurner 3.1
md5.h
1 /*NB_REVISION*/
2 
3 #ifndef _MD5_H_
4 #define _MD5_H_
5 
6 /* MD5.H - header file for MD5C.C
7  */
8 
9 /* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
10 rights reserved.
11 
12 License to copy and use this software is granted provided that it
13 is identified as the "RSA Data Security, Inc. MD5 Message-Digest
14 Algorithm" in all material mentioning or referencing this software
15 or this function.
16 
17 License is also granted to make and use derivative works provided
18 that such works are identified as "derived from the RSA Data
19 Security, Inc. MD5 Message-Digest Algorithm" in all material
20 mentioning or referencing the derived work.
21 
22 RSA Data Security, Inc. makes no representations concerning either
23 the merchantability of this software or the suitability of this
24 software for any particular purpose. It is provided "as is"
25 without express or implied warranty of any kind.
26 
27 These notices must be retained in any copies of any part of this
28 documentation and/or software.
29  */
30 
31 /* MD5 context. */
32 
33 // NB Definitions
34 #include <predef.h>
35 
36 // NB Libs
37 #include <basictypes.h>
38 #include <hash.h>
39 
40 struct MD5_CTX : public HASH_CTX
41 {
42  MD5_CTX() = default;
43  MD5_CTX(uint32_t _state[4],
44  uint32_t _count[2],
45  unsigned char _buffer[64]
46 #ifdef SSL_TLS_SUPPORT
47  ,
48  unsigned char inner[64],
49  unsigned char outer[64]
50 #endif
51  );
52 
53  uint32_t state[4]; /* state (ABCD) */
54  uint32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */
55  unsigned char buffer[64]; /* input buffer */
56 #ifdef SSL_TLS_SUPPORT
57  unsigned char hmac_inner_pad[64];
58  unsigned char hmac_outer_pad[64];
59 #endif
60  void __Init();
61  void __Update(const unsigned char *data, unsigned int len);
62  void __Final(unsigned char *);
63  int __GetDigestLen() const;
64  int __GetOIDLen() const;
65  const unsigned char *__GetOID() const;
66  void ctor();
67 
68  private:
69  static __vtable_HASH_CTX_t _s__vtable;
70 };
71 
72 typedef unsigned char md5_digest_t[16];
73 
74 inline void MD5Init(MD5_CTX *ctx)
75 {
76  ctx->ctor();
77 }
78 inline void MD5Update(MD5_CTX *ctx, const unsigned char *data, unsigned int len)
79 {
80  ctx->__Update(data, len);
81 }
82 inline void MD5Final(unsigned char digest[16], MD5_CTX *ctx)
83 {
84  ctx->__Final(digest);
85 }
86 
87 #endif /* #ifndef _MD5_H_ */