xref: /freebsd/crypto/openssl/providers/implementations/ciphers/cipher_aes_hw_armv8.inc (revision e7be843b4a162e68651d3911f0357ed464915629)
1*e7be843bSPierre Pronchery/*
2*e7be843bSPierre Pronchery * Copyright 2023 The OpenSSL Project Authors. All Rights Reserved.
3*e7be843bSPierre Pronchery *
4*e7be843bSPierre Pronchery * Licensed under the Apache License 2.0 (the "License").  You may not use
5*e7be843bSPierre Pronchery * this file except in compliance with the License.  You can obtain a copy
6*e7be843bSPierre Pronchery * in the file LICENSE in the source distribution or at
7*e7be843bSPierre Pronchery * https://www.openssl.org/source/license.html
8*e7be843bSPierre Pronchery */
9*e7be843bSPierre Pronchery
10*e7be843bSPierre Pronchery/*
11*e7be843bSPierre Pronchery * Crypto extension support for AES modes ecb, cbc, ofb, cfb, ctr.
12*e7be843bSPierre Pronchery * This file is included by cipher_aes_hw.c
13*e7be843bSPierre Pronchery */
14*e7be843bSPierre Pronchery
15*e7be843bSPierre Proncherystatic int cipher_hw_aes_arm_initkey(PROV_CIPHER_CTX *dat,
16*e7be843bSPierre Pronchery                                                       const unsigned char *key,
17*e7be843bSPierre Pronchery                                                       size_t keylen)
18*e7be843bSPierre Pronchery{
19*e7be843bSPierre Pronchery    int ret = cipher_hw_aes_initkey(dat, key, keylen);
20*e7be843bSPierre Pronchery    if (AES_UNROLL12_EOR3_CAPABLE && dat->mode == EVP_CIPH_CTR_MODE)
21*e7be843bSPierre Pronchery        dat->stream.ctr = (ctr128_f)HWAES_ctr32_encrypt_blocks_unroll12_eor3;
22*e7be843bSPierre Pronchery
23*e7be843bSPierre Pronchery    return ret;
24*e7be843bSPierre Pronchery}
25*e7be843bSPierre Pronchery
26*e7be843bSPierre Pronchery#define PROV_CIPHER_HW_declare(mode)                                           \
27*e7be843bSPierre Proncherystatic const PROV_CIPHER_HW aes_arm_##mode = {                                 \
28*e7be843bSPierre Pronchery    cipher_hw_aes_arm_initkey,                                                 \
29*e7be843bSPierre Pronchery    ossl_cipher_hw_generic_##mode,                                             \
30*e7be843bSPierre Pronchery    cipher_hw_aes_copyctx                                                      \
31*e7be843bSPierre Pronchery};
32*e7be843bSPierre Pronchery#define PROV_CIPHER_HW_select(mode)                                            \
33*e7be843bSPierre Proncheryif (ARMv8_HWAES_CAPABLE)                                                         \
34*e7be843bSPierre Pronchery    return &aes_arm_##mode;
35