CC_SHA(3cc)

CC_SHA3cc

Secure hash algorithms

Usage

#include <CommonCrypto/CommonDigest.h>

extern int

CC_SHA1_Init(CC_SHA1_CTX *c);

extern int

CC_SHA1_Update(CC_SHA1_CTX *c, const void *data, CC_LONG len);

extern int

CC_SHA1_Final(unsigned char *md, CC_SHA1_CTX *c);

extern unsigned char *

CC_SHA1(const void *data, CC_LONG len, unsigned char *md);

extern int

CC_SHA224_Init(CC_SHA256_CTX *c);

extern int

CC_SHA224_Update(CC_SHA256_CTX *c, const void *data, CC_LONG len);

extern int

CC_SHA224_Final(unsigned char *md, CC_SHA256_CTX *c);

extern unsigned char *

CC_SHA224(const void *data, CC_LONG len, unsigned char *md);

extern int

CC_SHA256_Init(CC_SHA256_CTX *c);

extern int

CC_SHA256_Update(CC_SHA256_CTX *c, const void *data, CC_LONG len);

extern int

CC_SHA256_Final(unsigned char *md, CC_SHA256_CTX *c);

extern unsigned char *

CC_SHA256(const void *data, CC_LONG len, unsigned char *md);

extern int

CC_SHA384_Init(CC_SHA512_CTX *c);

extern int

CC_SHA384_Update(CC_SHA512_CTX *c, const void *data, CC_LONG len);

extern int

CC_SHA384_Final(unsigned char *md, CC_SHA512_CTX *c);

extern unsigned char *

CC_SHA384(const void *data, CC_LONG len, unsigned char *md);

extern int

CC_SHA512_Init(CC_SHA512_CTX *c);

extern int

CC_SHA512_Update(CC_SHA512_CTX *c, const void *data, CC_LONG len);

extern int

CC_SHA512_Final(unsigned char *md, CC_SHA512_CTX *c);

extern unsigned char *

CC_SHA512(const void *data, CC_LONG len, unsigned char *md);

Overview

SHA-1 (Secure Hash Algorithm) is a cryptographic hash function with a 160 bit output.

CC_SHA1() computes the SHA-1 message digest of the len bytes at data and places it in md (which must have space for CC_SHA1_DIGEST_LENGTH == 20 bytes of output). It returns the md pointer.

CC_SHA1_Init() initializes a CC_SHA1_CTX structure.

CC_SHA1_Update() can be called repeatedly with chunks of the message to be hashed (len bytes at data).

CC_SHA1_Final() places the message digest in md, which must have space for CC_SHA1_DIGEST_LENGTH == 20 bytes of output, and erases the CC_SHA1_CTX.

The successor versions of SHA-1, SHA-2, are also implemented for hash bit lengths of 224, 256, 384, and 512. The functions to call to invoke the larger hash-size versions of the algorithms include the hash size as part of the function names:

CC_SHA224_Init(), CC_SHA224_Update(), CC_SHA224_Final(), CC_SHA224()

CC_SHA256_Init(), CC_SHA256_Update(), CC_SHA256_Final(), CC_SHA256()

CC_SHA384_Init(), CC_SHA384_Update(), CC_SHA384_Final(), CC_SHA384()

CC_SHA512_Init(), CC_SHA512_Update(), CC_SHA512_Final(), CC_SHA512()

Return values

All routines return 1 upon success and NULL upon failure, except for the one-shot routines ( CC_SHA1(), etc.), which return the pointer passed in via the md parameter.

Releases

115 releases since Mac OS X 10.5; the text changed 2 times.

  1. 10.5–10.8.5
  2. 10.9–14.6
  3. 15.0–26.5

Conforming to

SHA-1: US Federal Information Processing Standard FIPS PUB 180-1 (Secure Hash Standard), ANSI X9.30

SHA-2: US Federal Information Processing Standard FIPS PUB 180-2 (Secure Hash Standard)

History

These functions are available in OS X 10.4 and later.

These functions provide similar functionality to the routines found in OpenSSL 0.9.6 and may use the same implementation.

From CommonCrypto 600035 in macOS 26.5. Parsed by carta from the page's mdoc source.