/* * cipherapi.h- Sigmastar * * Copyright (c) [2019~2020] SigmaStar Technology. * * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and * may be copied, distributed, and modified under those terms. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License version 2 for more details. * */ #ifndef CIPHERAPI_H # define CIPHERAPI_H #include #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) # include typedef struct crypto_ablkcipher cryptodev_crypto_blkcipher_t; typedef struct ablkcipher_request cryptodev_blkcipher_request_t; # define cryptodev_crypto_alloc_blkcipher crypto_alloc_ablkcipher # define cryptodev_crypto_blkcipher_blocksize crypto_ablkcipher_blocksize # define cryptodev_crypto_blkcipher_ivsize crypto_ablkcipher_ivsize # define cryptodev_crypto_blkcipher_alignmask crypto_ablkcipher_alignmask # define cryptodev_crypto_blkcipher_setkey crypto_ablkcipher_setkey static inline void cryptodev_crypto_free_blkcipher(cryptodev_crypto_blkcipher_t *c) { if (c) crypto_free_ablkcipher(c); } # define cryptodev_blkcipher_request_alloc ablkcipher_request_alloc # define cryptodev_blkcipher_request_set_callback ablkcipher_request_set_callback static inline void cryptodev_blkcipher_request_free(cryptodev_blkcipher_request_t *r) { if (r) ablkcipher_request_free(r); } # define cryptodev_blkcipher_request_set_crypt ablkcipher_request_set_crypt # define cryptodev_crypto_blkcipher_encrypt crypto_ablkcipher_encrypt # define cryptodev_crypto_blkcipher_decrypt crypto_ablkcipher_decrypt # define cryptodev_crypto_blkcipher_tfm crypto_ablkcipher_tfm #else #include typedef struct crypto_skcipher cryptodev_crypto_blkcipher_t; typedef struct skcipher_request cryptodev_blkcipher_request_t; # define cryptodev_crypto_alloc_blkcipher crypto_alloc_skcipher # define cryptodev_crypto_blkcipher_blocksize crypto_skcipher_blocksize # define cryptodev_crypto_blkcipher_ivsize crypto_skcipher_ivsize # define cryptodev_crypto_blkcipher_alignmask crypto_skcipher_alignmask # define cryptodev_crypto_blkcipher_setkey crypto_skcipher_setkey # define cryptodev_crypto_free_blkcipher crypto_free_skcipher # define cryptodev_blkcipher_request_alloc skcipher_request_alloc # define cryptodev_blkcipher_request_set_callback skcipher_request_set_callback # define cryptodev_blkcipher_request_free skcipher_request_free # define cryptodev_blkcipher_request_set_crypt skcipher_request_set_crypt # define cryptodev_crypto_blkcipher_encrypt crypto_skcipher_encrypt # define cryptodev_crypto_blkcipher_decrypt crypto_skcipher_decrypt # define cryptodev_crypto_blkcipher_tfm crypto_skcipher_tfm #endif #endif