Integrated PIV applet

https://github.com/arekinath/PivApplet
This commit is contained in:
Frank Morgner
2019-09-09 15:17:01 +02:00
parent 6ec798d509
commit 75779ea77a
11 changed files with 64 additions and 21 deletions

3
.gitmodules vendored
View File

@@ -19,3 +19,6 @@
[submodule "virtualsmartcard/win32/DevMsi"]
path = virtualsmartcard/win32/DevMsi
url = https://github.com/nickrussler/DevMsi.git
[submodule "ACardEmulator/app/src/main/external/PivApplet"]
path = ACardEmulator/app/src/main/external/PivApplet
url = https://github.com/frankmorgner/PivApplet

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="ACardEmulator" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<module external.linked.project.id="ACardEmulator" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="java-gradle" name="Java-Gradle">
<configuration>
@@ -13,7 +13,7 @@
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
</content>
<orderEntry type="jdk" jdkName="JDK" jdkType="JavaSDK" />
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="ACardEmulator" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
@@ -17,24 +17,23 @@
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res;file://$MODULE_DIR$/build/generated/res/rs/debug;file://$MODULE_DIR$/build/generated/res/resValues/debug" />
<option name="TEST_RES_FOLDERS_RELATIVE_PATH" value="" />
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7">
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
@@ -62,6 +61,7 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/external/GidsApplet/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/external/IsoApplet/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/external/PivApplet/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/external/android-scio/src/main" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/external/ykneo-openpgp/applet/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/external/ykneo-oath/applet/src" isTestSource="false" />
@@ -81,7 +81,8 @@
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/.DS_Store" />
<excludeFolder url="file://$MODULE_DIR$/build/generated/not_namespaced_r_class_sources" />
<excludeFolder url="file://$MODULE_DIR$/build/generated/source/r" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
@@ -109,18 +110,18 @@
</content>
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="sdk-v1.0.0" level="project" />
<orderEntry type="library" exported="" name="zxing-android-embedded-3.2.0" level="project" />
<orderEntry type="library" exported="" name="accessory-v2.3.2" level="project" />
<orderEntry type="library" exported="" name="jcardsim-3.0.4-SNAPSHOT-android" level="project" />
<orderEntry type="library" exported="" name="design-23.2.1" level="project" />
<orderEntry type="library" exported="" name="core-3.2.1" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-23.2.1" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.2.1" level="project" />
<orderEntry type="library" exported="" name="core-1.51.0.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.2.1" level="project" />
<orderEntry type="library" exported="" name="animated-vector-drawable-23.2.1" level="project" />
<orderEntry type="library" exported="" name="support-vector-drawable-23.2.1" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.2.1" level="project" />
<orderEntry type="library" exported="" name="Gradle: com.android.support:animated-vector-drawable:23.2.1@aar" level="project" />
<orderEntry type="library" exported="" name="Gradle: com.google.zxing:core:3.2.1@jar" level="project" />
<orderEntry type="library" exported="" name="Gradle: __local_jars__:/home/fm/Dokumente/vsmartcard/ACardEmulator/app/libs/accessory-v2.3.2.jar:unspecified@jar" level="project" />
<orderEntry type="library" exported="" name="Gradle: com.android.support:recyclerview-v7:23.2.1@aar" level="project" />
<orderEntry type="library" exported="" name="Gradle: com.android.support:design:23.2.1@aar" level="project" />
<orderEntry type="library" exported="" name="Gradle: com.android.support:support-vector-drawable:23.2.1@aar" level="project" />
<orderEntry type="library" exported="" name="Gradle: __local_jars__:/home/fm/Dokumente/vsmartcard/ACardEmulator/app/libs/sdk-v1.0.0.jar:unspecified@jar" level="project" />
<orderEntry type="library" exported="" name="Gradle: com.android.support:support-annotations:23.2.1@jar" level="project" />
<orderEntry type="library" exported="" name="Gradle: com.android.support:appcompat-v7:23.2.1@aar" level="project" />
<orderEntry type="library" exported="" name="Gradle: com.madgag.spongycastle:core:1.51.0.0@jar" level="project" />
<orderEntry type="library" exported="" name="Gradle: com.android.support:support-v4:23.2.1@aar" level="project" />
<orderEntry type="library" exported="" name="Gradle: com.journeyapps:zxing-android-embedded:3.2.0@aar" level="project" />
<orderEntry type="library" exported="" name="Gradle: __local_jars__:/home/fm/Dokumente/vsmartcard/ACardEmulator/app/libs/jcardsim-3.0.4-SNAPSHOT-android.jar:unspecified@jar" level="project" />
</component>
</module>

View File

@@ -20,6 +20,7 @@ android {
main.java.srcDirs += 'src/main/external/GidsApplet/src'
main.java.exclude('**/gidsAppletTests/*.java')
main.java.srcDirs += 'src/main/external/IsoApplet/src'
main.java.srcDirs += 'src/main/external/PivApplet/src'
main.java.srcDirs += 'src/main/external/android-scio/src/main'
main.java.srcDirs += 'src/main/external/ykneo-openpgp/applet/src'
main.java.srcDirs += 'src/main/external/ykneo-oath/applet/src'

View File

@@ -185,6 +185,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
bindPreferenceSummaryToValue(findPreference("emulator"));
bindPreferenceSummaryToValue(findPreference("activate_helloworld"));
bindPreferenceSummaryToValue(findPreference("activate_pivapplet"));
bindPreferenceSummaryToValue(findPreference("activate_openpgp"));
bindPreferenceSummaryToValue(findPreference("activate_oath"));
bindPreferenceSummaryToValue(findPreference("activate_isoapplet"));

View File

@@ -85,6 +85,7 @@ public class EmulatorSingleton {
SP.getBoolean("activate_openpgp", false),
SP.getBoolean("activate_oath", false),
SP.getBoolean("activate_isoapplet", false),
SP.getBoolean("activate_pivapplet", false),
SP.getBoolean("activate_gidsapplet", false));
}
}

View File

@@ -13,6 +13,7 @@ import com.vsmartcard.acardemulator.R;
import com.vsmartcard.acardemulator.Util;
import net.pwendland.javacard.pki.isoapplet.IsoApplet;
import net.cooperi.pivapplet.PivApplet;
import openpgpcard.OpenPGPApplet;
import pkgYkneoOath.YkneoOath;
@@ -27,6 +28,7 @@ public class JCEmulator implements Emulator {
boolean activate_openpgp,
boolean activate_oath,
boolean activate_isoapplet,
boolean activate_pivapplet,
boolean activate_gidsapplet) {
String aid, name, extra_install = "", extra_error = "";
simulator = new Simulator(new SimulatorRuntime());
@@ -75,6 +77,18 @@ public class JCEmulator implements Emulator {
}
}
if (activate_pivapplet) {
name = context.getResources().getString(R.string.applet_pivapplet);
aid = context.getResources().getString(R.string.aid_pivapplet);
try {
simulator.installApplet(AIDUtil.create(aid), PivApplet.class);
extra_install += "\n" + name + " (AID: " + aid + ")";
} catch (Exception e) {
e.printStackTrace();
extra_error += "\n" + "Could not install " + name + " (AID: " + aid + ")";
}
}
if (activate_isoapplet) {
name = context.getResources().getString(R.string.applet_isoapplet);
aid = context.getResources().getString(R.string.aid_isoapplet);

View File

@@ -20,6 +20,12 @@
<string name="applet_gidsapplet">My Smart Logon\'s GIDS Applet</string>
<string name="aid_isoapplet">F276A288BCFBA69D34F31001</string>
<string name="applet_isoapplet">Philip Wendland\'s ISO Applet</string>
<string name="aid_pivapplet">A00000030800001000</string>
<string name="aid_pivapplet_truncated1">A000000308000010</string>
<string name="aid_pivapplet_truncated2">A0000003080000</string>
<string name="aid_pivapplet_truncated3">A00000030800</string>
<string name="aid_pivapplet_truncated4">A000000308</string>
<string name="applet_pivapplet">Alex Wilson\'s PIV Applet</string>
<string name="aid_helloworld">F000000001</string>
<string name="applet_helloworld">jCardSim Team\'s Hello World Applet</string>
<string name="aid_partial_openpgp">D27600012401</string>
@@ -33,6 +39,7 @@
<b>Hello World Applet</b> <small>(AID F000000001)</small>\n
<b>OpenPGP Applet</b> <small>(AID D2760001240102000000000000010000)</small>\n
<b>OATH Applet</b> <small>(AID A000000527210101)</small>\n
<b>PIV Applet</b> <small>(AID A00000030800001000)</small>\n
<b>ISO Applet</b> <small>(AID F276A288BCFBA69D34F31001)</small>\n
<b>GIDS Applet</b> <small>(AID A000000397425446590201)</small>\n
\n

View File

@@ -21,6 +21,14 @@
<aid-filter android:name="@string/aid_isoapplet"/>
</aid-group>
<aid-group android:description="@string/applet_pivapplet" android:category="other">
<aid-filter android:name="@string/aid_pivapplet"/>
<aid-filter android:name="@string/aid_pivapplet_truncated1"/>
<aid-filter android:name="@string/aid_pivapplet_truncated2"/>
<aid-filter android:name="@string/aid_pivapplet_truncated3"/>
<aid-filter android:name="@string/aid_pivapplet_truncated4"/>
</aid-group>
<aid-group android:description="@string/applet_gidsapplet" android:category="other">
<aid-filter android:name="@string/aid_gidsapplet"/>
<aid-filter android:name="@string/aid_gidsapplet_truncated1"/>

View File

@@ -37,6 +37,12 @@
android:key="activate_isoapplet"
android:defaultValue="true"
/>
<SwitchPreference
android:title="@string/applet_pivapplet"
android:switchTextOn="@string/aid_pivapplet"
android:key="activate_pivapplet"
android:defaultValue="true"
/>
<SwitchPreference
android:title="@string/applet_gidsapplet"
android:switchTextOn="@string/aid_gidsapplet"