1f08c3bdfSopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 2f08c3bdfSopenharmony_ci/* 3f08c3bdfSopenharmony_ci * Copyright (c) 2018 Richard Palethorpe <rpalethorpe@suse.com> 4f08c3bdfSopenharmony_ci */ 5f08c3bdfSopenharmony_ci 6f08c3bdfSopenharmony_ci#ifndef LAPI_CRYPTOUSER_H__ 7f08c3bdfSopenharmony_ci#define LAPI_CRYPTOUSER_H__ 8f08c3bdfSopenharmony_ci 9f08c3bdfSopenharmony_ci#ifdef HAVE_LINUX_CRYPTOUSER_H 10f08c3bdfSopenharmony_ci# include <linux/cryptouser.h> 11f08c3bdfSopenharmony_ci#else 12f08c3bdfSopenharmony_ci# include <stdint.h> 13f08c3bdfSopenharmony_ci# define CRYPTO_MAX_NAME 64 14f08c3bdfSopenharmony_ci 15f08c3bdfSopenharmony_cienum { 16f08c3bdfSopenharmony_ci CRYPTO_MSG_BASE = 0x10, 17f08c3bdfSopenharmony_ci CRYPTO_MSG_NEWALG = 0x10, 18f08c3bdfSopenharmony_ci CRYPTO_MSG_DELALG, 19f08c3bdfSopenharmony_ci CRYPTO_MSG_UPDATEALG, 20f08c3bdfSopenharmony_ci CRYPTO_MSG_GETALG, 21f08c3bdfSopenharmony_ci CRYPTO_MSG_DELRNG, 22f08c3bdfSopenharmony_ci __CRYPTO_MSG_MAX 23f08c3bdfSopenharmony_ci}; 24f08c3bdfSopenharmony_ci 25f08c3bdfSopenharmony_cienum crypto_attr_type_t { 26f08c3bdfSopenharmony_ci CRYPTOCFGA_UNSPEC, 27f08c3bdfSopenharmony_ci CRYPTOCFGA_PRIORITY_VAL, /* uint32_t */ 28f08c3bdfSopenharmony_ci CRYPTOCFGA_REPORT_LARVAL, /* struct crypto_report_larval */ 29f08c3bdfSopenharmony_ci CRYPTOCFGA_REPORT_HASH, /* struct crypto_report_hash */ 30f08c3bdfSopenharmony_ci CRYPTOCFGA_REPORT_BLKCIPHER, /* struct crypto_report_blkcipher */ 31f08c3bdfSopenharmony_ci CRYPTOCFGA_REPORT_AEAD, /* struct crypto_report_aead */ 32f08c3bdfSopenharmony_ci CRYPTOCFGA_REPORT_COMPRESS, /* struct crypto_report_comp */ 33f08c3bdfSopenharmony_ci CRYPTOCFGA_REPORT_RNG, /* struct crypto_report_rng */ 34f08c3bdfSopenharmony_ci CRYPTOCFGA_REPORT_CIPHER, /* struct crypto_report_cipher */ 35f08c3bdfSopenharmony_ci CRYPTOCFGA_REPORT_AKCIPHER, /* struct crypto_report_akcipher */ 36f08c3bdfSopenharmony_ci CRYPTOCFGA_REPORT_KPP, /* struct crypto_report_kpp */ 37f08c3bdfSopenharmony_ci CRYPTOCFGA_REPORT_ACOMP, /* struct crypto_report_acomp */ 38f08c3bdfSopenharmony_ci __CRYPTOCFGA_MAX 39f08c3bdfSopenharmony_ci 40f08c3bdfSopenharmony_ci#define CRYPTOCFGA_MAX (__CRYPTOCFGA_MAX - 1) 41f08c3bdfSopenharmony_ci}; 42f08c3bdfSopenharmony_ci 43f08c3bdfSopenharmony_cistruct crypto_user_alg { 44f08c3bdfSopenharmony_ci char cru_name[CRYPTO_MAX_NAME]; 45f08c3bdfSopenharmony_ci char cru_driver_name[CRYPTO_MAX_NAME]; 46f08c3bdfSopenharmony_ci char cru_module_name[CRYPTO_MAX_NAME]; 47f08c3bdfSopenharmony_ci uint32_t cru_type; 48f08c3bdfSopenharmony_ci uint32_t cru_mask; 49f08c3bdfSopenharmony_ci uint32_t cru_refcnt; 50f08c3bdfSopenharmony_ci uint32_t cru_flags; 51f08c3bdfSopenharmony_ci}; 52f08c3bdfSopenharmony_ci 53f08c3bdfSopenharmony_cistruct crypto_report_larval { 54f08c3bdfSopenharmony_ci char type[CRYPTO_MAX_NAME]; 55f08c3bdfSopenharmony_ci}; 56f08c3bdfSopenharmony_ci 57f08c3bdfSopenharmony_cistruct crypto_report_hash { 58f08c3bdfSopenharmony_ci char type[CRYPTO_MAX_NAME]; 59f08c3bdfSopenharmony_ci unsigned int blocksize; 60f08c3bdfSopenharmony_ci unsigned int digestsize; 61f08c3bdfSopenharmony_ci}; 62f08c3bdfSopenharmony_ci 63f08c3bdfSopenharmony_cistruct crypto_report_cipher { 64f08c3bdfSopenharmony_ci char type[CRYPTO_MAX_NAME]; 65f08c3bdfSopenharmony_ci unsigned int blocksize; 66f08c3bdfSopenharmony_ci unsigned int min_keysize; 67f08c3bdfSopenharmony_ci unsigned int max_keysize; 68f08c3bdfSopenharmony_ci}; 69f08c3bdfSopenharmony_ci 70f08c3bdfSopenharmony_cistruct crypto_report_blkcipher { 71f08c3bdfSopenharmony_ci char type[CRYPTO_MAX_NAME]; 72f08c3bdfSopenharmony_ci char geniv[CRYPTO_MAX_NAME]; 73f08c3bdfSopenharmony_ci unsigned int blocksize; 74f08c3bdfSopenharmony_ci unsigned int min_keysize; 75f08c3bdfSopenharmony_ci unsigned int max_keysize; 76f08c3bdfSopenharmony_ci unsigned int ivsize; 77f08c3bdfSopenharmony_ci}; 78f08c3bdfSopenharmony_ci 79f08c3bdfSopenharmony_cistruct crypto_report_aead { 80f08c3bdfSopenharmony_ci char type[CRYPTO_MAX_NAME]; 81f08c3bdfSopenharmony_ci char geniv[CRYPTO_MAX_NAME]; 82f08c3bdfSopenharmony_ci unsigned int blocksize; 83f08c3bdfSopenharmony_ci unsigned int maxauthsize; 84f08c3bdfSopenharmony_ci unsigned int ivsize; 85f08c3bdfSopenharmony_ci}; 86f08c3bdfSopenharmony_ci 87f08c3bdfSopenharmony_cistruct crypto_report_comp { 88f08c3bdfSopenharmony_ci char type[CRYPTO_MAX_NAME]; 89f08c3bdfSopenharmony_ci}; 90f08c3bdfSopenharmony_ci 91f08c3bdfSopenharmony_cistruct crypto_report_rng { 92f08c3bdfSopenharmony_ci char type[CRYPTO_MAX_NAME]; 93f08c3bdfSopenharmony_ci unsigned int seedsize; 94f08c3bdfSopenharmony_ci}; 95f08c3bdfSopenharmony_ci 96f08c3bdfSopenharmony_cistruct crypto_report_akcipher { 97f08c3bdfSopenharmony_ci char type[CRYPTO_MAX_NAME]; 98f08c3bdfSopenharmony_ci}; 99f08c3bdfSopenharmony_ci 100f08c3bdfSopenharmony_cistruct crypto_report_kpp { 101f08c3bdfSopenharmony_ci char type[CRYPTO_MAX_NAME]; 102f08c3bdfSopenharmony_ci}; 103f08c3bdfSopenharmony_ci 104f08c3bdfSopenharmony_cistruct crypto_report_acomp { 105f08c3bdfSopenharmony_ci char type[CRYPTO_MAX_NAME]; 106f08c3bdfSopenharmony_ci}; 107f08c3bdfSopenharmony_ci 108f08c3bdfSopenharmony_ci#endif /* HAVE_LINUX_CRYPTOUSER_H */ 109f08c3bdfSopenharmony_ci 110f08c3bdfSopenharmony_ci/* These are taken from include/crypto.h in the kernel tree. They are not 111f08c3bdfSopenharmony_ci * currently included in the user API. 112f08c3bdfSopenharmony_ci */ 113f08c3bdfSopenharmony_ci#ifndef CRYPTO_MAX_ALG_NAME 114f08c3bdfSopenharmony_ci# define CRYPTO_MAX_ALG_NAME 128 115f08c3bdfSopenharmony_ci#endif 116f08c3bdfSopenharmony_ci 117f08c3bdfSopenharmony_ci#ifndef CRYPTO_ALG_TYPE_MASK 118f08c3bdfSopenharmony_ci# define CRYPTO_ALG_TYPE_MASK 0x0000000f 119f08c3bdfSopenharmony_ci#endif 120f08c3bdfSopenharmony_ci#ifndef CRYPTO_ALG_TYPE_CIPHER 121f08c3bdfSopenharmony_ci# define CRYPTO_ALG_TYPE_CIPHER 0x00000001 122f08c3bdfSopenharmony_ci#endif 123f08c3bdfSopenharmony_ci#ifndef CRYPTO_ALG_TYPE_COMPRESS 124f08c3bdfSopenharmony_ci# define CRYPTO_ALG_TYPE_COMPRESS 0x00000002 125f08c3bdfSopenharmony_ci#endif 126f08c3bdfSopenharmony_ci#ifndef CRYPTO_ALG_TYPE_AEAD 127f08c3bdfSopenharmony_ci# define CRYPTO_ALG_TYPE_AEAD 0x00000003 128f08c3bdfSopenharmony_ci#endif 129f08c3bdfSopenharmony_ci#ifndef CRYPTO_ALG_TYPE_BLKCIPHER 130f08c3bdfSopenharmony_ci# define CRYPTO_ALG_TYPE_BLKCIPHER 0x00000004 131f08c3bdfSopenharmony_ci#endif 132f08c3bdfSopenharmony_ci#ifndef CRYPTO_ALG_TYPE_ABLKCIPHER 133f08c3bdfSopenharmony_ci# define CRYPTO_ALG_TYPE_ABLKCIPHER 0x00000005 134f08c3bdfSopenharmony_ci#endif 135f08c3bdfSopenharmony_ci#ifndef CRYPTO_ALG_TYPE_SKCIPHER 136f08c3bdfSopenharmony_ci# define CRYPTO_ALG_TYPE_SKCIPHER 0x00000005 137f08c3bdfSopenharmony_ci#endif 138f08c3bdfSopenharmony_ci#ifndef CRYPTO_ALG_TYPE_GIVCIPHER 139f08c3bdfSopenharmony_ci# define CRYPTO_ALG_TYPE_GIVCIPHER 0x00000006 140f08c3bdfSopenharmony_ci#endif 141f08c3bdfSopenharmony_ci#ifndef CRYPTO_ALG_TYPE_KPP 142f08c3bdfSopenharmony_ci# define CRYPTO_ALG_TYPE_KPP 0x00000008 143f08c3bdfSopenharmony_ci#endif 144f08c3bdfSopenharmony_ci#ifndef CRYPTO_ALG_TYPE_ACOMPRESS 145f08c3bdfSopenharmony_ci# define CRYPTO_ALG_TYPE_ACOMPRESS 0x0000000a 146f08c3bdfSopenharmony_ci#endif 147f08c3bdfSopenharmony_ci#ifndef CRYPTO_ALG_TYPE_SCOMPRESS 148f08c3bdfSopenharmony_ci# define CRYPTO_ALG_TYPE_SCOMPRESS 0x0000000b 149f08c3bdfSopenharmony_ci#endif 150f08c3bdfSopenharmony_ci#ifndef CRYPTO_ALG_TYPE_RNG 151f08c3bdfSopenharmony_ci# define CRYPTO_ALG_TYPE_RNG 0x0000000c 152f08c3bdfSopenharmony_ci#endif 153f08c3bdfSopenharmony_ci#ifndef CRYPTO_ALG_TYPE_AKCIPHER 154f08c3bdfSopenharmony_ci# define CRYPTO_ALG_TYPE_AKCIPHER 0x0000000d 155f08c3bdfSopenharmony_ci#endif 156f08c3bdfSopenharmony_ci#ifndef CRYPTO_ALG_TYPE_DIGEST 157f08c3bdfSopenharmony_ci# define CRYPTO_ALG_TYPE_DIGEST 0x0000000e 158f08c3bdfSopenharmony_ci#endif 159f08c3bdfSopenharmony_ci#ifndef CRYPTO_ALG_TYPE_HASH 160f08c3bdfSopenharmony_ci# define CRYPTO_ALG_TYPE_HASH 0x0000000e 161f08c3bdfSopenharmony_ci#endif 162f08c3bdfSopenharmony_ci#ifndef CRYPTO_ALG_TYPE_SHASH 163f08c3bdfSopenharmony_ci# define CRYPTO_ALG_TYPE_SHASH 0x0000000e 164f08c3bdfSopenharmony_ci#endif 165f08c3bdfSopenharmony_ci#ifndef CRYPTO_ALG_TYPE_AHASH 166f08c3bdfSopenharmony_ci# define CRYPTO_ALG_TYPE_AHASH 0x0000000f 167f08c3bdfSopenharmony_ci#endif 168f08c3bdfSopenharmony_ci 169f08c3bdfSopenharmony_ci#ifndef CRYPTO_ALG_TYPE_HASH_MASK 170f08c3bdfSopenharmony_ci# define CRYPTO_ALG_TYPE_HASH_MASK 0x0000000e 171f08c3bdfSopenharmony_ci#endif 172f08c3bdfSopenharmony_ci#ifndef CRYPTO_ALG_TYPE_AHASH_MASK 173f08c3bdfSopenharmony_ci# define CRYPTO_ALG_TYPE_AHASH_MASK 0x0000000e 174f08c3bdfSopenharmony_ci#endif 175f08c3bdfSopenharmony_ci#ifndef CRYPTO_ALG_TYPE_BLKCIPHER_MASK 176f08c3bdfSopenharmony_ci# define CRYPTO_ALG_TYPE_BLKCIPHER_MASK 0x0000000c 177f08c3bdfSopenharmony_ci#endif 178f08c3bdfSopenharmony_ci#ifndef CRYPTO_ALG_TYPE_ACOMPRESS_MASK 179f08c3bdfSopenharmony_ci# define CRYPTO_ALG_TYPE_ACOMPRESS_MASK 0x0000000e 180f08c3bdfSopenharmony_ci#endif 181f08c3bdfSopenharmony_ci 182f08c3bdfSopenharmony_ci#endif /* LAPI_CRYPTOUSER_H__ */ 183