Skip to content

Commit ca0697a

Browse files
stoggidjmdjm
authored andcommitted
Add make target for standalone sk-libfido2
Add a Makefile target for sk-libfido2, the standalone fido2 security key shared library, suitable for use with the SecurityKeyProvider option. Add a new configure option `--with-security-key-standalone` that optionally sets the shared library target sk-libfido2$(SHLIBEXT), and adds it to $(TARGETS). misc.h is required when SK_STANDALONE is defined, because of the use of `monotime_tv` in `sk_select_by_touch`. Sets the shared library extension for sk-libfido2 is by setting `SHLIBEXT` depending on the platform in configure.ac. Add the shared library to the CI builds in the `sk` target config to make sure it can compile under the same conditions as `--with-security-key-builtin`. Add a libssh-pic.a static library that compiles with `-fPIC` reusing .c.lo method in sk-dummy.so for use in the shared library sk-libfido2. Note, a separate static library libssh-pic.a is needed, since defining -DSK_STANDALONE excludes some symbols needed in sshkey.lo.
1 parent 74d7084 commit ca0697a

5 files changed

Lines changed: 38 additions & 3 deletions

File tree

.github/configs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ case "$config" in
181181
CONFIGFLAGS="--with-selinux"
182182
;;
183183
sk)
184-
CONFIGFLAGS="--with-security-key-builtin"
184+
CONFIGFLAGS="--with-security-key-builtin --with-security-key-standalone"
185185
;;
186186
without-openssl)
187187
LIBCRYPTOFLAGS="--without-openssl"

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ survey.sh
1212
**/*.o
1313
**/*.lo
1414
**/*.so
15+
**/*.dylib
16+
**/*.dll
1517
**/*.out
1618
**/*.a
1719
**/*.un~

Makefile.in

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ SSH_PRIVSEP_USER=@SSH_PRIVSEP_USER@
3333
STRIP_OPT=@STRIP_OPT@
3434
TEST_SHELL=@TEST_SHELL@
3535
BUILDDIR=@abs_top_builddir@
36+
SK_STANDALONE=@SK_STANDALONE@
3637

3738
PATHS= -DSSHDIR=\"$(sysconfdir)\" \
3839
-D_PATH_SSH_PROGRAM=\"$(SSH_PROGRAM)\" \
@@ -73,7 +74,7 @@ MKDIR_P=@MKDIR_P@
7374

7475
.SUFFIXES: .lo
7576

76-
TARGETS=ssh$(EXEEXT) sshd$(EXEEXT) sshd-session$(EXEEXT) sshd-auth$(EXEEXT) ssh-add$(EXEEXT) ssh-keygen$(EXEEXT) ssh-keyscan${EXEEXT} ssh-keysign${EXEEXT} ssh-pkcs11-helper$(EXEEXT) ssh-agent$(EXEEXT) scp$(EXEEXT) sftp-server$(EXEEXT) sftp$(EXEEXT) ssh-sk-helper$(EXEEXT)
77+
TARGETS=ssh$(EXEEXT) sshd$(EXEEXT) sshd-session$(EXEEXT) sshd-auth$(EXEEXT) ssh-add$(EXEEXT) ssh-keygen$(EXEEXT) ssh-keyscan${EXEEXT} ssh-keysign${EXEEXT} ssh-pkcs11-helper$(EXEEXT) ssh-agent$(EXEEXT) scp$(EXEEXT) sftp-server$(EXEEXT) sftp$(EXEEXT) ssh-sk-helper$(EXEEXT) $(SK_STANDALONE)
7778

7879
XMSS_OBJS=\
7980
ssh-xmss.o \
@@ -272,6 +273,16 @@ sftp$(EXEEXT): $(LIBCOMPAT) libssh.a $(SFTP_OBJS)
272273
logintest: logintest.o $(LIBCOMPAT) libssh.a loginrec.o
273274
$(LD) -o $@ logintest.o $(LDFLAGS) loginrec.o -lopenbsd-compat -lssh $(LIBS)
274275

276+
# compile libssh objects with -fPIC for use in the sk_libfido2 shared library
277+
LIBSSH_PIC_OBJS=$(LIBSSH_OBJS:.o=.lo)
278+
libssh-pic.a: $(LIBSSH_PIC_OBJS)
279+
$(AR) rv $@ $(LIBSSH_PIC_OBJS)
280+
$(RANLIB) $@
281+
282+
$(SK_STANDALONE): sk-usbhid.c $(LIBCOMPAT) libssh-pic.a
283+
$(CC) -o $@ -shared $(CFLAGS_NOPIE) $(CPPFLAGS) -DSK_STANDALONE $(PICFLAG) sk-usbhid.c \
284+
libssh-pic.a $(LDFLAGS_NOPIE) -lopenbsd-compat $(LIBS) $(LIBFIDO2) $(CHANNELLIBS)
285+
275286
$(MANPAGES): $(MANPAGES_IN)
276287
if test "$(MANTYPE)" = "cat"; then \
277288
manpage=$(srcdir)/`echo $@ | sed 's/\.[1-9]\.out$$/\.0/'`; \

configure.ac

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,9 @@ SPP_MSG="no"
614614
# the --with-solaris-privs option and --with-sandbox=solaris).
615615
SOLARIS_PRIVS="no"
616616

617+
# Default shared library extension
618+
SHLIBEXT=".so"
619+
617620
# Check for some target-specific stuff
618621
case "$host" in
619622
*-*-aix*)
@@ -732,6 +735,7 @@ case "$host" in
732735
# Cygwin defines optargs, optargs as declspec(dllimport) for historical
733736
# reasons which cause compile warnings, so we disable those warnings.
734737
OSSH_CHECK_CFLAG_COMPILE([-Wno-attributes])
738+
SHLIBEXT=".dll"
735739
;;
736740
*-*-dgux*)
737741
AC_DEFINE([IP_TOS_IS_BROKEN], [1],
@@ -791,6 +795,7 @@ int main(void) { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16))
791795
# cf. Apple bug 3710161 (not public, but searchable)
792796
AC_DEFINE([BROKEN_POLL], [1],
793797
[System poll(2) implementation is broken])
798+
SHLIBEXT=".dylib"
794799
;;
795800
*-*-dragonfly*)
796801
SSHDLIBS="$SSHDLIBS"
@@ -2079,6 +2084,12 @@ AC_ARG_WITH([security-key-builtin],
20792084
[ enable_sk_internal=$withval ]
20802085
)
20812086

2087+
enable_sk_standalone=
2088+
AC_ARG_WITH([security-key-standalone],
2089+
[ --with-security-key-standalone build standalone sk-libfido2 SecurityKeyProvider],
2090+
[ enable_sk_standalone=$withval ]
2091+
)
2092+
20822093
enable_dsa=
20832094
AC_ARG_ENABLE([dsa-keys],
20842095
[ --enable-dsa-keys enable DSA key support [no]],
@@ -3316,6 +3327,16 @@ if test "x$enable_sk" = "xyes" -a "x$enable_sk_internal" != "xno" ; then
33163327
fi
33173328
fi
33183329

3330+
# Check for standalone SecurityKeyProvider
3331+
AC_MSG_CHECKING([whether to build standlone sk-libfido2])
3332+
if test "x$enable_sk_standalone" = "xyes" ; then
3333+
AC_MSG_RESULT([yes])
3334+
AC_SUBST([SK_STANDALONE], [sk-libfido2$SHLIBEXT])
3335+
else
3336+
AC_MSG_RESULT([no])
3337+
AC_SUBST([SK_STANDALONE], [""])
3338+
fi
3339+
33193340
AC_CHECK_FUNCS([ \
33203341
arc4random \
33213342
arc4random_buf \

sk-usbhid.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,11 @@
7777
#define FIDO_CRED_PROT_UV_OPTIONAL_WITH_ID 0
7878
#endif
7979

80+
# include "misc.h"
81+
8082
#ifndef SK_STANDALONE
8183
# include "log.h"
8284
# include "xmalloc.h"
83-
# include "misc.h"
8485
/*
8586
* If building as part of OpenSSH, then rename exported functions.
8687
* This must be done before including sk-api.h.

0 commit comments

Comments
 (0)