~ecryptfs/ecryptfs/trunk

« back to all changes in this revision

Viewing changes to src/utils/ecryptfs_add_passphrase.c

  • Committer: Dustin Kirkland
  • Date: 2009-02-13 15:57:24 UTC
  • Revision ID: kirkland@canonical.com-20090213155724-1q3qz2o0cbyimu9x
debian/ubuntu packaging

Initial checkin of the Debian/Ubuntu packaging

Signed-off-by: Dustin Kirkland <kirkland@canonical.com>

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**
2
2
 * Copyright (C) 2007 International Business Machines
3
3
 * Author(s): Michael Halcrow <mhalcrow@us.ibm.com>
4
 
 *            Dustin Kirkland <kirkland@ubuntu.com>
 
4
 *            Dustin Kirkland <kirkland@canonical.com>
5
5
 *
6
6
 * This program is free software; you can redistribute it and/or
7
7
 * modify it under the terms of the GNU General Public License as
22
22
#include <stdio.h>
23
23
#include <string.h>
24
24
#include <ecryptfs.h>
 
25
#include "config.h"
25
26
 
26
27
void usage(void)
27
28
{
28
29
        printf("Usage:\n"
29
 
               "ecryptfs-add-passphrase [--fnek]\n"
 
30
               "\n"
 
31
               "ecryptfs-add-passphrase [--fnek]"
30
32
               "or\n"
31
33
               "printf \"%%s\" \"passphrase\" | ecryptfs-add-passphrase"
32
34
               " [--fnek] -\n"
68
70
        if (passphrase == NULL ||
69
71
            strlen(passphrase) > ECRYPTFS_MAX_PASSWORD_LENGTH) {
70
72
                usage();
71
 
                rc = 1;
72
73
                goto out;
73
74
        }
74
75
        if (fnek == 1) {
75
76
                rc = ecryptfs_get_version(&version);
76
77
                if (rc!=0 || !ecryptfs_supports_filename_encryption(version)) { 
77
78
                        fprintf(stderr, "%s\n", ECRYPTFS_ERROR_FNEK_SUPPORT);
78
 
                        rc = 1;
79
79
                        goto out;
80
80
                }
81
81
        }
82
82
 
83
83
        rc = ecryptfs_read_salt_hex_from_rc(salt_hex);
84
84
        if (rc) {
 
85
                fprintf(stderr, "%s\n", ECRYPTFS_WARN_DEFAULT_SALT);
85
86
                from_hex(salt, ECRYPTFS_DEFAULT_SALT_HEX, ECRYPTFS_SALT_SIZE);
86
87
        } else
87
88
                from_hex(salt, salt_hex, ECRYPTFS_SALT_SIZE);
88
89
        if ((rc = ecryptfs_add_passphrase_key_to_keyring(auth_tok_sig_hex,
89
 
                                                         passphrase,
90
 
                                                         salt)) < 0) {
 
90
                                                         passphrase, salt))) {
91
91
                fprintf(stderr, "%s [%d]\n", ECRYPTFS_ERROR_INSERT_KEY, rc);
92
92
                fprintf(stderr, "%s\n", ECRYPTFS_INFO_CHECK_LOG);
93
93
                rc = 1;
94
94
                goto out;
95
 
        } else
96
 
                rc = 0;
 
95
        }
97
96
        auth_tok_sig_hex[ECRYPTFS_SIG_SIZE_HEX] = '\0';
98
97
        printf("Inserted auth tok with sig [%s] into the user session "
99
98
               "keyring\n", auth_tok_sig_hex);
106
105
         * been requested that we add the fnek to the keyring too
107
106
         */
108
107
        if ((rc = ecryptfs_add_passphrase_key_to_keyring(auth_tok_sig_hex,
109
 
                                 passphrase,
110
 
                                 ECRYPTFS_DEFAULT_SALT_FNEK_HEX)) < 0) {
 
108
                                 passphrase, ECRYPTFS_DEFAULT_SALT_FNEK_HEX))) {
111
109
                fprintf(stderr, "%s [%d]\n", ECRYPTFS_ERROR_INSERT_KEY, rc);
112
110
                fprintf(stderr, "%s\n", ECRYPTFS_INFO_CHECK_LOG);
113
111
                rc = 1;
114
112
                goto out;
115
 
        } else
116
 
                rc = 0;
 
113
        }
117
114
        auth_tok_sig_hex[ECRYPTFS_SIG_SIZE_HEX] = '\0';
118
115
        printf("Inserted auth tok with sig [%s] into the user session "
119
116
               "keyring\n", auth_tok_sig_hex);