]>
Commit | Line | Data |
---|---|---|
e1178600 | 1 | /* |
a28d06f3 | 2 | * Copyright 2001-2021 The OpenSSL Project Authors. All Rights Reserved. |
e1178600 SL |
3 | * |
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 | |
8 | */ | |
9 | ||
f5f29796 | 10 | #include <openssl/proverr.h> |
4a42e264 | 11 | #include "cipher_aria.h" |
e1178600 SL |
12 | |
13 | static int cipher_hw_aria_initkey(PROV_CIPHER_CTX *dat, | |
14 | const unsigned char *key, size_t keylen) | |
15 | { | |
16 | int ret, mode = dat->mode; | |
17 | PROV_ARIA_CTX *adat = (PROV_ARIA_CTX *)dat; | |
18 | ARIA_KEY *ks = &adat->ks.ks; | |
19 | ||
20 | if (dat->enc || (mode != EVP_CIPH_ECB_MODE && mode != EVP_CIPH_CBC_MODE)) | |
21 | ret = aria_set_encrypt_key(key, keylen * 8, ks); | |
22 | else | |
23 | ret = aria_set_decrypt_key(key, keylen * 8, ks); | |
24 | if (ret < 0) { | |
f5f29796 | 25 | ERR_raise(ERR_LIB_PROV, PROV_R_KEY_SETUP_FAILED); |
e1178600 SL |
26 | return 0; |
27 | } | |
28 | dat->ks = ks; | |
29 | dat->block = (block128_f)aria_encrypt; | |
30 | return 1; | |
31 | } | |
32 | ||
f75abcc0 SL |
33 | IMPLEMENT_CIPHER_HW_COPYCTX(cipher_hw_aria_copyctx, PROV_ARIA_CTX) |
34 | ||
e1178600 SL |
35 | # define PROV_CIPHER_HW_aria_mode(mode) \ |
36 | static const PROV_CIPHER_HW aria_##mode = { \ | |
37 | cipher_hw_aria_initkey, \ | |
592dcfd3 | 38 | ossl_cipher_hw_chunked_##mode, \ |
f75abcc0 | 39 | cipher_hw_aria_copyctx \ |
e1178600 | 40 | }; \ |
7d6766cb | 41 | const PROV_CIPHER_HW *ossl_prov_cipher_hw_aria_##mode(size_t keybits) \ |
e1178600 SL |
42 | { \ |
43 | return &aria_##mode; \ | |
44 | } | |
45 | ||
46 | PROV_CIPHER_HW_aria_mode(cbc) | |
47 | PROV_CIPHER_HW_aria_mode(ecb) | |
48 | PROV_CIPHER_HW_aria_mode(ofb128) | |
49 | PROV_CIPHER_HW_aria_mode(cfb128) | |
50 | PROV_CIPHER_HW_aria_mode(cfb1) | |
51 | PROV_CIPHER_HW_aria_mode(cfb8) | |
52 | PROV_CIPHER_HW_aria_mode(ctr) |