~ecryptfs/ecryptfs/trunk

« back to all changes in this revision

Viewing changes to src/libecryptfs/main.c

  • Committer: Dustin Kirkland
  • Date: 2009-07-17 05:32:26 UTC
  • Revision ID: kirkland@canonical.com-20090717053226-5r04floeb2ocuq4p
  * README, configure.ac, debian/control, debian/rules,
    doc/sourceforge_webpage/README, src/libecryptfs-swig/libecryptfs.py,
    src/libecryptfs-swig/libecryptfs_wrap.c,
    src/libecryptfs/key_management.c, src/libecryptfs/libecryptfs.pc.in,
    src/libecryptfs/main.c, src/pam_ecryptfs/Makefile.am,
    src/utils/manager.c, src/utils/mount.ecryptfs.c: move build from gcrypt
    to nss (this change has been pending for some time)


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

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
#include "config.h"
23
23
#include <errno.h>
24
 
#ifdef ENABLE_NSS
25
24
#include <nss.h>
26
25
#include <pk11func.h>
27
 
#else
28
 
#include <gcrypt.h>
29
 
#endif /* #ifdef ENABLE_NSS */
30
26
#include <mntent.h>
31
27
#ifndef S_SPLINT_S
32
28
#include <stdio.h>
37
33
#include <signal.h>
38
34
#include <sys/mount.h>
39
35
#include <getopt.h>
 
36
#include <sys/types.h>
40
37
#include <keyutils.h>
41
 
#include <sys/types.h>
42
38
#include <sys/ipc.h>
43
39
#include <sys/shm.h>
44
40
#include <sys/sem.h>
77
73
 
78
74
int do_hash(char *src, int src_size, char *dst, int algo)
79
75
{
80
 
#ifdef ENABLE_NSS
81
76
        SECStatus err;
82
 
#else
83
 
        gcry_md_hd_t hd;
84
 
        gcry_error_t err = 0;
85
 
        unsigned char * hash;
86
 
        unsigned int mdlen;
87
 
#endif /* #ifdef ENABLE_NSS */
88
77
 
89
 
#ifdef ENABLE_NSS
90
78
        NSS_NoDB_Init(NULL);
91
79
        err = PK11_HashBuf(algo, (unsigned char *)dst, (unsigned char *)src,
92
80
                           src_size);
97
85
                err = -EINVAL;
98
86
                goto out;
99
87
        }
100
 
#else
101
 
        err = gcry_md_open(&hd, algo, 0);
102
 
        mdlen = gcry_md_get_algo_dlen(algo);
103
 
        if (err) {
104
 
                syslog(LOG_ERR, "Failed to open hash algo [%d]: "
105
 
                       "[%d]\n", algo, err);
106
 
                goto out;
107
 
        }
108
 
        gcry_md_write(hd, src, src_size);
109
 
        hash = gcry_md_read(hd, algo);
110
 
        memcpy(dst, hash, mdlen);
111
 
        gcry_md_close(hd);
112
 
#endif /* #ifdef ENABLE_NSS */
113
88
out:
114
89
        return (int)err;
115
90
}
133
108
        char salt_and_passphrase[ECRYPTFS_MAX_PASSPHRASE_BYTES
134
109
                                 + ECRYPTFS_SALT_SIZE];
135
110
        int passphrase_size;
136
 
#ifdef ENABLE_NSS
137
111
        int alg = SEC_OID_SHA512;
138
 
#else
139
 
        int alg = GCRY_MD_SHA512;
140
 
#endif /* #ifdef ENABLE_NSS */
141
112
        int dig_len = SHA512_DIGEST_LENGTH;
142
113
        char buf[SHA512_DIGEST_LENGTH];
143
114
        int hash_iterations = ECRYPTFS_DEFAULT_NUM_HASH_ITERATIONS;