1 1.1 christos /* 2 1.1 christos * Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved. 3 1.1 christos * 4 1.1 christos * Licensed under the Apache License 2.0 (the "License"). You may not use 5 1.1 christos * this file except in compliance with the License. You can obtain a copy 6 1.1 christos * in the file LICENSE in the source distribution or at 7 1.1 christos * https://www.openssl.org/source/license.html 8 1.1 christos */ 9 1.1 christos 10 1.1 christos /* Dispatch functions for ARIA cipher modes ecb, cbc, ofb, cfb, ctr */ 11 1.1 christos 12 1.1 christos #include "cipher_aria.h" 13 1.1 christos #include "prov/implementations.h" 14 1.1 christos #include "prov/providercommon.h" 15 1.1 christos 16 1.1 christos static OSSL_FUNC_cipher_freectx_fn aria_freectx; 17 1.1 christos static OSSL_FUNC_cipher_dupctx_fn aria_dupctx; 18 1.1 christos 19 1.1 christos static void aria_freectx(void *vctx) 20 1.1 christos { 21 1.1 christos PROV_ARIA_CTX *ctx = (PROV_ARIA_CTX *)vctx; 22 1.1 christos 23 1.1 christos ossl_cipher_generic_reset_ctx((PROV_CIPHER_CTX *)vctx); 24 1.1.1.2 christos OPENSSL_clear_free(ctx, sizeof(*ctx)); 25 1.1 christos } 26 1.1 christos 27 1.1 christos static void *aria_dupctx(void *ctx) 28 1.1 christos { 29 1.1 christos PROV_ARIA_CTX *in = (PROV_ARIA_CTX *)ctx; 30 1.1 christos PROV_ARIA_CTX *ret; 31 1.1 christos 32 1.1 christos if (!ossl_prov_is_running()) 33 1.1 christos return NULL; 34 1.1 christos 35 1.1 christos ret = OPENSSL_malloc(sizeof(*ret)); 36 1.1 christos if (ret == NULL) 37 1.1 christos return NULL; 38 1.1 christos in->base.hw->copyctx(&ret->base, &in->base); 39 1.1 christos 40 1.1 christos return ret; 41 1.1 christos } 42 1.1 christos 43 1.1 christos /* ossl_aria256ecb_functions */ 44 1.1 christos IMPLEMENT_generic_cipher(aria, ARIA, ecb, ECB, 0, 256, 128, 0, block) 45 1.1 christos /* ossl_aria192ecb_functions */ 46 1.1 christos IMPLEMENT_generic_cipher(aria, ARIA, ecb, ECB, 0, 192, 128, 0, block) 47 1.1 christos /* ossl_aria128ecb_functions */ 48 1.1 christos IMPLEMENT_generic_cipher(aria, ARIA, ecb, ECB, 0, 128, 128, 0, block) 49 1.1 christos /* ossl_aria256cbc_functions */ 50 1.1 christos IMPLEMENT_generic_cipher(aria, ARIA, cbc, CBC, 0, 256, 128, 128, block) 51 1.1 christos /* ossl_aria192cbc_functions */ 52 1.1 christos IMPLEMENT_generic_cipher(aria, ARIA, cbc, CBC, 0, 192, 128, 128, block) 53 1.1 christos /* ossl_aria128cbc_functions */ 54 1.1 christos IMPLEMENT_generic_cipher(aria, ARIA, cbc, CBC, 0, 128, 128, 128, block) 55 1.1 christos /* ossl_aria256ofb_functions */ 56 1.1 christos IMPLEMENT_generic_cipher(aria, ARIA, ofb, OFB, 0, 256, 8, 128, stream) 57 1.1 christos /* ossl_aria192ofb_functions */ 58 1.1 christos IMPLEMENT_generic_cipher(aria, ARIA, ofb, OFB, 0, 192, 8, 128, stream) 59 1.1 christos /* ossl_aria128ofb_functions */ 60 1.1 christos IMPLEMENT_generic_cipher(aria, ARIA, ofb, OFB, 0, 128, 8, 128, stream) 61 1.1 christos /* ossl_aria256cfb_functions */ 62 1.1.1.2 christos IMPLEMENT_generic_cipher(aria, ARIA, cfb, CFB, 0, 256, 8, 128, stream) 63 1.1 christos /* ossl_aria192cfb_functions */ 64 1.1.1.2 christos IMPLEMENT_generic_cipher(aria, ARIA, cfb, CFB, 0, 192, 8, 128, stream) 65 1.1 christos /* ossl_aria128cfb_functions */ 66 1.1.1.2 christos IMPLEMENT_generic_cipher(aria, ARIA, cfb, CFB, 0, 128, 8, 128, stream) 67 1.1 christos /* ossl_aria256cfb1_functions */ 68 1.1 christos IMPLEMENT_generic_cipher(aria, ARIA, cfb1, CFB, 0, 256, 8, 128, stream) 69 1.1 christos /* ossl_aria192cfb1_functions */ 70 1.1 christos IMPLEMENT_generic_cipher(aria, ARIA, cfb1, CFB, 0, 192, 8, 128, stream) 71 1.1 christos /* ossl_aria128cfb1_functions */ 72 1.1 christos IMPLEMENT_generic_cipher(aria, ARIA, cfb1, CFB, 0, 128, 8, 128, stream) 73 1.1 christos /* ossl_aria256cfb8_functions */ 74 1.1 christos IMPLEMENT_generic_cipher(aria, ARIA, cfb8, CFB, 0, 256, 8, 128, stream) 75 1.1 christos /* ossl_aria192cfb8_functions */ 76 1.1 christos IMPLEMENT_generic_cipher(aria, ARIA, cfb8, CFB, 0, 192, 8, 128, stream) 77 1.1 christos /* ossl_aria128cfb8_functions */ 78 1.1 christos IMPLEMENT_generic_cipher(aria, ARIA, cfb8, CFB, 0, 128, 8, 128, stream) 79 1.1 christos /* ossl_aria256ctr_functions */ 80 1.1 christos IMPLEMENT_generic_cipher(aria, ARIA, ctr, CTR, 0, 256, 8, 128, stream) 81 1.1 christos /* ossl_aria192ctr_functions */ 82 1.1 christos IMPLEMENT_generic_cipher(aria, ARIA, ctr, CTR, 0, 192, 8, 128, stream) 83 1.1 christos /* ossl_aria128ctr_functions */ 84 1.1 christos IMPLEMENT_generic_cipher(aria, ARIA, ctr, CTR, 0, 128, 8, 128, stream) 85