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_camellia_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
/*
11
 * Camellia low level APIs are deprecated for public use, but still ok for
12
 * internal use.
13
 */
14
#include "internal/deprecated.h"
15
16
#include <openssl/camellia.h>
17
#include <openssl/proverr.h>
18
#include "cipher_camellia.h"
19
20
static int cipher_hw_camellia_initkey(PROV_CIPHER_CTX *dat,
21
    const unsigned char *key, size_t keylen)
22
2.19k
{
23
2.19k
    int ret, mode = dat->mode;
24
2.19k
    PROV_CAMELLIA_CTX *adat = (PROV_CAMELLIA_CTX *)dat;
25
2.19k
    CAMELLIA_KEY *ks = &adat->ks.ks;
26
27
2.19k
    dat->ks = ks;
28
2.19k
    ret = Camellia_set_key(key, keylen * 8, ks);
29
2.19k
    if (ret < 0) {
30
0
        ERR_raise(ERR_LIB_PROV, PROV_R_KEY_SETUP_FAILED);
31
0
        return 0;
32
0
    }
33
2.19k
    if (dat->enc || (mode != EVP_CIPH_ECB_MODE && mode != EVP_CIPH_CBC_MODE)) {
34
1.32k
        dat->block = (block128_f)Camellia_encrypt;
35
1.32k
        dat->stream.cbc = mode == EVP_CIPH_CBC_MODE ? (cbc128_f)Camellia_cbc_encrypt : NULL;
36
1.32k
    } else {
37
866
        dat->block = (block128_f)Camellia_decrypt;
38
866
        dat->stream.cbc = mode == EVP_CIPH_CBC_MODE ? (cbc128_f)Camellia_cbc_encrypt : NULL;
39
866
    }
40
2.19k
    return 1;
41
2.19k
}
42
43
IMPLEMENT_CIPHER_HW_COPYCTX(cipher_hw_camellia_copyctx, PROV_CAMELLIA_CTX)
44
45
#if defined(SPARC_CMLL_CAPABLE)
46
#include "cipher_camellia_hw_t4.inc"
47
#else
48
/* The generic case */
49
#define PROV_CIPHER_HW_declare(mode)
50
#define PROV_CIPHER_HW_select(mode)
51
#endif /* SPARC_CMLL_CAPABLE */
52
53
#define PROV_CIPHER_HW_camellia_mode(mode)                   \
54
    static const PROV_CIPHER_HW camellia_##mode = {          \
55
        cipher_hw_camellia_initkey,                          \
56
        ossl_cipher_hw_generic_##mode,                       \
57
        cipher_hw_camellia_copyctx                           \
58
    };                                                       \
59
    PROV_CIPHER_HW_declare(mode)                             \
60
        const PROV_CIPHER_HW *                               \
61
        ossl_prov_cipher_hw_camellia_##mode(size_t keybits)  \
62
2.19k
    {                                                        \
63
2.19k
        PROV_CIPHER_HW_select(mode) return &camellia_##mode; \
64
2.19k
    }
ossl_prov_cipher_hw_camellia_cbc
Line
Count
Source
62
2.19k
    {                                                        \
63
2.19k
        PROV_CIPHER_HW_select(mode) return &camellia_##mode; \
64
2.19k
    }
Unexecuted instantiation: ossl_prov_cipher_hw_camellia_ecb
Unexecuted instantiation: ossl_prov_cipher_hw_camellia_ofb128
Unexecuted instantiation: ossl_prov_cipher_hw_camellia_cfb128
Unexecuted instantiation: ossl_prov_cipher_hw_camellia_cfb1
Unexecuted instantiation: ossl_prov_cipher_hw_camellia_cfb8
Unexecuted instantiation: ossl_prov_cipher_hw_camellia_ctr
65
66
PROV_CIPHER_HW_camellia_mode(cbc)
67
    PROV_CIPHER_HW_camellia_mode(ecb)
68
        PROV_CIPHER_HW_camellia_mode(ofb128)
69
            PROV_CIPHER_HW_camellia_mode(cfb128)
70
                PROV_CIPHER_HW_camellia_mode(cfb1)
71
                    PROV_CIPHER_HW_camellia_mode(cfb8)
72
                        PROV_CIPHER_HW_camellia_mode(ctr)