1*b077aed3SPierre Pronchery /*
2*b077aed3SPierre Pronchery * Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved.
3*b077aed3SPierre Pronchery *
4*b077aed3SPierre Pronchery * Licensed under the Apache License 2.0 (the "License"). You may not use
5*b077aed3SPierre Pronchery * this file except in compliance with the License. You can obtain a copy
6*b077aed3SPierre Pronchery * in the file LICENSE in the source distribution or at
7*b077aed3SPierre Pronchery * https://www.openssl.org/source/license.html
8*b077aed3SPierre Pronchery */
9*b077aed3SPierre Pronchery
10*b077aed3SPierre Pronchery /*
11*b077aed3SPierre Pronchery * Camellia low level APIs are deprecated for public use, but still ok for
12*b077aed3SPierre Pronchery * internal use.
13*b077aed3SPierre Pronchery */
14*b077aed3SPierre Pronchery #include "internal/deprecated.h"
15*b077aed3SPierre Pronchery
16*b077aed3SPierre Pronchery /* Dispatch functions for CAMELLIA cipher modes ecb, cbc, ofb, cfb, ctr */
17*b077aed3SPierre Pronchery
18*b077aed3SPierre Pronchery #include "cipher_camellia.h"
19*b077aed3SPierre Pronchery #include "prov/implementations.h"
20*b077aed3SPierre Pronchery #include "prov/providercommon.h"
21*b077aed3SPierre Pronchery
22*b077aed3SPierre Pronchery static OSSL_FUNC_cipher_freectx_fn camellia_freectx;
23*b077aed3SPierre Pronchery static OSSL_FUNC_cipher_dupctx_fn camellia_dupctx;
24*b077aed3SPierre Pronchery
camellia_freectx(void * vctx)25*b077aed3SPierre Pronchery static void camellia_freectx(void *vctx)
26*b077aed3SPierre Pronchery {
27*b077aed3SPierre Pronchery PROV_CAMELLIA_CTX *ctx = (PROV_CAMELLIA_CTX *)vctx;
28*b077aed3SPierre Pronchery
29*b077aed3SPierre Pronchery ossl_cipher_generic_reset_ctx((PROV_CIPHER_CTX *)vctx);
30*b077aed3SPierre Pronchery OPENSSL_clear_free(ctx, sizeof(*ctx));
31*b077aed3SPierre Pronchery }
32*b077aed3SPierre Pronchery
camellia_dupctx(void * ctx)33*b077aed3SPierre Pronchery static void *camellia_dupctx(void *ctx)
34*b077aed3SPierre Pronchery {
35*b077aed3SPierre Pronchery PROV_CAMELLIA_CTX *in = (PROV_CAMELLIA_CTX *)ctx;
36*b077aed3SPierre Pronchery PROV_CAMELLIA_CTX *ret;
37*b077aed3SPierre Pronchery
38*b077aed3SPierre Pronchery if (!ossl_prov_is_running())
39*b077aed3SPierre Pronchery return NULL;
40*b077aed3SPierre Pronchery
41*b077aed3SPierre Pronchery ret = OPENSSL_malloc(sizeof(*ret));
42*b077aed3SPierre Pronchery if (ret == NULL) {
43*b077aed3SPierre Pronchery ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
44*b077aed3SPierre Pronchery return NULL;
45*b077aed3SPierre Pronchery }
46*b077aed3SPierre Pronchery in->base.hw->copyctx(&ret->base, &in->base);
47*b077aed3SPierre Pronchery
48*b077aed3SPierre Pronchery return ret;
49*b077aed3SPierre Pronchery }
50*b077aed3SPierre Pronchery
51*b077aed3SPierre Pronchery /* ossl_camellia256ecb_functions */
52*b077aed3SPierre Pronchery IMPLEMENT_generic_cipher(camellia, CAMELLIA, ecb, ECB, 0, 256, 128, 0, block)
53*b077aed3SPierre Pronchery /* ossl_camellia192ecb_functions */
54*b077aed3SPierre Pronchery IMPLEMENT_generic_cipher(camellia, CAMELLIA, ecb, ECB, 0, 192, 128, 0, block)
55*b077aed3SPierre Pronchery /* ossl_camellia128ecb_functions */
56*b077aed3SPierre Pronchery IMPLEMENT_generic_cipher(camellia, CAMELLIA, ecb, ECB, 0, 128, 128, 0, block)
57*b077aed3SPierre Pronchery /* ossl_camellia256cbc_functions */
58*b077aed3SPierre Pronchery IMPLEMENT_generic_cipher(camellia, CAMELLIA, cbc, CBC, 0, 256, 128, 128, block)
59*b077aed3SPierre Pronchery /* ossl_camellia192cbc_functions */
60*b077aed3SPierre Pronchery IMPLEMENT_generic_cipher(camellia, CAMELLIA, cbc, CBC, 0, 192, 128, 128, block)
61*b077aed3SPierre Pronchery /* ossl_camellia128cbc_functions */
62*b077aed3SPierre Pronchery IMPLEMENT_generic_cipher(camellia, CAMELLIA, cbc, CBC, 0, 128, 128, 128, block)
63*b077aed3SPierre Pronchery /* ossl_camellia256ofb_functions */
64*b077aed3SPierre Pronchery IMPLEMENT_generic_cipher(camellia, CAMELLIA, ofb, OFB, 0, 256, 8, 128, stream)
65*b077aed3SPierre Pronchery /* ossl_camellia192ofb_functions */
66*b077aed3SPierre Pronchery IMPLEMENT_generic_cipher(camellia, CAMELLIA, ofb, OFB, 0, 192, 8, 128, stream)
67*b077aed3SPierre Pronchery /* ossl_camellia128ofb_functions */
68*b077aed3SPierre Pronchery IMPLEMENT_generic_cipher(camellia, CAMELLIA, ofb, OFB, 0, 128, 8, 128, stream)
69*b077aed3SPierre Pronchery /* ossl_camellia256cfb_functions */
70*b077aed3SPierre Pronchery IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb, CFB, 0, 256, 8, 128, stream)
71*b077aed3SPierre Pronchery /* ossl_camellia192cfb_functions */
72*b077aed3SPierre Pronchery IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb, CFB, 0, 192, 8, 128, stream)
73*b077aed3SPierre Pronchery /* ossl_camellia128cfb_functions */
74*b077aed3SPierre Pronchery IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb, CFB, 0, 128, 8, 128, stream)
75*b077aed3SPierre Pronchery /* ossl_camellia256cfb1_functions */
76*b077aed3SPierre Pronchery IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb1, CFB, 0, 256, 8, 128, stream)
77*b077aed3SPierre Pronchery /* ossl_camellia192cfb1_functions */
78*b077aed3SPierre Pronchery IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb1, CFB, 0, 192, 8, 128, stream)
79*b077aed3SPierre Pronchery /* ossl_camellia128cfb1_functions */
80*b077aed3SPierre Pronchery IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb1, CFB, 0, 128, 8, 128, stream)
81*b077aed3SPierre Pronchery /* ossl_camellia256cfb8_functions */
82*b077aed3SPierre Pronchery IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb8, CFB, 0, 256, 8, 128, stream)
83*b077aed3SPierre Pronchery /* ossl_camellia192cfb8_functions */
84*b077aed3SPierre Pronchery IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb8, CFB, 0, 192, 8, 128, stream)
85*b077aed3SPierre Pronchery /* ossl_camellia128cfb8_functions */
86*b077aed3SPierre Pronchery IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb8, CFB, 0, 128, 8, 128, stream)
87*b077aed3SPierre Pronchery /* ossl_camellia256ctr_functions */
88*b077aed3SPierre Pronchery IMPLEMENT_generic_cipher(camellia, CAMELLIA, ctr, CTR, 0, 256, 8, 128, stream)
89*b077aed3SPierre Pronchery /* ossl_camellia192ctr_functions */
90*b077aed3SPierre Pronchery IMPLEMENT_generic_cipher(camellia, CAMELLIA, ctr, CTR, 0, 192, 8, 128, stream)
91*b077aed3SPierre Pronchery /* ossl_camellia128ctr_functions */
92*b077aed3SPierre Pronchery IMPLEMENT_generic_cipher(camellia, CAMELLIA, ctr, CTR, 0, 128, 8, 128, stream)
93*b077aed3SPierre Pronchery
94*b077aed3SPierre Pronchery #include "cipher_camellia_cts.inc"
95