Skip to content

Commit 93ae347

Browse files
committed
prevent usage of ifdef in code
1 parent 78f9422 commit 93ae347

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/pk/asn1/x509/x509_decode_public_key_from_certificate.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ int x509_decode_public_key_from_certificate(const unsigned char *in, unsigned lo
3939
unsigned long tmpbuf_len, tmp_inlen;
4040
ltc_asn1_list *decoded_list = NULL, *l;
4141

42-
LTC_ARGCHK(in != NULL);
43-
LTC_ARGCHK(inlen != 0);
42+
LTC_ARGCHK(in != NULL);
43+
LTC_ARGCHK(inlen != 0);
44+
LTC_ARGCHK(callback != NULL);
4445

4546
tmpbuf_len = inlen;
4647
tmpbuf = XCALLOC(1, tmpbuf_len);
@@ -81,11 +82,7 @@ int x509_decode_public_key_from_certificate(const unsigned char *in, unsigned lo
8182
&& (l->data != NULL)
8283
&& LOOKS_LIKE_SPKI(l->child)) {
8384
if (algorithm == PKA_EC) {
84-
#ifdef LTC_MECC
85-
err = ecc_import_subject_public_key_info(l->data, l->size, ctx);
86-
#else
87-
err = CRYPT_ERROR;
88-
#endif
85+
err = callback(l->data, l->size, ctx);
8986
} else {
9087
err = x509_decode_subject_public_key_info(l->data, l->size,
9188
algorithm, tmpbuf, &tmpbuf_len,

src/pk/ecc/ecc_import_x509.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ int ecc_import_subject_public_key_info(const unsigned char *in, unsigned long in
106106
*/
107107
int ecc_import_x509(const unsigned char *in, unsigned long inlen, ecc_key *key)
108108
{
109-
return x509_decode_public_key_from_certificate(in, inlen, PKA_EC, LTC_ASN1_EOL, NULL, NULL, NULL, key);
109+
return x509_decode_public_key_from_certificate(in, inlen,
110+
PKA_EC,
111+
LTC_ASN1_EOL, NULL, NULL,
112+
(public_key_decode_cb)ecc_import_subject_public_key_info, key);
110113
}
111114

112115
#endif /* LTC_MECC */

0 commit comments

Comments
 (0)