From 39921f738770989e4d727dc8fb1c46a7da582aee Mon Sep 17 00:00:00 2001 From: Michele Balistreri Date: Mon, 15 Mar 2021 11:05:25 +0300 Subject: [PATCH] remove pairing argument internally --- .../keycard/RNStatusKeycardModule.java | 36 +++++++++--------- .../im/status/ethereum/keycard/SmartCard.java | 38 +++++++++---------- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/android/src/main/java/im/status/ethereum/keycard/RNStatusKeycardModule.java b/android/src/main/java/im/status/ethereum/keycard/RNStatusKeycardModule.java index 0c66b8d..a900b62 100644 --- a/android/src/main/java/im/status/ethereum/keycard/RNStatusKeycardModule.java +++ b/android/src/main/java/im/status/ethereum/keycard/RNStatusKeycardModule.java @@ -124,7 +124,7 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements new Thread(new Runnable() { public void run() { try { - promise.resolve(smartCard.generateMnemonic(pairing, words)); + promise.resolve(smartCard.generateMnemonic(words)); } catch (IOException | APDUException e) { Log.d(TAG, e.getMessage()); promise.reject(e); @@ -138,7 +138,7 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements new Thread(new Runnable() { public void run() { try { - promise.resolve(smartCard.generateAndLoadKey(mnemonic, pairing, pin)); + promise.resolve(smartCard.generateAndLoadKey(mnemonic, pin)); } catch (IOException | APDUException e) { Log.d(TAG, e.getMessage()); promise.reject(e); @@ -152,7 +152,7 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements new Thread(new Runnable() { public void run() { try { - smartCard.saveMnemonic(mnemonic, pairing, pin); + smartCard.saveMnemonic(mnemonic, pin); promise.resolve(true); } catch (IOException | APDUException e) { Log.d(TAG, e.getMessage()); @@ -167,7 +167,7 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements new Thread(new Runnable() { public void run() { try { - promise.resolve(smartCard.getApplicationInfo(pairingBase64)); + promise.resolve(smartCard.getApplicationInfo()); } catch (IOException | APDUException e) { Log.d(TAG, e.getMessage()); promise.reject(e); @@ -181,7 +181,7 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements new Thread(new Runnable() { public void run() { try { - smartCard.deriveKey(path, pairing, pin); + smartCard.deriveKey(path, pin); promise.resolve(path); } catch (IOException | APDUException e) { Log.d(TAG, e.getMessage()); @@ -196,7 +196,7 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements new Thread(new Runnable() { public void run() { try { - promise.resolve(smartCard.exportKey(pairing, pin)); + promise.resolve(smartCard.exportKey(pin)); } catch (IOException | APDUException e) { Log.d(TAG, e.getMessage()); promise.reject(e); @@ -210,7 +210,7 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements new Thread(new Runnable() { public void run() { try { - promise.resolve(smartCard.exportKeyWithPath(pairing, pin, path)); + promise.resolve(smartCard.exportKeyWithPath(pin, path)); } catch (IOException | APDUException e) { Log.d(TAG, e.getMessage()); promise.reject(e); @@ -224,7 +224,7 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements new Thread(new Runnable() { public void run() { try { - promise.resolve(smartCard.getKeys(pairing, pin)); + promise.resolve(smartCard.getKeys(pin)); } catch (IOException | APDUException e) { Log.d(TAG, e.getMessage()); promise.reject(e); @@ -238,7 +238,7 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements new Thread(new Runnable() { public void run() { try { - promise.resolve(smartCard.importKeys(pairing, pin)); + promise.resolve(smartCard.importKeys(pin)); } catch (IOException | APDUException e) { Log.d(TAG, e.getMessage()); promise.reject(e); @@ -252,7 +252,7 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements new Thread(new Runnable() { public void run() { try { - promise.resolve(smartCard.sign(pairing, pin, hash)); + promise.resolve(smartCard.sign(pin, hash)); } catch (IOException | APDUException e) { Log.d(TAG, e.getMessage()); promise.reject(e); @@ -266,7 +266,7 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements new Thread(new Runnable() { public void run() { try { - promise.resolve(smartCard.signWithPath(pairing, pin, path, hash)); + promise.resolve(smartCard.signWithPath(pin, path, hash)); } catch (IOException | APDUException e) { Log.d(TAG, e.getMessage()); promise.reject(e); @@ -332,7 +332,7 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements new Thread(new Runnable() { public void run() { try { - promise.resolve(smartCard.verifyPin(pairing, pin)); + promise.resolve(smartCard.verifyPin(pin)); } catch (IOException | APDUException e) { Log.d(TAG, e.getMessage()); promise.reject(e); @@ -346,7 +346,7 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements new Thread(new Runnable() { public void run() { try { - smartCard.changePin(pairing, currentPin, newPin); + smartCard.changePin(currentPin, newPin); promise.resolve(true); } catch (IOException | APDUException e) { Log.d(TAG, e.getMessage()); @@ -361,7 +361,7 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements new Thread(new Runnable() { public void run() { try { - smartCard.unblockPin(pairing, puk, newPin); + smartCard.unblockPin(puk, newPin); promise.resolve(true); } catch (IOException | APDUException e) { Log.d(TAG, e.getMessage()); @@ -376,7 +376,7 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements new Thread(new Runnable() { public void run() { try { - smartCard.unpair(pairing, pin); + smartCard.unpair(pin); promise.resolve(true); } catch (IOException | APDUException e) { Log.d(TAG, e.getMessage()); @@ -406,7 +406,7 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements new Thread(new Runnable() { public void run() { try { - smartCard.removeKey(pairing, pin); + smartCard.removeKey(pin); promise.resolve(true); } catch (IOException | APDUException e) { Log.d(TAG, e.getMessage()); @@ -421,7 +421,7 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements new Thread(new Runnable() { public void run() { try { - smartCard.removeKeyWithUnpair(pairing, pin); + smartCard.removeKeyWithUnpair(pin); promise.resolve(true); } catch (IOException | APDUException e) { Log.d(TAG, e.getMessage()); @@ -436,7 +436,7 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements new Thread(new Runnable() { public void run() { try { - smartCard.unpairAndDelete(pairing, pin); + smartCard.unpairAndDelete(pin); promise.resolve(true); } catch (IOException | APDUException e) { Log.d(TAG, e.getMessage()); diff --git a/android/src/main/java/im/status/ethereum/keycard/SmartCard.java b/android/src/main/java/im/status/ethereum/keycard/SmartCard.java index c673266..1ba7f40 100644 --- a/android/src/main/java/im/status/ethereum/keycard/SmartCard.java +++ b/android/src/main/java/im/status/ethereum/keycard/SmartCard.java @@ -179,7 +179,7 @@ public class SmartCard extends BroadcastReceiver implements CardListener { return pairing.toBase64(); } - public String generateMnemonic(String pairingBase64, String words) throws IOException, APDUException { + public String generateMnemonic(String words) throws IOException, APDUException { KeycardCommandSet cmdSet = securedCommandSet(); Mnemonic mnemonic = new Mnemonic(cmdSet.generateMnemonic(KeycardCommandSet.GENERATE_MNEMONIC_12_WORDS).checkOK().getData()); @@ -197,7 +197,7 @@ public class SmartCard extends BroadcastReceiver implements CardListener { return mnemonic.toMnemonicPhrase(); } - public void saveMnemonic(String mnemonic, String pairingBase64, String pin) throws IOException, APDUException { + public void saveMnemonic(String mnemonic, String pin) throws IOException, APDUException { KeycardCommandSet cmdSet = authenticatedCommandSet(pin); byte[] seed = Mnemonic.toBinarySeed(mnemonic, ""); @@ -206,7 +206,7 @@ public class SmartCard extends BroadcastReceiver implements CardListener { log("seed loaded to card"); } - public WritableMap getApplicationInfo(final String pairingBase64) throws IOException, APDUException { + public WritableMap getApplicationInfo() throws IOException, APDUException { KeycardCommandSet cmdSet = new KeycardCommandSet(this.cardChannel); ApplicationInfo info = new ApplicationInfo(cmdSet.select().checkOK().getData()); @@ -257,7 +257,7 @@ public class SmartCard extends BroadcastReceiver implements CardListener { return cardInfo; } - public void deriveKey(final String path, final String pairingBase64, final String pin) throws IOException, APDUException { + public void deriveKey(final String path, final String pin) throws IOException, APDUException { KeycardCommandSet cmdSet = authenticatedCommandSet(pin); KeyPath currentPath = new KeyPath(cmdSet.getStatus(KeycardCommandSet.GET_STATUS_P1_KEY_PATH).checkOK().getData()); @@ -269,7 +269,7 @@ public class SmartCard extends BroadcastReceiver implements CardListener { } } - public String exportKey(final String pairingBase64, final String pin) throws IOException, APDUException { + public String exportKey(final String pin) throws IOException, APDUException { KeycardCommandSet cmdSet = authenticatedCommandSet(pin); byte[] key = cmdSet.exportCurrentKey(true).checkOK().getData(); @@ -277,7 +277,7 @@ public class SmartCard extends BroadcastReceiver implements CardListener { return Hex.toHexString(key); } - public String exportKeyWithPath(final String pairingBase64, final String pin, final String path) throws IOException, APDUException { + public String exportKeyWithPath(final String pin, final String path) throws IOException, APDUException { KeycardCommandSet cmdSet = authenticatedCommandSet(pin); byte[] key = BIP32KeyPair.fromTLV(cmdSet.exportKey(path, false, true).checkOK().getData()).getPublicKey(); @@ -285,7 +285,7 @@ public class SmartCard extends BroadcastReceiver implements CardListener { return Hex.toHexString(key); } - public WritableMap getKeys(final String pairingBase64, final String pin) throws IOException, APDUException { + public WritableMap getKeys(final String pin) throws IOException, APDUException { KeycardCommandSet cmdSet = authenticatedCommandSet(pin); byte[] tlvWhisper = cmdSet.exportKey(WHISPER_PATH, false, false).checkOK().getData(); @@ -307,7 +307,7 @@ public class SmartCard extends BroadcastReceiver implements CardListener { return data; } - public WritableMap importKeys(final String pairingBase64, final String pin) throws IOException, APDUException { + public WritableMap importKeys(final String pin) throws IOException, APDUException { KeycardCommandSet cmdSet = authenticatedCommandSet(pin); byte[] tlvEncryption = cmdSet.exportKey(ENCRYPTION_PATH, false, false).checkOK().getData(); @@ -344,7 +344,7 @@ public class SmartCard extends BroadcastReceiver implements CardListener { return data; } - public WritableMap generateAndLoadKey(final String mnemonic, final String pairingBase64, final String pin) throws IOException, APDUException { + public WritableMap generateAndLoadKey(final String mnemonic, final String pin) throws IOException, APDUException { KeycardCommandSet cmdSet = authenticatedCommandSet(pin); byte[] seed = Mnemonic.toBinarySeed(mnemonic, ""); @@ -400,26 +400,26 @@ public class SmartCard extends BroadcastReceiver implements CardListener { return init(userPin); } - public int verifyPin(final String pairingBase64, final String pin) throws IOException, APDUException { + public int verifyPin(final String pin) throws IOException, APDUException { KeycardCommandSet cmdSet = authenticatedCommandSet(pin); return 3; } - public void changePin(final String pairingBase64, final String currentPin, final String newPin) throws IOException, APDUException { + public void changePin(final String currentPin, final String newPin) throws IOException, APDUException { KeycardCommandSet cmdSet = authenticatedCommandSet(currentPin); cmdSet.changePIN(0, newPin); Log.i(TAG, "pin changed"); } - public void unblockPin(final String pairingBase64, final String puk, final String newPin) throws IOException, APDUException { + public void unblockPin(final String puk, final String newPin) throws IOException, APDUException { KeycardCommandSet cmdSet = securedCommandSet(); cmdSet.unblockPIN(puk, newPin).checkOK(); Log.i(TAG, "pin unblocked"); } - public void unpair(final String pairingBase64, final String pin) throws IOException, APDUException { + public void unpair(final String pin) throws IOException, APDUException { KeycardCommandSet cmdSet = authenticatedCommandSet(pin); cmdSet.autoUnpair(); @@ -439,14 +439,14 @@ public class SmartCard extends BroadcastReceiver implements CardListener { Log.i(TAG, "instance and package deleted"); } - public void removeKey(final String pairingBase64, final String pin) throws IOException, APDUException { + public void removeKey(final String pin) throws IOException, APDUException { KeycardCommandSet cmdSet = authenticatedCommandSet(pin); cmdSet.removeKey(); Log.i(TAG, "key removed"); } - public void removeKeyWithUnpair(final String pairingBase64, final String pin) throws IOException, APDUException { + public void removeKeyWithUnpair(final String pin) throws IOException, APDUException { KeycardCommandSet cmdSet = authenticatedCommandSet(pin); cmdSet.removeKey(); @@ -462,12 +462,12 @@ public class SmartCard extends BroadcastReceiver implements CardListener { pairings.remove(instanceUID); } - public void unpairAndDelete(final String pairingBase64, final String pin) throws IOException, APDUException { - unpair(pairingBase64, pin); + public void unpairAndDelete(final String pin) throws IOException, APDUException { + unpair(pin); delete(); } - public String sign(final String pairingBase64, final String pin, final String message) throws IOException, APDUException { + public String sign(final String pin, final String message) throws IOException, APDUException { KeycardCommandSet cmdSet = authenticatedCommandSet(pin); byte[] hash = Hex.decode(message); @@ -490,7 +490,7 @@ public class SmartCard extends BroadcastReceiver implements CardListener { return sig; } - public String signWithPath(final String pairingBase64, final String pin, final String path, final String message) throws IOException, APDUException { + public String signWithPath(final String pin, final String path, final String message) throws IOException, APDUException { KeycardCommandSet cmdSet = authenticatedCommandSet(pin); byte[] hash = Hex.decode(message);