File: encrypt.h

package info (click to toggle)
uswsusp 0.7-1.2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 1,000 kB
  • ctags: 962
  • sloc: ansic: 6,060; xml: 755; sh: 425; makefile: 176
file content (62 lines) | stat: -rw-r--r-- 1,542 bytes parent folder | download
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
/*
 * encrypt.h
 *
 * Encryption-related definitions for user space suspend and resume
 * tools.
 *
 * Copyright (C) 2006 Rafael J. Wysocki <rjw@sisk.pl>
 *
 * This file is released under the GPLv2.
 *
 */

#ifdef CONFIG_ENCRYPT
#include <gcrypt.h>

/* Maximum length of a passphrase, in characters */
#define PASS_SIZE	128
/* 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 {
	unsigned short	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 KEY_FILE_PATH	"/etc/uswsusp.key"
#endif