3333 @param parameters_len [in/out] The number of parameters to include
3434 @param callback The callback
3535 @param ctx The context passed to the callback
36- @return CRYPT_OK on success
36+ @return CRYPT_OK on success, CRYPT_NOP if no SubjectPublicKeyInfo was found
3737*/
3838int x509_decode_public_key_from_certificate (const unsigned char * in , unsigned long inlen ,
3939 enum ltc_oid_id algorithm , ltc_asn1_type param_type ,
@@ -59,7 +59,7 @@ int x509_decode_public_key_from_certificate(const unsigned char *in, unsigned lo
5959 if ((err = der_decode_sequence_flexi (in , & tmp_inlen , & decoded_list )) == CRYPT_OK ) {
6060 l = decoded_list ;
6161
62- err = CRYPT_INVALID_ARG ;
62+ err = CRYPT_NOP ;
6363
6464 /* Move 2 levels up in the tree
6565 SEQUENCE
@@ -86,12 +86,16 @@ int x509_decode_public_key_from_certificate(const unsigned char *in, unsigned lo
8686 if ((l -> type == LTC_ASN1_SEQUENCE )
8787 && (l -> data != NULL )
8888 && LOOKS_LIKE_SPKI (l -> child )) {
89- err = x509_decode_subject_public_key_info (l -> data , l -> size ,
90- algorithm , tmpbuf , & tmpbuf_len ,
91- param_type , parameters , parameters_len );
92- if (err == CRYPT_OK ) {
93- err = callback (tmpbuf , tmpbuf_len , ctx );
94- goto LBL_OUT ;
89+ if (algorithm == PKA_EC ) {
90+ err = ecc_import_subject_public_key_info (l -> data , l -> size , ctx );
91+ } else {
92+ err = x509_decode_subject_public_key_info (l -> data , l -> size ,
93+ algorithm , tmpbuf , & tmpbuf_len ,
94+ param_type , parameters , parameters_len );
95+ if (err == CRYPT_OK ) {
96+ err = callback (tmpbuf , tmpbuf_len , ctx );
97+ goto LBL_OUT ;
98+ }
9599 }
96100 }
97101 l = l -> next ;
0 commit comments