gnunet-android

GNUnet for Android
Log | Files | Refs | README

bcm_public.h (2101B)


      1 // Copyright 2024 The BoringSSL Authors
      2 //
      3 // Licensed under the Apache License, Version 2.0 (the "License");
      4 // you may not use this file except in compliance with the License.
      5 // You may obtain a copy of the License at
      6 //
      7 //     https://www.apache.org/licenses/LICENSE-2.0
      8 //
      9 // Unless required by applicable law or agreed to in writing, software
     10 // distributed under the License is distributed on an "AS IS" BASIS,
     11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 // See the License for the specific language governing permissions and
     13 // limitations under the License.
     14 
     15 #ifndef OPENSSL_HEADER_BCM_PUBLIC_H_
     16 #define OPENSSL_HEADER_BCM_PUBLIC_H_
     17 
     18 #include <openssl/base.h>   // IWYU pragma: export
     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_