2 * Copyright 2001-2019 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (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
11 * Sparc t4 support for AES modes ecb, cbc, ofb, cfb, ctr.
12 * This file is included by cipher_aes_hw.c
15 static int cipher_hw_aes_t4_initkey(PROV_CIPHER_CTX *dat,
16 const unsigned char *key, size_t keylen)
19 PROV_AES_CTX *adat = (PROV_AES_CTX *)dat;
20 AES_KEY *ks = &adat->ks.ks;
22 dat->ks = (const void *)ks; /* used by cipher_hw_generic_XXX */
25 if ((dat->mode == EVP_CIPH_ECB_MODE || dat->mode == EVP_CIPH_CBC_MODE)
28 aes_t4_set_decrypt_key(key, bits, ks);
29 dat->block = (block128_f)aes_t4_decrypt;
32 dat->stream.cbc = dat->mode == EVP_CIPH_CBC_MODE ?
33 (cbc128_f)aes128_t4_cbc_decrypt : NULL;
36 dat->stream.cbc = dat->mode == EVP_CIPH_CBC_MODE ?
37 (cbc128_f)aes192_t4_cbc_decrypt : NULL;
40 dat->stream.cbc = dat->mode == EVP_CIPH_CBC_MODE ?
41 (cbc128_f)aes256_t4_cbc_decrypt : NULL;
48 aes_t4_set_encrypt_key(key, bits, ks);
49 dat->block = (block128_f)aes_t4_encrypt;
52 if (dat->mode == EVP_CIPH_CBC_MODE)
53 dat->stream.cbc = (cbc128_f)aes128_t4_cbc_encrypt;
54 else if (dat->mode == EVP_CIPH_CTR_MODE)
55 dat->stream.ctr = (ctr128_f)aes128_t4_ctr32_encrypt;
57 dat->stream.cbc = NULL;
60 if (dat->mode == EVP_CIPH_CBC_MODE)
61 dat->stream.cbc = (cbc128_f)aes192_t4_cbc_encrypt;
62 else if (dat->mode == EVP_CIPH_CTR_MODE)
63 dat->stream.ctr = (ctr128_f)aes192_t4_ctr32_encrypt;
65 dat->stream.cbc = NULL;
68 if (dat->mode == EVP_CIPH_CBC_MODE)
69 dat->stream.cbc = (cbc128_f)aes256_t4_cbc_encrypt;
70 else if (dat->mode == EVP_CIPH_CTR_MODE)
71 dat->stream.ctr = (ctr128_f)aes256_t4_ctr32_encrypt;
73 dat->stream.cbc = NULL;
81 ERR_raise(ERR_LIB_PROV, PROV_R_AES_KEY_SETUP_FAILED);
88 #define PROV_CIPHER_HW_declare(mode) \
89 static const PROV_CIPHER_HW aes_t4_##mode = { \
90 cipher_hw_aes_t4_initkey, \
91 cipher_hw_generic_##mode, \
92 cipher_hw_aes_copyctx \
94 #define PROV_CIPHER_HW_select(mode) \
95 if (SPARC_AES_CAPABLE) \
96 return &aes_t4_##mode;