mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-23 10:29:58 +01:00
scd:p15: Prepare AODF parsing for other authentication types.
* scd/app-p15.c (auth_type_t): New. (struct aodf_object_s): Add field auth_type. (read_ef_aodf): Distinguish between pin and authkey types. Include the authtype in the verbose mode diags. -- Note that the bulk of changes are just indentation changes. There should be no functional change. Signed-off-by: Werner Koch <wk@gnupg.org> (cherry picked from commit e387cc97c82313457e4f79729a137e5871891bc1)
This commit is contained in:
parent
80cf64c651
commit
29fd805818
131
scd/app-p15.c
131
scd/app-p15.c
@ -156,6 +156,14 @@ typedef enum
|
|||||||
PIN_TYPE_ISO9564_1 = 4
|
PIN_TYPE_ISO9564_1 = 4
|
||||||
} pin_type_t;
|
} pin_type_t;
|
||||||
|
|
||||||
|
/* The AuthenticationTypes as defined in pkcs#15 v1.1 (6.8.1) */
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
AUTH_TYPE_PIN = -1,
|
||||||
|
AUTH_TYPE_BIOMETRIC = 0,
|
||||||
|
AUTH_TYPE_AUTHKEY = 1,
|
||||||
|
AUTH_TYPE_EXTERNAL = 2,
|
||||||
|
} auth_type_t;
|
||||||
|
|
||||||
/* A bit array with for the key usage flags from the
|
/* A bit array with for the key usage flags from the
|
||||||
commonKeyAttributes. */
|
commonKeyAttributes. */
|
||||||
@ -376,6 +384,11 @@ struct aodf_object_s
|
|||||||
/* The file ID of this AODF. */
|
/* The file ID of this AODF. */
|
||||||
unsigned short fid;
|
unsigned short fid;
|
||||||
|
|
||||||
|
/* The type of this authentication object. */
|
||||||
|
auth_type_t auth_type;
|
||||||
|
|
||||||
|
/* Info used for AUTH_TYPE_PIN: */
|
||||||
|
|
||||||
/* The PIN Flags. */
|
/* The PIN Flags. */
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
@ -423,6 +436,9 @@ struct aodf_object_s
|
|||||||
may be NULL. Malloced.*/
|
may be NULL. Malloced.*/
|
||||||
size_t pathlen;
|
size_t pathlen;
|
||||||
unsigned short *path;
|
unsigned short *path;
|
||||||
|
|
||||||
|
/* Info used for AUTH_TYPE_AUTHKEY: */
|
||||||
|
|
||||||
};
|
};
|
||||||
typedef struct aodf_object_s *aodf_object_t;
|
typedef struct aodf_object_s *aodf_object_t;
|
||||||
|
|
||||||
@ -2638,37 +2654,46 @@ read_ef_cdf (app_t app, unsigned short fid, int cdftype, cdf_object_t *result)
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
SEQUENCE {
|
* SEQUENCE {
|
||||||
SEQUENCE { -- CommonObjectAttributes
|
* SEQUENCE { -- CommonObjectAttributes
|
||||||
UTF8String 'specific PIN for DS'
|
* UTF8String 'specific PIN for DS'
|
||||||
BIT STRING 0 unused bits
|
* BIT STRING 0 unused bits
|
||||||
'00000011'B
|
* '00000011'B
|
||||||
}
|
* }
|
||||||
SEQUENCE { -- CommonAuthenticationObjectAttributes
|
* SEQUENCE { -- CommonAuthenticationObjectAttributes
|
||||||
OCTET STRING
|
* OCTET STRING
|
||||||
07 -- iD
|
* 07 -- iD
|
||||||
}
|
* }
|
||||||
|
*
|
||||||
[1] { -- typeAttributes
|
* [1] { -- typeAttributes
|
||||||
SEQUENCE { -- PinAttributes
|
* SEQUENCE { -- PinAttributes
|
||||||
BIT STRING 0 unused bits
|
* BIT STRING 0 unused bits
|
||||||
'0000100000110010'B -- local,initialized,needs-padding
|
* '0000100000110010'B -- local,initialized,needs-padding
|
||||||
-- exchangeRefData
|
* -- exchangeRefData
|
||||||
ENUMERATED 1 -- ascii-numeric
|
* ENUMERATED 1 -- ascii-numeric
|
||||||
INTEGER 6 -- minLength
|
* INTEGER 6 -- minLength
|
||||||
INTEGER 6 -- storedLength
|
* INTEGER 6 -- storedLength
|
||||||
INTEGER 8 -- maxLength
|
* INTEGER 8 -- maxLength
|
||||||
[0]
|
* [0]
|
||||||
02 -- pinReference
|
* 02 -- pinReference
|
||||||
GeneralizedTime 19/04/2002 12:12 GMT -- lastPinChange
|
* GeneralizedTime 19/04/2002 12:12 GMT -- lastPinChange
|
||||||
SEQUENCE {
|
* SEQUENCE {
|
||||||
OCTET STRING
|
* OCTET STRING
|
||||||
3F 00 40 16 -- path to DF of PIN
|
* 3F 00 40 16 -- path to DF of PIN
|
||||||
}
|
* }
|
||||||
}
|
* }
|
||||||
}
|
* }
|
||||||
}
|
* }
|
||||||
|
*
|
||||||
|
* Or for an authKey:
|
||||||
|
*
|
||||||
|
* [1] { -- typeAttributes
|
||||||
|
* SEQUENCE { -- AuthKeyAttributes
|
||||||
|
* BOOLEAN TRUE -- derivedKey
|
||||||
|
* OCTET STRING 02 -- authKeyId
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }
|
||||||
*/
|
*/
|
||||||
/* Read and parse an Authentication Object Directory File identified
|
/* Read and parse an Authentication Object Directory File identified
|
||||||
by FID. On success a newlist of AODF objects gets stored at RESULT
|
by FID. On success a newlist of AODF objects gets stored at RESULT
|
||||||
@ -2705,6 +2730,7 @@ read_ef_aodf (app_t app, unsigned short fid, aodf_object_t *result)
|
|||||||
size_t nn;
|
size_t nn;
|
||||||
int where;
|
int where;
|
||||||
const char *errstr = NULL;
|
const char *errstr = NULL;
|
||||||
|
auth_type_t auth_type;
|
||||||
aodf_object_t aodf = NULL;
|
aodf_object_t aodf = NULL;
|
||||||
unsigned long ul;
|
unsigned long ul;
|
||||||
const char *s;
|
const char *s;
|
||||||
@ -2717,13 +2743,14 @@ read_ef_aodf (app_t app, unsigned short fid, aodf_object_t *result)
|
|||||||
else if (objlen > n)
|
else if (objlen > n)
|
||||||
err = gpg_error (GPG_ERR_INV_OBJ);
|
err = gpg_error (GPG_ERR_INV_OBJ);
|
||||||
else if (class == CLASS_UNIVERSAL && tag == TAG_SEQUENCE)
|
else if (class == CLASS_UNIVERSAL && tag == TAG_SEQUENCE)
|
||||||
; /* PinAttributes */
|
auth_type = AUTH_TYPE_PIN; /* PinAttributes */
|
||||||
|
else if (class == CLASS_CONTEXT && tag == 1 )
|
||||||
|
auth_type = AUTH_TYPE_AUTHKEY; /* AuthKeyAttributes */
|
||||||
else if (class == CLASS_CONTEXT)
|
else if (class == CLASS_CONTEXT)
|
||||||
{
|
{
|
||||||
switch (tag)
|
switch (tag)
|
||||||
{
|
{
|
||||||
case 0: errstr = "biometric auth types are not supported"; break;
|
case 0: errstr = "biometric auth types are not supported"; break;
|
||||||
case 1: errstr = "authKey auth types are not supported"; break;
|
|
||||||
case 2: errstr = "external auth type are not supported"; break;
|
case 2: errstr = "external auth type are not supported"; break;
|
||||||
default: errstr = "unknown privateKeyObject"; break;
|
default: errstr = "unknown privateKeyObject"; break;
|
||||||
}
|
}
|
||||||
@ -2735,7 +2762,6 @@ read_ef_aodf (app_t app, unsigned short fid, aodf_object_t *result)
|
|||||||
goto parse_error;
|
goto parse_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
log_error ("p15: error parsing AODF record: %s\n",
|
log_error ("p15: error parsing AODF record: %s\n",
|
||||||
@ -2752,6 +2778,7 @@ read_ef_aodf (app_t app, unsigned short fid, aodf_object_t *result)
|
|||||||
if (!aodf)
|
if (!aodf)
|
||||||
goto no_core;
|
goto no_core;
|
||||||
aodf->fid = fid;
|
aodf->fid = fid;
|
||||||
|
aodf->auth_type = auth_type;
|
||||||
|
|
||||||
/* Parse the commonObjectAttributes. */
|
/* Parse the commonObjectAttributes. */
|
||||||
where = __LINE__;
|
where = __LINE__;
|
||||||
@ -2810,7 +2837,7 @@ read_ef_aodf (app_t app, unsigned short fid, aodf_object_t *result)
|
|||||||
else if (!err && objlen > nn)
|
else if (!err && objlen > nn)
|
||||||
err = gpg_error (GPG_ERR_INV_OBJ);
|
err = gpg_error (GPG_ERR_INV_OBJ);
|
||||||
else if (class == CLASS_UNIVERSAL && tag == TAG_SEQUENCE)
|
else if (class == CLASS_UNIVERSAL && tag == TAG_SEQUENCE)
|
||||||
; /* A typeAttribute always starts with a sequence */
|
; /* Okay */
|
||||||
else
|
else
|
||||||
err = gpg_error (GPG_ERR_INV_OBJ);
|
err = gpg_error (GPG_ERR_INV_OBJ);
|
||||||
if (err)
|
if (err)
|
||||||
@ -2818,6 +2845,8 @@ read_ef_aodf (app_t app, unsigned short fid, aodf_object_t *result)
|
|||||||
|
|
||||||
nn = objlen;
|
nn = objlen;
|
||||||
|
|
||||||
|
if (auth_type == AUTH_TYPE_PIN)
|
||||||
|
{
|
||||||
/* PinFlags */
|
/* PinFlags */
|
||||||
where = __LINE__;
|
where = __LINE__;
|
||||||
err = parse_ber_header (&pp, &nn, &class, &tag, &constructed,
|
err = parse_ber_header (&pp, &nn, &class, &tag, &constructed,
|
||||||
@ -2898,7 +2927,6 @@ read_ef_aodf (app_t app, unsigned short fid, aodf_object_t *result)
|
|||||||
nn -= objlen;
|
nn -= objlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* PinType */
|
/* PinType */
|
||||||
where = __LINE__;
|
where = __LINE__;
|
||||||
err = parse_ber_header (&pp, &nn, &class, &tag, &constructed,
|
err = parse_ber_header (&pp, &nn, &class, &tag, &constructed,
|
||||||
@ -2919,7 +2947,6 @@ read_ef_aodf (app_t app, unsigned short fid, aodf_object_t *result)
|
|||||||
}
|
}
|
||||||
aodf->pintype = ul;
|
aodf->pintype = ul;
|
||||||
|
|
||||||
|
|
||||||
/* minLength */
|
/* minLength */
|
||||||
where = __LINE__;
|
where = __LINE__;
|
||||||
err = parse_ber_header (&pp, &nn, &class, &tag, &constructed,
|
err = parse_ber_header (&pp, &nn, &class, &tag, &constructed,
|
||||||
@ -2939,7 +2966,6 @@ read_ef_aodf (app_t app, unsigned short fid, aodf_object_t *result)
|
|||||||
}
|
}
|
||||||
aodf->min_length = ul;
|
aodf->min_length = ul;
|
||||||
|
|
||||||
|
|
||||||
/* storedLength */
|
/* storedLength */
|
||||||
where = __LINE__;
|
where = __LINE__;
|
||||||
err = parse_ber_header (&pp, &nn, &class, &tag, &constructed,
|
err = parse_ber_header (&pp, &nn, &class, &tag, &constructed,
|
||||||
@ -3080,10 +3106,10 @@ read_ef_aodf (app_t app, unsigned short fid, aodf_object_t *result)
|
|||||||
if (err)
|
if (err)
|
||||||
goto parse_error;
|
goto parse_error;
|
||||||
|
|
||||||
/* Make sure that the next element is a non zero FID and of
|
/* Make sure that the next element has a path of even
|
||||||
even length (FID are two bytes each). */
|
* length (FIDs are two bytes each). */
|
||||||
if (class != CLASS_UNIVERSAL || tag != TAG_OCTET_STRING
|
if (class != CLASS_UNIVERSAL || tag != TAG_OCTET_STRING
|
||||||
|| !objlen || (objlen & 1) )
|
|| (objlen & 1) )
|
||||||
{
|
{
|
||||||
errstr = "invalid path reference";
|
errstr = "invalid path reference";
|
||||||
goto parse_error;
|
goto parse_error;
|
||||||
@ -3101,10 +3127,12 @@ read_ef_aodf (app_t app, unsigned short fid, aodf_object_t *result)
|
|||||||
/* An index and length follows. */
|
/* An index and length follows. */
|
||||||
aodf->have_off = 1;
|
aodf->have_off = 1;
|
||||||
where = __LINE__;
|
where = __LINE__;
|
||||||
err = parse_ber_header (&ppp, &nnn, &class, &tag, &constructed,
|
err = parse_ber_header (&ppp, &nnn, &class, &tag,
|
||||||
|
&constructed,
|
||||||
&ndef, &objlen, &hdrlen);
|
&ndef, &objlen, &hdrlen);
|
||||||
if (!err && (objlen > nnn
|
if (!err && (objlen > nnn
|
||||||
|| class != CLASS_UNIVERSAL || tag != TAG_INTEGER))
|
|| class != CLASS_UNIVERSAL
|
||||||
|
|| tag != TAG_INTEGER))
|
||||||
err = gpg_error (GPG_ERR_INV_OBJ);
|
err = gpg_error (GPG_ERR_INV_OBJ);
|
||||||
if (err)
|
if (err)
|
||||||
goto parse_error;
|
goto parse_error;
|
||||||
@ -3118,7 +3146,8 @@ read_ef_aodf (app_t app, unsigned short fid, aodf_object_t *result)
|
|||||||
aodf->off = ul;
|
aodf->off = ul;
|
||||||
|
|
||||||
where = __LINE__;
|
where = __LINE__;
|
||||||
err = parse_ber_header (&ppp, &nnn, &class, &tag, &constructed,
|
err = parse_ber_header (&ppp, &nnn, &class, &tag,
|
||||||
|
&constructed,
|
||||||
&ndef, &objlen, &hdrlen);
|
&ndef, &objlen, &hdrlen);
|
||||||
if (!err && (objlen > nnn
|
if (!err && (objlen > nnn
|
||||||
|| class != CLASS_CONTEXT || tag != 0))
|
|| class != CLASS_CONTEXT || tag != 0))
|
||||||
@ -3135,6 +3164,11 @@ read_ef_aodf (app_t app, unsigned short fid, aodf_object_t *result)
|
|||||||
aodf->len = ul;
|
aodf->len = ul;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else if (auth_type == AUTH_TYPE_AUTHKEY)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/* Ignore further objects which might be there due to future
|
/* Ignore further objects which might be there due to future
|
||||||
extensions of pkcs#15. */
|
extensions of pkcs#15. */
|
||||||
@ -3150,6 +3184,9 @@ read_ef_aodf (app_t app, unsigned short fid, aodf_object_t *result)
|
|||||||
if (aodf->label)
|
if (aodf->label)
|
||||||
log_printf (" (%s)", aodf->label);
|
log_printf (" (%s)", aodf->label);
|
||||||
log_info ("p15: ");
|
log_info ("p15: ");
|
||||||
|
log_printf (" %s",
|
||||||
|
aodf->auth_type == AUTH_TYPE_PIN? "pin" :
|
||||||
|
aodf->auth_type == AUTH_TYPE_AUTHKEY? "authkey" : "?");
|
||||||
if (aodf->pathlen)
|
if (aodf->pathlen)
|
||||||
{
|
{
|
||||||
log_printf (" path=");
|
log_printf (" path=");
|
||||||
@ -3164,6 +3201,8 @@ read_ef_aodf (app_t app, unsigned short fid, aodf_object_t *result)
|
|||||||
for (i=0; i < aodf->authidlen; i++)
|
for (i=0; i < aodf->authidlen; i++)
|
||||||
log_printf ("%02X", aodf->authid[i]);
|
log_printf ("%02X", aodf->authid[i]);
|
||||||
}
|
}
|
||||||
|
if (aodf->auth_type == AUTH_TYPE_PIN)
|
||||||
|
{
|
||||||
if (aodf->pin_reference_valid)
|
if (aodf->pin_reference_valid)
|
||||||
log_printf (" pinref=0x%02lX", aodf->pin_reference);
|
log_printf (" pinref=0x%02lX", aodf->pin_reference);
|
||||||
log_printf (" min=%lu", aodf->min_length);
|
log_printf (" min=%lu", aodf->min_length);
|
||||||
@ -3216,6 +3255,10 @@ read_ef_aodf (app_t app, unsigned short fid, aodf_object_t *result)
|
|||||||
}
|
}
|
||||||
log_printf ("%stype=%s", s, s2); s = ",";
|
log_printf ("%stype=%s", s, s2); s = ",";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else if (aodf->auth_type == AUTH_TYPE_AUTHKEY)
|
||||||
|
{
|
||||||
|
}
|
||||||
log_printf ("\n");
|
log_printf ("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user