2 * test.c: Check for expected output from generate_passphrase_sig() function
3 * Author: Tyler Hicks <tyhicks@canonical.com>
5 * Copyright (C) 2012 Canonical, Ltd.
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 #include "../../src/include/ecryptfs.h"
28 #define ECRYPTFS_MAX_KEY_HEX_BYTES (ECRYPTFS_MAX_KEY_BYTES * 2)
30 void usage(const char *name)
32 fprintf(stderr, "%s PASSPHRASE SALT_HEX EXPECTED_SIG_HEX "
33 "EXPECTED_FEKEK_HEX\n", name);
36 int main(int argc, char *argv[])
38 char sig_hex[ECRYPTFS_PASSWORD_SIG_SIZE + 1];
39 char fekek[ECRYPTFS_MAX_KEY_BYTES + 1];
40 char fekek_hex[ECRYPTFS_MAX_KEY_HEX_BYTES + 1];
41 char salt[ECRYPTFS_SALT_SIZE + 1];
45 strlen(argv[2]) != ECRYPTFS_SALT_SIZE_HEX ||
46 strlen(argv[3]) != ECRYPTFS_PASSWORD_SIG_SIZE ||
47 strlen(argv[4]) != ECRYPTFS_MAX_KEY_HEX_BYTES) {
52 memset(sig_hex, 0, ECRYPTFS_PASSWORD_SIG_SIZE + 1);
53 memset(fekek, 0, ECRYPTFS_MAX_KEY_BYTES + 1);
54 memset(fekek_hex, 0, ECRYPTFS_MAX_KEY_HEX_BYTES + 1);
55 memset(salt, 0, ECRYPTFS_SALT_SIZE + 1);
56 from_hex(salt, argv[2], ECRYPTFS_SALT_SIZE);
58 rc = generate_passphrase_sig(sig_hex, fekek, salt, argv[1]);
62 to_hex(fekek_hex, fekek, ECRYPTFS_MAX_KEY_BYTES);
63 if (strcmp(sig_hex, argv[3]) ||
64 strcmp(fekek_hex, argv[4])) {