Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:49

0001 /*
0002  * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved.
0003  *
0004  * Licensed under the Apache License 2.0 (the "License").  You may not use
0005  * this file except in compliance with the License.  You can obtain a copy
0006  * in the file LICENSE in the source distribution or at
0007  * https://www.openssl.org/source/license.html
0008  */
0009 
0010 #ifndef OPENSSL_SHA_H
0011 # define OPENSSL_SHA_H
0012 # pragma once
0013 
0014 # include <openssl/macros.h>
0015 # ifndef OPENSSL_NO_DEPRECATED_3_0
0016 #  define HEADER_SHA_H
0017 # endif
0018 
0019 # include <openssl/e_os2.h>
0020 # include <stddef.h>
0021 
0022 # ifdef  __cplusplus
0023 extern "C" {
0024 # endif
0025 
0026 # define SHA_DIGEST_LENGTH 20
0027 
0028 # ifndef OPENSSL_NO_DEPRECATED_3_0
0029 /*-
0030  * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
0031  * ! SHA_LONG has to be at least 32 bits wide.                    !
0032  * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
0033  */
0034 #  define SHA_LONG unsigned int
0035 
0036 #  define SHA_LBLOCK      16
0037 #  define SHA_CBLOCK      (SHA_LBLOCK*4)/* SHA treats input data as a
0038                                          * contiguous array of 32 bit wide
0039                                          * big-endian values. */
0040 #  define SHA_LAST_BLOCK  (SHA_CBLOCK-8)
0041 
0042 typedef struct SHAstate_st {
0043     SHA_LONG h0, h1, h2, h3, h4;
0044     SHA_LONG Nl, Nh;
0045     SHA_LONG data[SHA_LBLOCK];
0046     unsigned int num;
0047 } SHA_CTX;
0048 
0049 OSSL_DEPRECATEDIN_3_0 int SHA1_Init(SHA_CTX *c);
0050 OSSL_DEPRECATEDIN_3_0 int SHA1_Update(SHA_CTX *c, const void *data, size_t len);
0051 OSSL_DEPRECATEDIN_3_0 int SHA1_Final(unsigned char *md, SHA_CTX *c);
0052 OSSL_DEPRECATEDIN_3_0 void SHA1_Transform(SHA_CTX *c, const unsigned char *data);
0053 # endif
0054 
0055 unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md);
0056 
0057 # ifndef OPENSSL_NO_DEPRECATED_3_0
0058 #  define SHA256_CBLOCK   (SHA_LBLOCK*4)/* SHA-256 treats input data as a
0059                                         * contiguous array of 32 bit wide
0060                                         * big-endian values. */
0061 
0062 typedef struct SHA256state_st {
0063     SHA_LONG h[8];
0064     SHA_LONG Nl, Nh;
0065     SHA_LONG data[SHA_LBLOCK];
0066     unsigned int num, md_len;
0067 } SHA256_CTX;
0068 
0069 OSSL_DEPRECATEDIN_3_0 int SHA224_Init(SHA256_CTX *c);
0070 OSSL_DEPRECATEDIN_3_0 int SHA224_Update(SHA256_CTX *c,
0071                                         const void *data, size_t len);
0072 OSSL_DEPRECATEDIN_3_0 int SHA224_Final(unsigned char *md, SHA256_CTX *c);
0073 OSSL_DEPRECATEDIN_3_0 int SHA256_Init(SHA256_CTX *c);
0074 OSSL_DEPRECATEDIN_3_0 int SHA256_Update(SHA256_CTX *c,
0075                                         const void *data, size_t len);
0076 OSSL_DEPRECATEDIN_3_0 int SHA256_Final(unsigned char *md, SHA256_CTX *c);
0077 OSSL_DEPRECATEDIN_3_0 void SHA256_Transform(SHA256_CTX *c,
0078                                             const unsigned char *data);
0079 # endif
0080 
0081 unsigned char *SHA224(const unsigned char *d, size_t n, unsigned char *md);
0082 unsigned char *SHA256(const unsigned char *d, size_t n, unsigned char *md);
0083 
0084 # define SHA256_192_DIGEST_LENGTH 24
0085 # define SHA224_DIGEST_LENGTH    28
0086 # define SHA256_DIGEST_LENGTH    32
0087 # define SHA384_DIGEST_LENGTH    48
0088 # define SHA512_DIGEST_LENGTH    64
0089 
0090 # ifndef OPENSSL_NO_DEPRECATED_3_0
0091 /*
0092  * Unlike 32-bit digest algorithms, SHA-512 *relies* on SHA_LONG64
0093  * being exactly 64-bit wide. See Implementation Notes in sha512.c
0094  * for further details.
0095  */
0096 /*
0097  * SHA-512 treats input data as a
0098  * contiguous array of 64 bit
0099  * wide big-endian values.
0100  */
0101 #  define SHA512_CBLOCK   (SHA_LBLOCK*8)
0102 #  if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__)
0103 #   define SHA_LONG64 unsigned __int64
0104 #  elif defined(__arch64__)
0105 #   define SHA_LONG64 unsigned long
0106 #  else
0107 #   define SHA_LONG64 unsigned long long
0108 #  endif
0109 
0110 typedef struct SHA512state_st {
0111     SHA_LONG64 h[8];
0112     SHA_LONG64 Nl, Nh;
0113     union {
0114         SHA_LONG64 d[SHA_LBLOCK];
0115         unsigned char p[SHA512_CBLOCK];
0116     } u;
0117     unsigned int num, md_len;
0118 } SHA512_CTX;
0119 
0120 OSSL_DEPRECATEDIN_3_0 int SHA384_Init(SHA512_CTX *c);
0121 OSSL_DEPRECATEDIN_3_0 int SHA384_Update(SHA512_CTX *c,
0122                                         const void *data, size_t len);
0123 OSSL_DEPRECATEDIN_3_0 int SHA384_Final(unsigned char *md, SHA512_CTX *c);
0124 OSSL_DEPRECATEDIN_3_0 int SHA512_Init(SHA512_CTX *c);
0125 OSSL_DEPRECATEDIN_3_0 int SHA512_Update(SHA512_CTX *c,
0126                                         const void *data, size_t len);
0127 OSSL_DEPRECATEDIN_3_0 int SHA512_Final(unsigned char *md, SHA512_CTX *c);
0128 OSSL_DEPRECATEDIN_3_0 void SHA512_Transform(SHA512_CTX *c,
0129                                             const unsigned char *data);
0130 # endif
0131 
0132 unsigned char *SHA384(const unsigned char *d, size_t n, unsigned char *md);
0133 unsigned char *SHA512(const unsigned char *d, size_t n, unsigned char *md);
0134 
0135 # ifdef  __cplusplus
0136 }
0137 # endif
0138 
0139 #endif