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