Add exportKeyWithPath() fn

This commit is contained in:
Vitaliy Vlasov 2019-11-19 15:29:11 +02:00
parent 29fe98beb3
commit 73c41d1a3d
No known key found for this signature in database
GPG Key ID: A7D57C347F2B2964
3 changed files with 34 additions and 1 deletions

View File

@ -204,6 +204,21 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements
}).start();
}
@ReactMethod
public void exportKeyWithPath(final String pairing, final String pin, final String path, final Promise promise) {
new Thread(new Runnable() {
public void run() {
try {
promise.resolve(smartCard.exportKeyWithPath(pairing, pin, path));
} catch (IOException | APDUException e) {
Log.d(TAG, e.getMessage());
promise.reject(e);
}
}
}).start();
}
@ReactMethod
public void getKeys(final String pairing, final String pin, final Promise promise) {
new Thread(new Runnable() {

View File

@ -299,6 +299,24 @@ 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 {
KeycardCommandSet cmdSet = new KeycardCommandSet(this.cardChannel);
cmdSet.select().checkOK();
Pairing pairing = new Pairing(pairingBase64);
cmdSet.setPairing(pairing);
cmdSet.autoOpenSecureChannel();
Log.i(TAG, "secure channel opened");
cmdSet.verifyPIN(pin).checkOK();
Log.i(TAG, "pin verified");
byte[] key = BIP32KeyPair.fromTLV(cmdSet.exportKey(path, false, true).checkOK().getData()).getPublicKey();
return Hex.toHexString(key);
}
public WritableMap getKeys(final String pairingBase64, final String pin) throws IOException, APDUException {
KeycardCommandSet cmdSet = new KeycardCommandSet(this.cardChannel);
cmdSet.select().checkOK();

View File

@ -1,7 +1,7 @@
{
"name": "react-native-status-keycard",
"homepage": "https://keycard.status.im/",
"version": "2.5.15",
"version": "2.5.16",
"description": "React Native library to interact with Status Keycard using NFC connection (Android only)",
"main": "index.js",
"scripts": {