Logo Search packages:      
Sourcecode: ecryptfs-utils version File versions

ecryptfs_insert_wrapped_passphrase_into_keyring.c

#include <stdio.h>
#include <ecryptfs.h>

void usage(void)
{
      printf("Usage:\n"
             "\n"
             "ecryptfs_insert_wrapped_passphrase_into_keyring [file] [wrapping passphrase]\n"
             "\n");
}

int main(int argc, char *argv[])
{
      char *file;
      char passphrase[ECRYPTFS_MAX_PASSWORD_LENGTH + 1];
      char *wrapping_passphrase;
      char auth_tok_sig_hex[ECRYPTFS_SIG_SIZE_HEX + 1];
      char salt[ECRYPTFS_SALT_SIZE];
      char salt_hex[ECRYPTFS_SALT_SIZE_HEX];
      int rc = 0;

      if (argc != 3) {
            usage();
            goto out;
      }
      file = argv[1];
      wrapping_passphrase = argv[2];
      rc = ecryptfs_read_salt_hex_from_rc(salt_hex);
      if (rc) {
            printf("Unable to read salt value from user's "
                   ".ecryptfsrc file; using default\n");
            from_hex(salt, ECRYPTFS_DEFAULT_SALT_HEX, ECRYPTFS_SALT_SIZE);
      } else
            from_hex(salt, salt_hex, ECRYPTFS_SALT_SIZE);
      if ((rc = ecryptfs_insert_wrapped_passphrase_into_keyring(
                 auth_tok_sig_hex, file, wrapping_passphrase, salt))) {
            printf("Error attempting to unwrap passphrase and insert "
                   "into the user session keyring; rc = [%d]. "
                   "Check the system log for more information from "
                   "libecryptfs.\n", rc);
            rc = 1;
            goto out;
      }
      auth_tok_sig_hex[ECRYPTFS_SIG_SIZE_HEX] = '\0';
      printf("Inserted auth tok with sig [%s] into the user session "
             "keyring\n", auth_tok_sig_hex);
out:
      return rc;
}

Generated by  Doxygen 1.6.0   Back to index