2 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
13 # include <openssl/e_os2.h>
21 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
22 * ! SHA_LONG has to be at least 32 bits wide. !
23 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
25 # define SHA_LONG unsigned int
27 # define SHA_LBLOCK 16
28 # define SHA_CBLOCK (SHA_LBLOCK*4)/* SHA treats input data as a
29 * contiguous array of 32 bit wide
30 * big-endian values. */
31 # define SHA_LAST_BLOCK (SHA_CBLOCK-8)
32 # define SHA_DIGEST_LENGTH 20
34 typedef struct SHAstate_st {
35 SHA_LONG h0, h1, h2, h3, h4;
37 SHA_LONG data[SHA_LBLOCK];
41 int SHA1_Init(SHA_CTX *c);
42 int SHA1_Update(SHA_CTX *c, const void *data, size_t len);
43 int SHA1_Final(unsigned char *md, SHA_CTX *c);
44 unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md);
45 void SHA1_Transform(SHA_CTX *c, const unsigned char *data);
47 # define SHA256_CBLOCK (SHA_LBLOCK*4)/* SHA-256 treats input data as a
48 * contiguous array of 32 bit wide
49 * big-endian values. */
51 typedef struct SHA256state_st {
54 SHA_LONG data[SHA_LBLOCK];
55 unsigned int num, md_len;
58 int SHA224_Init(SHA256_CTX *c);
59 int SHA224_Update(SHA256_CTX *c, const void *data, size_t len);
60 int SHA224_Final(unsigned char *md, SHA256_CTX *c);
61 unsigned char *SHA224(const unsigned char *d, size_t n, unsigned char *md);
62 int SHA256_Init(SHA256_CTX *c);
63 int SHA256_Update(SHA256_CTX *c, const void *data, size_t len);
64 int SHA256_Final(unsigned char *md, SHA256_CTX *c);
65 unsigned char *SHA256(const unsigned char *d, size_t n, unsigned char *md);
66 void SHA256_Transform(SHA256_CTX *c, const unsigned char *data);
68 # define SHA224_DIGEST_LENGTH 28
69 # define SHA256_DIGEST_LENGTH 32
70 # define SHA384_DIGEST_LENGTH 48
71 # define SHA512_DIGEST_LENGTH 64
74 * Unlike 32-bit digest algorithms, SHA-512 *relies* on SHA_LONG64
75 * being exactly 64-bit wide. See Implementation Notes in sha512.c
76 * for further details.
79 * SHA-512 treats input data as a
80 * contiguous array of 64 bit
81 * wide big-endian values.
83 # define SHA512_CBLOCK (SHA_LBLOCK*8)
84 # if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__)
85 # define SHA_LONG64 unsigned __int64
86 # define U64(C) C##UI64
87 # elif defined(__arch64__)
88 # define SHA_LONG64 unsigned long
91 # define SHA_LONG64 unsigned long long
92 # define U64(C) C##ULL
95 typedef struct SHA512state_st {
99 SHA_LONG64 d[SHA_LBLOCK];
100 unsigned char p[SHA512_CBLOCK];
102 unsigned int num, md_len;
105 int SHA384_Init(SHA512_CTX *c);
106 int SHA384_Update(SHA512_CTX *c, const void *data, size_t len);
107 int SHA384_Final(unsigned char *md, SHA512_CTX *c);
108 unsigned char *SHA384(const unsigned char *d, size_t n, unsigned char *md);
109 int SHA512_Init(SHA512_CTX *c);
110 int SHA512_Update(SHA512_CTX *c, const void *data, size_t len);
111 int SHA512_Final(unsigned char *md, SHA512_CTX *c);
112 unsigned char *SHA512(const unsigned char *d, size_t n, unsigned char *md);
113 void SHA512_Transform(SHA512_CTX *c, const unsigned char *data);