libmd(3LIB) Interface Libraries libmd(3LIB)NAME
libmd - Message Digest library
SYNOPSIS
cc [ flag... ] file... -lmd [ library... ]
#include <md4.h>
#include <md5.h>
#include <sha1.h>
#include <sha2.h>
DESCRIPTION
Functions in this library provide hashing routines for MD4 (RFC1320), MD5 (RFC1321), SHA1 (RFC3174), SHA256 (FIPS 180-2), SHA384 (FIPS
180-2), SHA512 (FIPS 180-2).
INTERFACES
The shared object libmd.so.1 provides the public interfaces defined below. See Intro(3) for additional information on shared object inter-
faces.
MD4Final MD4Init
MD4Update md5_calc
MD5Final MD5Init
MD5Update SHA1Final
SHA1Init SHA1Update
SHA2Final SHA2Init
SHA2Update
SECURITY
The MD4 and MD5 algorithms are currently considered weak for cryptographic use. The algorithms should be used only for compatibility with
legacy systems or protocols.
The SHA1 algorithm is also believed to have some weaknesses. Migration to one of the SHA2 algorithms-including SHA256, SHA386 or SHA512-is
highly recommended when compatibility with data formats and on wire protocols is permitted.
FILES
/lib/libmd.so.1 shared object
/lib/64/libmd.so.1 64-bit shared object
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Committed |
+-----------------------------+-----------------------------+
|MT-Level |MT-Safe |
+-----------------------------+-----------------------------+
SunOS 5.11 16 Jun 2008 libmd(3LIB)
Check Out this Related Man Page
sha1(3EXT) Extended Library Functions sha1(3EXT)NAME
sha1, SHA1Init, SHA1Update, SHA1Final - SHA1 digest functions
SYNOPSIS
cc [ flag ... ] file ... -lmd [ library ... ]
#include <sha1.h>
void SHA1Init(SHA1_CTX *context);
void SHA1Update(SHA1_CTX *context, unsigned char *input,
unsigned int inlen);
void SHA1Final(unsigned char *output, SHA1_CTX *context);
DESCRIPTION
The SHA1 functions implement the SHA1 message-digest algorithm. The algorithm takes as input a message of arbitrary length and produces a
200-bit "fingerprint" or "message digest" as output. The SHA1 message-digest algorithm is intended for digital signature applications in
which large files are "compressed" in a secure manner before being encrypted with a private (secret) key under a public-key cryptosystem
such as RSA.
SHA1Init(), SHA1Update(), SHA1Final()
The SHA1Init(), SHA1Update(), and SHA1Final() functions allow a SHA1 digest to be computed over multiple message blocks. Between
blocks, the state of the SHA1 computation is held in an SHA1 context structure allocated by the caller. A complete digest computation
consists of calls to SHA1 functions in the following order: one call to SHA1Init(), one or more calls to SHA1Update(), and one call to
SHA1Final().
The SHA1Init() function initializes the SHA1 context structure pointed to by context.
The SHA1Update() function computes a partial SHA1 digest on the inlen-byte message block pointed to by input, and updates the SHA1 con-
text structure pointed to by context accordingly.
The SHA1Final() function generates the final SHA1 digest, using the SHA1 context structure pointed to by context. The 16-bit SHA1
digest is written to output. After a call to SHA1Final(), the state of the context structure is undefined. It must be reinitialized
with SHA1Init() before it can be used again.
SECURITY
The SHA1 algorithm is also believed to have some weaknesses. Migration to one of the SHA2 algorithms-including SHA256, SHA386 or SHA512-is
highly recommended when compatibility with data formats and on wire protocols is permitted.
RETURN VALUES
These functions do not return a value.
EXAMPLES
Example 1 Authenticate a message found in multiple buffers
The following is a sample function that authenticates a message found in multiple buffers. The calling function provides an authentication
buffer to contain the result of the SHA1 digest.
#include <sys/types.h>
#include <sys/uio.h>
#include <sha1.h>
int
AuthenticateMsg(unsigned char *auth_buffer, struct iovec
*messageIov, unsigned int num_buffers)
{
SHA1_CTX sha1_context;
unsigned int i;
SHA1Init(&sha1_context);
for(i=0; i<num_buffers; i++)
{
SHA1Update(&sha1_context, messageIov->iov_base,
messageIov->iov_len);
messageIov += sizeof(struct iovec);
}
SHA1Final(auth_buffer, &sha1_context);
return 0;
}
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Committed |
+-----------------------------+-----------------------------+
|MT-Level |MT-Safe |
+-----------------------------+-----------------------------+
SEE ALSO sha2(3EXT), libmd(3LIB)
RFC 1374
SunOS 5.11 13 Nov 2007 sha1(3EXT)