Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add openconnect_has_tss2_blob_support()
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
  • Loading branch information
dwmw2 committed Oct 11, 2018
1 parent a8d550e commit ae8d3c1
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 2 deletions.
1 change: 1 addition & 0 deletions java/src/com/example/LibTest.java
Expand Up @@ -232,6 +232,7 @@ public static void main(String argv[]) {
System.out.println("OpenConnect version: " + lib.getVersion());
System.out.println(" PKCS=" + lib.hasPKCS11Support() +
", TSS=" + lib.hasTSSBlobSupport() +
", TSS2=" + lib.hasTSS2BlobSupport() +
", STOKEN=" + lib.hasStokenSupport() +
", OATH=" + lib.hasOATHSupport() +
", YUBIOATH=" + lib.hasYubiOATHSupport());
Expand Down
1 change: 1 addition & 0 deletions java/src/org/infradead/libopenconnect/LibOpenConnect.java
Expand Up @@ -176,6 +176,7 @@ public synchronized native void setMobileInfo(String mobilePlatformVersion,
public static native String getVersion();
public static native boolean hasPKCS11Support();
public static native boolean hasTSSBlobSupport();
public static native boolean hasTSS2BlobSupport();
public static native boolean hasStokenSupport();
public static native boolean hasOATHSupport();
public static native boolean hasYubiOATHSupport();
Expand Down
6 changes: 6 additions & 0 deletions jni.c
Expand Up @@ -925,6 +925,12 @@ JNIEXPORT jboolean JNICALL Java_org_infradead_libopenconnect_LibOpenConnect_hasT
return openconnect_has_tss_blob_support();
}

JNIEXPORT jboolean JNICALL Java_org_infradead_libopenconnect_LibOpenConnect_hasTSS2BlobSupport(
JNIEnv *jenv, jclass jcls)
{
return openconnect_has_tss2_blob_support();
}

JNIEXPORT jboolean JNICALL Java_org_infradead_libopenconnect_LibOpenConnect_hasStokenSupport(
JNIEnv *jenv, jclass jcls)
{
Expand Down
1 change: 1 addition & 0 deletions libopenconnect.map.in
Expand Up @@ -98,6 +98,7 @@ OPENCONNECT_5_5 {
openconnect_get_protocol;
openconnect_get_supported_protocols;
openconnect_free_supported_protocols;
openconnect_has_tss2_blob_support;
} OPENCONNECT_5_4;

OPENCONNECT_PRIVATE {
Expand Down
18 changes: 18 additions & 0 deletions library.c
Expand Up @@ -730,6 +730,24 @@ int openconnect_has_tss_blob_support(void)
return 0;
}

int openconnect_has_tss2_blob_support(void)
{
#if defined(OPENCONNECT_OPENSSL) && defined(HAVE_ENGINE)
ENGINE *e;

ENGINE_load_builtin_engines();

e = ENGINE_by_id("tpm2");
if (e) {
ENGINE_free(e);
return 1;
}
#elif defined(OPENCONNECT_GNUTLS) && defined(HAVE_TSS2)
return 1;
#endif
return 0;
}

int openconnect_has_stoken_support(void)
{
#ifdef HAVE_LIBSTOKEN
Expand Down
4 changes: 4 additions & 0 deletions main.c
Expand Up @@ -592,6 +592,10 @@ static void print_build_opts(void)
printf("%sTPM", sep);
sep = comma;
}
if (openconnect_has_tss2_blob_support()) {
printf("%sTPMv2", sep);
sep = comma;
}
#if defined(OPENCONNECT_OPENSSL) && defined(HAVE_ENGINE)
else {
printf("%sTPM (%s)", sep, _("OpenSSL ENGINE not present"));
Expand Down
5 changes: 3 additions & 2 deletions openconnect.h
Expand Up @@ -37,6 +37,7 @@ extern "C" {

/*
* API version 5.5:
* - Add openconnect_has_tss2_blob_support()
* - Add openconnect_get_supported_protocols()
* - Add openconnect_free_supported_protocols()
* - Add openconnect_get_protocol()
Expand Down Expand Up @@ -654,9 +655,9 @@ void openconnect_set_stats_handler(struct openconnect_info *vpninfo,
int openconnect_has_pkcs11_support(void);

/* The OpenSSL TPM ENGINE stores keys in a PEM file labelled with the string
-----BEGIN TSS KEY BLOB-----. GnuTLS may learn to support this format too,
in the near future. */
-----BEGIN TSS KEY BLOB-----. */
int openconnect_has_tss_blob_support(void);
int openconnect_has_tss2_blob_support(void);

/* Software token capabilities. */
int openconnect_has_stoken_support(void);
Expand Down

0 comments on commit ae8d3c1

Please sign in to comment.