37 |
|
|
38 |
|
|
39 |
/* Reference to the passphrase cache. */ |
/* Reference to the passphrase cache. */ |
40 |
extern char gpgoe_pass_cache[HASH_BUCKETS][256]; |
extern char gpgoe_pass_cache[HASH_BUCKETS][MAX_PASS_LEN]; |
41 |
|
|
42 |
|
|
43 |
DWORD hash_string (const char *str_param); |
DWORD hash_string (const char *str_param); |
45 |
/* Store the passphrase @pass in the hash table using the keyid @keyid |
/* Store the passphrase @pass in the hash table using the keyid @keyid |
46 |
as the index. */ |
as the index. */ |
47 |
static void |
static void |
48 |
passphrase_put (char ctx[HASH_BUCKETS][256], const char *keyid, const char *pass) |
passphrase_put (char ctx[HASH_BUCKETS][MAX_PASS_LEN], const char *keyid, |
49 |
|
const char *pass) |
50 |
{ |
{ |
51 |
int pos = hash_string (keyid) % HASH_BUCKETS; |
int pos = hash_string (keyid) % HASH_BUCKETS; |
52 |
int n, passlen; |
int n, passlen; |
53 |
|
|
54 |
/* We cannot store passphrase of that size. */ |
/* We cannot store passphrase of that size. */ |
55 |
passlen = strlen (pass); |
passlen = strlen (pass); |
56 |
if (passlen > 255) |
if (passlen > MAX_PASS_LEN-1) |
57 |
return; |
return; |
58 |
|
|
59 |
n = 0; |
n = 0; |
73 |
using the keyid @keyid as the index. Or NULL if there is |
using the keyid @keyid as the index. Or NULL if there is |
74 |
no stored passphrase. */ |
no stored passphrase. */ |
75 |
static const char* |
static const char* |
76 |
passphrase_get (char ctx[HASH_BUCKETS][256], const char *keyid) |
passphrase_get (char ctx[HASH_BUCKETS][MAX_PASS_LEN], const char *keyid) |
77 |
{ |
{ |
78 |
const char *item; |
const char *item; |
79 |
int pos = hash_string (keyid) % HASH_BUCKETS; |
int pos = hash_string (keyid) % HASH_BUCKETS; |