xref: /openbsd-src/lib/libcrypto/sha/sha256_amd64.c (revision 228e7c1edf50bd8bdd3aca0a9db75db8848ad9e0)
1*228e7c1eSjsing /* $OpenBSD: sha256_amd64.c,v 1.2 2024/11/16 15:31:36 jsing Exp $ */
20acd6edbSjsing /*
30acd6edbSjsing  * Copyright (c) 2024 Joel Sing <jsing@openbsd.org>
40acd6edbSjsing  *
50acd6edbSjsing  * Permission to use, copy, modify, and distribute this software for any
60acd6edbSjsing  * purpose with or without fee is hereby granted, provided that the above
70acd6edbSjsing  * copyright notice and this permission notice appear in all copies.
80acd6edbSjsing  *
90acd6edbSjsing  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
100acd6edbSjsing  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
110acd6edbSjsing  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
120acd6edbSjsing  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
130acd6edbSjsing  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
140acd6edbSjsing  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
150acd6edbSjsing  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
160acd6edbSjsing  */
170acd6edbSjsing 
180acd6edbSjsing #include <openssl/sha.h>
190acd6edbSjsing 
20*228e7c1eSjsing #include "crypto_arch.h"
21*228e7c1eSjsing 
220acd6edbSjsing void sha256_block_generic(SHA256_CTX *ctx, const void *in, size_t num);
23*228e7c1eSjsing void sha256_block_shani(SHA256_CTX *ctx, const void *in, size_t num);
240acd6edbSjsing 
250acd6edbSjsing void
260acd6edbSjsing sha256_block_data_order(SHA256_CTX *ctx, const void *in, size_t num)
270acd6edbSjsing {
28*228e7c1eSjsing 	if ((crypto_cpu_caps_amd64 & CRYPTO_CPU_CAPS_AMD64_SHA) != 0) {
29*228e7c1eSjsing 		sha256_block_shani(ctx, in, num);
30*228e7c1eSjsing 		return;
31*228e7c1eSjsing 	}
32*228e7c1eSjsing 
330acd6edbSjsing 	sha256_block_generic(ctx, in, num);
340acd6edbSjsing }
35