wolfSSL 3.11.1 for TLS1.3 beta
Fork of wolfSSL by
wolfssl/openssl/sha.h@13:80fb167dafdf, 2017-05-30 (annotated)
- Committer:
- wolfSSL
- Date:
- Tue May 30 06:16:19 2017 +0000
- Revision:
- 13:80fb167dafdf
- Parent:
- 11:cee25a834751
wolfSSL 3.11.1: TLS1.3 Beta
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wolfSSL | 11:cee25a834751 | 1 | /* sha.h for openssl */ |
wolfSSL | 11:cee25a834751 | 2 | |
wolfSSL | 11:cee25a834751 | 3 | |
wolfSSL | 11:cee25a834751 | 4 | #ifndef WOLFSSL_SHA_H_ |
wolfSSL | 11:cee25a834751 | 5 | #define WOLFSSL_SHA_H_ |
wolfSSL | 11:cee25a834751 | 6 | |
wolfSSL | 11:cee25a834751 | 7 | #include <wolfssl/wolfcrypt/settings.h> |
wolfSSL | 11:cee25a834751 | 8 | #include <wolfssl/wolfcrypt/types.h> |
wolfSSL | 11:cee25a834751 | 9 | |
wolfSSL | 11:cee25a834751 | 10 | #ifdef WOLFSSL_PREFIX |
wolfSSL | 11:cee25a834751 | 11 | #include "prefix_sha.h" |
wolfSSL | 11:cee25a834751 | 12 | #endif |
wolfSSL | 11:cee25a834751 | 13 | |
wolfSSL | 11:cee25a834751 | 14 | #ifdef __cplusplus |
wolfSSL | 11:cee25a834751 | 15 | extern "C" { |
wolfSSL | 11:cee25a834751 | 16 | #endif |
wolfSSL | 11:cee25a834751 | 17 | |
wolfSSL | 11:cee25a834751 | 18 | |
wolfSSL | 11:cee25a834751 | 19 | typedef struct WOLFSSL_SHA_CTX { |
wolfSSL | 11:cee25a834751 | 20 | /* big enough to hold wolfcrypt Sha, but check on init */ |
wolfSSL | 11:cee25a834751 | 21 | int holder[28 + (WC_ASYNC_DEV_SIZE / sizeof(int))]; |
wolfSSL | 11:cee25a834751 | 22 | } WOLFSSL_SHA_CTX; |
wolfSSL | 11:cee25a834751 | 23 | |
wolfSSL | 11:cee25a834751 | 24 | WOLFSSL_API void wolfSSL_SHA_Init(WOLFSSL_SHA_CTX*); |
wolfSSL | 11:cee25a834751 | 25 | WOLFSSL_API void wolfSSL_SHA_Update(WOLFSSL_SHA_CTX*, const void*, unsigned long); |
wolfSSL | 11:cee25a834751 | 26 | WOLFSSL_API void wolfSSL_SHA_Final(unsigned char*, WOLFSSL_SHA_CTX*); |
wolfSSL | 11:cee25a834751 | 27 | |
wolfSSL | 11:cee25a834751 | 28 | /* SHA1 points to above, shouldn't use SHA0 ever */ |
wolfSSL | 11:cee25a834751 | 29 | WOLFSSL_API void wolfSSL_SHA1_Init(WOLFSSL_SHA_CTX*); |
wolfSSL | 11:cee25a834751 | 30 | WOLFSSL_API void wolfSSL_SHA1_Update(WOLFSSL_SHA_CTX*, const void*, unsigned long); |
wolfSSL | 11:cee25a834751 | 31 | WOLFSSL_API void wolfSSL_SHA1_Final(unsigned char*, WOLFSSL_SHA_CTX*); |
wolfSSL | 11:cee25a834751 | 32 | |
wolfSSL | 11:cee25a834751 | 33 | enum { |
wolfSSL | 11:cee25a834751 | 34 | SHA_DIGEST_LENGTH = 20 |
wolfSSL | 11:cee25a834751 | 35 | }; |
wolfSSL | 11:cee25a834751 | 36 | |
wolfSSL | 11:cee25a834751 | 37 | |
wolfSSL | 11:cee25a834751 | 38 | typedef WOLFSSL_SHA_CTX SHA_CTX; |
wolfSSL | 11:cee25a834751 | 39 | |
wolfSSL | 11:cee25a834751 | 40 | #define SHA_Init wolfSSL_SHA_Init |
wolfSSL | 11:cee25a834751 | 41 | #define SHA_Update wolfSSL_SHA_Update |
wolfSSL | 11:cee25a834751 | 42 | #define SHA_Final wolfSSL_SHA_Final |
wolfSSL | 11:cee25a834751 | 43 | |
wolfSSL | 11:cee25a834751 | 44 | #define SHA1_Init wolfSSL_SHA1_Init |
wolfSSL | 11:cee25a834751 | 45 | #define SHA1_Update wolfSSL_SHA1_Update |
wolfSSL | 11:cee25a834751 | 46 | #define SHA1_Final wolfSSL_SHA1_Final |
wolfSSL | 11:cee25a834751 | 47 | |
wolfSSL | 11:cee25a834751 | 48 | |
wolfSSL | 11:cee25a834751 | 49 | #ifdef WOLFSSL_SHA224 |
wolfSSL | 11:cee25a834751 | 50 | |
wolfSSL | 11:cee25a834751 | 51 | /* Using ALIGN16 because when AES-NI is enabled digest and buffer in Sha256 |
wolfSSL | 11:cee25a834751 | 52 | * struct are 16 byte aligned. Any derefrence to those elements after casting to |
wolfSSL | 11:cee25a834751 | 53 | * Sha224, is expected to also be 16 byte aligned addresses. */ |
wolfSSL | 11:cee25a834751 | 54 | typedef struct WOLFSSL_SHA224_CTX { |
wolfSSL | 11:cee25a834751 | 55 | /* big enough to hold wolfcrypt Sha224, but check on init */ |
wolfSSL | 11:cee25a834751 | 56 | ALIGN16 int holder[34 + (WC_ASYNC_DEV_SIZE / sizeof(int))]; |
wolfSSL | 11:cee25a834751 | 57 | } WOLFSSL_SHA224_CTX; |
wolfSSL | 11:cee25a834751 | 58 | |
wolfSSL | 11:cee25a834751 | 59 | WOLFSSL_API void wolfSSL_SHA224_Init(WOLFSSL_SHA224_CTX*); |
wolfSSL | 11:cee25a834751 | 60 | WOLFSSL_API void wolfSSL_SHA224_Update(WOLFSSL_SHA224_CTX*, const void*, |
wolfSSL | 11:cee25a834751 | 61 | unsigned long); |
wolfSSL | 11:cee25a834751 | 62 | WOLFSSL_API void wolfSSL_SHA224_Final(unsigned char*, WOLFSSL_SHA224_CTX*); |
wolfSSL | 11:cee25a834751 | 63 | |
wolfSSL | 11:cee25a834751 | 64 | enum { |
wolfSSL | 11:cee25a834751 | 65 | SHA224_DIGEST_LENGTH = 28 |
wolfSSL | 11:cee25a834751 | 66 | }; |
wolfSSL | 11:cee25a834751 | 67 | |
wolfSSL | 11:cee25a834751 | 68 | |
wolfSSL | 11:cee25a834751 | 69 | typedef WOLFSSL_SHA224_CTX SHA224_CTX; |
wolfSSL | 11:cee25a834751 | 70 | |
wolfSSL | 11:cee25a834751 | 71 | #define SHA224_Init wolfSSL_SHA224_Init |
wolfSSL | 11:cee25a834751 | 72 | #define SHA224_Update wolfSSL_SHA224_Update |
wolfSSL | 11:cee25a834751 | 73 | #define SHA224_Final wolfSSL_SHA224_Final |
wolfSSL | 11:cee25a834751 | 74 | |
wolfSSL | 11:cee25a834751 | 75 | #endif /* WOLFSSL_SHA224 */ |
wolfSSL | 11:cee25a834751 | 76 | |
wolfSSL | 11:cee25a834751 | 77 | |
wolfSSL | 11:cee25a834751 | 78 | /* Using ALIGN16 because when AES-NI is enabled digest and buffer in Sha256 |
wolfSSL | 11:cee25a834751 | 79 | * struct are 16 byte aligned. Any derefrence to those elements after casting to |
wolfSSL | 11:cee25a834751 | 80 | * Sha256, is expected to also be 16 byte aligned addresses. */ |
wolfSSL | 11:cee25a834751 | 81 | typedef struct WOLFSSL_SHA256_CTX { |
wolfSSL | 11:cee25a834751 | 82 | /* big enough to hold wolfcrypt Sha256, but check on init */ |
wolfSSL | 11:cee25a834751 | 83 | ALIGN16 int holder[34 + (WC_ASYNC_DEV_SIZE / sizeof(int))]; |
wolfSSL | 11:cee25a834751 | 84 | } WOLFSSL_SHA256_CTX; |
wolfSSL | 11:cee25a834751 | 85 | |
wolfSSL | 11:cee25a834751 | 86 | WOLFSSL_API void wolfSSL_SHA256_Init(WOLFSSL_SHA256_CTX*); |
wolfSSL | 11:cee25a834751 | 87 | WOLFSSL_API void wolfSSL_SHA256_Update(WOLFSSL_SHA256_CTX*, const void*, |
wolfSSL | 11:cee25a834751 | 88 | unsigned long); |
wolfSSL | 11:cee25a834751 | 89 | WOLFSSL_API void wolfSSL_SHA256_Final(unsigned char*, WOLFSSL_SHA256_CTX*); |
wolfSSL | 11:cee25a834751 | 90 | |
wolfSSL | 11:cee25a834751 | 91 | enum { |
wolfSSL | 11:cee25a834751 | 92 | SHA256_DIGEST_LENGTH = 32 |
wolfSSL | 11:cee25a834751 | 93 | }; |
wolfSSL | 11:cee25a834751 | 94 | |
wolfSSL | 11:cee25a834751 | 95 | |
wolfSSL | 11:cee25a834751 | 96 | typedef WOLFSSL_SHA256_CTX SHA256_CTX; |
wolfSSL | 11:cee25a834751 | 97 | |
wolfSSL | 11:cee25a834751 | 98 | #define SHA256_Init wolfSSL_SHA256_Init |
wolfSSL | 11:cee25a834751 | 99 | #define SHA256_Update wolfSSL_SHA256_Update |
wolfSSL | 11:cee25a834751 | 100 | #define SHA256_Final wolfSSL_SHA256_Final |
wolfSSL | 11:cee25a834751 | 101 | |
wolfSSL | 11:cee25a834751 | 102 | |
wolfSSL | 11:cee25a834751 | 103 | #ifdef WOLFSSL_SHA384 |
wolfSSL | 11:cee25a834751 | 104 | |
wolfSSL | 11:cee25a834751 | 105 | typedef struct WOLFSSL_SHA384_CTX { |
wolfSSL | 11:cee25a834751 | 106 | /* big enough to hold wolfCrypt Sha384, but check on init */ |
wolfSSL | 11:cee25a834751 | 107 | long long holder[32 + (WC_ASYNC_DEV_SIZE / sizeof(long long))]; |
wolfSSL | 11:cee25a834751 | 108 | } WOLFSSL_SHA384_CTX; |
wolfSSL | 11:cee25a834751 | 109 | |
wolfSSL | 11:cee25a834751 | 110 | WOLFSSL_API void wolfSSL_SHA384_Init(WOLFSSL_SHA384_CTX*); |
wolfSSL | 11:cee25a834751 | 111 | WOLFSSL_API void wolfSSL_SHA384_Update(WOLFSSL_SHA384_CTX*, const void*, |
wolfSSL | 11:cee25a834751 | 112 | unsigned long); |
wolfSSL | 11:cee25a834751 | 113 | WOLFSSL_API void wolfSSL_SHA384_Final(unsigned char*, WOLFSSL_SHA384_CTX*); |
wolfSSL | 11:cee25a834751 | 114 | |
wolfSSL | 11:cee25a834751 | 115 | enum { |
wolfSSL | 11:cee25a834751 | 116 | SHA384_DIGEST_LENGTH = 48 |
wolfSSL | 11:cee25a834751 | 117 | }; |
wolfSSL | 11:cee25a834751 | 118 | |
wolfSSL | 11:cee25a834751 | 119 | |
wolfSSL | 11:cee25a834751 | 120 | typedef WOLFSSL_SHA384_CTX SHA384_CTX; |
wolfSSL | 11:cee25a834751 | 121 | |
wolfSSL | 11:cee25a834751 | 122 | #define SHA384_Init wolfSSL_SHA384_Init |
wolfSSL | 11:cee25a834751 | 123 | #define SHA384_Update wolfSSL_SHA384_Update |
wolfSSL | 11:cee25a834751 | 124 | #define SHA384_Final wolfSSL_SHA384_Final |
wolfSSL | 11:cee25a834751 | 125 | |
wolfSSL | 11:cee25a834751 | 126 | #endif /* WOLFSSL_SHA384 */ |
wolfSSL | 11:cee25a834751 | 127 | |
wolfSSL | 11:cee25a834751 | 128 | #ifdef WOLFSSL_SHA512 |
wolfSSL | 11:cee25a834751 | 129 | |
wolfSSL | 11:cee25a834751 | 130 | typedef struct WOLFSSL_SHA512_CTX { |
wolfSSL | 11:cee25a834751 | 131 | /* big enough to hold wolfCrypt Sha384, but check on init */ |
wolfSSL | 11:cee25a834751 | 132 | long long holder[36 + (WC_ASYNC_DEV_SIZE / sizeof(long long))]; |
wolfSSL | 11:cee25a834751 | 133 | } WOLFSSL_SHA512_CTX; |
wolfSSL | 11:cee25a834751 | 134 | |
wolfSSL | 11:cee25a834751 | 135 | WOLFSSL_API void wolfSSL_SHA512_Init(WOLFSSL_SHA512_CTX*); |
wolfSSL | 11:cee25a834751 | 136 | WOLFSSL_API void wolfSSL_SHA512_Update(WOLFSSL_SHA512_CTX*, const void*, |
wolfSSL | 11:cee25a834751 | 137 | unsigned long); |
wolfSSL | 11:cee25a834751 | 138 | WOLFSSL_API void wolfSSL_SHA512_Final(unsigned char*, WOLFSSL_SHA512_CTX*); |
wolfSSL | 11:cee25a834751 | 139 | |
wolfSSL | 11:cee25a834751 | 140 | enum { |
wolfSSL | 11:cee25a834751 | 141 | SHA512_DIGEST_LENGTH = 64 |
wolfSSL | 11:cee25a834751 | 142 | }; |
wolfSSL | 11:cee25a834751 | 143 | |
wolfSSL | 11:cee25a834751 | 144 | |
wolfSSL | 11:cee25a834751 | 145 | typedef WOLFSSL_SHA512_CTX SHA512_CTX; |
wolfSSL | 11:cee25a834751 | 146 | |
wolfSSL | 11:cee25a834751 | 147 | #define SHA512_Init wolfSSL_SHA512_Init |
wolfSSL | 11:cee25a834751 | 148 | #define SHA512_Update wolfSSL_SHA512_Update |
wolfSSL | 11:cee25a834751 | 149 | #define SHA512_Final wolfSSL_SHA512_Final |
wolfSSL | 11:cee25a834751 | 150 | |
wolfSSL | 11:cee25a834751 | 151 | #endif /* WOLFSSL_SHA512 */ |
wolfSSL | 11:cee25a834751 | 152 | |
wolfSSL | 11:cee25a834751 | 153 | |
wolfSSL | 11:cee25a834751 | 154 | |
wolfSSL | 11:cee25a834751 | 155 | |
wolfSSL | 11:cee25a834751 | 156 | #ifdef __cplusplus |
wolfSSL | 11:cee25a834751 | 157 | } /* extern "C" */ |
wolfSSL | 11:cee25a834751 | 158 | #endif |
wolfSSL | 11:cee25a834751 | 159 | |
wolfSSL | 11:cee25a834751 | 160 | |
wolfSSL | 11:cee25a834751 | 161 | #endif /* WOLFSSL_SHA_H_ */ |
wolfSSL | 11:cee25a834751 | 162 | |
wolfSSL | 11:cee25a834751 | 163 |