]>
git.saurik.com Git - apple/xnu.git/blob - libkern/libkern/crypto/sha2.h
7908f7ef8d2d4715b2fb4d3db6daf61a0313221f
2 * copyright (c) 2012 apple computer, inc. all rights reserved.
4 * @apple_osreference_license_header_start@
6 * this file contains original code and/or modifications of original code
7 * as defined in and that are subject to the apple public source license
8 * version 2.0 (the 'license'). you may not use this file except in
9 * compliance with the license. the rights granted to you under the license
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an apple operating system software license agreement.
15 * please obtain a copy of the license at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * the original code and all software distributed under the license are
19 * distributed on an 'as is' basis, without warranty of any kind, either
20 * express or implied, and apple hereby disclaims all such warranties,
21 * including without limitation, any warranties of merchantability,
22 * fitness for a particular purpose, quiet enjoyment or non-infringement.
23 * please see the license for the specific language governing rights and
24 * limitations under the license.
26 * @apple_osreference_license_header_end@
29 #ifndef _CRYPTO_SHA2_H__
30 #define _CRYPTO_SHA2_H__
36 #include <corecrypto/ccsha2.h>
38 /*** SHA-256/384/512 Various Length Definitions ***********************/
39 #define SHA256_BLOCK_LENGTH CCSHA256_BLOCK_SIZE
40 #define SHA256_DIGEST_LENGTH CCSHA256_OUTPUT_SIZE
41 #define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1)
42 #define SHA384_BLOCK_LENGTH CCSHA512_BLOCK_SIZE
43 #define SHA384_DIGEST_LENGTH CCSHA384_OUTPUT_SIZE
44 #define SHA384_DIGEST_STRING_LENGTH (SHA384_DIGEST_LENGTH * 2 + 1)
45 #define SHA512_BLOCK_LENGTH CCSHA512_BLOCK_SIZE
46 #define SHA512_DIGEST_LENGTH CCSHA384_OUTPUT_SIZE
47 #define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1)
50 ccdigest_ctx_decl(CCSHA256_STATE_SIZE
, CCSHA256_BLOCK_SIZE
, ctx
);
53 typedef struct SHA512_CTX
{
54 ccdigest_ctx_decl(CCSHA256_STATE_SIZE
, CCSHA256_BLOCK_SIZE
, ctx
);
57 typedef SHA512_CTX SHA384_CTX
;
59 /*** SHA-256/384/512 Function Prototypes ******************************/
61 void SHA256_Init(SHA256_CTX
*ctx
);
62 void SHA256_Update(SHA256_CTX
*ctx
, const void *data
, size_t len
);
63 void SHA256_Final(void *digest
, SHA256_CTX
*ctx
);
65 void SHA384_Init(SHA384_CTX
*ctx
);
66 void SHA384_Update(SHA384_CTX
*ctx
, const void *data
, size_t len
);
67 void SHA384_Final(void *digest
, SHA384_CTX
*ctx
);
69 void SHA512_Init(SHA512_CTX
*ctx
);
70 void SHA512_Update(SHA512_CTX
*ctx
, const void *data
, size_t len
);
71 void SHA512_Final(void *digest
, SHA512_CTX
*ctx
);
75 #endif /* __cplusplus */
77 #endif /* _CRYPTO_SHA2_H__ */