1 /* Copyright 2024 The BoringSSL Authors 2 * 3 * Permission to use, copy, modify, and/or distribute this software for any 4 * purpose with or without fee is hereby granted, provided that the above 5 * copyright notice and this permission notice appear in all copies. 6 * 7 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 10 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 12 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 13 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ 14 15 #ifndef OPENSSL_HEADER_BCM_PUBLIC_H_ 16 #define OPENSSL_HEADER_BCM_PUBLIC_H_ 17 18 #include <openssl/base.h> 19 20 #if defined(__cplusplus) 21 extern "C" { 22 #endif 23 24 // Public types referenced by BoringCrypto 25 // 26 // This header contains public types referenced by BCM. Such types are difficult 27 // to hide from the libcrypto interface, so we treat them as part of BCM. 28 29 // BCM_SHA_CBLOCK is the block size of SHA-1. 30 #define BCM_SHA_CBLOCK 64 31 32 // SHA_CTX 33 struct sha_state_st { 34 #if defined(__cplusplus) || defined(OPENSSL_WINDOWS) 35 uint32_t h[5]; 36 #else 37 // wpa_supplicant accesses |h0|..|h4| so we must support those names for 38 // compatibility with it until it can be updated. Anonymous unions are only 39 // standard in C11, so disable this workaround in C++. 40 union { 41 uint32_t h[5]; 42 struct { 43 uint32_t h0; 44 uint32_t h1; 45 uint32_t h2; 46 uint32_t h3; 47 uint32_t h4; 48 }; 49 }; 50 #endif 51 uint32_t Nl, Nh; 52 uint8_t data[BCM_SHA_CBLOCK]; 53 unsigned num; 54 }; 55 56 // SHA256_CBLOCK is the block size of SHA-256. 57 #define BCM_SHA256_CBLOCK 64 58 59 // SHA256_CTX 60 struct sha256_state_st { 61 uint32_t h[8]; 62 uint32_t Nl, Nh; 63 uint8_t data[BCM_SHA256_CBLOCK]; 64 unsigned num, md_len; 65 }; 66 67 // BCM_SHA512_CBLOCK is the block size of SHA-512. 68 #define BCM_SHA512_CBLOCK 128 69 70 struct sha512_state_st { 71 uint64_t h[8]; 72 uint64_t Nl, Nh; 73 uint8_t p[BCM_SHA512_CBLOCK]; 74 unsigned num, md_len; 75 }; 76 77 78 #if defined(__cplusplus) 79 } // extern C 80 #endif 81 82 #endif // OPENSSL_HEADER_BCM_PUBLIC_H_ 83