/src/boringssl/crypto/sha/sha1.cc
Line | Count | Source |
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 | | #include <openssl/sha.h> |
16 | | |
17 | | #include <openssl/mem.h> |
18 | | |
19 | | #include "../fipsmodule/bcm_interface.h" |
20 | | |
21 | | |
22 | | using namespace bssl; |
23 | | |
24 | 17.5k | int SHA1_Init(SHA_CTX *sha) { |
25 | 17.5k | BCM_sha1_init(sha); |
26 | 17.5k | return 1; |
27 | 17.5k | } |
28 | | |
29 | 67.4k | int SHA1_Update(SHA_CTX *sha, const void *data, size_t len) { |
30 | 67.4k | BCM_sha1_update(sha, data, len); |
31 | 67.4k | return 1; |
32 | 67.4k | } |
33 | | |
34 | 16.4k | int SHA1_Final(uint8_t out[SHA_DIGEST_LENGTH], SHA_CTX *sha) { |
35 | 16.4k | BCM_sha1_final(out, sha); |
36 | 16.4k | return 1; |
37 | 16.4k | } |
38 | | |
39 | 0 | uint8_t *SHA1(const uint8_t *data, size_t len, uint8_t out[SHA_DIGEST_LENGTH]) { |
40 | 0 | SHA_CTX ctx; |
41 | 0 | BCM_sha1_init(&ctx); |
42 | 0 | BCM_sha1_update(&ctx, data, len); |
43 | 0 | BCM_sha1_final(out, &ctx); |
44 | 0 | OPENSSL_cleanse(&ctx, sizeof(ctx)); |
45 | 0 | return out; |
46 | 0 | } |
47 | | |
48 | 4.51k | void SHA1_Transform(SHA_CTX *sha, const uint8_t block[SHA_CBLOCK]) { |
49 | 4.51k | BCM_sha1_transform(sha, block); |
50 | 4.51k | } |
51 | | |
52 | | void CRYPTO_fips_186_2_prf(uint8_t *out, size_t out_len, |
53 | 0 | const uint8_t xkey[SHA_DIGEST_LENGTH]) { |
54 | 0 | BCM_fips_186_2_prf(out, out_len, xkey); |
55 | 0 | } |