Coverage Report

Created: 2025-06-13 06:58

/src/openssl32/providers/implementations/ciphers/cipher_camellia_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
/*
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
877
{
23
877
    int ret, mode = dat->mode;
24
877
    PROV_CAMELLIA_CTX *adat = (PROV_CAMELLIA_CTX *)dat;
25
877
    CAMELLIA_KEY *ks = &adat->ks.ks;
26
27
877
    dat->ks = ks;
28
877
    ret = Camellia_set_key(key, keylen * 8, ks);
29
877
    if (ret < 0) {
30
0
        ERR_raise(ERR_LIB_PROV, PROV_R_KEY_SETUP_FAILED);
31
0
        return 0;
32
0
    }
33
877
    if (dat->enc || (mode != EVP_CIPH_ECB_MODE && mode != EVP_CIPH_CBC_MODE)) {
34
558
        dat->block = (block128_f) Camellia_encrypt;
35
558
        dat->stream.cbc = mode == EVP_CIPH_CBC_MODE ?
36
558
            (cbc128_f) Camellia_cbc_encrypt : NULL;
37
558
    } else {
38
319
        dat->block = (block128_f) Camellia_decrypt;
39
319
        dat->stream.cbc = mode == EVP_CIPH_CBC_MODE ?
40
319
            (cbc128_f) Camellia_cbc_encrypt : NULL;
41
319
    }
42
877
    return 1;
43
877
}
44
45
IMPLEMENT_CIPHER_HW_COPYCTX(cipher_hw_camellia_copyctx, PROV_CAMELLIA_CTX)
46
47
# if defined(SPARC_CMLL_CAPABLE)
48
#  include "cipher_camellia_hw_t4.inc"
49
# else
50
/* The generic case */
51
#  define PROV_CIPHER_HW_declare(mode)
52
#  define PROV_CIPHER_HW_select(mode)
53
# endif /* SPARC_CMLL_CAPABLE */
54
55
#define PROV_CIPHER_HW_camellia_mode(mode)                                     \
56
static const PROV_CIPHER_HW camellia_##mode = {                                \
57
    cipher_hw_camellia_initkey,                                                \
58
    ossl_cipher_hw_generic_##mode,                                             \
59
    cipher_hw_camellia_copyctx                                                 \
60
};                                                                             \
61
PROV_CIPHER_HW_declare(mode)                                                   \
62
877
const PROV_CIPHER_HW *ossl_prov_cipher_hw_camellia_##mode(size_t keybits)      \
63
877
{                                                                              \
64
877
    PROV_CIPHER_HW_select(mode)                                                \
65
877
    return &camellia_##mode;                                                   \
66
877
}
ossl_prov_cipher_hw_camellia_cbc
Line
Count
Source
62
877
const PROV_CIPHER_HW *ossl_prov_cipher_hw_camellia_##mode(size_t keybits)      \
63
877
{                                                                              \
64
877
    PROV_CIPHER_HW_select(mode)                                                \
65
877
    return &camellia_##mode;                                                   \
66
877
}
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
67
68
PROV_CIPHER_HW_camellia_mode(cbc)
69
PROV_CIPHER_HW_camellia_mode(ecb)
70
PROV_CIPHER_HW_camellia_mode(ofb128)
71
PROV_CIPHER_HW_camellia_mode(cfb128)
72
PROV_CIPHER_HW_camellia_mode(cfb1)
73
PROV_CIPHER_HW_camellia_mode(cfb8)
74
PROV_CIPHER_HW_camellia_mode(ctr)