Compare commits

...
Author SHA1 Message Date
Dmitry Novotochinov e3870c6669 add signPinless() 2019-04-09 17:57:30 +03:00
3 changed files with 39 additions and 1 deletions
+1 -1
View File
@@ -40,5 +40,5 @@ repositories {
dependencies {
implementation 'com.facebook.react:react-native:+'
implementation 'org.bouncycastle:bcprov-jdk15on:1.60'
implementation 'com.github.status-im.status-keycard-java:android:2.1.0'
implementation 'com.github.status-im.status-keycard-java:android:2.2.1'
}
@@ -220,6 +220,20 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements
}).start();
}
@ReactMethod
public void signPinless(final String hash, final Promise promise) {
new Thread(new Runnable() {
public void run() {
try {
promise.resolve(smartCard.signPinless(hash));
} catch (IOException | APDUException e) {
Log.d(TAG, e.getMessage());
promise.reject(e);
}
}
}).start();
}
@ReactMethod
public void installApplet(final Promise promise) {
final ReactContext ctx = this.reactContext;
@@ -507,4 +507,28 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
return sig;
}
public String signPinless(final String message) throws IOException, APDUException {
KeycardCommandSet cmdSet = new KeycardCommandSet(this.cardChannel);
cmdSet.select().checkOK();
byte[] hash = Hex.decode(message);
RecoverableSignature signature = new RecoverableSignature(hash, cmdSet.signPinless(hash).checkOK().getData());
Log.i(TAG, "Signed hash: " + Hex.toHexString(hash));
Log.i(TAG, "Recovery ID: " + signature.getRecId());
Log.i(TAG, "R: " + Hex.toHexString(signature.getR()));
Log.i(TAG, "S: " + Hex.toHexString(signature.getS()));
ByteArrayOutputStream out = new ByteArrayOutputStream();
out.write(signature.getR());
out.write(signature.getS());
out.write(signature.getRecId());
String sig = Hex.toHexString(out.toByteArray());
Log.i(TAG, "Signature: " + sig);
return sig;
}
}