Contenues dansTrouver plus de documentationRessources d'assistance comprises | Télécharger cet ouvrage au format PDF (4971 Ko)
sha1(3EXT)Name | Synopsis | Description | Security | Return Values | Examples | Attributes | See Also Name
Synopsiscc [ 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. SecurityThe 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 ValuesThese functions do not return a value. ExamplesExample 1 Authenticate a message found in multiple buffersThe 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;
}
AttributesSee attributes(5) for descriptions of the following attributes:
See AlsoRFC 1374 Name | Synopsis | Description | Security | Return Values | Examples | Attributes | See Also |
||||||