/*-1* SPDX-License-Identifier: BSD-2-Clause-FreeBSD2*3* Copyright (c) 2023 Stormshield4* Copyright (c) 2023 Semihalf5*6* Redistribution and use in source and binary forms, with or without7* modification, are permitted provided that the following conditions8* are met:9* 1. Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer,11* without modification.12* 2. Redistributions in binary form must reproduce at minimum a disclaimer13* similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any14* redistribution must be conditioned upon including a substantially15* similar Disclaimer requirement for further binary redistribution.16*17* NO WARRANTY18* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS19* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT20* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY21* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL22* THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,23* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF24* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS25* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER26* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)27* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF28* THE POSSIBILITY OF SUCH DAMAGES.29*/3031#include <sys/param.h>3233#include <machine/elf.h>34#include <machine/md_var.h>3536#include <crypto/openssl/ossl.h>37#include <crypto/openssl/ossl_cipher.h>38#include <crypto/openssl/arm_arch.h>3940ossl_cipher_setkey_t AES_set_encrypt_key;41ossl_cipher_setkey_t AES_set_decrypt_key;4243ossl_cipher_setkey_t ossl_aes_gcm_setkey;4445unsigned int OPENSSL_armcap_P;4647void48ossl_cpuid(struct ossl_softc *sc)49{50if (elf_hwcap & HWCAP_NEON) {51OPENSSL_armcap_P |= ARMV7_NEON;5253sc->has_aes = true;54ossl_cipher_aes_cbc.set_encrypt_key = AES_set_encrypt_key;55ossl_cipher_aes_cbc.set_decrypt_key = AES_set_decrypt_key;5657sc->has_aes_gcm = true;58ossl_cipher_aes_gcm.set_encrypt_key = ossl_aes_gcm_setkey;59ossl_cipher_aes_gcm.set_decrypt_key = ossl_aes_gcm_setkey;60}61}626364