Coverage Report

Created: 2025-12-31 06:58

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl33/providers/implementations/ciphers/cipher_aria_hw.c
Line
Count
Source
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
147
{
16
147
    int ret, mode = dat->mode;
17
147
    PROV_ARIA_CTX *adat = (PROV_ARIA_CTX *)dat;
18
147
    ARIA_KEY *ks = &adat->ks.ks;
19
20
147
    if (dat->enc || (mode != EVP_CIPH_ECB_MODE && mode != EVP_CIPH_CBC_MODE))
21
147
        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
147
    if (ret < 0) {
25
0
        ERR_raise(ERR_LIB_PROV, PROV_R_KEY_SETUP_FAILED);
26
0
        return 0;
27
0
    }
28
147
    dat->ks = ks;
29
147
    dat->block = (block128_f)ossl_aria_encrypt;
30
147
    return 1;
31
147
}
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
    const PROV_CIPHER_HW *ossl_prov_cipher_hw_aria_##mode(size_t keybits) \
42
173
    {                                                                     \
43
173
        return &aria_##mode;                                              \
44
173
    }
ossl_prov_cipher_hw_aria_cbc
Line
Count
Source
42
23
    {                                                                     \
43
23
        return &aria_##mode;                                              \
44
23
    }
ossl_prov_cipher_hw_aria_ecb
Line
Count
Source
42
8
    {                                                                     \
43
8
        return &aria_##mode;                                              \
44
8
    }
ossl_prov_cipher_hw_aria_ofb128
Line
Count
Source
42
35
    {                                                                     \
43
35
        return &aria_##mode;                                              \
44
35
    }
ossl_prov_cipher_hw_aria_cfb128
Line
Count
Source
42
35
    {                                                                     \
43
35
        return &aria_##mode;                                              \
44
35
    }
ossl_prov_cipher_hw_aria_cfb1
Line
Count
Source
42
35
    {                                                                     \
43
35
        return &aria_##mode;                                              \
44
35
    }
ossl_prov_cipher_hw_aria_cfb8
Line
Count
Source
42
35
    {                                                                     \
43
35
        return &aria_##mode;                                              \
44
35
    }
ossl_prov_cipher_hw_aria_ctr
Line
Count
Source
42
2
    {                                                                     \
43
2
        return &aria_##mode;                                              \
44
2
    }
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)