temp revert rk change
[firefly-linux-kernel-4.4.55.git] / drivers / misc / tegra-cryptodev.h
1 /*
2  * Copyright (c) 2010, NVIDIA Corporation.
3  *
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.
8  *
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
12  * more details.
13  *
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.
17  */
18
19 #ifndef __TEGRA_CRYPTODEV_H
20 #define __TEGRA_CRYPTODEV_H
21
22 #include <crypto/aes.h>
23
24 #include <asm-generic/ioctl.h>
25
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*)
31
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
35
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
38
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)
43
44 /* a pointer to this struct needs to be passed to:
45  * TEGRA_CRYPTO_IOCTL_PROCESS_REQ
46  */
47 struct tegra_crypt_req {
48         int op; /* e.g. TEGRA_CRYPTO_ECB */
49         bool encrypt;
50         char key[TEGRA_CRYPTO_MAX_KEY_SIZE];
51         int keylen;
52         char iv[TEGRA_CRYPTO_IV_SIZE];
53         int ivlen;
54         u8 *plaintext;
55         int plaintext_sz;
56         u8 *result;
57 };
58
59 /* pointer to this struct should be passed to:
60  * TEGRA_CRYPTO_IOCTL_SET_SEED
61  * TEGRA_CRYPTO_IOCTL_GET_RANDOM
62  */
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 */
67 };
68
69 #endif