2
* Copyright (C) 2004-2006 International Business Machines
3
* Written by Michael A. Halcrow <mhalcrow@us.ibm.com>
4
* Modified by Michael C. Thompson <mcthomps@us.ibm.com>
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License as
8
* published by the Free Software Foundation; either version 2 of the
9
* License, or (at your option) any later version.
11
* This program is distributed in the hope that it will be useful, but
12
* WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
30
void PRINT(char *fmt, ...)
36
vfprintf(stdout, fmt, args);
38
syslog(LOG_NOTICE, fmt, args);
44
* Dump hexadecimal representation of char array
49
void dump_hex(char *data, int bytes)
57
sprintf(tmp, "0x%.2x.", (unsigned char)data[i]);
62
sprintf(tmp, "0x%.2x.", (unsigned char)data[i]);
78
void dump_auth_tok(struct ecryptfs_auth_tok *auth_tok)
80
struct ecryptfs_password *password;
82
PRINT("Auth tok at mem loc [%p]:\n", auth_tok);
83
PRINT(" * instanceof = [%d]\n", auth_tok->instanceof);
84
PRINT(" * instantiated = [%d]\n", auth_tok->instantiated);
85
switch (auth_tok->instanceof) {
86
char salt[ECRYPTFS_SALT_SIZE + 1];
87
char sig[ECRYPTFS_SIG_SIZE_HEX + 1];
88
case ECRYPTFS_PASSWORD:
89
password = &(auth_tok->token.password);
90
PRINT("eCryptfs Password:\n");
91
PRINT(" * password = [%s]\n", password->password);
92
PRINT(" * password_size = [%d]\n", password->password_size);
94
dump_hex(password->salt, ECRYPTFS_SALT_SIZE);
95
PRINT(" * saltless = [%d]\n", password->saltless);
96
PRINT(" * signature = [%.*s]\n", ECRYPTFS_SIG_SIZE_HEX,
98
PRINT(" * hash algorithm = [%d]\n", password->hash_algo);
99
PRINT(" * hash iterations = [%d]\n", password->hash_iterations);
100
if (!password->session_key_encryption_key_set) {
101
PRINT("Session key encryption key not set\n");
102
goto skip_password_key;
104
PRINT(" * Session key encryption key set = [%d]\n",
105
password->session_key_encryption_key_set);
106
PRINT(" * Session key encryption key size = [0x%x]\n",
107
password->session_key_encryption_key_size);
108
PRINT(" * Key dump:\n" );
109
dump_hex(password->session_key_encryption_key,
110
password->session_key_encryption_key_size);
113
case ECRYPTFS_PRIVATE_KEY:
114
PRINT(" * signature = [%.*s]\n", ECRYPTFS_SIG_SIZE_HEX,
115
auth_tok->token.private_key.signature);
118
PRINT(" * Unrecognized instanceof\n" );
120
PRINT(" * session_key.flags = [0x%x]\n",
121
auth_tok->session_key.flags );
122
PRINT("Contents of session_key field\n");
123
if (auth_tok->session_key.flags
124
& ECRYPTFS_USERSPACE_SHOULD_TRY_TO_DECRYPT) {
125
PRINT(" * Userspace decrypt request set\n" );
127
if (auth_tok->session_key.flags
128
& ECRYPTFS_USERSPACE_SHOULD_TRY_TO_ENCRYPT) {
129
PRINT(" * Userspace encrypt request set\n" );
131
if (auth_tok->session_key.flags
132
& ECRYPTFS_CONTAINS_DECRYPTED_KEY) {
133
PRINT(" * Contains decrypted key\n" );
134
PRINT(" * session_key.decrypted_key_size = "
135
"[0x%x]\n", auth_tok->session_key.decrypted_key_size );
136
PRINT(" * Key dump:\n" );
137
dump_hex( auth_tok->session_key.decrypted_key,
138
ECRYPTFS_MAX_KEY_BYTES );
140
if (auth_tok->session_key.flags
141
& ECRYPTFS_CONTAINS_ENCRYPTED_KEY) {
142
PRINT(" * Contains encrypted key\n" );
143
PRINT(" * session_key.encrypted_key_size = "
144
"[0x%x]\n", auth_tok->session_key.encrypted_key_size );
145
PRINT(" * Key dump:\n" );
146
dump_hex( auth_tok->session_key.encrypted_key,
147
ECRYPTFS_MAX_ENCRYPTED_KEY_BYTES );