- GPK now reports it's PK abilities correctly
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@286 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
2a4afb8319
commit
ae306cf06f
|
@ -152,7 +152,7 @@ gpk_init(struct sc_card *card)
|
|||
{
|
||||
struct gpk_private_data *priv;
|
||||
struct atrinfo *ai;
|
||||
unsigned int exponent, flags;
|
||||
unsigned long exponent, flags;
|
||||
|
||||
if (!(ai = gpk_identify(card)))
|
||||
return SC_ERROR_INVALID_CARD;
|
||||
|
@ -166,12 +166,14 @@ gpk_init(struct sc_card *card)
|
|||
|
||||
/* Set up algorithm info. GPK 16000 will do any RSA
|
||||
* exponent, earlier ones are restricted to 0x10001 */
|
||||
flags = SC_ALGORITHM_RSA_HASH_MD5
|
||||
| SC_ALGORITHM_RSA_PAD_PKCS1;
|
||||
exponent = (ai->variant / 1000 < 16)? 0x10001 : 0;
|
||||
_sc_card_add_rsa_alg(card, 512, 0, exponent);
|
||||
_sc_card_add_rsa_alg(card, 768, 0, exponent);
|
||||
_sc_card_add_rsa_alg(card, 1024, 0, exponent);
|
||||
flags = SC_ALGORITHM_RSA_HASH_MD5 | SC_ALGORITHM_RSA_HASH_SHA1
|
||||
| SC_ALGORITHM_RSA_HASH_MD5_SHA1;
|
||||
flags |= SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_PAD_ANSI
|
||||
| SC_ALGORITHM_RSA_PAD_ISO9796;
|
||||
exponent = (ai->variant / 1000 < 16)? 0x10001 : -1;
|
||||
_sc_card_add_rsa_alg(card, 512, flags, exponent);
|
||||
_sc_card_add_rsa_alg(card, 768, flags, exponent);
|
||||
_sc_card_add_rsa_alg(card, 1024, flags, exponent);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1274,6 +1276,8 @@ gpk_compute_signature(struct sc_card *card, const u8 *data,
|
|||
* padding itself, but the upper layers of OpenSC insist on
|
||||
* doing the padding for us. So strip away the pkcs#1 padding
|
||||
* first. */
|
||||
/* XXX FIXME: There's no padding, if the card indicates that it's
|
||||
* able to do it itself. */
|
||||
if (data_len < priv->sec_hash_len + 11)
|
||||
return SC_ERROR_INTERNAL;
|
||||
r = gpk_init_hashed(card, data + data_len - priv->sec_hash_len,
|
||||
|
|
|
@ -75,7 +75,7 @@ static int miocos_init(struct sc_card *card)
|
|||
flags = SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_PAD_PKCS1;
|
||||
flags |= SC_ALGORITHM_RSA_HASH_NONE | SC_ALGORITHM_RSA_HASH_SHA1;
|
||||
|
||||
_sc_card_add_rsa_alg(card, 1024, flags, -1);
|
||||
_sc_card_add_rsa_alg(card, 1024, flags, 0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -84,7 +84,7 @@ static int setcos_init(struct sc_card *card)
|
|||
flags = SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_PAD_PKCS1;
|
||||
flags |= SC_ALGORITHM_RSA_HASH_NONE | SC_ALGORITHM_RSA_HASH_SHA1;
|
||||
|
||||
_sc_card_add_rsa_alg(card, 1024, flags, -1);
|
||||
_sc_card_add_rsa_alg(card, 1024, flags, 0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -743,7 +743,7 @@ int _sc_card_add_algorithm(struct sc_card *card, const struct sc_algorithm_info
|
|||
}
|
||||
|
||||
int _sc_card_add_rsa_alg(struct sc_card *card, unsigned int key_length,
|
||||
unsigned long flags, long exponent)
|
||||
unsigned long flags, unsigned long exponent)
|
||||
{
|
||||
struct sc_algorithm_info info;
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ int _sc_match_atr(struct sc_card *card, struct sc_atr_table *table, int *id_out)
|
|||
|
||||
int _sc_card_add_algorithm(struct sc_card *card, const struct sc_algorithm_info *info);
|
||||
int _sc_card_add_rsa_alg(struct sc_card *card, unsigned int key_length,
|
||||
unsigned long flags, long exponent);
|
||||
unsigned long flags, unsigned long exponent);
|
||||
struct sc_algorithm_info * _sc_card_find_rsa_alg(struct sc_card *card,
|
||||
unsigned int key_length);
|
||||
|
||||
|
|
|
@ -235,9 +235,14 @@ struct sc_file {
|
|||
#define SC_ALGORITHM_SPECIFIC_FLAGS 0x0000FFFF
|
||||
|
||||
#define SC_ALGORITHM_RSA_RAW 0x00000001
|
||||
/* If the card is willing to produce a cryptogram padded with the following
|
||||
* methods, set these flags accordingly. */
|
||||
#define SC_ALGORITHM_RSA_PAD_PKCS1 0x00000002
|
||||
#define SC_ALGORITHM_RSA_PAD_ANSI 0x00000004
|
||||
#define SC_ALGORITHM_RSA_PAD_ISO9796 0x00000008
|
||||
|
||||
/* If the card is willing to produce a cryptogram with the following
|
||||
* hash values, set these flags accordingly. */
|
||||
#define SC_ALGORITHM_RSA_HASH_NONE 0x00000010
|
||||
#define SC_ALGORITHM_RSA_HASH_SHA1 0x00000020
|
||||
#define SC_ALGORITHM_RSA_HASH_MD5 0x00000040
|
||||
|
@ -267,7 +272,6 @@ struct sc_algorithm_info {
|
|||
union {
|
||||
struct sc_rsa_info {
|
||||
long exponent;
|
||||
int unwrap;
|
||||
} _rsa;
|
||||
} u;
|
||||
};
|
||||
|
|
|
@ -49,7 +49,7 @@ int _sc_match_atr(struct sc_card *card, struct sc_atr_table *table, int *id_out)
|
|||
|
||||
int _sc_card_add_algorithm(struct sc_card *card, const struct sc_algorithm_info *info);
|
||||
int _sc_card_add_rsa_alg(struct sc_card *card, unsigned int key_length,
|
||||
unsigned long flags, long exponent);
|
||||
unsigned long flags, unsigned long exponent);
|
||||
struct sc_algorithm_info * _sc_card_find_rsa_alg(struct sc_card *card,
|
||||
unsigned int key_length);
|
||||
|
||||
|
|
Loading…
Reference in New Issue