2 * Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
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
11 * Camellia low level APIs are deprecated for public use, but still ok for
14 #include "internal/deprecated.h"
16 /* Dispatch functions for CAMELLIA cipher modes ecb, cbc, ofb, cfb, ctr */
18 #include "cipher_camellia.h"
19 #include "prov/implementations.h"
21 static OSSL_FUNC_cipher_freectx_fn camellia_freectx;
22 static OSSL_FUNC_cipher_dupctx_fn camellia_dupctx;
24 static void camellia_freectx(void *vctx)
26 PROV_CAMELLIA_CTX *ctx = (PROV_CAMELLIA_CTX *)vctx;
28 cipher_generic_reset_ctx((PROV_CIPHER_CTX *)vctx);
29 OPENSSL_clear_free(ctx, sizeof(*ctx));
32 static void *camellia_dupctx(void *ctx)
34 PROV_CAMELLIA_CTX *in = (PROV_CAMELLIA_CTX *)ctx;
35 PROV_CAMELLIA_CTX *ret = OPENSSL_malloc(sizeof(*ret));
38 ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
41 in->base.hw->copyctx(&ret->base, &in->base);
46 /* camellia256ecb_functions */
47 IMPLEMENT_generic_cipher(camellia, CAMELLIA, ecb, ECB, 0, 256, 128, 0, block)
48 /* camellia192ecb_functions */
49 IMPLEMENT_generic_cipher(camellia, CAMELLIA, ecb, ECB, 0, 192, 128, 0, block)
50 /* camellia128ecb_functions */
51 IMPLEMENT_generic_cipher(camellia, CAMELLIA, ecb, ECB, 0, 128, 128, 0, block)
52 /* camellia256cbc_functions */
53 IMPLEMENT_generic_cipher(camellia, CAMELLIA, cbc, CBC, 0, 256, 128, 128, block)
54 /* camellia192cbc_functions */
55 IMPLEMENT_generic_cipher(camellia, CAMELLIA, cbc, CBC, 0, 192, 128, 128, block)
56 /* camellia128cbc_functions */
57 IMPLEMENT_generic_cipher(camellia, CAMELLIA, cbc, CBC, 0, 128, 128, 128, block)
58 /* camellia256ofb_functions */
59 IMPLEMENT_generic_cipher(camellia, CAMELLIA, ofb, OFB, 0, 256, 8, 128, stream)
60 /* camellia192ofb_functions */
61 IMPLEMENT_generic_cipher(camellia, CAMELLIA, ofb, OFB, 0, 192, 8, 128, stream)
62 /* camellia128ofb_functions */
63 IMPLEMENT_generic_cipher(camellia, CAMELLIA, ofb, OFB, 0, 128, 8, 128, stream)
64 /* camellia256cfb_functions */
65 IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb, CFB, 0, 256, 8, 128, stream)
66 /* camellia192cfb_functions */
67 IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb, CFB, 0, 192, 8, 128, stream)
68 /* camellia128cfb_functions */
69 IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb, CFB, 0, 128, 8, 128, stream)
70 /* camellia256cfb1_functions */
71 IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb1, CFB, 0, 256, 8, 128, stream)
72 /* camellia192cfb1_functions */
73 IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb1, CFB, 0, 192, 8, 128, stream)
74 /* camellia128cfb1_functions */
75 IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb1, CFB, 0, 128, 8, 128, stream)
76 /* camellia256cfb8_functions */
77 IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb8, CFB, 0, 256, 8, 128, stream)
78 /* camellia192cfb8_functions */
79 IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb8, CFB, 0, 192, 8, 128, stream)
80 /* camellia128cfb8_functions */
81 IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb8, CFB, 0, 128, 8, 128, stream)
82 /* camellia256ctr_functions */
83 IMPLEMENT_generic_cipher(camellia, CAMELLIA, ctr, CTR, 0, 256, 8, 128, stream)
84 /* camellia192ctr_functions */
85 IMPLEMENT_generic_cipher(camellia, CAMELLIA, ctr, CTR, 0, 192, 8, 128, stream)
86 /* camellia128ctr_functions */
87 IMPLEMENT_generic_cipher(camellia, CAMELLIA, ctr, CTR, 0, 128, 8, 128, stream)