summaryrefslogtreecommitdiff
path: root/drivers/misc/tegra-cryptodev.h
diff options
context:
space:
mode:
authorVarun Wadekar <vwadekar@nvidia.com>2011-02-11 02:02:14 -0800
committerDan Willemsen <dwillemsen@nvidia.com>2011-11-30 21:43:03 -0800
commit41e361ff01e39494a8b4dce6664a428b22f1dfc3 (patch)
treefae8d1193decd53baa148f7f5027f5f0378ebf32 /drivers/misc/tegra-cryptodev.h
parent8051399a2fe395ef7a6344d242dff13103a3b993 (diff)
misc: tegra-cryptodev: device node to access tegra aes hw
/dev/tegra-crypto node to access tegra aes hw from the user space. currently ecb/cbc/ansi_x9.31 modes are supported Original-Change-Id: I8d9e48d4b139e9c2e26a885773fb2f792fb6ca87 Signed-off-by: Varun Wadekar <vwadekar@nvidia.com> Reviewed-on: http://git-master/r/16046 Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com> Rebase-Id: R1e3e1f059255adb13d39c4332f6cdfb3f3c8c3f0
Diffstat (limited to 'drivers/misc/tegra-cryptodev.h')
-rw-r--r--drivers/misc/tegra-cryptodev.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/drivers/misc/tegra-cryptodev.h b/drivers/misc/tegra-cryptodev.h
new file mode 100644
index 000000000000..ed62a52eca03
--- /dev/null
+++ b/drivers/misc/tegra-cryptodev.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2010, NVIDIA Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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 for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __TEGRA_CRYPTODEV_H
+#define __TEGRA_CRYPTODEV_H
+
+#include <crypto/aes.h>
+
+#include <asm-generic/ioctl.h>
+
+/* ioctl arg = 1 if you want to use ssk. arg = 0 to use normal key */
+#define TEGRA_CRYPTO_IOCTL_NEED_SSK _IOWR(0x98, 100, int)
+#define TEGRA_CRYPTO_IOCTL_PROCESS_REQ _IOWR(0x98, 101, int*)
+#define TEGRA_CRYPTO_IOCTL_SET_SEED _IOWR(0x98, 102, int*)
+#define TEGRA_CRYPTO_IOCTL_GET_RANDOM _IOWR(0x98, 103, int*)
+
+#define TEGRA_CRYPTO_MAX_KEY_SIZE AES_MAX_KEY_SIZE
+#define TEGRA_CRYPTO_IV_SIZE AES_BLOCK_SIZE
+#define DEFAULT_RNG_BLK_SZ 16
+
+/* the seed consists of 16 bytes of key + 16 bytes of init vector */
+#define TEGRA_CRYPTO_RNG_SEED_SIZE AES_KEYSIZE_128 + DEFAULT_RNG_BLK_SZ
+#define TEGRA_CRYPTO_RNG_SIZE SZ_16
+
+/* encrypt/decrypt operations */
+#define TEGRA_CRYPTO_ECB BIT(0)
+#define TEGRA_CRYPTO_CBC BIT(1)
+#define TEGRA_CRYPTO_RNG BIT(2)
+
+/* a pointer to this struct needs to be passed to:
+ * TEGRA_CRYPTO_IOCTL_PROCESS_REQ
+ */
+struct tegra_crypt_req {
+ int op; /* e.g. TEGRA_CRYPTO_ECB */
+ bool encrypt;
+ char key[TEGRA_CRYPTO_MAX_KEY_SIZE];
+ int keylen;
+ char iv[TEGRA_CRYPTO_IV_SIZE];
+ int ivlen;
+ u8 *plaintext;
+ int plaintext_sz;
+ u8 *result;
+};
+
+/* pointer to this struct should be passed to:
+ * TEGRA_CRYPTO_IOCTL_SET_SEED
+ * TEGRA_CRYPTO_IOCTL_GET_RANDOM
+ */
+struct tegra_rng_req {
+ u8 seed[TEGRA_CRYPTO_RNG_SEED_SIZE];
+ u8 *rdata; /* random generated data */
+ int nbytes; /* random data length */
+};
+
+#endif