xref: /freebsd/crypto/openssl/providers/implementations/ciphers/cipher_idea.c (revision b077aed33b7b6aefca7b17ddb250cf521f938613)
1*b077aed3SPierre Pronchery /*
2*b077aed3SPierre Pronchery  * Copyright 2019-2020 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  * IDEA low level APIs are deprecated for public use, but still ok for internal
12*b077aed3SPierre Pronchery  * use where we're using them to implement the higher level EVP interface, as is
13*b077aed3SPierre Pronchery  * the case here.
14*b077aed3SPierre Pronchery  */
15*b077aed3SPierre Pronchery #include "internal/deprecated.h"
16*b077aed3SPierre Pronchery 
17*b077aed3SPierre Pronchery /* Dispatch functions for Idea cipher modes ecb, cbc, ofb, cfb */
18*b077aed3SPierre Pronchery 
19*b077aed3SPierre Pronchery #include "cipher_idea.h"
20*b077aed3SPierre Pronchery #include "prov/implementations.h"
21*b077aed3SPierre Pronchery #include "prov/providercommon.h"
22*b077aed3SPierre Pronchery 
23*b077aed3SPierre Pronchery static OSSL_FUNC_cipher_freectx_fn idea_freectx;
24*b077aed3SPierre Pronchery static OSSL_FUNC_cipher_dupctx_fn idea_dupctx;
25*b077aed3SPierre Pronchery 
idea_freectx(void * vctx)26*b077aed3SPierre Pronchery static void idea_freectx(void *vctx)
27*b077aed3SPierre Pronchery {
28*b077aed3SPierre Pronchery     PROV_IDEA_CTX *ctx = (PROV_IDEA_CTX *)vctx;
29*b077aed3SPierre Pronchery 
30*b077aed3SPierre Pronchery     ossl_cipher_generic_reset_ctx((PROV_CIPHER_CTX *)vctx);
31*b077aed3SPierre Pronchery     OPENSSL_clear_free(ctx,  sizeof(*ctx));
32*b077aed3SPierre Pronchery }
33*b077aed3SPierre Pronchery 
idea_dupctx(void * ctx)34*b077aed3SPierre Pronchery static void *idea_dupctx(void *ctx)
35*b077aed3SPierre Pronchery {
36*b077aed3SPierre Pronchery     PROV_IDEA_CTX *in = (PROV_IDEA_CTX *)ctx;
37*b077aed3SPierre Pronchery     PROV_IDEA_CTX *ret;
38*b077aed3SPierre Pronchery 
39*b077aed3SPierre Pronchery     if (!ossl_prov_is_running())
40*b077aed3SPierre Pronchery         return NULL;
41*b077aed3SPierre Pronchery 
42*b077aed3SPierre Pronchery     ret = OPENSSL_malloc(sizeof(*ret));
43*b077aed3SPierre Pronchery     if (ret == NULL) {
44*b077aed3SPierre Pronchery         ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
45*b077aed3SPierre Pronchery         return NULL;
46*b077aed3SPierre Pronchery     }
47*b077aed3SPierre Pronchery     *ret = *in;
48*b077aed3SPierre Pronchery 
49*b077aed3SPierre Pronchery     return ret;
50*b077aed3SPierre Pronchery }
51*b077aed3SPierre Pronchery 
52*b077aed3SPierre Pronchery /* ossl_idea128ecb_functions */
53*b077aed3SPierre Pronchery IMPLEMENT_generic_cipher(idea, IDEA, ecb, ECB, 0, 128, 64, 0, block)
54*b077aed3SPierre Pronchery /* ossl_idea128cbc_functions */
55*b077aed3SPierre Pronchery IMPLEMENT_generic_cipher(idea, IDEA, cbc, CBC, 0, 128, 64, 64, block)
56*b077aed3SPierre Pronchery /* ossl_idea128ofb64_functions */
57*b077aed3SPierre Pronchery IMPLEMENT_generic_cipher(idea, IDEA, ofb64, OFB, 0, 128, 8, 64, stream)
58*b077aed3SPierre Pronchery /* ossl_idea128cfb64_functions */
59*b077aed3SPierre Pronchery IMPLEMENT_generic_cipher(idea, IDEA, cfb64,  CFB, 0, 128, 8, 64, stream)
60