1md4(3EXT) Extended Library Functions md4(3EXT)
2
3
4
6 md4, MD4Init, MD4Update, MD4Final - MD4 digest functions
7
9 cc [ flag ... ] file ... -lmd [ library ... ]
10 #include <md4.h>
11
12 void MD4Init(MD4_CTX *context);
13
14
15 void MD4Update(MD4_CTX *context, unsigned char *input,
16 unsigned int inlen);
17
18
19 void MD4Final(unsigned char *output, MD4_CTX *context);
20
21
23 The MD4 functions implement the MD4 message-digest algorithm. The algo‐
24 rithm takes as input a message of arbitrary length and produces a "fin‐
25 gerprint" or "message digest" as output. The MD4 message-digest algo‐
26 rithm is intended for digital signature applications in which large
27 files are "compressed" in a secure manner before being encrypted with a
28 private (secret) key under a public-key cryptosystem such as RSA.
29
30 MD4Init(), MD4Update(), MD4Final()
31 The MD4Init(), MD4Update(), and MD4Final() functions allow an MD4
32 digest to be computed over multiple message blocks. Between blocks, the
33 state of the MD4 computation is held in an MD4 context structure allo‐
34 cated by the caller. A complete digest computation consists of calls to
35 MD4 functions in the following order: one call to MD4Init(), one or
36 more calls to MD4Update(), and one call to MD4Final().
37
38
39 The MD4Init() function initializes the MD4 context structure pointed to
40 by context.
41
42
43 The MD4Update() function computes a partial MD4 digest on the inlen-
44 byte message block pointed to by input, and updates the MD4 context
45 structure pointed to by context accordingly.
46
47
48 The MD4Final() function generates the final MD4 digest, using the MD4
49 context structure pointed to by context. The MD4 digest is written to
50 output. After a call to MD4Final(), the state of the context structure
51 is undefined. It must be reinitialized with MD4Init() before it can be
52 used again.
53
55 These functions do not return a value.
56
58 The MD4 digest algorithm is not currently considered cryptographically
59 secure. It is included in libmd(3LIB) for use by legacy protocols and
60 systems only. It should not be used by new systems or protocols.
61
63 Example 1 Authenticate a message found in multiple buffers
64
65
66 The following is a sample function that must authenticate a message
67 that is found in multiple buffers. The calling function provides an
68 authentication buffer that will contain the result of the MD4 digest.
69
70
71 #include <sys/types.h>
72 #include <sys/uio.h>
73 #include <md4.h>
74
75 int
76 AuthenticateMsg(unsigned char *auth_buffer, struct iovec
77 *messageIov, unsigned int num_buffers)
78 {
79 MD4_CTX ctx;
80 unsigned int i;
81
82 MD4Init(&ctx);
83
84 for(i=0; i<num_buffers; i++)
85 {
86 MD4Update(&ctx, messageIov->iov_base,
87 messageIov->iov_len);
88 messageIov += sizeof(struct iovec);
89 }
90
91 MD4Final(auth_buffer, &ctx);
92
93 return 0;
94 }
95
96
98 See attributes(5) for descriptions of the following attributes:
99
100
101
102
103 ┌─────────────────────────────┬─────────────────────────────┐
104 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
105 ├─────────────────────────────┼─────────────────────────────┤
106 │Interface Stability │Committed │
107 ├─────────────────────────────┼─────────────────────────────┤
108 │MT-Level │MT-Safe │
109 └─────────────────────────────┴─────────────────────────────┘
110
112 libmd(3LIB)
113
114
115 RFC 1320
116
117
118
119SunOS 5.11 13 Nov 2007 md4(3EXT)