From 29064d763b852b19ae98c23a4105755ae3f31430 Mon Sep 17 00:00:00 2001 From: millert <> Date: Thu, 29 Apr 2004 15:51:16 +0000 Subject: [PATCH] Undo some recent prototype changes; it is legal to pass the helper functions can take a NULL buf pointer. They will malloc memory as needed in this case. --- src/include/md4.h | 8 ++++---- src/include/md5.h | 8 ++++---- src/include/rmd160.h | 8 ++++---- src/include/sha1.h | 24 ++++++++++++------------ src/include/sha2.h | 26 +++++++++++++------------- src/lib/libc/hash/helper.c | 14 +++++++------- src/lib/libc/hash/mdX.3 | 10 +++++----- src/lib/libc/hash/rmd160.3 | 12 ++++++------ src/lib/libc/hash/sha1.3 | 12 ++++++------ src/lib/libc/hash/sha2.3 | 22 +++++++++++----------- 10 files changed, 72 insertions(+), 72 deletions(-) diff --git a/src/include/md4.h b/src/include/md4.h index 5f43cdba..27538c24 100644 --- a/src/include/md4.h +++ b/src/include/md4.h @@ -1,4 +1,4 @@ -/* $OpenBSD: md4.h,v 1.12 2004/04/28 16:54:00 millert Exp $ */ +/* $OpenBSD: md4.h,v 1.13 2004/04/29 15:51:16 millert Exp $ */ /* * This code implements the MD4 message-digest algorithm. @@ -37,11 +37,11 @@ void MD4Final(u_int8_t [MD4_DIGEST_LENGTH], MD4_CTX *) void MD4Transform(u_int32_t [4], const u_int8_t [MD4_BLOCK_LENGTH]) __attribute__((__bounded__(__minbytes__,1,4))) __attribute__((__bounded__(__minbytes__,2,MD4_BLOCK_LENGTH))); -char *MD4End(MD4_CTX *, char [MD4_DIGEST_STRING_LENGTH]) +char *MD4End(MD4_CTX *, char *) __attribute__((__bounded__(__minbytes__,2,MD4_DIGEST_STRING_LENGTH))); -char *MD4File(char *, char [MD4_DIGEST_STRING_LENGTH]) +char *MD4File(char *, char *) __attribute__((__bounded__(__minbytes__,2,MD4_DIGEST_STRING_LENGTH))); -char *MD4Data(const u_int8_t *, size_t, char [MD4_DIGEST_STRING_LENGTH]) +char *MD4Data(const u_int8_t *, size_t, char *) __attribute__((__bounded__(__string__,1,2))) __attribute__((__bounded__(__minbytes__,3,MD4_DIGEST_STRING_LENGTH))); __END_DECLS diff --git a/src/include/md5.h b/src/include/md5.h index 533db75a..cc4a2d93 100644 --- a/src/include/md5.h +++ b/src/include/md5.h @@ -1,4 +1,4 @@ -/* $OpenBSD: md5.h,v 1.13 2004/04/28 16:52:08 millert Exp $ */ +/* $OpenBSD: md5.h,v 1.14 2004/04/29 15:51:16 millert Exp $ */ /* * This code implements the MD5 message-digest algorithm. @@ -36,11 +36,11 @@ void MD5Final(u_int8_t [MD5_DIGEST_LENGTH], MD5_CTX *) void MD5Transform(u_int32_t [4], const u_int8_t [MD5_BLOCK_LENGTH]) __attribute__((__bounded__(__minbytes__,1,4))) __attribute__((__bounded__(__minbytes__,2,MD5_BLOCK_LENGTH))); -char *MD5End(MD5_CTX *, char [MD5_DIGEST_STRING_LENGTH]) +char *MD5End(MD5_CTX *, char *) __attribute__((__bounded__(__minbytes__,2,MD5_DIGEST_STRING_LENGTH))); -char *MD5File(char *, char [MD5_DIGEST_STRING_LENGTH]) +char *MD5File(char *, char *) __attribute__((__bounded__(__minbytes__,2,MD5_DIGEST_STRING_LENGTH))); -char *MD5Data(const u_int8_t *, size_t, char [MD5_DIGEST_STRING_LENGTH]) +char *MD5Data(const u_int8_t *, size_t, char *) __attribute__((__bounded__(__string__,1,2))) __attribute__((__bounded__(__minbytes__,3,MD5_DIGEST_STRING_LENGTH))); __END_DECLS diff --git a/src/include/rmd160.h b/src/include/rmd160.h index f8032735..e9b2603b 100644 --- a/src/include/rmd160.h +++ b/src/include/rmd160.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rmd160.h,v 1.13 2004/04/26 19:38:12 millert Exp $ */ +/* $OpenBSD: rmd160.h,v 1.14 2004/04/29 15:51:16 millert Exp $ */ /* * Copyright (c) 2001 Markus Friedl. All rights reserved. * @@ -47,11 +47,11 @@ void RMD160Update(RMD160_CTX *, const u_int8_t *, u_int32_t) __attribute__((__bounded__(__string__,2,3))); void RMD160Final(u_int8_t [RMD160_DIGEST_LENGTH], RMD160_CTX *) __attribute__((__bounded__(__minbytes__,1,RMD160_DIGEST_LENGTH))); -char *RMD160End(RMD160_CTX *, char [RMD160_DIGEST_STRING_LENGTH]) +char *RMD160End(RMD160_CTX *, char *) __attribute__((__bounded__(__minbytes__,2,RMD160_DIGEST_STRING_LENGTH))); -char *RMD160File(char *, char [RMD160_DIGEST_STRING_LENGTH]) +char *RMD160File(char *, char *) __attribute__((__bounded__(__minbytes__,2,RMD160_DIGEST_STRING_LENGTH))); -char *RMD160Data(const u_int8_t *, size_t, char [RMD160_DIGEST_STRING_LENGTH]) +char *RMD160Data(const u_int8_t *, size_t, char *) __attribute__((__bounded__(__string__,1,2))) __attribute__((__bounded__(__minbytes__,3,RMD160_DIGEST_STRING_LENGTH))); __END_DECLS diff --git a/src/include/sha1.h b/src/include/sha1.h index 7fbeeb4f..1187fb9d 100644 --- a/src/include/sha1.h +++ b/src/include/sha1.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sha1.h,v 1.18 2004/04/27 15:54:56 millert Exp $ */ +/* $OpenBSD: sha1.h,v 1.19 2004/04/29 15:51:16 millert Exp $ */ /* * SHA-1 in C @@ -24,19 +24,19 @@ typedef struct { __BEGIN_DECLS void SHA1Init(SHA1_CTX *); void SHA1Transform(u_int32_t [5], const u_int8_t [SHA1_BLOCK_LENGTH]) - __attribute__((__bounded__(__minbytes__,1,5))) - __attribute__((__bounded__(__minbytes__,2,SHA1_BLOCK_LENGTH))); + __attribute__((__bounded__(__minbytes__,1,5))) + __attribute__((__bounded__(__minbytes__,2,SHA1_BLOCK_LENGTH))); void SHA1Update(SHA1_CTX *, const u_int8_t *, unsigned int) - __attribute__((__bounded__(__string__,2,3))); + __attribute__((__bounded__(__string__,2,3))); void SHA1Final(u_int8_t [SHA1_DIGEST_LENGTH], SHA1_CTX *) - __attribute__((__bounded__(__minbytes__,1,SHA1_DIGEST_LENGTH))); -char *SHA1End(SHA1_CTX *, char [SHA1_DIGEST_STRING_LENGTH]) - __attribute__((__bounded__(__minbytes__,2,SHA1_DIGEST_STRING_LENGTH))); -char *SHA1File(char *, char [SHA1_DIGEST_STRING_LENGTH]) - __attribute__((__bounded__(__minbytes__,2,SHA1_DIGEST_STRING_LENGTH))); -char *SHA1Data(const u_int8_t *, size_t, char [SHA1_DIGEST_STRING_LENGTH]) - __attribute__((__bounded__(__string__,1,2))) - __attribute__((__bounded__(__minbytes__,3,SHA1_DIGEST_STRING_LENGTH))); + __attribute__((__bounded__(__minbytes__,1,SHA1_DIGEST_LENGTH))); +char *SHA1End(SHA1_CTX *, char *) + __attribute__((__bounded__(__minbytes__,2,SHA1_DIGEST_STRING_LENGTH))); +char *SHA1File(char *, char *) + __attribute__((__bounded__(__minbytes__,2,SHA1_DIGEST_STRING_LENGTH))); +char *SHA1Data(const u_int8_t *, size_t, char *) + __attribute__((__bounded__(__string__,1,2))) + __attribute__((__bounded__(__minbytes__,3,SHA1_DIGEST_STRING_LENGTH))); __END_DECLS #define HTONDIGEST(x) do { \ diff --git a/src/include/sha2.h b/src/include/sha2.h index cb5749d3..a03bbc49 100644 --- a/src/include/sha2.h +++ b/src/include/sha2.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sha2.h,v 1.2 2004/04/27 17:50:36 millert Exp $ */ +/* $OpenBSD: sha2.h,v 1.3 2004/04/29 15:51:16 millert Exp $ */ /* * FILE: sha2.h @@ -70,39 +70,39 @@ __BEGIN_DECLS void SHA256_Init(SHA256_CTX *); void SHA256_Update(SHA256_CTX *, const u_int8_t *, size_t) __attribute__((__bounded__(__string__,2,3))); -void SHA256_Final(u_int8_t[SHA256_DIGEST_LENGTH], SHA256_CTX *) +void SHA256_Final(u_int8_t [SHA256_DIGEST_LENGTH], SHA256_CTX *) __attribute__((__bounded__(__minbytes__,1,SHA256_DIGEST_LENGTH))); -char *SHA256_End(SHA256_CTX *, char[SHA256_DIGEST_STRING_LENGTH]) +char *SHA256_End(SHA256_CTX *, char *) __attribute__((__bounded__(__minbytes__,2,SHA256_DIGEST_STRING_LENGTH))); -char *SHA256_File(char *, char [SHA256_DIGEST_STRING_LENGTH]) +char *SHA256_File(char *, char *) __attribute__((__bounded__(__minbytes__,2,SHA256_DIGEST_STRING_LENGTH))); -char *SHA256_Data(const u_int8_t *, size_t, char[SHA256_DIGEST_STRING_LENGTH]) +char *SHA256_Data(const u_int8_t *, size_t, char *) __attribute__((__bounded__(__string__,1,2))) __attribute__((__bounded__(__minbytes__,3,SHA256_DIGEST_STRING_LENGTH))); void SHA384_Init(SHA384_CTX *); void SHA384_Update(SHA384_CTX *, const u_int8_t *, size_t) __attribute__((__bounded__(__string__,2,3))); -void SHA384_Final(u_int8_t[SHA384_DIGEST_LENGTH], SHA384_CTX *) +void SHA384_Final(u_int8_t [SHA384_DIGEST_LENGTH], SHA384_CTX *) __attribute__((__bounded__(__minbytes__,1,SHA384_DIGEST_LENGTH))); -char *SHA384_End(SHA384_CTX *, char[SHA384_DIGEST_STRING_LENGTH]) +char *SHA384_End(SHA384_CTX *, char *) __attribute__((__bounded__(__minbytes__,2,SHA384_DIGEST_STRING_LENGTH))); -char *SHA384_File(char *, char [SHA384_DIGEST_STRING_LENGTH]) +char *SHA384_File(char *, char *) __attribute__((__bounded__(__minbytes__,2,SHA384_DIGEST_STRING_LENGTH))); -char *SHA384_Data(const u_int8_t *, size_t, char[SHA384_DIGEST_STRING_LENGTH]) +char *SHA384_Data(const u_int8_t *, size_t, char *) __attribute__((__bounded__(__string__,1,2))) __attribute__((__bounded__(__minbytes__,3,SHA384_DIGEST_STRING_LENGTH))); void SHA512_Init(SHA512_CTX *); void SHA512_Update(SHA512_CTX *, const u_int8_t *, size_t) __attribute__((__bounded__(__string__,2,3))); -void SHA512_Final(u_int8_t[SHA512_DIGEST_LENGTH], SHA512_CTX *) +void SHA512_Final(u_int8_t [SHA512_DIGEST_LENGTH], SHA512_CTX *) __attribute__((__bounded__(__minbytes__,1,SHA512_DIGEST_LENGTH))); -char *SHA512_End(SHA512_CTX *, char[SHA512_DIGEST_STRING_LENGTH]) +char *SHA512_End(SHA512_CTX *, char *) __attribute__((__bounded__(__minbytes__,2,SHA512_DIGEST_STRING_LENGTH))); -char *SHA512_File(char *, char [SHA512_DIGEST_STRING_LENGTH]) +char *SHA512_File(char *, char *) __attribute__((__bounded__(__minbytes__,2,SHA512_DIGEST_STRING_LENGTH))); -char *SHA512_Data(const u_int8_t *, size_t, char[SHA512_DIGEST_STRING_LENGTH]) +char *SHA512_Data(const u_int8_t *, size_t, char *) __attribute__((__bounded__(__string__,1,2))) __attribute__((__bounded__(__minbytes__,3,SHA512_DIGEST_STRING_LENGTH))); __END_DECLS diff --git a/src/lib/libc/hash/helper.c b/src/lib/libc/hash/helper.c index 8c686e30..a1fd763f 100644 --- a/src/lib/libc/hash/helper.c +++ b/src/lib/libc/hash/helper.c @@ -1,4 +1,4 @@ -/* $OpenBSD: helper.c,v 1.3 2004/04/29 02:43:06 millert Exp $ */ +/* $OpenBSD: helper.c,v 1.4 2004/04/29 15:51:16 millert Exp $ */ /* * ---------------------------------------------------------------------------- @@ -10,7 +10,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "$OpenBSD: helper.c,v 1.3 2004/04/29 02:43:06 millert Exp $"; +static const char rcsid[] = "$OpenBSD: helper.c,v 1.4 2004/04/29 15:51:16 millert Exp $"; #endif /* LIBC_SCCS and not lint */ #include @@ -26,14 +26,14 @@ static const char rcsid[] = "$OpenBSD: helper.c,v 1.3 2004/04/29 02:43:06 miller /* ARGSUSED */ char * -HASHEnd(HASH_CTX *ctx, char buf[HASH_DIGEST_STRING_LENGTH]) +HASHEnd(HASH_CTX *ctx, char *buf) { int i; u_int8_t digest[HASH_DIGEST_LENGTH]; static const char hex[] = "0123456789abcdef"; if (buf == NULL && (buf = malloc(HASH_DIGEST_STRING_LENGTH)) == NULL) - return(NULL); + return (NULL); HASHFinal(digest, ctx); for (i = 0; i < HASH_DIGEST_LENGTH; i++) { @@ -46,7 +46,7 @@ HASHEnd(HASH_CTX *ctx, char buf[HASH_DIGEST_STRING_LENGTH]) } char * -HASHFile(char *filename, char buf[HASH_DIGEST_STRING_LENGTH]) +HASHFile(char *filename, char *buf) { u_char buffer[BUFSIZ]; HASH_CTX ctx; @@ -55,7 +55,7 @@ HASHFile(char *filename, char buf[HASH_DIGEST_STRING_LENGTH]) HASHInit(&ctx); if ((fd = open(filename, O_RDONLY)) < 0) - return(NULL); + return (NULL); while ((num = read(fd, buffer, sizeof(buffer))) > 0) HASHUpdate(&ctx, buffer, num); @@ -67,7 +67,7 @@ HASHFile(char *filename, char buf[HASH_DIGEST_STRING_LENGTH]) } char * -HASHData(const u_char *data, size_t len, char buf[HASH_DIGEST_STRING_LENGTH]) +HASHData(const u_char *data, size_t len, char *buf) { HASH_CTX ctx; diff --git a/src/lib/libc/hash/mdX.3 b/src/lib/libc/hash/mdX.3 index 2b36cfce..a5dcb19e 100644 --- a/src/lib/libc/hash/mdX.3 +++ b/src/lib/libc/hash/mdX.3 @@ -6,9 +6,9 @@ .\" this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp .\" ---------------------------------------------------------------------------- .\" -.\" $OpenBSD: mdX.3,v 1.2 2004/04/29 13:33:58 jmc Exp $ +.\" $OpenBSD: mdX.3,v 1.3 2004/04/29 15:51:16 millert Exp $ .\" -.Dd October 9, 1996 +.Dd April 29, 2004 .Dt MDX 3 .Os .Sh NAME @@ -32,11 +32,11 @@ .Ft void .Fn MDXTransform "u_int32_t state[4]" "u_int8_t block[MDX_BLOCK_LENGTH]" .Ft "char *" -.Fn MDXEnd "MDX_CTX *context" "char buf[MDX_DIGEST_STRING_LENGTH]" +.Fn MDXEnd "MDX_CTX *context" "char *buf" .Ft "char *" -.Fn MDXFile "char *filename" "char buf[MDX_DIGEST_STRING_LENGTH]" +.Fn MDXFile "char *filename" "char *buf" .Ft "char *" -.Fn MDXData "const u_int8_t *data" "unsigned int len" "char buf[MDX_DIGEST_STRING_LENGTH]" +.Fn MDXData "const u_int8_t *data" "size_t len" "char *buf" .Sh DESCRIPTION The MDX functions calculate a 128-bit cryptographic checksum (digest) for any number of input bytes. diff --git a/src/lib/libc/hash/rmd160.3 b/src/lib/libc/hash/rmd160.3 index cba5a3ba..bcb6714a 100644 --- a/src/lib/libc/hash/rmd160.3 +++ b/src/lib/libc/hash/rmd160.3 @@ -1,6 +1,6 @@ -.\" $OpenBSD: rmd160.3,v 1.22 2004/04/28 16:54:57 millert Exp $ +.\" $OpenBSD: rmd160.3,v 1.23 2004/04/29 15:51:16 millert Exp $ .\" -.\" Copyright (c) 1997 Todd C. Miller +.\" Copyright (c) 1997, 2004 Todd C. Miller .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above @@ -17,7 +17,7 @@ .\" See http://www.esat.kuleuven.ac.be/~bosselae/ripemd160.html .\" for detailed information about RIPEMD-160. .\" -.Dd July 16, 1997 +.Dd April 29, 2004 .Dt RMD160 3 .Os .Sh NAME @@ -41,11 +41,11 @@ .Ft void .Fn RMD160Transform "u_int32_t state[5]" "const u_int8_t block[RMD160_BLOCK_LENGTH]" .Ft "char *" -.Fn RMD160End "RMD160_CTX *context" "char buf[RMD160_DIGEST_STRING_LENGTH]" +.Fn RMD160End "RMD160_CTX *context" "char *buf" .Ft "char *" -.Fn RMD160File "char *filename" "char buf[RMD160_DIGEST_STRING_LENGTH]" +.Fn RMD160File "char *filename" "char *buf" .Ft "char *" -.Fn RMD160Data "const u_int8_t *data" "size_t len" "char buf[RMD160_DIGEST_STRING_LENGTH]" +.Fn RMD160Data "const u_int8_t *data" "size_t len" "char *buf" .Sh DESCRIPTION The RMD160 functions implement the 160-bit RIPE message digest hash algorithm (RMD-160). diff --git a/src/lib/libc/hash/sha1.3 b/src/lib/libc/hash/sha1.3 index 8514f047..937423cb 100644 --- a/src/lib/libc/hash/sha1.3 +++ b/src/lib/libc/hash/sha1.3 @@ -1,6 +1,6 @@ -.\" $OpenBSD: sha1.3,v 1.28 2004/04/28 16:54:57 millert Exp $ +.\" $OpenBSD: sha1.3,v 1.29 2004/04/29 15:51:16 millert Exp $ .\" -.\" Copyright (c) 1997 Todd C. Miller +.\" Copyright (c) 1997, 2004 Todd C. Miller .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above @@ -17,7 +17,7 @@ .\" See http://csrc.nist.gov/publications/fips/fips180-1/fip180-1.txt .\" for the detailed standard .\" -.Dd July 10, 1997 +.Dd April 29, 2004 .Dt SHA1 3 .Os .Sh NAME @@ -41,11 +41,11 @@ .Ft void .Fn SHA1Transform "u_int32_t state[5]" "u_int8_t buffer[SHA1_BLOCK_LENGTH]" .Ft "char *" -.Fn SHA1End "SHA1_CTX *context" "char buf[SHA1_DIGEST_STRING_LENGTH]" +.Fn SHA1End "SHA1_CTX *context" "char *buf" .Ft "char *" -.Fn SHA1File "char *filename" "char buf[SHA1_DIGEST_STRING_LENGTH]" +.Fn SHA1File "char *filename" "char *buf" .Ft "char *" -.Fn SHA1Data "const u_int8_t *data" "u_int len" "char buf[SHA1_DIGEST_STRING_LENGTH]" +.Fn SHA1Data "const u_int8_t *data" "size_t len" "char *buf" .Sh DESCRIPTION The SHA1 functions implement the NIST Secure Hash Algorithm (SHA-1), FIPS PUB 180-1. diff --git a/src/lib/libc/hash/sha2.3 b/src/lib/libc/hash/sha2.3 index f74784af..deabd6f5 100644 --- a/src/lib/libc/hash/sha2.3 +++ b/src/lib/libc/hash/sha2.3 @@ -1,6 +1,6 @@ -.\" $OpenBSD: sha2.3,v 1.5 2003/10/03 13:57:39 jmc Exp $ +.\" $OpenBSD: sha2.3,v 1.6 2004/04/29 15:51:16 millert Exp $ .\" -.\" Copyright (c) 2003 Todd C. Miller +.\" Copyright (c) 2003, 2004 Todd C. Miller .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above @@ -41,11 +41,11 @@ .Ft void .Fn SHA256_Final "u_int8_t digest[SHA256_DIGEST_LENGTH]" "SHA256_CTX *context" .Ft "char *" -.Fn SHA256_End "SHA256_CTX *context" "char buf[SHA256_DIGEST_STRING_LENGTH]" +.Fn SHA256_End "SHA256_CTX *context" "char *buf" .Ft "char *" -.Fn SHA256_File "char *filename" "char buf[SHA256_DIGEST_STRING_LENGTH]" +.Fn SHA256_File "char *filename" "char *buf" .Ft "char *" -.Fn SHA256_Data "u_int8_t *data" "u_int len" "char buf[SHA256_DIGEST_STRING_LENGTH]" +.Fn SHA256_Data "u_int8_t *data" "u_int len" "char *buf" .Ft void .Fn SHA384_Init "SHA384_CTX *context" .Ft void @@ -53,11 +53,11 @@ .Ft void .Fn SHA384_Final "u_int8_t digest[SHA384_DIGEST_LENGTH]" "SHA384_CTX *context" .Ft "char *" -.Fn SHA384_End "SHA384_CTX *context" "char buf[SHA384_DIGEST_STRING_LENGTH]" +.Fn SHA384_End "SHA384_CTX *context" "char *buf" .Ft "char *" -.Fn SHA384_File "char *filename" "char buf[SHA384_DIGEST_STRING_LENGTH]" +.Fn SHA384_File "char *filename" "char *buf" .Ft "char *" -.Fn SHA384_Data "u_int8_t *data" "size_t len" "char buf[SHA384_DIGEST_STRING_LENGTH]" +.Fn SHA384_Data "u_int8_t *data" "size_t len" "char *buf" .Ft void .Fn SHA512_Init "SHA512_CTX *context" .Ft void @@ -65,11 +65,11 @@ .Ft void .Fn SHA512_Final "u_int8_t digest[SHA512_DIGEST_LENGTH]" "SHA512_CTX *context" .Ft "char *" -.Fn SHA512_End "SHA512_CTX *context" "char buf[SHA512_DIGEST_STRING_LENGTH]" +.Fn SHA512_End "SHA512_CTX *context" "char *buf" .Ft "char *" -.Fn SHA512_File "char *filename" "char buf[SHA512_DIGEST_STRING_LENGTH]" +.Fn SHA512_File "char *filename" "char *buf" .Ft "char *" -.Fn SHA512_Data "u_int8_t *data" "size_t len" "char buf[SHA512_DIGEST_STRING_LENGTH]" +.Fn SHA512_Data "u_int8_t *data" "size_t len" "char *buf" .Sh DESCRIPTION The SHA2 functions implement the NIST Secure Hash Standard, FIPS PUB 180-2.