Skip to content

Commit f43d3f8

Browse files
committed
Add Javacard tests and mingw build to Github Actions
* PIV applet * Isoapplet * Gids Applet * openpgp applet * Split clang-tidy to separate task as it is too slow
1 parent 5d33873 commit f43d3f8

File tree

10 files changed

+333
-25
lines changed

10 files changed

+333
-25
lines changed

.github/build.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ if [ "$RUNNER_OS" == "macOS" ]; then
2323
exit $?
2424
fi
2525

26+
if [ "$1" == "mingw" -o "$1" == "mingw32" ]; then
27+
if [ "$1" == "mingw" ]; then
28+
HOST=x86_64-w64-mingw32
29+
elif [ "$1" == "mingw32" ]; then
30+
HOST=i686-w64-mingw32
31+
fi
32+
unset CC
33+
unset CXX
34+
./configure --host=$HOST --with-completiondir=/tmp --disable-openssl --disable-readline --disable-zlib --disable-notify --prefix=$PWD/win32/opensc || cat config.log;
35+
fi
2636
# normal procedure
2737
./configure --disable-dependency-tracking
2838

@@ -36,3 +46,7 @@ if [ "$1" == "dist" ]; then
3646
fi
3747

3848
sudo make install
49+
50+
if [ "$1" == "mingw" -o "$1" == "mingw32" ]; then
51+
wine "C:/Program Files (x86)/Inno Setup 5/ISCC.exe" win32/OpenSC.iss
52+
fi

.github/setup-java.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash -e
2+
3+
# Select the right java
4+
sudo update-java-alternatives -s java-1.8.0-openjdk-amd64
5+
sudo update-alternatives --get-selections | grep ^java
6+
export PATH="/usr/lib/jvm/java-8-openjdk-amd64/bin/:$PATH"
7+
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/
8+
env | grep -i openjdk
9+
10+
# VSmartcard
11+
./.github/setup-vsmartcard.sh
12+
13+
# Javacard SDKs
14+
git clone https://github.com/martinpaljak/oracle_javacard_sdks.git
15+
export JC_HOME=$PWD/oracle_javacard_sdks/jc222_kit
16+
export JC_CLASSIC_HOME=$PWD/oracle_javacard_sdks/jc305u3_kit
17+
18+
# jCardSim
19+
git clone https://github.com/arekinath/jcardsim.git
20+
pushd jcardsim
21+
env | grep -i openjdk
22+
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/
23+
mvn initialize && mvn clean install
24+
popd

.github/setup-linux.sh

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,41 @@
11
#!/bin/bash -e
22

3-
DEPS="docbook-xsl libpcsclite-dev xsltproc gengetopt libcmocka-dev help2man pcscd check clang-tidy softhsm2 pcsc-tools libtool make autoconf autoconf-archive automake libssl-dev zlib1g-dev pkg-config libreadline-dev openssl git"
4-
if [ "$1" == "cac" ]; then
3+
DEPS="docbook-xsl libpcsclite-dev xsltproc gengetopt libcmocka-dev help2man pcscd check softhsm2 pcsc-tools libtool make autoconf autoconf-archive automake libssl-dev zlib1g-dev pkg-config libreadline-dev openssl git"
4+
5+
if [ "$1" == "clang-tidy" ]; then
6+
DEPS="$DEPS clang-tidy"
7+
elif [ "$1" == "cac" ]; then
58
DEPS="$DEPS libglib2.0-dev libnss3-dev gnutls-bin libusb-dev libudev-dev flex libnss3-tools"
69
elif [ "$1" == "oseid" ]; then
710
DEPS="$DEPS socat gawk xxd"
8-
elif [ "$1" == "piv"]; then
9-
DEPS="$DEPS ant cmake"
10-
elif [ "$1" == "mingw" ]; then
11-
DEPS="$DEPS wine binutils-mingw-w64-i686 binutils-mingw-w64-x86-64 gcc-mingw-w64-i686 gcc-mingw-w64-x86-64 mingw-w64"
11+
elif [ "$1" == "piv" -o "$1" == "isoapplet" -o "$1" == "gidsapplet" -o "$1" == "openpgp" ]; then
12+
if [ "$1" == "piv" ]; then
13+
DEPS="$DEPS cmake"
14+
fi
15+
DEPS="$DEPS ant openjdk-8-jdk"
16+
elif [ "$1" == "mingw" -o "$1" == "mingw32" ]; then
17+
sudo dpkg --add-architecture i386
18+
if [ "$1" == "mingw" ]; then
19+
DEPS="$DEPS wine wine32 binutils-mingw-w64-x86-64 gcc-mingw-w64-x86-64 mingw-w64"
20+
elif [ "$1" == "mingw32" ]; then
21+
DEPS="$DEPS wine wine32 binutils-mingw-w64-i686 gcc-mingw-w64-i686"
22+
fi
1223
fi
1324

1425
# make sure we do not get prompts
1526
export DEBIAN_FRONTEND=noninteractive
1627
sudo apt-get update
1728
sudo apt-get install -y build-essential $DEPS
29+
30+
if [ "$1" == "mingw" -o "$1" == "mingw32" ]; then
31+
if [ ! -f "$(winepath 'C:/Program Files (x86)/Inno Setup 5/ISCC.exe')" ]; then
32+
/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16
33+
export DISPLAY=:99.0
34+
[ -d isetup ] || mkdir isetup
35+
pushd isetup
36+
[ -f isetup-5.5.6.exe ] || wget http://files.jrsoftware.org/is/5/isetup-5.5.6.exe
37+
sleep 5 # make sure the X server is ready ?
38+
wine isetup-5.5.6.exe /SILENT /VERYSILENT /SP- /SUPPRESSMSGBOXES /NORESTART
39+
popd
40+
fi
41+
fi

.github/setup-vsmartcard.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
if [ ! -d "vsmartcard" ]; then
4+
git clone https://github.com/frankmorgner/vsmartcard.git
5+
fi
6+
pushd vsmartcard/virtualsmartcard
7+
autoreconf -vis && ./configure && make -j2 && sudo make install
8+
popd

.github/test-cac.sh

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@ sudo make install
55
export LD_LIBRARY_PATH=/usr/local/lib
66

77
# VSmartcard
8-
if [ ! -d "vsmartcard" ]; then
9-
git clone https://github.com/frankmorgner/vsmartcard.git
10-
fi
11-
pushd vsmartcard/virtualsmartcard
12-
autoreconf -vis && ./configure && make -j2 && sudo make install
13-
popd
8+
./.github/setup-vsmartcard.sh
149

1510
# libcacard
1611
if [ ! -d "libcacard" ]; then

.github/test-gidsapplet.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash -e
2+
3+
# install the opensc
4+
sudo make install
5+
export LD_LIBRARY_PATH=/usr/local/lib
6+
7+
# setup java stuff
8+
. .github/setup-java.sh
9+
10+
# GidsApplet
11+
git clone https://github.com/vletoux/GidsApplet.git;
12+
javac -classpath jcardsim/target/jcardsim-3.0.5-SNAPSHOT.jar GidsApplet/src/com/mysmartlogon/gidsApplet/*.java;
13+
echo "com.licel.jcardsim.card.applet.0.AID=A000000397425446590201" > gids_jcardsim.cfg;
14+
echo "com.licel.jcardsim.card.applet.0.Class=com.mysmartlogon.gidsApplet.GidsApplet" >> gids_jcardsim.cfg;
15+
echo "com.licel.jcardsim.card.ATR=3B80800101" >> gids_jcardsim.cfg;
16+
echo "com.licel.jcardsim.vsmartcard.host=localhost" >> gids_jcardsim.cfg;
17+
echo "com.licel.jcardsim.vsmartcard.port=35963" >> gids_jcardsim.cfg;
18+
19+
# log errors from pcscd to console
20+
sudo systemctl stop pcscd.service pcscd.socket
21+
sudo /usr/sbin/pcscd -f &
22+
PCSCD_PID=$!
23+
24+
25+
# start the applet and run couple of commands against that
26+
java -noverify -cp GidsApplet/src/:jcardsim/target/jcardsim-3.0.5-SNAPSHOT.jar com.licel.jcardsim.remote.VSmartCard gids_jcardsim.cfg >/dev/null &
27+
PID=$!;
28+
sleep 5;
29+
opensc-tool --card-driver default --send-apdu 80b80000190bA0000003974254465902010bA00000039742544659020100;
30+
opensc-tool -n;
31+
gids-tool --initialize --pin 123456 --admin-key 000000000000000000000000000000000000000000000000 --serial 00000000000000000000000000000000;
32+
kill -9 $PID
33+
34+
35+
# cleanup
36+
sudo kill -9 $PCSCD_PID

.github/test-isoapplet.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash -e
2+
3+
# install the opensc
4+
sudo make install
5+
export LD_LIBRARY_PATH=/usr/local/lib
6+
7+
# setup java stuff
8+
./.github/setup-java.sh
9+
10+
# The ISO applet
11+
git clone https://github.com/philipWendland/IsoApplet.git;
12+
javac -classpath jcardsim/target/jcardsim-3.0.5-SNAPSHOT.jar IsoApplet/src/net/pwendland/javacard/pki/isoapplet/*.java;
13+
echo "com.licel.jcardsim.card.applet.0.AID=F276A288BCFBA69D34F31001" > isoapplet_jcardsim.cfg;
14+
echo "com.licel.jcardsim.card.applet.0.Class=net.pwendland.javacard.pki.isoapplet.IsoApplet" >> isoapplet_jcardsim.cfg;
15+
echo "com.licel.jcardsim.card.ATR=3B80800101" >> isoapplet_jcardsim.cfg;
16+
echo "com.licel.jcardsim.vsmartcard.host=localhost" >> isoapplet_jcardsim.cfg;
17+
echo "com.licel.jcardsim.vsmartcard.port=35963" >> isoapplet_jcardsim.cfg;
18+
19+
# log errors from pcscd to console
20+
sudo systemctl stop pcscd.service pcscd.socket
21+
sudo /usr/sbin/pcscd -f &
22+
PCSCD_PID=$!
23+
24+
# start the applet and run couple of commands against that
25+
java -noverify -cp IsoApplet/src/:jcardsim/target/jcardsim-3.0.5-SNAPSHOT.jar com.licel.jcardsim.remote.VSmartCard isoapplet_jcardsim.cfg >/dev/null &
26+
PID=$!;
27+
sleep 5;
28+
opensc-tool --card-driver default --send-apdu 80b800001a0cf276a288bcfba69d34f310010cf276a288bcfba69d34f3100100;
29+
opensc-tool -n;
30+
pkcs15-init --create-pkcs15 --so-pin 123456 --so-puk 0123456789abcdef;
31+
pkcs15-tool --change-pin --pin 123456 --new-pin 654321;
32+
pkcs15-tool --unblock-pin --puk 0123456789abcdef --new-pin 123456;
33+
pkcs15-init --generate-key rsa/2048 --id 1 --key-usage decrypt,sign --auth-id FF --pin 123456;
34+
pkcs15-init --generate-key rsa/2048 --id 2 --key-usage decrypt --auth-id FF --pin 123456;
35+
pkcs15-init --generate-key ec/secp256r1 --id 3 --key-usage sign --auth-id FF --pin 123456;
36+
pkcs15-tool -D;
37+
pkcs11-tool -l -t -p 123456;
38+
kill -9 $PID;
39+
40+
# cleanup
41+
sudo kill -9 $PCSCD_PID

.github/test-openpgp.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash -e
2+
3+
# install the opensc
4+
sudo make install
5+
export LD_LIBRARY_PATH=/usr/local/lib
6+
7+
# setup java stuff
8+
. .github/setup-java.sh
9+
10+
# The OpenPGP applet
11+
git clone --recursive https://github.com/Yubico/ykneo-openpgp.git;
12+
cd ykneo-openpgp;
13+
ant -DJAVACARD_HOME=${JC_HOME};
14+
cd $TRAVIS_BUILD_DIR;
15+
echo "com.licel.jcardsim.card.applet.0.AID=D2760001240102000000000000010000" > openpgp_jcardsim.cfg;
16+
echo "com.licel.jcardsim.card.applet.0.Class=openpgpcard.OpenPGPApplet" >> openpgp_jcardsim.cfg;
17+
echo "com.licel.jcardsim.card.ATR=3B80800101" >> openpgp_jcardsim.cfg;
18+
echo "com.licel.jcardsim.vsmartcard.host=localhost" >> openpgp_jcardsim.cfg;
19+
echo "com.licel.jcardsim.vsmartcard.port=35963" >> openpgp_jcardsim.cfg;
20+
21+
# log errors from pcscd to console
22+
sudo systemctl stop pcscd.service pcscd.socket
23+
sudo /usr/sbin/pcscd -f &
24+
PCSCD_PID=$!
25+
26+
27+
# start the applet and run couple of commands against that
28+
java -noverify -cp ykneo-openpgp/applet/bin:jcardsim/target/jcardsim-3.0.5-SNAPSHOT.jar com.licel.jcardsim.remote.VSmartCard openpgp_jcardsim.cfg >/dev/null &
29+
PID=$!;
30+
sleep 5;
31+
opensc-tool --card-driver default --send-apdu 80b800002210D276000124010200000000000001000010D276000124010200000000000001000000;
32+
opensc-tool -n;
33+
openpgp-tool --verify CHV3 --pin 12345678 --gen-key 2;
34+
pkcs15-init --verify --auth-id 3 --pin 12345678 --delete-objects privkey,pubkey --id 2 --generate-key rsa/2048;
35+
pkcs11-tool -l -t -p 123456;
36+
kill -9 $PID
37+
38+
39+
# cleanup
40+
sudo kill -9 $PCSCD_PID

.github/test-piv.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash -e
2+
3+
# install the opensc
4+
sudo make install
5+
export LD_LIBRARY_PATH=/usr/local/lib
6+
7+
# setup java stuff
8+
. .github/setup-java.sh
9+
10+
# The PIV Applet
11+
git clone --recursive https://github.com/arekinath/PivApplet.git
12+
pushd PivApplet
13+
JC_HOME=${JC_CLASSIC_HOME} ant dist
14+
popd
15+
16+
# yubico-piv-tool is needed for PIV Applet management
17+
git clone https://github.com/Yubico/yubico-piv-tool.git
18+
pushd yubico-piv-tool
19+
mkdir build
20+
pushd build
21+
cmake .. && make && sudo make install
22+
popd
23+
popd
24+
25+
26+
# log errors from pcscd to console
27+
sudo systemctl stop pcscd.service pcscd.socket
28+
sudo /usr/sbin/pcscd -f &
29+
PCSCD_PID=$!
30+
31+
32+
# start the applet and run couple of commands against that
33+
java -noverify -cp PivApplet/bin/:jcardsim/target/jcardsim-3.0.5-SNAPSHOT.jar com.licel.jcardsim.remote.VSmartCard PivApplet/test/jcardsim.cfg >/dev/null &
34+
PID=$!
35+
sleep 5
36+
opensc-tool --card-driver default --send-apdu 80b80000120ba000000308000010000100050000020F0F7f
37+
opensc-tool -n
38+
yubico-piv-tool -v 9999 -r 'Virtual PCD 00 00' -P 123456 -s 9e -a generate -A RSA2048
39+
yubico-piv-tool -v 9999 -r 'Virtual PCD 00 00' -P 123456 -s 9a -a generate -A ECCP256
40+
pkcs11-tool -l -t -p 123456
41+
kill -9 $PID
42+
43+
44+
# cleanup
45+
sudo kill -9 $PCSCD_PID

0 commit comments

Comments
 (0)