pkcs15: new function to encode an OID in DER format

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5380 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
vtarasov 2011-04-21 14:12:03 +00:00
parent 669a10572a
commit 38103c64cf
3 changed files with 23 additions and 0 deletions

View File

@ -1659,3 +1659,23 @@ sc_der_copy(sc_pkcs15_der_t *dst, const sc_pkcs15_der_t *src)
return SC_SUCCESS;
}
int
sc_encode_oid (struct sc_context *ctx, struct sc_object_id *id,
unsigned char **out, size_t *size)
{
static const struct sc_asn1_entry c_asn1_object_id[2] = {
{ "oid", SC_ASN1_OBJECT, SC_ASN1_TAG_OBJECT, SC_ASN1_ALLOC, NULL, NULL },
{ NULL, 0, 0, 0, NULL, NULL }
};
struct sc_asn1_entry asn1_object_id[2];
int rv;
sc_copy_asn1_entry(c_asn1_object_id, asn1_object_id);
sc_format_asn1_entry(asn1_object_id + 0, id, NULL, 1);
rv = _sc_asn1_encode(ctx, asn1_object_id, out, size, 1);
LOG_TEST_RET(ctx, rv, "Cannot encode object ID");
return SC_SUCCESS;
}

View File

@ -82,6 +82,7 @@ sc_disconnect_card
sc_do_log
_sc_debug
sc_enum_apps
sc_encode_oid
sc_parse_ef_atr
sc_establish_context
sc_file_add_acl_entry

View File

@ -777,6 +777,8 @@ int sc_der_copy(sc_pkcs15_der_t *, const sc_pkcs15_der_t *);
int sc_pkcs15_get_object_id(const struct sc_pkcs15_object *, struct sc_pkcs15_id *);
int sc_pkcs15_get_guid(struct sc_pkcs15_card *, const struct sc_pkcs15_object *,
char *, size_t);
int sc_encode_oid (struct sc_context *, struct sc_object_id *,
unsigned char **, size_t *);
/* Prepend 'parent' to 'child' in case 'child' is a relative path */
int sc_pkcs15_make_absolute_path(const sc_path_t *parent, sc_path_t *child);