Coverage Report

Created: 2026-09-13 06:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl/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
0
{
30
0
    PROV_CAMELLIA_CTX *ctx = (PROV_CAMELLIA_CTX *)vctx;
31
32
0
    ossl_cipher_generic_reset_ctx((PROV_CIPHER_CTX *)vctx);
33
0
    OPENSSL_clear_free(ctx, sizeof(*ctx));
34
0
}
35
36
static void *camellia_dupctx(void *ctx)
37
0
{
38
0
    PROV_CAMELLIA_CTX *in = (PROV_CAMELLIA_CTX *)ctx;
39
0
    PROV_CAMELLIA_CTX *ret;
40
41
0
    if (!ossl_prov_is_running())
42
0
        return NULL;
43
44
0
    ret = OPENSSL_malloc(sizeof(*ret));
45
0
    if (ret == NULL)
46
0
        return NULL;
47
0
    in->base.hw->copyctx(&ret->base, &in->base);
48
49
0
    return ret;
50
0
}
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
0
{
56
0
    if (!ossl_cipher_generic_einit(ctx, key, keylen, iv, ivlen, NULL))
57
0
        return 0;
58
0
    return ossl_cipher_cbc_cts_set_ctx_params(ctx, params);
59
0
}
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
0
IMPLEMENT_generic_cipher(camellia, CAMELLIA, ecb, ECB, 0, 256, 128, 0, block)
72
0
/* ossl_camellia192ecb_functions */
73
0
IMPLEMENT_generic_cipher(camellia, CAMELLIA, ecb, ECB, 0, 192, 128, 0, block)
74
0
/* ossl_camellia128ecb_functions */
75
0
IMPLEMENT_generic_cipher(camellia, CAMELLIA, ecb, ECB, 0, 128, 128, 0, block)
76
0
/* ossl_camellia256cbc_functions */
77
0
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cbc, CBC, 0, 256, 128, 128, block)
78
0
/* ossl_camellia192cbc_functions */
79
0
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cbc, CBC, 0, 192, 128, 128, block)
80
0
/* ossl_camellia128cbc_functions */
81
0
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cbc, CBC, 0, 128, 128, 128, block)
82
0
/* ossl_camellia256ofb_functions */
83
0
IMPLEMENT_generic_cipher(camellia, CAMELLIA, ofb, OFB, 0, 256, 8, 128, stream)
84
0
/* ossl_camellia192ofb_functions */
85
0
IMPLEMENT_generic_cipher(camellia, CAMELLIA, ofb, OFB, 0, 192, 8, 128, stream)
86
0
/* ossl_camellia128ofb_functions */
87
0
IMPLEMENT_generic_cipher(camellia, CAMELLIA, ofb, OFB, 0, 128, 8, 128, stream)
88
0
/* ossl_camellia256cfb_functions */
89
0
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb, CFB, 0, 256, 8, 128, stream)
90
0
/* ossl_camellia192cfb_functions */
91
0
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb, CFB, 0, 192, 8, 128, stream)
92
0
/* ossl_camellia128cfb_functions */
93
0
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb, CFB, 0, 128, 8, 128, stream)
94
0
/* ossl_camellia256cfb1_functions */
95
0
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb1, CFB, 0, 256, 8, 128, stream)
96
0
/* ossl_camellia192cfb1_functions */
97
0
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb1, CFB, 0, 192, 8, 128, stream)
98
0
/* ossl_camellia128cfb1_functions */
99
0
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb1, CFB, 0, 128, 8, 128, stream)
100
0
/* ossl_camellia256cfb8_functions */
101
0
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb8, CFB, 0, 256, 8, 128, stream)
102
0
/* ossl_camellia192cfb8_functions */
103
0
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb8, CFB, 0, 192, 8, 128, stream)
104
0
/* ossl_camellia128cfb8_functions */
105
0
IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb8, CFB, 0, 128, 8, 128, stream)
106
0
/* ossl_camellia256ctr_functions */
107
0
IMPLEMENT_generic_cipher(camellia, CAMELLIA, ctr, CTR, 0, 256, 8, 128, stream)
108
0
/* ossl_camellia192ctr_functions */
109
0
IMPLEMENT_generic_cipher(camellia, CAMELLIA, ctr, CTR, 0, 192, 8, 128, stream)
110
0
/* 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)