diff --git a/ACardEmulator/ACardEmulator.iml b/ACardEmulator/ACardEmulator.iml
index 7771d4c..507b069 100644
--- a/ACardEmulator/ACardEmulator.iml
+++ b/ACardEmulator/ACardEmulator.iml
@@ -13,7 +13,7 @@
-
+
\ No newline at end of file
diff --git a/ACardEmulator/app/app.iml b/ACardEmulator/app/app.iml
index 99dc74d..1c17e52 100644
--- a/ACardEmulator/app/app.iml
+++ b/ACardEmulator/app/app.iml
@@ -89,7 +89,6 @@
-
@@ -100,18 +99,11 @@
-
-
-
-
-
-
-
@@ -134,6 +126,5 @@
-
\ No newline at end of file
diff --git a/ACardEmulator/app/build.gradle b/ACardEmulator/app/build.gradle
index 1273232..6f5295e 100644
--- a/ACardEmulator/app/build.gradle
+++ b/ACardEmulator/app/build.gradle
@@ -1,18 +1,6 @@
apply plugin: 'com.android.application'
-def keystorePropertiesFile = rootProject.file("keystore.properties")
-def keystoreProperties = new Properties()
-keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
-
android {
- signingConfigs {
- config {
- keyAlias keystoreProperties['keyAlias']
- keyPassword keystoreProperties['keyPassword']
- storeFile file(keystoreProperties['storeFile'])
- storePassword keystoreProperties['storePassword']
- }
- }
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
@@ -26,10 +14,6 @@ android {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- signingConfig signingConfigs.config
- }
- debug {
- signingConfig signingConfigs.config
}
}
sourceSets {
diff --git a/ACardEmulator/app/src/main/java/com/vsmartcard/acardemulator/SmartcardProviderService.java b/ACardEmulator/app/src/main/java/com/vsmartcard/acardemulator/SmartcardProviderService.java
index 64e4917..fa35f93 100644
--- a/ACardEmulator/app/src/main/java/com/vsmartcard/acardemulator/SmartcardProviderService.java
+++ b/ACardEmulator/app/src/main/java/com/vsmartcard/acardemulator/SmartcardProviderService.java
@@ -23,11 +23,7 @@
package com.vsmartcard.acardemulator;
-import android.content.Context;
import android.content.Intent;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.Signature;
import android.os.Binder;
import android.os.Handler;
import android.os.IBinder;
@@ -43,12 +39,7 @@ import com.samsung.android.sdk.accessory.SAPeerAgent;
import com.samsung.android.sdk.accessory.SASocket;
import com.vsmartcard.acardemulator.emulators.EmulatorSingleton;
-import java.io.ByteArrayInputStream;
import java.io.IOException;
-import java.util.Arrays;
-
-import javax.security.cert.CertificateException;
-import javax.security.cert.X509Certificate;
public class SmartcardProviderService extends SAAgent {
private static final String TAG = "ACardEmulator";
@@ -110,7 +101,8 @@ public class SmartcardProviderService extends SAAgent {
@Override
protected void onServiceConnectionRequested(SAPeerAgent peerAgent) {
if (peerAgent != null) {
- authenticatePeerAgent(peerAgent);
+ //TODO: Check for keys and everything
+ acceptServiceConnectionRequest(peerAgent);
}
}
@@ -126,36 +118,12 @@ public class SmartcardProviderService extends SAAgent {
}
}
- private static byte[] getApplicationCertificate(Context context) {
- byte[] cert = new byte[0];
- String packageName = context.getPackageName();
- try {
- PackageInfo pkgInfo = context.getPackageManager().getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
- if (pkgInfo != null) {
- Signature[] sigs = pkgInfo.signatures;
- if (sigs != null) {
- ByteArrayInputStream stream = new ByteArrayInputStream(sigs[0].toByteArray());
- X509Certificate x509cert = X509Certificate.getInstance(stream);
- cert = x509cert.getPublicKey().getEncoded();
- }
- }
- } catch (PackageManager.NameNotFoundException | CertificateException e) {
- Log.e(TAG, e.getMessage());
- }
- return cert;
- }
-
@Override
protected void onAuthenticationResponse(SAPeerAgent peerAgent, SAAuthenticationToken authToken, int error) {
- if (authToken.getAuthenticationType() == SAAuthenticationToken.AUTHENTICATION_TYPE_CERTIFICATE_X509) {
- byte[] myAppKey = getApplicationCertificate(getApplicationContext());
- if (authToken.getKey().length == myAppKey.length) {
- if (Arrays.equals(authToken.getKey(), myAppKey)) {
- acceptServiceConnectionRequest(peerAgent);
- }
- }
- }
- rejectServiceConnectionRequest(peerAgent);
+ /*
+ * The authenticatePeerAgent(peerAgent) API may not be working properly depending on the firmware
+ * version of accessory device. Please refer to another sample application for Security.
+ */
}
@Override
@@ -229,7 +197,7 @@ public class SmartcardProviderService extends SAAgent {
new Thread(new Runnable() {
public void run() {
try {
- mConnectionHandler.secureSend(ACCESSORY_CHANNEL_ID, sendResponse);
+ mConnectionHandler.send(ACCESSORY_CHANNEL_ID, sendResponse);
} catch (IOException e) {
e.printStackTrace();
}
diff --git a/TCardEmulator/src/sap.c b/TCardEmulator/src/sap.c
index ba7265a..1eb92ca 100644
--- a/TCardEmulator/src/sap.c
+++ b/TCardEmulator/src/sap.c
@@ -106,8 +106,8 @@ gboolean send_data(nfc_se_h nfc_handle, char* prefix, unsigned int prefix_len, v
void *final_message = malloc(prefix_len + message_len);
memcpy(final_message, prefix, prefix_len);
memcpy(final_message + prefix_len * sizeof(char), message, message_len);
- result = sap_socket_send_secure_data(priv_data.socket,
- ACCESSORY_CHANNELID, prefix_len + message_len, final_message);
+ result = sap_socket_send_data(priv_data.socket,
+ ACCESSORY_CHANNELID, prefix_len + message_len, final_message);
if (result != SAP_RESULT_SUCCESS) {
dlog_print(DLOG_INFO, LOG_TAG, "couldn't send sap message: %d", result);