|
1 | | -name: smartgpg-test-applet |
| 1 | +name: SmartPGP CI |
2 | 2 |
|
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 |
5 | 12 |
|
6 | 13 | jobs: |
7 | | - applet_tests: |
8 | | - runs-on: ubuntu-20.04 |
| 14 | + build-and-test: |
| 15 | + name: Build and test |
| 16 | + runs-on: ubuntu-latest |
9 | 17 | 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 | + |
0 commit comments