diff options
author | Michal Ludvig <mludvig@suse.cz> | 2009-05-05 14:25:06 -0500 |
---|---|---|
committer | Frank Li <Frank.Li@freescale.com> | 2011-04-01 11:33:19 +0800 |
commit | 36f3adcc2d02375597bdc457acc98611c4fae5fd (patch) | |
tree | 7412cd55fda1e87e324fe1c9553995eaecef6b3d /include | |
parent | df02bd534a51bf62f5b61352a849bba33fb3c53e (diff) |
ENGR00112200 Add cryptodev device
Linux driver for /dev/crypto (aka CryptoDev)
See http://www.logix.cz/michal/devel/cryptodev for details.
Signed-off-by: Michal Ludvig <mludvig@suse.cz>
Signed-off-by: Rob Herring <r.herring@freescale.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/Kbuild | 1 | ||||
-rw-r--r-- | include/linux/cryptodev.h | 82 |
2 files changed, 83 insertions, 0 deletions
diff --git a/include/linux/Kbuild b/include/linux/Kbuild index b0ada6f37dd6..1ae232b5d16d 100644 --- a/include/linux/Kbuild +++ b/include/linux/Kbuild @@ -97,6 +97,7 @@ header-y += const.h header-y += cramfs_fs.h header-y += cuda.h header-y += cyclades.h +header-y += cryptodev.h header-y += cycx_cfm.h header-y += dcbnl.h header-y += dccp.h diff --git a/include/linux/cryptodev.h b/include/linux/cryptodev.h new file mode 100644 index 000000000000..0f8f6705cdc9 --- /dev/null +++ b/include/linux/cryptodev.h @@ -0,0 +1,82 @@ +/* + * Driver for /dev/crypto device (aka CryptoDev) + * + * Copyright (c) 2004 Michal Ludvig <mludvig@suse.cz>, SuSE Labs + * + * Structures and ioctl command names were taken from + * OpenBSD to preserve compatibility with their API. + * + */ + +#ifndef _CRYPTODEV_H +#define _CRYPTODEV_H + +#ifndef __KERNEL__ +#include <inttypes.h> +#endif + +#define CRYPTODEV_MINOR MISC_DYNAMIC_MINOR + +#define CRYPTO_FLAG_ECB 0x0000 +#define CRYPTO_FLAG_CBC 0x0001 +#define CRYPTO_FLAG_CFB 0x0002 +#define CRYPTO_FLAG_OFB 0x0003 +#define CRYPTO_FLAG_CTR 0x0004 +#define CRYPTO_FLAG_HMAC 0x0010 +#define CRYPTO_FLAG_MASK 0x00FF + +#define CRYPTO_CIPHER_NAME 0x0100 +#define CRYPTO_CIPHER_NAME_CBC (CRYPTO_CIPHER_NAME | CRYPTO_FLAG_CBC) +#define CRYPTO_HASH_NAME 0x0200 +#define CRYPTO_HASH_NAME_HMAC (CRYPTO_HASH_NAME | CRYPTO_FLAG_HMAC) + +/* ioctl parameter to create a session */ +struct session_op { + unsigned int cipher; /* e.g. CRYPTO_DES_CBC */ + unsigned int mac; /* e.g. CRYPTO_MD5_HMAC */ + char *alg_name; /* set cipher=CRYPTO_CIPHER_NAME + or mac=CRYPTO_HASH_NAME */ + #define MAX_ALG_NAME_LEN 128 + size_t alg_namelen; + + size_t keylen; /* cipher key */ + char *key; + int mackeylen; /* mac key */ + char *mackey; + + /* Return values */ + unsigned int blocksize; /* selected algorithm's block size */ + uint32_t ses; /* session ID */ +}; + +/* ioctl parameter to request a crypt/decrypt operation against a session */ +struct crypt_op { + uint32_t ses; /* from session_op->ses */ + #define COP_DECRYPT 0 + #define COP_ENCRYPT 1 + uint32_t op; /* ie. COP_ENCRYPT */ + uint32_t flags; /* unused */ + + size_t len; + char *src, *dst; + char *mac; + char *iv; +}; + +/* clone original filedescriptor */ +#define CRIOGET _IOWR('c', 100, uint32_t) + +/* create crypto session */ +#define CIOCGSESSION _IOWR('c', 101, struct session_op) + +/* finish crypto session */ +#define CIOCFSESSION _IOW('c', 102, uint32_t) + +/* request encryption/decryptions of a given buffer */ +#define CIOCCRYPT _IOWR('c', 103, struct crypt_op) + +/* ioctl()s for asym-crypto. Not yet supported. */ +#define CIOCKEY _IOWR('c', 104, void *) +#define CIOCASYMFEAT _IOR('c', 105, uint32_t) + +#endif /* _CRYPTODEV_H */ |