summaryrefslogtreecommitdiff
path: root/openbsd-compat/sha2.h
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@dtucker.net>2019-07-23 21:51:22 +1000
committerDarren Tucker <dtucker@dtucker.net>2019-07-23 22:06:24 +1000
commit11cba2a4523fda447e2554ea457484655bedc831 (patch)
tree93ec07a9e0db784b0a729eb339d74a5a2c40ea9d /openbsd-compat/sha2.h
parent09159594a3bbd363429ee6fafde57ce77986dd7c (diff)
Re-apply portability changes to current sha2.{c,h}.
Rather than attempt to apply 14 years' worth of changes to OpenBSD's sha2 I imported the current versions directly then re-applied the portability changes. This also allowed re-syncing digest-libc.c against upstream.
Diffstat (limited to 'openbsd-compat/sha2.h')
-rw-r--r--openbsd-compat/sha2.h25
1 files changed, 22 insertions, 3 deletions
diff --git a/openbsd-compat/sha2.h b/openbsd-compat/sha2.h
index 52ddb3f79..bf7dafc52 100644
--- a/openbsd-compat/sha2.h
+++ b/openbsd-compat/sha2.h
@@ -34,9 +34,16 @@
34 * $From: sha2.h,v 1.1 2001/11/08 00:02:01 adg Exp adg $ 34 * $From: sha2.h,v 1.1 2001/11/08 00:02:01 adg Exp adg $
35 */ 35 */
36 36
37#ifndef _SHA2_H 37/* OPENBSD ORIGINAL: include/sha2.h */
38#define _SHA2_H
39 38
39#ifndef _SSHSHA2_H
40#define _SSHSHA2_H
41
42#include "includes.h"
43#include <sys/cdefs.h>
44
45#if !defined(HAVE_SHA256UPDATE) || !defined(HAVE_SHA384UPDATE) || \
46 !defined(HAVE_SHA512UPDATE)
40 47
41/*** SHA-256/384/512 Various Length Definitions ***********************/ 48/*** SHA-256/384/512 Various Length Definitions ***********************/
42#define SHA224_BLOCK_LENGTH 64 49#define SHA224_BLOCK_LENGTH 64
@@ -66,6 +73,7 @@ typedef struct _SHA2_CTX {
66 u_int8_t buffer[SHA512_BLOCK_LENGTH]; 73 u_int8_t buffer[SHA512_BLOCK_LENGTH];
67} SHA2_CTX; 74} SHA2_CTX;
68 75
76#if 0
69__BEGIN_DECLS 77__BEGIN_DECLS
70void SHA224Init(SHA2_CTX *); 78void SHA224Init(SHA2_CTX *);
71void SHA224Transform(u_int32_t state[8], const u_int8_t [SHA224_BLOCK_LENGTH]); 79void SHA224Transform(u_int32_t state[8], const u_int8_t [SHA224_BLOCK_LENGTH]);
@@ -83,7 +91,9 @@ char *SHA224FileChunk(const char *, char *, off_t, off_t)
83char *SHA224Data(const u_int8_t *, size_t, char *) 91char *SHA224Data(const u_int8_t *, size_t, char *)
84 __attribute__((__bounded__(__string__,1,2))) 92 __attribute__((__bounded__(__string__,1,2)))
85 __attribute__((__bounded__(__minbytes__,3,SHA224_DIGEST_STRING_LENGTH))); 93 __attribute__((__bounded__(__minbytes__,3,SHA224_DIGEST_STRING_LENGTH)));
94#endif /* 0 */
86 95
96#ifndef HAVE_SHA256UPDATE
87void SHA256Init(SHA2_CTX *); 97void SHA256Init(SHA2_CTX *);
88void SHA256Transform(u_int32_t state[8], const u_int8_t [SHA256_BLOCK_LENGTH]); 98void SHA256Transform(u_int32_t state[8], const u_int8_t [SHA256_BLOCK_LENGTH]);
89void SHA256Update(SHA2_CTX *, const u_int8_t *, size_t) 99void SHA256Update(SHA2_CTX *, const u_int8_t *, size_t)
@@ -100,7 +110,9 @@ char *SHA256FileChunk(const char *, char *, off_t, off_t)
100char *SHA256Data(const u_int8_t *, size_t, char *) 110char *SHA256Data(const u_int8_t *, size_t, char *)
101 __attribute__((__bounded__(__string__,1,2))) 111 __attribute__((__bounded__(__string__,1,2)))
102 __attribute__((__bounded__(__minbytes__,3,SHA256_DIGEST_STRING_LENGTH))); 112 __attribute__((__bounded__(__minbytes__,3,SHA256_DIGEST_STRING_LENGTH)));
113#endif /* HAVE_SHA256UPDATE */
103 114
115#ifndef HAVE_SHA384UPDATE
104void SHA384Init(SHA2_CTX *); 116void SHA384Init(SHA2_CTX *);
105void SHA384Transform(u_int64_t state[8], const u_int8_t [SHA384_BLOCK_LENGTH]); 117void SHA384Transform(u_int64_t state[8], const u_int8_t [SHA384_BLOCK_LENGTH]);
106void SHA384Update(SHA2_CTX *, const u_int8_t *, size_t) 118void SHA384Update(SHA2_CTX *, const u_int8_t *, size_t)
@@ -117,7 +129,9 @@ char *SHA384FileChunk(const char *, char *, off_t, off_t)
117char *SHA384Data(const u_int8_t *, size_t, char *) 129char *SHA384Data(const u_int8_t *, size_t, char *)
118 __attribute__((__bounded__(__string__,1,2))) 130 __attribute__((__bounded__(__string__,1,2)))
119 __attribute__((__bounded__(__minbytes__,3,SHA384_DIGEST_STRING_LENGTH))); 131 __attribute__((__bounded__(__minbytes__,3,SHA384_DIGEST_STRING_LENGTH)));
132#endif /* HAVE_SHA384UPDATE */
120 133
134#ifndef HAVE_SHA512UPDATE
121void SHA512Init(SHA2_CTX *); 135void SHA512Init(SHA2_CTX *);
122void SHA512Transform(u_int64_t state[8], const u_int8_t [SHA512_BLOCK_LENGTH]); 136void SHA512Transform(u_int64_t state[8], const u_int8_t [SHA512_BLOCK_LENGTH]);
123void SHA512Update(SHA2_CTX *, const u_int8_t *, size_t) 137void SHA512Update(SHA2_CTX *, const u_int8_t *, size_t)
@@ -134,7 +148,9 @@ char *SHA512FileChunk(const char *, char *, off_t, off_t)
134char *SHA512Data(const u_int8_t *, size_t, char *) 148char *SHA512Data(const u_int8_t *, size_t, char *)
135 __attribute__((__bounded__(__string__,1,2))) 149 __attribute__((__bounded__(__string__,1,2)))
136 __attribute__((__bounded__(__minbytes__,3,SHA512_DIGEST_STRING_LENGTH))); 150 __attribute__((__bounded__(__minbytes__,3,SHA512_DIGEST_STRING_LENGTH)));
151#endif /* HAVE_SHA512UPDATE */
137 152
153#if 0
138void SHA512_256Init(SHA2_CTX *); 154void SHA512_256Init(SHA2_CTX *);
139void SHA512_256Transform(u_int64_t state[8], const u_int8_t [SHA512_256_BLOCK_LENGTH]); 155void SHA512_256Transform(u_int64_t state[8], const u_int8_t [SHA512_256_BLOCK_LENGTH]);
140void SHA512_256Update(SHA2_CTX *, const u_int8_t *, size_t) 156void SHA512_256Update(SHA2_CTX *, const u_int8_t *, size_t)
@@ -152,5 +168,8 @@ char *SHA512_256Data(const u_int8_t *, size_t, char *)
152 __attribute__((__bounded__(__string__,1,2))) 168 __attribute__((__bounded__(__string__,1,2)))
153 __attribute__((__bounded__(__minbytes__,3,SHA512_256_DIGEST_STRING_LENGTH))); 169 __attribute__((__bounded__(__minbytes__,3,SHA512_256_DIGEST_STRING_LENGTH)));
154__END_DECLS 170__END_DECLS
171#endif /* 0 */
172
173#endif /* HAVE_SHA{256,384,512}UPDATE */
155 174
156#endif /* _SHA2_H */ 175#endif /* _SSHSHA2_H */