1e1051a39Sopenharmony_ci/* 2e1051a39Sopenharmony_ci * Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved. 3e1051a39Sopenharmony_ci * 4e1051a39Sopenharmony_ci * Licensed under the Apache License 2.0 (the "License"). You may not use 5e1051a39Sopenharmony_ci * this file except in compliance with the License. You can obtain a copy 6e1051a39Sopenharmony_ci * in the file LICENSE in the source distribution or at 7e1051a39Sopenharmony_ci * https://www.openssl.org/source/license.html 8e1051a39Sopenharmony_ci */ 9e1051a39Sopenharmony_ci 10e1051a39Sopenharmony_ci/* Dispatch functions for Seed cipher modes ecb, cbc, ofb, cfb */ 11e1051a39Sopenharmony_ci 12e1051a39Sopenharmony_ci/* 13e1051a39Sopenharmony_ci * SEED low level APIs are deprecated for public use, but still ok for 14e1051a39Sopenharmony_ci * internal use. 15e1051a39Sopenharmony_ci */ 16e1051a39Sopenharmony_ci#include "internal/deprecated.h" 17e1051a39Sopenharmony_ci 18e1051a39Sopenharmony_ci#include "cipher_seed.h" 19e1051a39Sopenharmony_ci#include "prov/implementations.h" 20e1051a39Sopenharmony_ci#include "prov/providercommon.h" 21e1051a39Sopenharmony_ci 22e1051a39Sopenharmony_cistatic OSSL_FUNC_cipher_freectx_fn seed_freectx; 23e1051a39Sopenharmony_cistatic OSSL_FUNC_cipher_dupctx_fn seed_dupctx; 24e1051a39Sopenharmony_ci 25e1051a39Sopenharmony_cistatic void seed_freectx(void *vctx) 26e1051a39Sopenharmony_ci{ 27e1051a39Sopenharmony_ci PROV_SEED_CTX *ctx = (PROV_SEED_CTX *)vctx; 28e1051a39Sopenharmony_ci 29e1051a39Sopenharmony_ci ossl_cipher_generic_reset_ctx((PROV_CIPHER_CTX *)vctx); 30e1051a39Sopenharmony_ci OPENSSL_clear_free(ctx, sizeof(*ctx)); 31e1051a39Sopenharmony_ci} 32e1051a39Sopenharmony_ci 33e1051a39Sopenharmony_cistatic void *seed_dupctx(void *ctx) 34e1051a39Sopenharmony_ci{ 35e1051a39Sopenharmony_ci PROV_SEED_CTX *in = (PROV_SEED_CTX *)ctx; 36e1051a39Sopenharmony_ci PROV_SEED_CTX *ret; 37e1051a39Sopenharmony_ci 38e1051a39Sopenharmony_ci if (!ossl_prov_is_running()) 39e1051a39Sopenharmony_ci return NULL; 40e1051a39Sopenharmony_ci 41e1051a39Sopenharmony_ci ret = OPENSSL_malloc(sizeof(*ret)); 42e1051a39Sopenharmony_ci if (ret == NULL) { 43e1051a39Sopenharmony_ci ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE); 44e1051a39Sopenharmony_ci return NULL; 45e1051a39Sopenharmony_ci } 46e1051a39Sopenharmony_ci *ret = *in; 47e1051a39Sopenharmony_ci 48e1051a39Sopenharmony_ci return ret; 49e1051a39Sopenharmony_ci} 50e1051a39Sopenharmony_ci 51e1051a39Sopenharmony_ci/* ossl_seed128ecb_functions */ 52e1051a39Sopenharmony_ciIMPLEMENT_generic_cipher(seed, SEED, ecb, ECB, 0, 128, 128, 0, block) 53e1051a39Sopenharmony_ci/* ossl_seed128cbc_functions */ 54e1051a39Sopenharmony_ciIMPLEMENT_generic_cipher(seed, SEED, cbc, CBC, 0, 128, 128, 128, block) 55e1051a39Sopenharmony_ci/* ossl_seed128ofb128_functions */ 56e1051a39Sopenharmony_ciIMPLEMENT_generic_cipher(seed, SEED, ofb128, OFB, 0, 128, 8, 128, stream) 57e1051a39Sopenharmony_ci/* ossl_seed128cfb128_functions */ 58e1051a39Sopenharmony_ciIMPLEMENT_generic_cipher(seed, SEED, cfb128, CFB, 0, 128, 8, 128, stream) 59