diff options
author | Michele Calgaro <[email protected]> | 2020-06-07 21:12:15 +0900 |
---|---|---|
committer | Michele Calgaro <[email protected]> | 2020-06-07 21:13:08 +0900 |
commit | 6d6ab7d7ae65acb90bc194b0263b8f615c39917d (patch) | |
tree | 63cbf922c6ac575fc40a99421839c09be9ef7fe1 | |
parent | f8116fd3ef168194065494b5c40eed8106370941 (diff) | |
download | smartcardauth-6d6ab7d7ae65acb90bc194b0263b8f615c39917d.tar.gz smartcardauth-6d6ab7d7ae65acb90bc194b0263b8f615c39917d.zip |
Minor code refactoring of previous commit.
Signed-off-by: Michele Calgaro <[email protected]>
-rw-r--r-- | src/cardpincheck.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/src/cardpincheck.c b/src/cardpincheck.c index e57f86c..ff5d4de 100644 --- a/src/cardpincheck.c +++ b/src/cardpincheck.c @@ -131,7 +131,6 @@ char* tde_autopin(X509* x509_cert) { ASN1_TYPE* asnValue = otherName->value; if (asnValue) { // Found autopin structure - int index; ASN1_TYPE* asnSeqValue = NULL; ASN1_GENERALSTRING* asnGeneralString = NULL; STACK_OF(ASN1_TYPE) *asnSeqValueStack = NULL; @@ -139,17 +138,14 @@ char* tde_autopin(X509* x509_cert) { int asn1SeqValueObjectTag; int asn1SeqValueObjectClass; int returnCode; -#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) - uint8_t* asnSeqValueString = ASN1_STRING_data(asnValue->value.sequence); -#else + int index = 0; // Search for the PIN field +; +#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER) const uint8_t* asnSeqValueString = ASN1_STRING_get0_data(asnValue->value.sequence); -#endif - - index = 0; // Search for the PIN field -#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) - asnSeqValueStack = ASN1_seq_unpack_ASN1_TYPE(asnSeqValueString, ASN1_STRING_length(asnValue->value.sequence), d2i_ASN1_TYPE, ASN1_TYPE_free); -#else asnSeqValueStack = d2i_ASN1_SEQUENCE_ANY(NULL, &asnSeqValueString, ASN1_STRING_length(asnValue->value.sequence)); +#else + uint8_t* asnSeqValueString = ASN1_STRING_data(asnValue->value.sequence); + asnSeqValueStack = ASN1_seq_unpack_ASN1_TYPE(asnSeqValueString, ASN1_STRING_length(asnValue->value.sequence), d2i_ASN1_TYPE, ASN1_TYPE_free); #endif asnSeqValue = sk_ASN1_TYPE_value(asnSeqValueStack, index); if (asnSeqValue) { @@ -159,10 +155,10 @@ char* tde_autopin(X509* x509_cert) { if (!(returnCode & 0x80)) { if (returnCode == (V_ASN1_CONSTRUCTED + index)) { if (d2i_ASN1_GENERALSTRING(&asnGeneralString, &asn1SeqValueObjectData, asn1SeqValueObjectLength) != NULL) { -#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) - retString = strdup(ASN1_STRING_data(asnGeneralString)); -#else +#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER) retString = strdup(ASN1_STRING_get0_data(asnGeneralString)); +#else + retString = strdup(ASN1_STRING_data(asnGeneralString)); #endif } } |