| 1 | /* |
| 2 | * Copyright 2019 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 | /* Dispatch functions for CAMELLIA cipher modes ecb, cbc, ofb, cfb, ctr */ |
| 11 | |
| 12 | #include "cipher_camellia.h" |
| 13 | #include "prov/implementations.h" |
| 14 | |
| 15 | static OSSL_OP_cipher_freectx_fn camellia_freectx; |
| 16 | static OSSL_OP_cipher_dupctx_fn camellia_dupctx; |
| 17 | |
| 18 | static void camellia_freectx(void *vctx) |
| 19 | { |
| 20 | PROV_CAMELLIA_CTX *ctx = (PROV_CAMELLIA_CTX *)vctx; |
| 21 | |
| 22 | OPENSSL_clear_free(ctx, sizeof(*ctx)); |
| 23 | } |
| 24 | |
| 25 | static void *camellia_dupctx(void *ctx) |
| 26 | { |
| 27 | PROV_CAMELLIA_CTX *in = (PROV_CAMELLIA_CTX *)ctx; |
| 28 | PROV_CAMELLIA_CTX *ret = OPENSSL_malloc(sizeof(*ret)); |
| 29 | |
| 30 | if (ret == NULL) { |
| 31 | ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE); |
| 32 | return NULL; |
| 33 | } |
| 34 | in->base.hw->copyctx(&ret->base, &in->base); |
| 35 | |
| 36 | return ret; |
| 37 | } |
| 38 | |
| 39 | /* camellia256ecb_functions */ |
| 40 | IMPLEMENT_generic_cipher(camellia, CAMELLIA, ecb, ECB, 0, 256, 128, 0, block) |
| 41 | /* camellia192ecb_functions */ |
| 42 | IMPLEMENT_generic_cipher(camellia, CAMELLIA, ecb, ECB, 0, 192, 128, 0, block) |
| 43 | /* camellia128ecb_functions */ |
| 44 | IMPLEMENT_generic_cipher(camellia, CAMELLIA, ecb, ECB, 0, 128, 128, 0, block) |
| 45 | /* camellia256cbc_functions */ |
| 46 | IMPLEMENT_generic_cipher(camellia, CAMELLIA, cbc, CBC, 0, 256, 128, 128, block) |
| 47 | /* camellia192cbc_functions */ |
| 48 | IMPLEMENT_generic_cipher(camellia, CAMELLIA, cbc, CBC, 0, 192, 128, 128, block) |
| 49 | /* camellia128cbc_functions */ |
| 50 | IMPLEMENT_generic_cipher(camellia, CAMELLIA, cbc, CBC, 0, 128, 128, 128, block) |
| 51 | /* camellia256ofb_functions */ |
| 52 | IMPLEMENT_generic_cipher(camellia, CAMELLIA, ofb, OFB, 0, 256, 8, 128, stream) |
| 53 | /* camellia192ofb_functions */ |
| 54 | IMPLEMENT_generic_cipher(camellia, CAMELLIA, ofb, OFB, 0, 192, 8, 128, stream) |
| 55 | /* camellia128ofb_functions */ |
| 56 | IMPLEMENT_generic_cipher(camellia, CAMELLIA, ofb, OFB, 0, 128, 8, 128, stream) |
| 57 | /* camellia256cfb_functions */ |
| 58 | IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb, CFB, 0, 256, 8, 128, stream) |
| 59 | /* camellia192cfb_functions */ |
| 60 | IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb, CFB, 0, 192, 8, 128, stream) |
| 61 | /* camellia128cfb_functions */ |
| 62 | IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb, CFB, 0, 128, 8, 128, stream) |
| 63 | /* camellia256cfb1_functions */ |
| 64 | IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb1, CFB, 0, 256, 8, 128, stream) |
| 65 | /* camellia192cfb1_functions */ |
| 66 | IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb1, CFB, 0, 192, 8, 128, stream) |
| 67 | /* camellia128cfb1_functions */ |
| 68 | IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb1, CFB, 0, 128, 8, 128, stream) |
| 69 | /* camellia256cfb8_functions */ |
| 70 | IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb8, CFB, 0, 256, 8, 128, stream) |
| 71 | /* camellia192cfb8_functions */ |
| 72 | IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb8, CFB, 0, 192, 8, 128, stream) |
| 73 | /* camellia128cfb8_functions */ |
| 74 | IMPLEMENT_generic_cipher(camellia, CAMELLIA, cfb8, CFB, 0, 128, 8, 128, stream) |
| 75 | /* camellia256ctr_functions */ |
| 76 | IMPLEMENT_generic_cipher(camellia, CAMELLIA, ctr, CTR, 0, 256, 8, 128, stream) |
| 77 | /* camellia192ctr_functions */ |
| 78 | IMPLEMENT_generic_cipher(camellia, CAMELLIA, ctr, CTR, 0, 192, 8, 128, stream) |
| 79 | /* camellia128ctr_functions */ |
| 80 | IMPLEMENT_generic_cipher(camellia, CAMELLIA, ctr, CTR, 0, 128, 8, 128, stream) |
| 81 | |
| 82 | |