int sc_pkcs15_pubkey_from_spki_filename(sc_context_t *ctx, char * filename, sc_pkcs15_pubkey_t ** outpubkey) { int r; u8 * buf = NULL; size_t buflen = 0; r = sc_pkcs15_read_der_file(ctx, filename, &buf, &buflen); if (r < 0) return r; r = sc_pkcs15_pubkey_from_spki_object(ctx, buf, buflen, outpubkey); if (buf) free(buf); return r; }
int sc_pkcs15_pubkey_from_spki_filename(sc_context_t *ctx, char * filename, sc_pkcs15_pubkey_t ** outpubkey) { int r; u8 * buf = NULL; size_t buflen = 0; sc_pkcs15_pubkey_t * pubkey = NULL; struct sc_asn1_entry asn1_spki[] = { { "PublicKeyInfo",SC_ASN1_CALLBACK, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, 0, sc_pkcs15_pubkey_from_spki, &pubkey}, { NULL, 0, 0, 0, NULL, NULL } }; *outpubkey = NULL; r = sc_pkcs15_read_der_file(ctx, filename, &buf, &buflen); if (r < 0) return r; r = sc_asn1_decode(ctx, asn1_spki, buf, buflen, NULL, NULL); if (buf) free(buf); *outpubkey = pubkey; return r; }