• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2023 Google LLC
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 //     http://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 /// BoringSSL implementation for SHA256
16 pub struct Sha256;
17 
18 impl crypto_provider::sha2::Sha256 for Sha256 {
sha256(input: &[u8]) -> [u8; 32]19     fn sha256(input: &[u8]) -> [u8; 32] {
20         let mut digest = bssl_crypto::digest::Sha256::new();
21         digest.update(input);
22         digest.digest()
23     }
24 }
25 
26 /// BoringSSL implementation for SHA512
27 pub struct Sha512;
28 
29 impl crypto_provider::sha2::Sha512 for Sha512 {
sha512(input: &[u8]) -> [u8; 64]30     fn sha512(input: &[u8]) -> [u8; 64] {
31         let mut digest = bssl_crypto::digest::Sha512::new();
32         digest.update(input);
33         digest.digest()
34     }
35 }
36