Currently, this supports SHA1 and SHA2-{224,256,384,512} both as plain hashes and in HMAC mode on both amd64 and i386. It uses the SHA intrinsics when present similar to aesni(4), but uses SSE/AVX instructions when they are not. Note that some files from OpenSSL that normally wrap the assembly routines have been adapted to export methods usable by 'struct auth_xform' as is used by existing software crypto routines. Reviewed by: gallatin, jkim, delphij, gnn Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D26821
69 lines
1.8 KiB
C
69 lines
1.8 KiB
C
/*
|
|
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
|
*
|
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
|
* this file except in compliance with the License. You can obtain a copy
|
|
* in the file LICENSE in the source distribution or at
|
|
* https://www.openssl.org/source/license.html
|
|
*
|
|
* $FreeBSD$
|
|
*/
|
|
|
|
#ifndef __OSSL_SHA_H__
|
|
#define __OSSL_SHA_H__
|
|
|
|
/*
|
|
* This is always included last which permits the namespace hacks below
|
|
* to work.
|
|
*/
|
|
#define SHA256_CTX OSSL_SHA256_CTX
|
|
#define SHA512_CTX OSSL_SHA512_CTX
|
|
|
|
/* From include/openssl/sha.h */
|
|
# define SHA_LONG unsigned int
|
|
|
|
# define SHA_LBLOCK 16
|
|
# define SHA_CBLOCK (SHA_LBLOCK*4)/* SHA treats input data as a
|
|
* contiguous array of 32 bit wide
|
|
* big-endian values. */
|
|
|
|
typedef struct SHAstate_st {
|
|
SHA_LONG h0, h1, h2, h3, h4;
|
|
SHA_LONG Nl, Nh;
|
|
SHA_LONG data[SHA_LBLOCK];
|
|
unsigned int num;
|
|
} SHA_CTX;
|
|
|
|
# define SHA256_CBLOCK (SHA_LBLOCK*4)/* SHA-256 treats input data as a
|
|
* contiguous array of 32 bit wide
|
|
* big-endian values. */
|
|
|
|
typedef struct SHA256state_st {
|
|
SHA_LONG h[8];
|
|
SHA_LONG Nl, Nh;
|
|
SHA_LONG data[SHA_LBLOCK];
|
|
unsigned int num, md_len;
|
|
} SHA256_CTX;
|
|
|
|
/*
|
|
* SHA-512 treats input data as a
|
|
* contiguous array of 64 bit
|
|
* wide big-endian values.
|
|
*/
|
|
# define SHA512_CBLOCK (SHA_LBLOCK*8)
|
|
|
|
# define SHA_LONG64 unsigned long long
|
|
# define U64(C) C##ULL
|
|
|
|
typedef struct SHA512state_st {
|
|
SHA_LONG64 h[8];
|
|
SHA_LONG64 Nl, Nh;
|
|
union {
|
|
SHA_LONG64 d[SHA_LBLOCK];
|
|
unsigned char p[SHA512_CBLOCK];
|
|
} u;
|
|
unsigned int num, md_len;
|
|
} SHA512_CTX;
|
|
|
|
#endif /* !__OSSL_SHA_H__ */
|