make compatible with 2.1 Keycard applet

This commit is contained in:
Michele Balistreri 2020-05-18 13:36:18 +03:00
parent 267bf1184f
commit 59052a36d7
No known key found for this signature in database
GPG Key ID: E9567DA33A4F791A
1 changed files with 12 additions and 1 deletions

View File

@ -565,7 +565,18 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
Log.i(TAG, "pin verified");
byte[] hash = Hex.decode(message);
RecoverableSignature signature = new RecoverableSignature(hash, cmdSet.signWithPath(hash, path, false).checkOK().getData());
RecoverableSignature signature;
if (cmdSet.getApplicationInfo().getAppVersion() < 0x0202) {
String actualPath = new KeyPath(cmdSet.getStatus(KeycardCommandSet.GET_STATUS_P1_KEY_PATH).checkOK().getData()).toString();
if (!actualPath.equals(path)) {
cmdSet.deriveKey(path).checkOK();
}
signature = new RecoverableSignature(hash, cmdSet.sign(hash).checkOK().getData());
} else {
signature = new RecoverableSignature(hash, cmdSet.signWithPath(hash, path, false).checkOK().getData());
}
Log.i(TAG, "Signed hash: " + Hex.toHexString(hash));
Log.i(TAG, "Recovery ID: " + signature.getRecId());