[pkg-opensc-commit] [opensc] 76/295: pkcs15-esteid: remove openssl dependency (#863)

Eric Dorland eric at moszumanska.debian.org
Sat Jun 24 21:11:17 UTC 2017


This is an automated email from the git hooks/post-receive script.

eric pushed a commit to branch master
in repository opensc.

commit 14a5e628be8ee5ec76b3d23f26c3d22d31861dc5
Author: Raul Metsma <raul at metsma.ee>
Date:   Fri Sep 2 22:48:44 2016 +0300

    pkcs15-esteid: remove openssl dependency (#863)
    
    Uses e4f5f845129e3d0311e8e2994ae7e471b337f7f5 API instead
---
 src/libopensc/pkcs15-esteid.c | 50 +++++++------------------------------------
 1 file changed, 8 insertions(+), 42 deletions(-)

diff --git a/src/libopensc/pkcs15-esteid.c b/src/libopensc/pkcs15-esteid.c
index 7bbba7e..f80cb98 100644
--- a/src/libopensc/pkcs15-esteid.c
+++ b/src/libopensc/pkcs15-esteid.c
@@ -28,9 +28,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
-#ifdef ENABLE_OPENSSL
-#include <openssl/x509v3.h>
-#endif
 
 #include "common/compat_strlcpy.h"
 #include "common/compat_strlcat.h"
@@ -110,53 +107,22 @@ sc_pkcs15emu_esteid_init (sc_pkcs15_card_t * p15card)
 		r = sc_pkcs15emu_add_x509_cert(p15card, &cert_obj, &cert_info);
 		if (r < 0)
 			return SC_ERROR_INTERNAL;
-#ifdef ENABLE_OPENSSL
 		if (i == 0) {
-			BIO *mem = NULL;
-			X509 *x509 = NULL;
 			sc_pkcs15_cert_t *cert;
-			char cardholder_name[64];
-			unsigned char *tmp = NULL;
 			r = sc_pkcs15_read_certificate(p15card, &cert_info, &cert);
 			if (r == SC_SUCCESS) {
-				mem = BIO_new_mem_buf(cert->data.value, cert->data.len);
-				if (!mem) {
-					sc_pkcs15_free_certificate(cert);
-					return SC_ERROR_INTERNAL;
+				static const struct sc_object_id cn_oid = {{ 2, 5, 4, 3, -1 }};
+				u8 *cn_name = NULL;
+				size_t cn_len = 0;
+				sc_pkcs15_get_name_from_dn(card->ctx, cert->subject,
+					cert->subject_len, &cn_oid, &cn_name, &cn_len);
+				if (cn_len > 0) {
+					set_string(&p15card->tokeninfo->label, (const char*)cn_name);
 				}
-				x509 = d2i_X509_bio(mem, NULL);
-				BIO_free(mem);
+				free(cn_name);
 				sc_pkcs15_free_certificate(cert);
-				if (!x509)
-					return SC_ERROR_INTERNAL;
-				r = X509_NAME_get_index_by_NID(X509_get_subject_name(x509), NID_commonName, -1);
-				if (r >= 0) {
-					X509_NAME_ENTRY *ne;
-					ASN1_STRING *a_str;
-					ne = X509_NAME_get_entry(X509_get_subject_name(x509), r);
-					if (!ne) {
-						X509_free(x509);
-						return SC_ERROR_INTERNAL;
-					}
-					a_str = X509_NAME_ENTRY_get_data(ne);
-					if (!a_str) {
-						X509_free(x509);
-						return SC_ERROR_INTERNAL;
-					}
-					r = ASN1_STRING_to_UTF8(&tmp, a_str);
-					if (r > 0) {
-						if ((unsigned)r > sizeof(cardholder_name) - 1)
-							r = sizeof(cardholder_name) -1;
-						memcpy(cardholder_name, tmp, r);
-						cardholder_name[r] = '\0';
-						set_string(&p15card->tokeninfo->label, cardholder_name);
-						OPENSSL_free(tmp);
-					}
-				}
-				X509_free(x509);
 			}
 		}
-#endif
 	}
 
 	/* the file with key pin info (tries left) */

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-opensc/opensc.git



More information about the pkg-opensc-commit mailing list