aboutsummaryrefslogtreecommitdiffstats
path: root/agent/protect.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2011-01-21 11:00:57 +0000
committerWerner Koch <[email protected]>2011-01-21 11:00:57 +0000
commit90b0ff23b7e51332592668e4034967c1aac1c593 (patch)
treea3ef4cbd4c679a954a2cceba218b54cc2e2e9be5 /agent/protect.c
parentAdd ignore file (diff)
downloadgnupg-90b0ff23b7e51332592668e4034967c1aac1c593.tar.gz
gnupg-90b0ff23b7e51332592668e4034967c1aac1c593.zip
Editorial changes and allow building with old libgcrypts.
Changed order of some conditional to make to put the special case into the true branch. Indentation changes. Minor other changes to make the ECC code more similar to the rest of our code. It builds but many sefltests still fail. Need to fix that before using it with an ECDH enabled libgcrypt. [/] 2011-01-21 Werner Koch <[email protected]> * configure.ac: Need Libgcrypt 1.4.6 due to AESWRAP. (HAVE_GCRY_PK_ECDH): Add new test. [agent/] 2011-01-21 Werner Koch <[email protected]> * cvt-openpgp.c (GCRY_PK_ECDH) [!HAVE_GCRY_PK_ECDH]: New. [include/] 2011-01-21 Werner Koch <[email protected]> * cipher.h (GCRY_PK_USAGE_CERT): Remove compatibility macros because we now require libgcrypt 1.4.6. (GCRY_PK_ECDH): Add replacement.
Diffstat (limited to '')
-rw-r--r--agent/protect.c37
1 files changed, 10 insertions, 27 deletions
diff --git a/agent/protect.c b/agent/protect.c
index d14665363..d0a5fe9e3 100644
--- a/agent/protect.c
+++ b/agent/protect.c
@@ -43,7 +43,7 @@
/* A table containing the information needed to create a protected
- private key */
+ private key. */
static struct {
const char *algo;
const char *parmlist;
@@ -428,9 +428,6 @@ agent_protect (const unsigned char *plainkey, const char *passphrase,
unsigned char *p;
gcry_md_hd_t md;
- if (opt.debug & DBG_CRYPTO_VALUE)
- log_info ("Protecting key=%s, passphrase=%s\n", plainkey, passphrase);
-
/* Create an S-expression with the protected-at timestamp. */
memcpy (timestamp_exp, "(12:protected-at15:", 19);
gnupg_get_isotime (timestamp_exp+19);
@@ -459,55 +456,41 @@ agent_protect (const unsigned char *plainkey, const char *passphrase,
for (infidx=0; protect_info[infidx].algo
&& !smatch (&s, n, protect_info[infidx].algo); infidx++)
;
- if (!protect_info[infidx].algo) {
- log_info ("Unsupported alg %d for protection\n", protect_info[infidx].algo);
+ if (!protect_info[infidx].algo)
return gpg_error (GPG_ERR_UNSUPPORTED_ALGORITHM);
- }
prot_begin = prot_end = NULL;
for (i=0; (c=protect_info[infidx].parmlist[i]); i++)
{
if (i == protect_info[infidx].prot_from)
prot_begin = s;
- if (*s != '(') {
- log_info ("Unbalanced bracket in S-expression #1\n");
+ if (*s != '(')
return gpg_error (GPG_ERR_INV_SEXP);
- }
depth++;
s++;
n = snext (&s);
- if (!n) {
- log_info ("Cannot get the length of S-expression field\n");
+ if (!n)
return gpg_error (GPG_ERR_INV_SEXP);
- }
- if (n != 1 || c != *s) {
- log_info ("Invalid length in S-expression field\n");
+ if (n != 1 || c != *s)
return gpg_error (GPG_ERR_INV_SEXP);
- }
- s += n;
+ s += n;
n = snext (&s);
- if (!n) {
- log_info ("Invalid fieled in S-expression field\n");
+ if (!n)
return gpg_error (GPG_ERR_INV_SEXP);
- }
s +=n; /* skip value */
- if (*s != ')') {
- log_info ("Unbalanced bracket in S-expression #2\n");
+ if (*s != ')')
return gpg_error (GPG_ERR_INV_SEXP);
- }
depth--;
if (i == protect_info[infidx].prot_to)
prot_end = s;
s++;
}
- if (*s != ')' || !prot_begin || !prot_end ) {
- log_info ("Unbalanced bracket in S-expression #3\n");
+ if (*s != ')' || !prot_begin || !prot_end )
return gpg_error (GPG_ERR_INV_SEXP);
- }
depth--;
hash_end = s;
s++;
- /* skip to the end of the S-exp */
+ /* Skip to the end of the S-expression. */
assert (depth == 1);
rc = sskip (&s, &depth);
if (rc)