pkcs15: add array with supported algos references to the key info data type ...
and imlement API to access it git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5089 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
66412d6e53
commit
2a8fc56402
|
@ -2075,3 +2075,62 @@ int sc_pkcs15_allocate_object_content(struct sc_pkcs15_object *obj,
|
|||
|
||||
return SC_SUCCESS;
|
||||
}
|
||||
|
||||
struct sc_supported_algo_info *
|
||||
sc_pkcs15_get_supported_algo(struct sc_pkcs15_card *p15card,
|
||||
unsigned operation, unsigned mechanism)
|
||||
{
|
||||
struct sc_context *ctx = p15card->card->ctx;
|
||||
struct sc_supported_algo_info *info = NULL;
|
||||
int ii;
|
||||
|
||||
for (ii=0;ii<SC_MAX_SUPPORTED_ALGORITHMS && p15card->tokeninfo->supported_algos[ii].reference; ii++)
|
||||
if ((p15card->tokeninfo->supported_algos[ii].operations & operation)
|
||||
&& (p15card->tokeninfo->supported_algos[ii].mechanism == mechanism))
|
||||
break;
|
||||
|
||||
if (ii < SC_MAX_SUPPORTED_ALGORITHMS && p15card->tokeninfo->supported_algos[ii].reference) {
|
||||
info = &p15card->tokeninfo->supported_algos[ii];
|
||||
sc_log(ctx, "found supported algorithm (ref:%X,mech:%X,ops:%X,algo_ref:%X)",
|
||||
info->reference, info->mechanism, info->operations, info->algo_ref);
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
sc_pkcs15_add_supported_algo_ref(struct sc_pkcs15_object *obj,
|
||||
struct sc_supported_algo_info *algo)
|
||||
{
|
||||
int *algo_refs = NULL;
|
||||
int ii;
|
||||
|
||||
if (!algo)
|
||||
return SC_SUCCESS;
|
||||
|
||||
switch (obj->type) {
|
||||
case SC_PKCS15_TYPE_PRKEY_RSA:
|
||||
algo_refs = ((struct sc_pkcs15_prkey_info *)obj->data)->algo_refs;
|
||||
break;
|
||||
case SC_PKCS15_TYPE_PUBKEY_RSA:
|
||||
algo_refs = ((struct sc_pkcs15_pubkey_info *)obj->data)->algo_refs;
|
||||
break;
|
||||
}
|
||||
if (!algo_refs)
|
||||
return SC_ERROR_NOT_SUPPORTED;
|
||||
|
||||
for (ii=0;ii<SC_MAX_SUPPORTED_ALGORITHMS && *(algo_refs + ii);ii++)
|
||||
if (*(algo_refs + ii) == algo->reference)
|
||||
return SC_SUCCESS;
|
||||
|
||||
for (ii=0;ii<SC_MAX_SUPPORTED_ALGORITHMS;ii++) {
|
||||
if (*(algo_refs + ii) == 0) {
|
||||
*(algo_refs + ii) = algo->reference;
|
||||
return SC_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
return SC_ERROR_TOO_MANY_OBJECTS;
|
||||
}
|
||||
|
||||
|
|
|
@ -319,6 +319,8 @@ struct sc_pkcs15_prkey_info {
|
|||
size_t modulus_length; /* RSA */
|
||||
size_t field_length; /* EC in bits */
|
||||
|
||||
int algo_refs[SC_MAX_SUPPORTED_ALGORITHMS];
|
||||
|
||||
struct sc_pkcs15_der subject;
|
||||
|
||||
void *params;
|
||||
|
@ -336,6 +338,8 @@ struct sc_pkcs15_pubkey_info {
|
|||
size_t modulus_length; /* RSA */
|
||||
size_t field_length; /* EC in bits */
|
||||
|
||||
int algo_refs[SC_MAX_SUPPORTED_ALGORITHMS];
|
||||
|
||||
struct sc_pkcs15_der subject;
|
||||
|
||||
void *params;
|
||||
|
@ -781,6 +785,11 @@ void sc_pkcs15_free_object_content(struct sc_pkcs15_object *);
|
|||
int sc_pkcs15_allocate_object_content(struct sc_pkcs15_object *,
|
||||
const unsigned char *, size_t);
|
||||
|
||||
struct sc_supported_algo_info *sc_pkcs15_get_supported_algo(struct sc_pkcs15_card *,
|
||||
unsigned, unsigned);
|
||||
int sc_pkcs15_add_supported_algo_ref(struct sc_pkcs15_object *,
|
||||
struct sc_supported_algo_info *);
|
||||
|
||||
/* New object search API.
|
||||
* More complex, but also more powerful.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue