/src/openssl32/providers/implementations/ciphers/cipher_aria_hw.c
Line  | Count  | Source (jump to first uncovered line)  | 
1  |  | /*  | 
2  |  |  * Copyright 2001-2021 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  |  |  | 
10  |  | #include <openssl/proverr.h>  | 
11  |  | #include "cipher_aria.h"  | 
12  |  |  | 
13  |  | static int cipher_hw_aria_initkey(PROV_CIPHER_CTX *dat,  | 
14  |  |                                   const unsigned char *key, size_t keylen)  | 
15  | 44  | { | 
16  | 44  |     int ret, mode = dat->mode;  | 
17  | 44  |     PROV_ARIA_CTX *adat = (PROV_ARIA_CTX *)dat;  | 
18  | 44  |     ARIA_KEY *ks = &adat->ks.ks;  | 
19  |  |  | 
20  | 44  |     if (dat->enc || (mode != EVP_CIPH_ECB_MODE && mode != EVP_CIPH_CBC_MODE))  | 
21  | 44  |         ret = ossl_aria_set_encrypt_key(key, keylen * 8, ks);  | 
22  | 0  |     else  | 
23  | 0  |         ret = ossl_aria_set_decrypt_key(key, keylen * 8, ks);  | 
24  | 44  |     if (ret < 0) { | 
25  | 0  |         ERR_raise(ERR_LIB_PROV, PROV_R_KEY_SETUP_FAILED);  | 
26  | 0  |         return 0;  | 
27  | 0  |     }  | 
28  | 44  |     dat->ks = ks;  | 
29  | 44  |     dat->block = (block128_f)ossl_aria_encrypt;  | 
30  | 44  |     return 1;  | 
31  | 44  | }  | 
32  |  |  | 
33  |  | IMPLEMENT_CIPHER_HW_COPYCTX(cipher_hw_aria_copyctx, PROV_ARIA_CTX)  | 
34  |  |  | 
35  |  | # define PROV_CIPHER_HW_aria_mode(mode)                                        \  | 
36  |  | static const PROV_CIPHER_HW aria_##mode = {                                    \ | 
37  |  |     cipher_hw_aria_initkey,                                                    \  | 
38  |  |     ossl_cipher_hw_chunked_##mode,                                             \  | 
39  |  |     cipher_hw_aria_copyctx                                                     \  | 
40  |  | };                                                                             \  | 
41  | 47  | const PROV_CIPHER_HW *ossl_prov_cipher_hw_aria_##mode(size_t keybits)          \  | 
42  | 47  | {                                                                              \ | 
43  | 47  |     return &aria_##mode;                                                       \  | 
44  | 47  | } ossl_prov_cipher_hw_aria_cbc Line  | Count  | Source  |  41  | 47  | const PROV_CIPHER_HW *ossl_prov_cipher_hw_aria_##mode(size_t keybits)          \  |  42  | 47  | {                                                                              \ |  43  | 47  |     return &aria_##mode;                                                       \  |  44  | 47  | }  |  
 Unexecuted instantiation: ossl_prov_cipher_hw_aria_ecb Unexecuted instantiation: ossl_prov_cipher_hw_aria_ofb128 Unexecuted instantiation: ossl_prov_cipher_hw_aria_cfb128 Unexecuted instantiation: ossl_prov_cipher_hw_aria_cfb1 Unexecuted instantiation: ossl_prov_cipher_hw_aria_cfb8 Unexecuted instantiation: ossl_prov_cipher_hw_aria_ctr  | 
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)  |