diff options
author | Werner Koch <[email protected]> | 2012-02-07 13:17:33 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2012-02-07 13:17:33 +0000 |
commit | b817ae7df947093384a25797999a9aa187e20f9c (patch) | |
tree | 2c27e1f31ebc1954ce384d18874fd544e4b7b7df /agent/protect.c | |
parent | Use new status printing functions. (diff) | |
download | gnupg-b817ae7df947093384a25797999a9aa187e20f9c.tar.gz gnupg-b817ae7df947093384a25797999a9aa187e20f9c.zip |
agent: Add pin length field to the shadowed private key format.
This is not yet fully implemented. It will eventually allow to
support pinpad equipped readers which do not support variable length
pin lengths.
* agent/protect.c (parse_shadow_info): Add optional arg R_PINLEN and
parse pinlen info. Change all callers to pass NULL for it.
Diffstat (limited to 'agent/protect.c')
-rw-r--r-- | agent/protect.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/agent/protect.c b/agent/protect.c index 64af4ed8e..68e1a049f 100644 --- a/agent/protect.c +++ b/agent/protect.c @@ -1272,7 +1272,7 @@ agent_get_shadow_info (const unsigned char *shadowkey, required, NULL may be passed for them. */ gpg_error_t parse_shadow_info (const unsigned char *shadow_info, - char **r_hexsn, char **r_idstr) + char **r_hexsn, char **r_idstr, int *r_pinlen) { const unsigned char *s; size_t n; @@ -1281,6 +1281,8 @@ parse_shadow_info (const unsigned char *shadow_info, *r_hexsn = NULL; if (r_idstr) *r_idstr = NULL; + if (r_pinlen) + *r_pinlen = 0; s = shadow_info; if (*s != '(') @@ -1325,5 +1327,34 @@ parse_shadow_info (const unsigned char *shadow_info, (*r_idstr)[n] = 0; } + /* Parse the optional PINLEN. */ + n = snext (&s); + if (!n) + return 0; + + if (r_pinlen) + { + char *tmpstr = xtrymalloc (n+1); + if (!tmpstr) + { + if (r_hexsn) + { + xfree (*r_hexsn); + *r_hexsn = NULL; + } + if (r_idstr) + { + xfree (*r_idstr); + *r_idstr = NULL; + } + return gpg_error_from_syserror (); + } + memcpy (tmpstr, s, n); + tmpstr[n] = 0; + + *r_pinlen = (int)strtol (tmpstr, NULL, 10); + xfree (tmpstr); + } + return 0; } |