2 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
10 #include <sys/cdefs.h>
11 __FBSDID("$FreeBSD$");
13 #include <sys/libkern.h>
14 #include <sys/malloc.h>
16 #include <opencrypto/cryptodev.h>
17 #include <opencrypto/xform_auth.h>
19 #include <crypto/openssl/ossl.h>
20 #include <crypto/openssl/ossl_sha.h>
23 void sha1_block_data_order(SHA_CTX *c, const void *p, size_t len);
25 /* From crypto/sha/sha_local.h */
26 #define DATA_ORDER_IS_BIG_ENDIAN
28 #define HASH_LONG SHA_LONG
29 #define HASH_CTX SHA_CTX
30 #define HASH_CBLOCK SHA_CBLOCK
31 #define HASH_MAKE_STRING(c,s) do { \
33 ll=(c)->h0; (void)HOST_l2c(ll,(s)); \
34 ll=(c)->h1; (void)HOST_l2c(ll,(s)); \
35 ll=(c)->h2; (void)HOST_l2c(ll,(s)); \
36 ll=(c)->h3; (void)HOST_l2c(ll,(s)); \
37 ll=(c)->h4; (void)HOST_l2c(ll,(s)); \
40 #define HASH_UPDATE ossl_sha1_update
41 #define HASH_FINAL ossl_sha1_final
42 #define HASH_INIT ossl_sha1_init
43 #define HASH_BLOCK_DATA_ORDER sha1_block_data_order
45 #define INIT_DATA_h0 0x67452301UL
46 #define INIT_DATA_h1 0xefcdab89UL
47 #define INIT_DATA_h2 0x98badcfeUL
48 #define INIT_DATA_h3 0x10325476UL
49 #define INIT_DATA_h4 0xc3d2e1f0UL
55 memset(c, 0, sizeof(*c));
63 #include "ossl_hash.h"
65 struct auth_hash ossl_hash_sha1 = {
67 .name = "OpenSSL-SHA1",
68 .hashsize = SHA1_HASH_LEN,
69 .ctxsize = sizeof(SHA_CTX),
70 .blocksize = SHA1_BLOCK_LEN,
72 .Update = HASH_UPDATE,
76 _Static_assert(sizeof(SHA_CTX) <= sizeof(struct ossl_hash_context),
77 "ossl_hash_context too small");