/* * Driver for EIP97 cryptographic accelerator. * * Copyright (c) 2018 AVM GmbH * * SPDX-License-Identifier: GPL-2.0-only * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This driver is heavily based on the Mediatek driver from Ryder Lee. * */ #ifndef __EIP97_UTEST_H_ #define __EIP97_UTEST_H_ #define MAX_CHUNKS 16 struct template_scatter_attr { const u8 *data; u32 len; u32 chunks[MAX_CHUNKS]; u32 misaligns[MAX_CHUNKS]; u32 nchunks; }; struct template_raw_attr { const u8 *data; u32 len; }; enum template_dir { ENCRYPT, DECRYPT }; struct aead_template { struct template_raw_attr key; struct template_scatter_attr in; struct template_scatter_attr out; struct template_raw_attr iv; unsigned int textlen; unsigned int assoclen; unsigned int taglen; enum template_dir dir; int err_setkey; int err_setauthsize; int err_crypt; bool identical_sgs; bool sg_copy_to_buffer_fail; bool kmalloc_fail; bool dma_map_single_fail; u32 dma_map_sg_fail; bool eip97_alloc_tag_fail; bool eip97_create_cmd_descs_fail; bool eip97_create_res_descs_fail; bool sg_copy_from_buffer_fail; }; struct skcipher_template { struct template_raw_attr key; struct template_scatter_attr in; struct template_scatter_attr out; struct template_raw_attr iv; unsigned int nbytes; enum template_dir dir; int err_setkey; int err_crypt; bool identical_sgs; bool kmalloc_fail; bool sg_copy_to_buffer_fail; bool dma_map_single_fail; u32 dma_map_sg_fail; bool eip97_alloc_tag_fail; bool eip97_create_cmd_descs_fail; bool eip97_create_res_descs_fail; bool sg_copy_from_buffer_fail; }; struct ahash_template { struct template_raw_attr key; struct template_scatter_attr in; struct template_raw_attr out; unsigned int nbytes; bool hmac; int err_setkey; int err_crypt; u32 kmalloc_fail; bool sg_copy_to_buffer_fail; bool dma_map_single_fail; bool dma_map_sg_fail; bool eip97_alloc_tag_fail; bool eip97_create_cmd_descs_fail; bool eip97_create_res_descs_fail; }; struct test_template { const char *test_name; const char *cra_name; union { struct skcipher_template skcipher; struct aead_template aead; struct ahash_template ahash; } attrs; }; struct test_template *eip97_find_test(const char *cra_name); struct test_template *eip97_find_next_test(struct test_template *test); struct scatterlist *eip97_alloc_pile(struct template_scatter_attr *attr, bool copy); void eip97_free_pile(struct template_scatter_attr *attr, struct scatterlist *sg); #endif /* __EIP97_UTEST_H_ */