2 * Copyright (c) 2010, NVIDIA Corporation.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #ifndef __TEGRA_CRYPTODEV_H
20 #define __TEGRA_CRYPTODEV_H
22 #include <crypto/aes.h>
24 #include <asm-generic/ioctl.h>
26 /* ioctl arg = 1 if you want to use ssk. arg = 0 to use normal key */
27 #define TEGRA_CRYPTO_IOCTL_NEED_SSK _IOWR(0x98, 100, int)
28 #define TEGRA_CRYPTO_IOCTL_PROCESS_REQ _IOWR(0x98, 101, int*)
29 #define TEGRA_CRYPTO_IOCTL_SET_SEED _IOWR(0x98, 102, int*)
30 #define TEGRA_CRYPTO_IOCTL_GET_RANDOM _IOWR(0x98, 103, int*)
32 #define TEGRA_CRYPTO_MAX_KEY_SIZE AES_MAX_KEY_SIZE
33 #define TEGRA_CRYPTO_IV_SIZE AES_BLOCK_SIZE
34 #define DEFAULT_RNG_BLK_SZ 16
36 /* the seed consists of 16 bytes of key + 16 bytes of init vector */
37 #define TEGRA_CRYPTO_RNG_SEED_SIZE AES_KEYSIZE_128 + DEFAULT_RNG_BLK_SZ
39 /* encrypt/decrypt operations */
40 #define TEGRA_CRYPTO_ECB BIT(0)
41 #define TEGRA_CRYPTO_CBC BIT(1)
42 #define TEGRA_CRYPTO_RNG BIT(2)
44 /* a pointer to this struct needs to be passed to:
45 * TEGRA_CRYPTO_IOCTL_PROCESS_REQ
47 struct tegra_crypt_req {
48 int op; /* e.g. TEGRA_CRYPTO_ECB */
50 char key[TEGRA_CRYPTO_MAX_KEY_SIZE];
52 char iv[TEGRA_CRYPTO_IV_SIZE];
59 /* pointer to this struct should be passed to:
60 * TEGRA_CRYPTO_IOCTL_SET_SEED
61 * TEGRA_CRYPTO_IOCTL_GET_RANDOM
63 struct tegra_rng_req {
64 u8 seed[TEGRA_CRYPTO_RNG_SEED_SIZE];
65 u8 *rdata; /* random generated data */
66 int nbytes; /* random data length */