1197ff4c3SKornel Duleba /*- 24d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 3197ff4c3SKornel Duleba * 4197ff4c3SKornel Duleba * Copyright (c) 2021 Stormshield. 5197ff4c3SKornel Duleba * Copyright (c) 2021 Semihalf. 6197ff4c3SKornel Duleba * 7197ff4c3SKornel Duleba * Redistribution and use in source and binary forms, with or without 8197ff4c3SKornel Duleba * modification, are permitted provided that the following conditions 9197ff4c3SKornel Duleba * are met: 10197ff4c3SKornel Duleba * 1. Redistributions of source code must retain the above copyright 11197ff4c3SKornel Duleba * notice, this list of conditions and the following disclaimer. 12197ff4c3SKornel Duleba * 2. Redistributions in binary form must reproduce the above copyright 13197ff4c3SKornel Duleba * notice, this list of conditions and the following disclaimer in the 14197ff4c3SKornel Duleba * documentation and/or other materials provided with the distribution. 15197ff4c3SKornel Duleba * 16197ff4c3SKornel Duleba * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17197ff4c3SKornel Duleba * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18197ff4c3SKornel Duleba * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19197ff4c3SKornel Duleba * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20197ff4c3SKornel Duleba * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21197ff4c3SKornel Duleba * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22197ff4c3SKornel Duleba * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23197ff4c3SKornel Duleba * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24197ff4c3SKornel Duleba * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25197ff4c3SKornel Duleba * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26197ff4c3SKornel Duleba */ 27197ff4c3SKornel Duleba 28197ff4c3SKornel Duleba #ifndef __OSSL_CIPHER_H__ 29197ff4c3SKornel Duleba #define __OSSL_CIPHER_H__ 30197ff4c3SKornel Duleba 31*44f8e1e8SMark Johnston #include <sys/types.h> 32*44f8e1e8SMark Johnston #include <crypto/rijndael/rijndael.h> 33*44f8e1e8SMark Johnston 34197ff4c3SKornel Duleba struct ossl_session_cipher; 35197ff4c3SKornel Duleba struct cryptop; 36197ff4c3SKornel Duleba struct crypto_session_params; 37197ff4c3SKornel Duleba 38197ff4c3SKornel Duleba typedef int (ossl_cipher_setkey_t)(const unsigned char*, int, void*); 39197ff4c3SKornel Duleba typedef int (ossl_cipher_process_t)(struct ossl_session_cipher*, struct cryptop*, 40197ff4c3SKornel Duleba const struct crypto_session_params*); 41197ff4c3SKornel Duleba typedef void (ossl_cipher_encrypt_t)(const unsigned char*, unsigned char*, size_t, 42197ff4c3SKornel Duleba const void*, unsigned char*, int); 43197ff4c3SKornel Duleba 44197ff4c3SKornel Duleba ossl_cipher_encrypt_t ossl_aes_cbc_encrypt; 45197ff4c3SKornel Duleba 46197ff4c3SKornel Duleba struct ossl_cipher { 47197ff4c3SKornel Duleba int type; 48197ff4c3SKornel Duleba uint16_t blocksize; 49197ff4c3SKornel Duleba uint16_t ivsize; 50197ff4c3SKornel Duleba 51197ff4c3SKornel Duleba ossl_cipher_setkey_t *set_encrypt_key; 52197ff4c3SKornel Duleba ossl_cipher_setkey_t *set_decrypt_key; 53197ff4c3SKornel Duleba ossl_cipher_process_t *process; 54197ff4c3SKornel Duleba }; 55197ff4c3SKornel Duleba 56*44f8e1e8SMark Johnston struct ossl_aes_keysched { 57*44f8e1e8SMark Johnston uint32_t ks[4 * (RIJNDAEL_MAXNR + 1)]; 58*44f8e1e8SMark Johnston int rounds; 59*44f8e1e8SMark Johnston }; 60*44f8e1e8SMark Johnston 61197ff4c3SKornel Duleba #endif 62