Coverage Report

Created: 2026-09-12 06:55

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl41/providers/implementations/ciphers/cipher_camellia.c
Line
Count
Source
1
/*
2
 * Copyright 2019-2026 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
/* Dispatch functions for CAMELLIA cipher modes ecb, cbc, cts, ofb, cfb, ctr */
17
18
#include "cipher_cts.h"
19
#include "cipher_camellia.h"
20
#include "prov/implementations.h"
21
#include "prov/providercommon.h"
22
23
static OSSL_FUNC_cipher_freectx_fn camellia_freectx;
24
static OSSL_FUNC_cipher_dupctx_fn camellia_dupctx;
25
static OSSL_FUNC_cipher_encrypt_init_fn camellia_cbc_cts_einit;
26
static OSSL_FUNC_cipher_decrypt_init_fn camellia_cbc_cts_dinit;
27
28
static void camellia_freectx(void *vctx)
29
3.36k
{
30
3.36k
    PROV_CAMELLIA_CTX *ctx = (PROV_CAMELLIA_CTX *)vctx;
31
32
3.36k
    ossl_cipher_generic_reset_ctx((PROV_CIPHER_CTX *)vctx);
33
3.36k
    OPENSSL_clear_free(ctx, sizeof(*ctx));
34
3.36k
}
35
36
static void *camellia_dupctx(void *ctx)
37
38
{
38
38
    PROV_CAMELLIA_CTX *in = (PROV_CAMELLIA_CTX *)ctx;
39
38
    PROV_CAMELLIA_CTX *ret;
40
41
38
    if (!ossl_prov_is_running())
42
0
        return NULL;
43
44
38
    ret = OPENSSL_malloc(sizeof(*ret));
45
38
    if (ret == NULL)
46
0
        return NULL;
47
38
    in->base.hw->copyctx(&ret->base, &in->base);
48
49
38
    return ret;
50
38
}
51
52
static int camellia_cbc_cts_einit(void *ctx, const unsigned char *key, size_t keylen,
53
    const unsigned char *iv, size_t ivlen,
54
    const OSSL_PARAM params[])
55
6
{
56
6
    if (!ossl_cipher_generic_einit(ctx, key, keylen, iv, ivlen, NULL))
57
0
        return 0;
58
6
    return ossl_cipher_cbc_cts_set_ctx_params(ctx, params);
59
6
}
60
61
static int camellia_cbc_cts_dinit(void *ctx, const unsigned char *key, size_t keylen,
62
    const unsigned char *iv, size_t ivlen,
63
    const OSSL_PARAM params[])
64
0
{
65
0
    if (!ossl_cipher_generic_dinit(ctx, key, keylen, iv, ivlen, NULL))
66
0
        return 0;
67
0
    return ossl_cipher_cbc_cts_set_ctx_params(ctx, params);
68
0
}
69
70
/* ossl_camellia256ecb_functions */
71
1
IMPLEMENT_generic_cipher(camellia, CAMELLIA, ecb, ECB, 0, 256, 128, 0, block)
72
1
/* ossl_camellia192ecb_functions */
73
2
IMPLEMENT_generic_cipher(camellia, CAMELLIA, ecb, ECB, 0, 192, 128, 0, block)
74
2
/* ossl_camellia128ecb_functions */
75
2
IMPLEMENT_generic_cipher(camellia, CAMELLIA, ecb, ECB, 0, 128, 128, 0, block)
76
2
/* ossl_camellia256cbc_functions */
77
1.10k
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cbc, CBC, 0, 256, 128, 128, block)
78
1.10k
/* ossl_camellia192cbc_functions */
79
1.10k
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cbc, CBC, 0, 192, 128, 128, block)
80
1
/* ossl_camellia128cbc_functions */
81
237
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cbc, CBC, 0, 128, 128, 128, block)
82
237
/* ossl_camellia256ofb_functions */
83
237
IMPLEMENT_generic_cipher(camellia, CAMELLIA, ofb, OFB, 0, 256, 8, 128, stream)
84
1
/* ossl_camellia192ofb_functions */
85
1
IMPLEMENT_generic_cipher(camellia, CAMELLIA, ofb, OFB, 0, 192, 8, 128, stream)
86
1
/* ossl_camellia128ofb_functions */
87
2
IMPLEMENT_generic_cipher(camellia, CAMELLIA, ofb, OFB, 0, 128, 8, 128, stream)
88
2
/* ossl_camellia256cfb_functions */
89
2
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb, CFB, 0, 256, 8, 128, stream)
90
2
/* ossl_camellia192cfb_functions */
91
2
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb, CFB, 0, 192, 8, 128, stream)
92
1
/* ossl_camellia128cfb_functions */
93
2
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb, CFB, 0, 128, 8, 128, stream)
94
2
/* ossl_camellia256cfb1_functions */
95
2
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb1, CFB, 0, 256, 8, 128, stream)
96
2
/* ossl_camellia192cfb1_functions */
97
2
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb1, CFB, 0, 192, 8, 128, stream)
98
1
/* ossl_camellia128cfb1_functions */
99
1
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb1, CFB, 0, 128, 8, 128, stream)
100
1
/* ossl_camellia256cfb8_functions */
101
1
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb8, CFB, 0, 256, 8, 128, stream)
102
1
/* ossl_camellia192cfb8_functions */
103
1
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb8, CFB, 0, 192, 8, 128, stream)
104
1
/* ossl_camellia128cfb8_functions */
105
2
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb8, CFB, 0, 128, 8, 128, stream)
106
2
/* ossl_camellia256ctr_functions */
107
2
IMPLEMENT_generic_cipher(camellia, CAMELLIA, ctr, CTR, 0, 256, 8, 128, stream)
108
1
/* ossl_camellia192ctr_functions */
109
2
IMPLEMENT_generic_cipher(camellia, CAMELLIA, ctr, CTR, 0, 192, 8, 128, stream)
110
2
/* ossl_camellia128ctr_functions */
111
IMPLEMENT_generic_cipher(camellia, CAMELLIA, ctr, CTR, 0, 128, 8, 128, stream)
112
113
/* ossl_camellia256cbc_cts_functions */
114
IMPLEMENT_cts_cipher(camellia, CAMELLIA, cbc, CBC, PROV_CIPHER_FLAG_CTS, 256, 128, 128, block)
115
/* ossl_camellia192cbc_cts_functions */
116
IMPLEMENT_cts_cipher(camellia, CAMELLIA, cbc, CBC, PROV_CIPHER_FLAG_CTS, 192, 128, 128, block)
117
/* ossl_camellia128cbc_cts_functions */
118
IMPLEMENT_cts_cipher(camellia, CAMELLIA, cbc, CBC, PROV_CIPHER_FLAG_CTS, 128, 128, 128, block)