1ba610be9SJohn Baldwin /* 2ba610be9SJohn Baldwin * Copyright (c) 2020 Netflix, Inc 3ba610be9SJohn Baldwin * 4ba610be9SJohn Baldwin * Redistribution and use in source and binary forms, with or without 5ba610be9SJohn Baldwin * modification, are permitted provided that the following conditions 6ba610be9SJohn Baldwin * are met: 7ba610be9SJohn Baldwin * 1. Redistributions of source code must retain the above copyright 8ba610be9SJohn Baldwin * notice, this list of conditions and the following disclaimer, 9ba610be9SJohn Baldwin * without modification. 10ba610be9SJohn Baldwin * 2. Redistributions in binary form must reproduce at minimum a disclaimer 11ba610be9SJohn Baldwin * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any 12ba610be9SJohn Baldwin * redistribution must be conditioned upon including a substantially 13ba610be9SJohn Baldwin * similar Disclaimer requirement for further binary redistribution. 14ba610be9SJohn Baldwin * 15ba610be9SJohn Baldwin * NO WARRANTY 16ba610be9SJohn Baldwin * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17ba610be9SJohn Baldwin * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18ba610be9SJohn Baldwin * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY 19ba610be9SJohn Baldwin * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 20ba610be9SJohn Baldwin * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, 21ba610be9SJohn Baldwin * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22ba610be9SJohn Baldwin * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23ba610be9SJohn Baldwin * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 24ba610be9SJohn Baldwin * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25ba610be9SJohn Baldwin * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 26ba610be9SJohn Baldwin * THE POSSIBILITY OF SUCH DAMAGES. 27ba610be9SJohn Baldwin * 28ba610be9SJohn Baldwin * $FreeBSD$ 29ba610be9SJohn Baldwin */ 30ba610be9SJohn Baldwin 31ba610be9SJohn Baldwin #ifndef __OSSL_H__ 32ba610be9SJohn Baldwin #define __OSSL_H__ 33ba610be9SJohn Baldwin 34ba610be9SJohn Baldwin /* Compatibility shims. */ 35ba610be9SJohn Baldwin #define OPENSSL_cleanse explicit_bzero 36ba610be9SJohn Baldwin 3792aecd1eSJohn Baldwin struct cryptop; 3892aecd1eSJohn Baldwin struct crypto_session_params; 39197ff4c3SKornel Duleba struct ossl_softc; 40197ff4c3SKornel Duleba struct ossl_session; 4192aecd1eSJohn Baldwin 4278991a93SJohn Baldwin int ossl_chacha20_poly1305_decrypt(struct cryptop *crp, 4378991a93SJohn Baldwin const struct crypto_session_params *csp); 4478991a93SJohn Baldwin int ossl_chacha20_poly1305_encrypt(struct cryptop *crp, 4578991a93SJohn Baldwin const struct crypto_session_params *csp); 46197ff4c3SKornel Duleba void ossl_cpuid(struct ossl_softc *sc); 47197ff4c3SKornel Duleba 48197ff4c3SKornel Duleba struct ossl_softc { 49197ff4c3SKornel Duleba int32_t sc_cid; 50197ff4c3SKornel Duleba bool has_aes; 51*9a3444d9SMark Johnston bool has_aes_gcm; 52197ff4c3SKornel Duleba }; 53ba610be9SJohn Baldwin 54ba610be9SJohn Baldwin /* Needs to be big enough to hold any hash context. */ 55ba610be9SJohn Baldwin struct ossl_hash_context { 56*9a3444d9SMark Johnston uint32_t dummy[196]; 57ba610be9SJohn Baldwin } __aligned(32); 58ba610be9SJohn Baldwin 59197ff4c3SKornel Duleba struct ossl_cipher_context { 60*9a3444d9SMark Johnston uint32_t dummy[196]; 61197ff4c3SKornel Duleba } __aligned(32); 62197ff4c3SKornel Duleba 63197ff4c3SKornel Duleba struct ossl_session_hash { 64197ff4c3SKornel Duleba struct ossl_hash_context ictx; 65197ff4c3SKornel Duleba struct ossl_hash_context octx; 66197ff4c3SKornel Duleba struct auth_hash *axf; 67197ff4c3SKornel Duleba u_int mlen; 68197ff4c3SKornel Duleba }; 69197ff4c3SKornel Duleba 70197ff4c3SKornel Duleba struct ossl_session_cipher { 71197ff4c3SKornel Duleba struct ossl_cipher_context dec_ctx; 72197ff4c3SKornel Duleba struct ossl_cipher_context enc_ctx; 73197ff4c3SKornel Duleba struct ossl_cipher *cipher; 74197ff4c3SKornel Duleba }; 75197ff4c3SKornel Duleba 76197ff4c3SKornel Duleba struct ossl_session { 77197ff4c3SKornel Duleba struct ossl_session_cipher cipher; 78197ff4c3SKornel Duleba struct ossl_session_hash hash; 79197ff4c3SKornel Duleba }; 80197ff4c3SKornel Duleba 81a079e38bSJohn Baldwin extern struct auth_hash ossl_hash_poly1305; 82ba610be9SJohn Baldwin extern struct auth_hash ossl_hash_sha1; 83ba610be9SJohn Baldwin extern struct auth_hash ossl_hash_sha224; 84ba610be9SJohn Baldwin extern struct auth_hash ossl_hash_sha256; 85ba610be9SJohn Baldwin extern struct auth_hash ossl_hash_sha384; 86ba610be9SJohn Baldwin extern struct auth_hash ossl_hash_sha512; 87ba610be9SJohn Baldwin 88197ff4c3SKornel Duleba extern struct ossl_cipher ossl_cipher_aes_cbc; 89*9a3444d9SMark Johnston extern struct ossl_cipher ossl_cipher_aes_gcm; 90197ff4c3SKornel Duleba extern struct ossl_cipher ossl_cipher_chacha20; 91197ff4c3SKornel Duleba 92ba610be9SJohn Baldwin #endif /* !__OSSL_H__ */ 93