-
Notifications
You must be signed in to change notification settings - Fork 8
/
nvaes.h
48 lines (37 loc) · 1.27 KB
/
nvaes.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef _AES_H
#define _AES_H
#include <stdint.h>
#include <linux/ioctl.h>
#define AES_BLOCK_SIZE 16
#define AES_KEYSIZE_128 AES_BLOCK_SIZE
#define AES_KEYSIZE_256 (AES_BLOCK_SIZE * 2)
#define AES_KEYSIZE AES_KEYSIZE_128
#define TEGRA_CRYPTO_IOCTL_NEED_SSK _IOWR(0x98, 100, int)
#define TEGRA_CRYPTO_IOCTL_PROCESS_REQ _IOWR(0x98, 101, int*)
#define TEGRA_CRYPTO_CBC (1UL << 1)
struct tegra_crypt_req {
int op;
char encrypt;
char key[AES_KEYSIZE_256];
int keylen;
char iv[AES_BLOCK_SIZE];
int ivlen;
unsigned char *plaintext;
int plaintext_sz;
unsigned char *result;
};
typedef void * nvaes_ctx;
nvaes_ctx nvaes_open();
void nvaes_close(nvaes_ctx);
int nvaes_encrypt(nvaes_ctx, unsigned char *, int, unsigned char *, int, unsigned char *);
int nvaes_decrypt(nvaes_ctx, unsigned char *, int, unsigned char *, int, unsigned char *);
int nvaes_sign(nvaes_ctx, unsigned char *, int, unsigned char *);
int nvaes_use_ssk(nvaes_ctx, int);
void nvaes_set_key(nvaes_ctx, char[AES_BLOCK_SIZE]);
int nvaes_encrypt_fd(nvaes_ctx, int, int);
int nvaes_decrypt_fd(nvaes_ctx, int, int);
int nvaes_sign_fd(nvaes_ctx, int, unsigned char *);
#define NVAES_TEGRA_DEVICE "/dev/tegra-crypto"
#define NVAES_PAGE_SIZE 4096
#define NVAES_PADDED_SIZE(x) (x + AES_BLOCK_SIZE - (x % AES_BLOCK_SIZE))
#endif