Initial modifications to support OpenPGP v2.0 (CryptoStick)
* Correct naming: openpgp not opengpg * Set the card name from ATR table * Add card type enums * Currently OpenPGP is read-only. git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5072 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
2d5c76d3d1
commit
75c1254e22
|
@ -18,6 +18,12 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
* Specifications:
|
||||
* http://www.g10code.de/docs/openpgp-card-1.1.pdf
|
||||
* http://www.g10code.de/docs/openpgp-card-2.0.pdf
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
@ -29,7 +35,8 @@
|
|||
#include "cardctl.h"
|
||||
|
||||
static struct sc_atr_table pgp_atrs[] = {
|
||||
{ "3b:fa:13:00:ff:81:31:80:45:00:31:c1:73:c0:01:00:00:90:00:b1", NULL, NULL, SC_CARD_TYPE_OPENPGP_GENERIC, 0, NULL },
|
||||
{ "3b:fa:13:00:ff:81:31:80:45:00:31:c1:73:c0:01:00:00:90:00:b1", NULL, "OpenPGP card v1.0/1.1", SC_CARD_TYPE_OPENPGP_V1, 0, NULL },
|
||||
{ "3b:da:18:ff:81:b1:fe:75:1f:03:00:31:c5:73:c0:01:40:00:90:00:0c", NULL, "CryptoStick v1.2 (OpenPGP v2.0)", SC_CARD_TYPE_OPENPGP_V2, 0, NULL },
|
||||
{ NULL, NULL, NULL, 0, 0, NULL }
|
||||
};
|
||||
|
||||
|
@ -115,9 +122,11 @@ pgp_match_card(sc_card_t *card)
|
|||
int i;
|
||||
|
||||
i = _sc_match_atr(card, pgp_atrs, &card->type);
|
||||
if (i < 0)
|
||||
return 0;
|
||||
return 1;
|
||||
if (i >= 0) {
|
||||
card->name = pgp_atrs[i].name;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -133,7 +142,6 @@ pgp_init(sc_card_t *card)
|
|||
priv = calloc (1, sizeof *priv);
|
||||
if (!priv)
|
||||
return SC_ERROR_OUT_OF_MEMORY;
|
||||
card->name = "OpenPGP";
|
||||
card->drv_data = priv;
|
||||
card->cla = 0x00;
|
||||
|
||||
|
|
|
@ -101,7 +101,8 @@ enum {
|
|||
|
||||
/* openpgp driver */
|
||||
SC_CARD_TYPE_OPENPGP_BASE = 9000,
|
||||
SC_CARD_TYPE_OPENPGP_GENERIC,
|
||||
SC_CARD_TYPE_OPENPGP_V1,
|
||||
SC_CARD_TYPE_OPENPGP_V2,
|
||||
|
||||
/* jcop driver */
|
||||
SC_CARD_TYPE_JCOP_BASE = 10000,
|
||||
|
|
|
@ -62,7 +62,7 @@ static const struct _sc_driver_entry internal_card_drivers[] = {
|
|||
{ "asepcos", (void *(*)(void)) sc_get_asepcos_driver },
|
||||
{ "starcos", (void *(*)(void)) sc_get_starcos_driver },
|
||||
{ "tcos", (void *(*)(void)) sc_get_tcos_driver },
|
||||
{ "opengpg", (void *(*)(void)) sc_get_openpgp_driver },
|
||||
{ "openpgp", (void *(*)(void)) sc_get_openpgp_driver },
|
||||
{ "jcop", (void *(*)(void)) sc_get_jcop_driver },
|
||||
#ifdef ENABLE_OPENSSL
|
||||
{ "oberthur", (void *(*)(void)) sc_get_oberthur_driver },
|
||||
|
|
|
@ -236,7 +236,10 @@ failed: sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Failed to initialize OpenPGP e
|
|||
|
||||
static int openpgp_detect_card(sc_pkcs15_card_t *p15card)
|
||||
{
|
||||
return strcmp(p15card->card->name, "OpenPGP");
|
||||
if (p15card->card->type == SC_CARD_TYPE_OPENPGP_V1 || p15card->card->type == SC_CARD_TYPE_OPENPGP_V2)
|
||||
return SC_SUCCESS;
|
||||
else
|
||||
return SC_ERROR_WRONG_CARD;
|
||||
}
|
||||
|
||||
int sc_pkcs15emu_openpgp_init_ex(sc_pkcs15_card_t *p15card,
|
||||
|
|
|
@ -107,6 +107,8 @@ int sc_pkcs15_is_emulation_only(sc_card_t *card)
|
|||
case SC_CARD_TYPE_MCRD_ESTEID_V30:
|
||||
case SC_CARD_TYPE_IAS_PTEID:
|
||||
case SC_CARD_TYPE_GEMSAFEV1_PTEID:
|
||||
case SC_CARD_TYPE_OPENPGP_V1:
|
||||
case SC_CARD_TYPE_OPENPGP_V2:
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue