~colin-king/ecryptfs/ecryptfs-spelling-fixes

« back to all changes in this revision

Viewing changes to src/utils/ecryptfs_insert_wrapped_passphrase_into_keyring.c

  • Committer: Dustin Kirkland
  • Date: 2009-01-26 19:11:04 UTC
  • Revision ID: git-v1:a61c4ba37b04403749dc5d131fd930778fe3936c
remove insert wrapped passphrase changes

This work has been moved into the library.

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

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
void usage(void)
28
28
{
29
29
        printf("Usage:\n"
30
 
           "\n"
31
 
           "ecryptfs-insert-wrapped-passphrase-into-keyring [--fnek] [file]\n"
32
 
           "or\n"
33
 
           "printf \"%%s\" \"wrapping passphrase\" | "
34
 
           "ecryptfs-insert-wrapped-passphrase-into-keyring [--fnek] [file] -\n"
35
 
           "\n");
 
30
               "\n"
 
31
               "ecryptfs-insert-wrapped-passphrase-into-keyring [file]\n"
 
32
               "or\n"
 
33
               "printf \"%%s\" \"wrapping passphrase\" | "
 
34
               "ecryptfs-insert-wrapped-passphrase-into-keyring [file] -\n"
 
35
               "\n");
36
36
}
37
37
 
38
38
int main(int argc, char *argv[])
44
44
        char salt[ECRYPTFS_SALT_SIZE];
45
45
        char salt_hex[ECRYPTFS_SALT_SIZE_HEX];
46
46
        int rc = 0;
47
 
        int fnek = 0;
48
 
        uint32_t version;
49
47
 
50
48
        if (argc == 2) {
51
49
                /* interactive mode */
52
50
                wrapping_passphrase = ecryptfs_get_passphrase("Passphrase");
53
51
        } else if (argc == 3 &&
54
 
                   strlen(argv[2]) == 6 && strncmp(argv[2], "--fnek", 6) == 0) {
55
 
                /* interactive mode, plus fnek */
56
 
                wrapping_passphrase = ecryptfs_get_passphrase("Passphrase");
57
 
                fnek = 1;
58
 
        } else if (argc == 3 &&
59
52
                   strlen(argv[2]) == 1 && strncmp(argv[2], "-", 1) == 0) {
60
53
                /* stdin mode */
61
54
                wrapping_passphrase = ecryptfs_get_passphrase(NULL);
62
 
        } else if (argc == 4 &&
63
 
                   strlen(argv[2]) == 6 && strncmp(argv[2], "--fnek", 6) == 0 &&
64
 
                   strlen(argv[3]) == 1 && strncmp(argv[3], "-", 1) == 0) {
65
 
                /* stdin mode, plus fnek */
66
 
                wrapping_passphrase = ecryptfs_get_passphrase(NULL);
67
 
                fnek = 1;
 
55
        } else if (argc == 3 &&
 
56
                   (strlen(argv[2]) != 1 || strncmp(argv[2], "-", 1) != 0)) {
 
57
                /* argument mode */
 
58
                wrapping_passphrase = argv[2];
68
59
        } else {
69
60
                usage();
70
61
                goto out;
74
65
                usage();
75
66
                goto out;
76
67
        }
77
 
        if (fnek == 1) {
78
 
                rc = ecryptfs_get_version(&version);
79
 
                if (rc!=0 || !ecryptfs_supports_filename_encryption(version)) {
80
 
                        fprintf(stderr, "%s\n", ECRYPTFS_ERROR_FNEK_SUPPORT);
81
 
                        goto out;
82
 
                }
83
 
        }
84
68
 
85
69
        file = argv[1];
86
70
        rc = ecryptfs_read_salt_hex_from_rc(salt_hex);
100
84
        auth_tok_sig_hex[ECRYPTFS_SIG_SIZE_HEX] = '\0';
101
85
        printf("Inserted auth tok with sig [%s] into the user session "
102
86
               "keyring\n", auth_tok_sig_hex);
103
 
 
104
 
        if (fnek == 0) {
105
 
                goto out;
106
 
        }
107
 
 
108
 
        /* If we make it here, filename encryption is enabled, and it has
109
 
         * been requested that we add the fnek to the keyring too
110
 
         */
111
 
        if ((rc = ecryptfs_insert_wrapped_passphrase_into_keyring(
112
 
             auth_tok_sig_hex, file, wrapping_passphrase,
113
 
             ECRYPTFS_DEFAULT_SALT_FNEK_HEX))) {
114
 
                fprintf(stderr, "%s [%d]\n", ECRYPTFS_ERROR_INSERT_KEY, rc);
115
 
                fprintf(stderr, "%s\n", ECRYPTFS_INFO_CHECK_LOG);
116
 
                rc = 1;
117
 
                goto out;
118
 
        }
119
 
        auth_tok_sig_hex[ECRYPTFS_SIG_SIZE_HEX] = '\0';
120
 
        printf("Inserted auth tok with sig [%s] into the user session "
121
 
                "keyring\n", auth_tok_sig_hex);
122
 
 
123
87
out:
124
88
        return rc;
125
89
}