---
name: "CC_SHA"
section: "3cc"
platform: "macos"
package: "CommonCrypto"
version: "600035"
release: "macOS 26.5"
platforms: ["macos"]
url: "https://new.carta.tech/CC_SHA"
---

# CC\_SHA(3cc)

Secure Hash Algorithms

## NAME

**CC\_SHA1\_Init** **CC\_SHA1\_Update** **CC\_SHA1\_Final** **CC\_SHA1**

**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**

– Secure Hash Algorithms

## SYNOPSIS

**#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*);

## DESCRIPTION

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.

## 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.

## SEE ALSO

[CC\_MD5(3cc)](/CC_MD5/3cc.md), [CCCryptor(3cc)](/CCCryptor/3cc.md), [CCHmac(3cc)](/CCHmac/3cc.md), [CC\_crypto(3cc)](/CC_crypto/3cc.md)
