-
Notifications
You must be signed in to change notification settings - Fork 4
/
encrypt.h
67 lines (59 loc) · 1.64 KB
/
encrypt.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* encrypt.h
*
* Encryption-related definitions for user space suspend and resume
* tools.
*
* Copyright (C) 2006 Rafael J. Wysocki <[email protected]>
*
* This file is released under the GPLv2.
*
*/
#ifdef CONFIG_ENCRYPT
#include <gcrypt.h>
/* Maximum length of a passphrase, in characters */
#define PASS_SIZE 128
#define PASSBUF_SIZE (2 * PASS_SIZE)
/* Symmetric cipher used for image encryption, the size of its key and its
* block, in bytes
*/
#define IMAGE_CIPHER GCRY_CIPHER_BLOWFISH
#define KEY_SIZE 16
#define CIPHER_BLOCK 8
/* Symmetric cipher used for encrypting RSA private keys, the size of its key
* and its block, in bytes
*/
#define PK_CIPHER GCRY_CIPHER_AES
#define PK_KEY_SIZE 16
#define PK_CIPHER_BLOCK 16
/* Auxiliary constants */
#define RSA_DATA_SIZE (512+16+512+256+256+256) /* n,e,d,p,q,u */
#define KEY_DATA_SIZE 512
#define RSA_FIELDS 6
#define RSA_FIELDS_PUB 2
#define KEY_TEST_SIZE 8
#define KEY_TEST_DATA (unsigned char *)"12345678"
struct RSA_data {
char field[RSA_FIELDS][2];
unsigned short size[RSA_FIELDS];
unsigned char key_test[KEY_TEST_SIZE];
unsigned char data[RSA_DATA_SIZE];
};
struct encrypted_key {
size_t size;
unsigned char data[KEY_DATA_SIZE];
};
struct key_data {
unsigned char key[KEY_SIZE];
unsigned char ivec[CIPHER_BLOCK];
struct RSA_data rsa;
struct encrypted_key encrypted_key;
};
void read_password(char *pass_buf, int vrfy);
void encrypt_init(unsigned char *, unsigned char *, char *);
void get_random_salt(unsigned char *salt, size_t size);
#define SUSPEND_KEY_FILE_PATH "/etc/suspend.key"
#define ENCRYPT_BUF_PAGES 256
extern gcry_cipher_hd_t cipher_handle;
extern struct key_data key_data;
#endif