Skip to content

Commit 733cb47

Browse files
committed
Merge branch 'javacard-3.0.4-without-secure-messaging' into javacard-3.0.4
2 parents a7add4b + e1f33b1 commit 733cb47

File tree

7 files changed

+150
-52
lines changed

7 files changed

+150
-52
lines changed

.github/workflows/main.yml

Lines changed: 107 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,111 @@
1-
name: smartgpg-test-applet
1+
name: SmartPGP CI
22

3-
# Run this workflow every time a new commit pushed to your repository
4-
on: push
3+
on:
4+
push:
5+
branches: [ '*' ]
6+
tags: [ 'v*' ]
7+
workflow_dispatch:
8+
9+
env:
10+
SUFFIX: ${{ github.ref_type == 'tag' && github.ref_name || github.sha }}
11+
JCKIT: jc304_kit
512

613
jobs:
7-
applet_tests:
8-
runs-on: ubuntu-20.04
14+
build-and-test:
15+
name: Build and test
16+
runs-on: ubuntu-latest
917
steps:
10-
# Checkout repository
11-
- name: checkout repository
12-
uses: actions/checkout@v2
13-
# Run actions
14-
# Compilation tests
15-
- name: applet tests
16-
shell: bash
17-
run: |
18-
# get dependencies
19-
echo "==== get dependencies";
20-
sudo apt-get install -y --no-install-recommends procps autoconf automake libtool m4 pkg-config help2man make gcc ant automake autotools-dev sudo wget gnupg software-properties-common maven git pcscd libpcsclite-dev opensc;
21-
sudo apt-get install -y python3-setuptools python3-pyscard python3-pyasn1;
22-
pip3 install OpenPGPpy;
23-
# get JavaCard SDKs
24-
echo "==== get JavaCard SDKs";
25-
git clone https://github.com/martinpaljak/oracle_javacard_sdks && mv oracle_javacard_sdks/jc304_kit/ /tmp/ && mv oracle_javacard_sdks/jc305u4_kit/ /tmp/ && rm -rf oracle_javacard_sdks;
26-
# compile SmartPGP
27-
echo "==== compile SmartPGP";
28-
cat build.xml | sed 's/<cap /<cap export="SmartPGPApplet" /' > /tmp/build.xml && mv /tmp/build.xml ./;
29-
JC_HOME=/tmp/jc304_kit/ ant;
30-
# clone jcardsim repository, compile and install
31-
echo "==== clone jcardsim repository, compile and install";
32-
git clone https://github.com/licel/jcardsim;
33-
cd jcardsim && export JC_CLASSIC_HOME=/tmp/jc305u4_kit/ && mvn initialize && mvn clean package && cd -;
34-
# clone vsmartcard, compile and install
35-
echo "==== clone vsmartcard, compile and install";
36-
git clone https://github.com/frankmorgner/vsmartcard.git;
37-
cd vsmartcard/virtualsmartcard && autoreconf --verbose --install && ./configure --sysconfdir=/etc && make && sudo make install && cd -;
38-
# relaunch PCSC
39-
echo "==== relaunch PCSC";
40-
sudo killall -KILL pcscd 2> /dev/null || true;
41-
sudo pcscd -fad 2>&1 > /tmp/log_pcsc &
42-
sleep 2;
43-
# launch jcardsim
44-
echo "==== launch jcardsim";
45-
java -cp jcardsim/target/jcardsim-3.0.5-SNAPSHOT.jar:SmartPGPApplet/smartpgp.jar com.licel.jcardsim.remote.VSmartCard .github/workflows/smartpgp.cfg 2>&1 > /tmp/log_jcardsim &
46-
sleep 5;
47-
# install SmartPGP
48-
echo "==== test SmartPGP";
49-
opensc-tool -l;
50-
opensc-tool -s 80b800001810d276000124010304AFAF000000000000050000020F0F00;
51-
# get card status
52-
python3 .github/workflows/card-status.py;
53-
# main tests
54-
python3 .github/workflows/test_SmartPGP.py;
18+
- uses: actions/checkout@v4
19+
20+
- name: Install Oracle JCSDKs
21+
run: |
22+
git clone https://github.com/martinpaljak/oracle_javacard_sdks
23+
mv oracle_javacard_sdks/${{ env.JCKIT }}/ /tmp/
24+
mv oracle_javacard_sdks/jc305u4_kit /tmp/
25+
rm -rf oracle_javacard_sdks
26+
27+
- name: Install build dependencies
28+
run: sudo apt-get install -y --no-install-recommends openjdk-11-jdk-headless ant git
29+
30+
- name: Build applet
31+
run: JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 JC_HOME=/tmp/${{ env.JCKIT }}/ ant
32+
33+
- name: Install test environment dependencies
34+
run: |
35+
sudo apt-get install -y --no-install-recommends procps autoconf automake libtool m4 pkg-config help2man make gcc automake autotools-dev libpcsclite-dev wget gnupg software-properties-common maven git pcscd libpcsclite-dev pcsc-tools opensc
36+
37+
- name: Build and install vmsartcard
38+
run: |
39+
git clone https://github.com/frankmorgner/vsmartcard
40+
cd vsmartcard/virtualsmartcard
41+
autoreconf --install
42+
autoupdate
43+
autoreconf --install
44+
./configure --enable-vpcdslots=1
45+
make
46+
sudo make install
47+
48+
- name: Build and launch jcardsim
49+
run: |
50+
git clone https://github.com/licel/jcardsim
51+
cd jcardsim
52+
export JC_CLASSIC_HOME=/tmp/jc305u4_kit/
53+
mvn --quiet initialize
54+
mvn --quiet clean package -DskipTests=true
55+
cd ..
56+
57+
- name: Install test dependencies
58+
run: |
59+
sudo apt install -y python3-setuptools python3-pyscard python3-pyasn1
60+
pip3 install OpenPGPpy
61+
62+
- name: Create virtual smartcard
63+
run: |
64+
sudo systemctl disable --now pcscd.service pcscd.socket
65+
sudo chmod -R 777 /run/pcscd
66+
pcscd --disable-polkit
67+
sleep 1
68+
pcsc_scan -r -v
69+
java -cp jcardsim/target/jcardsim-3.0.5-SNAPSHOT.jar:build/smartpgp.jar com.licel.jcardsim.remote.VSmartCard .github/workflows/smartpgp.cfg 2>&1 > /tmp/log_jcardsim &
70+
sleep 2
71+
pcsc_scan -c -v
72+
opensc-tool -s 80b800001810d276000124010304AFAF000000000000050000020F0F00
73+
74+
- name: Run tests
75+
run: |
76+
python3 .github/workflows/card-status.py
77+
python3 .github/workflows/test_SmartPGP.py
78+
79+
- name: Build applet (RSA 2048)
80+
run: |
81+
patch -p1 < .github/workflows/rsa-2048.patch
82+
JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 JC_HOME=/tmp/${{ env.JCKIT }}/ ant
83+
patch -p1 -R < .github/workflows/rsa-2048.patch
84+
mv SmartPGPApplet.cap SmartPGPApplet-rsa_up_to_2048.cap
85+
86+
- name: Build applet (RSA 3072)
87+
run: |
88+
patch -p1 < .github/workflows/rsa-3072.patch
89+
JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 JC_HOME=/tmp/${{ env.JCKIT }}/ ant
90+
patch -p1 -R < .github/workflows/rsa-3072.patch
91+
mv SmartPGPApplet.cap SmartPGPApplet-rsa_up_to_3072.cap
92+
93+
- name: Build applet (RSA 4096)
94+
run: |
95+
patch -p1 < .github/workflows/rsa-4096.patch
96+
JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 JC_HOME=/tmp/${{ env.JCKIT }}/ ant
97+
patch -p1 -R < .github/workflows/rsa-4096.patch
98+
mv SmartPGPApplet.cap SmartPGPApplet-rsa_up_to_4096.cap
99+
100+
- name: Gather applets
101+
run: |
102+
mkdir -p output/SmartPGP-${{ env.SUFFIX }}
103+
cp -R *.cap output/SmartPGP-${{ env.SUFFIX }}/
104+
105+
- name: Upload applets
106+
uses: actions/upload-artifact@v4
107+
with:
108+
name: SmartPGP-${{ env.SUFFIX }}
109+
path: output
110+
retention-days: 0
111+

.github/workflows/rsa-2048.patch

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/src/fr/anssi/smartpgp/Constants.java b/src/fr/anssi/smartpgp/Constants.java
2+
index 1cdd733..b369ee1 100644
3+
--- a/src/fr/anssi/smartpgp/Constants.java
4+
+++ b/src/fr/anssi/smartpgp/Constants.java
5+
@@ -25,7 +25,7 @@ import javacard.framework.*;
6+
public final class Constants {
7+
8+
protected static final short INTERNAL_BUFFER_MAX_LENGTH =
9+
- (short)0x500;
10+
+ (short)0x3b0;
11+
12+
protected static final short APDU_MAX_LENGTH = (short)0x400;
13+

.github/workflows/rsa-3072.patch

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/src/fr/anssi/smartpgp/Constants.java b/src/fr/anssi/smartpgp/Constants.java
2+
index 1cdd733..f89e011 100644
3+
--- a/src/fr/anssi/smartpgp/Constants.java
4+
+++ b/src/fr/anssi/smartpgp/Constants.java
5+
@@ -25,7 +25,7 @@ import javacard.framework.*;
6+
public final class Constants {
7+
8+
protected static final short INTERNAL_BUFFER_MAX_LENGTH =
9+
- (short)0x500;
10+
+ (short)0x570;
11+
12+
protected static final short APDU_MAX_LENGTH = (short)0x400;
13+

.github/workflows/rsa-4096.patch

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/src/fr/anssi/smartpgp/Constants.java b/src/fr/anssi/smartpgp/Constants.java
2+
index 1cdd733..0af26dc 100644
3+
--- a/src/fr/anssi/smartpgp/Constants.java
4+
+++ b/src/fr/anssi/smartpgp/Constants.java
5+
@@ -25,7 +25,7 @@ import javacard.framework.*;
6+
public final class Constants {
7+
8+
protected static final short INTERNAL_BUFFER_MAX_LENGTH =
9+
- (short)0x500;
10+
+ (short)0x730;
11+
12+
protected static final short APDU_MAX_LENGTH = (short)0x400;
13+

.github/workflows/smartpgp.cfg

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ com.licel.jcardsim.card.applet.0.Class=fr.anssi.smartpgp.SmartPGPApplet
33
com.licel.jcardsim.card.ATR=3B80800101
44
com.licel.jcardsim.vsmartcard.host=localhost
55
com.licel.jcardsim.vsmartcard.port=35963
6-
com.licel.jcardsim.randomdata.secure=1

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ant-javacard.jar
2+
build
3+
SmartPGPApplet.cap

build.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<taskdef name="javacard" classname="pro.javacard.ant.JavaCard" classpath="ant-javacard.jar"/>
66
<target name="convert">
77
<javacard>
8-
<cap output="SmartPGPApplet.cap" sources="src" aid="d27600012401" version="1.0">
8+
<cap export="build" output="SmartPGPApplet.cap" sources="src" aid="d27600012401" version="1.0">
99
<applet class="fr.anssi.smartpgp.SmartPGPApplet" aid="d276000124010304AFAF000000000000"/>
1010
</cap>
1111
</javacard>

0 commit comments

Comments
 (0)