~ecryptfs/ecryptfs/trunk

« back to all changes in this revision

Viewing changes to tests/lib/etl_add_passphrase_key_to_keyring.c

  • Committer: Tyler Hicks
  • Date: 2012-01-25 10:05:09 UTC
  • Revision ID: tyhicks@canonical.com-20120125100509-jjhslpdp3p36w9ek
* tests/lib/etl_funcs.sh:
  - created eCryptfs test library of bash functions for use in test
    cases and test harnesses
* test/etl_add_passphrase_key_to_keyring.c:
  - created a C helper program to allow bash scripts to interface to
    the libecryptfs function that adds passphrase-based keys to the
    kernel keyring
* tests/kernel/tests.rc, tests/userspace/tests.rc:
  - created a test case category files for test harnesses to source
    when running testcases of a certain category (destructive, safe,
    etc.)
* tests/run_tests.sh:
  - created a test harness to run eCryptfs test cases
* tests/kernel/miscdev-bad-count.sh,
  tests/kernel/miscdev-bad-count/test.c:
  - created test case for miscdev issue reported to mailing list
* tests/kernel/lp-885744.sh:
  - created test case for pathconf bug
* tests/new.sh:
  - created new test case template to copy from
* configure.ac, Makefile.am, tests/Makefile.am, tests/lib/Makefile.am,
  tests/kernel/Makefile.am:
  - updated and created autoconf/automake files to build the new tests
    directory

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * etl_add_passphrase_key_to_keyring: C bindings for libecryptfs's
 
3
 *                      ecryptfs_add_passphrase_key_to_keyring() function
 
4
 * Author: Tyler Hicks <tyhicks@canonical.com>
 
5
 *
 
6
 * Copyright (C) 2012 Canonical, Ltd.
 
7
 *
 
8
 * This program is free software; you can redistribute it and/or
 
9
 * modify it under the terms of the GNU General Public License
 
10
 * as published by the Free Software Foundation; either version 2
 
11
 * of the License, or (at your option) any later version.
 
12
 *
 
13
 * This program is distributed in the hope that it will be useful,
 
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
 * GNU General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU General Public License
 
19
 * along with this program; if not, write to the Free Software
 
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 
21
 * 02110-1301, USA
 
22
 */
 
23
 
 
24
#include <errno.h>
 
25
#include <stdio.h>
 
26
#include "../../src/include/ecryptfs.h"
 
27
 
 
28
int main(int argc, char *argv[])
 
29
{
 
30
        char auth_tok_sig_hex[ECRYPTFS_SIG_SIZE_HEX + 1];
 
31
        char salt[ECRYPTFS_SALT_SIZE + 1];
 
32
        int rc;
 
33
 
 
34
        if (argc != 3) {
 
35
                fprintf(stderr, "%s PASSPHRASE SALT_HEX\n", argv[0]);
 
36
                return EINVAL;
 
37
        }
 
38
 
 
39
        from_hex(salt, argv[2], ECRYPTFS_SALT_SIZE);
 
40
        rc = ecryptfs_add_passphrase_key_to_keyring(auth_tok_sig_hex, argv[1],
 
41
                                                    salt);
 
42
        if (!rc)
 
43
                printf("%s\n", auth_tok_sig_hex);
 
44
 
 
45
        return rc;
 
46
}
 
47