| 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 | int SHA1_Init(SHA_CTX *sha) { |
| 22 | BCM_sha1_init(sha); |
| 23 | return 1; |
| 24 | } |
| 25 |
| 26 | int SHA1_Update(SHA_CTX *sha, const void *data, size_t len) { |
| 27 | BCM_sha1_update(sha, data, len); |
| 28 | return 1; |
| 29 | } |
| 30 |
| 31 | int SHA1_Final(uint8_t out[SHA_DIGEST_LENGTH], SHA_CTX *sha) { |
| 32 | BCM_sha1_final(out, sha); |
| 33 | return 1; |
| 34 | } |
| 35 |
| 36 | uint8_t *SHA1(const uint8_t *data, size_t len, uint8_t out[SHA_DIGEST_LENGTH]) { |
| 37 | SHA_CTX ctx; |
| 38 | BCM_sha1_init(&ctx); |
| 39 | BCM_sha1_update(&ctx, data, len); |
| 40 | BCM_sha1_final(out, &ctx); |
| 41 | OPENSSL_cleanse(&ctx, sizeof(ctx)); |
| 42 | return out; |
| 43 | } |
| 44 |
| 45 | void SHA1_Transform(SHA_CTX *sha, const uint8_t block[SHA_CBLOCK]) { |
| 46 | BCM_sha1_transform(sha, block); |
| 47 | } |
| 48 |
| 49 | void CRYPTO_fips_186_2_prf(uint8_t *out, size_t out_len, |
| 50 | const uint8_t xkey[SHA_DIGEST_LENGTH]) { |
| 51 | BCM_fips_186_2_prf(out, out_len, xkey); |
| 52 | } |
| 53 |