Compare commits
27
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e3870c6669 | ||
|
|
d9ccdd6a7d | ||
|
|
7b1e6cce65 | ||
|
|
b9a66144b3 | ||
|
|
8032e1c30f | ||
|
|
56069b4b07 | ||
|
|
7f416b0380 | ||
|
|
8cf3cf5785 | ||
|
|
a6da0a7889 | ||
|
|
97de3e6066 | ||
|
|
d6378e434f | ||
|
|
d7854a33bb | ||
|
|
e0448b0960 | ||
|
|
c7a37ffef8 | ||
|
|
9e6df66bfd | ||
|
|
c8b803ab07 | ||
|
|
0bc6dcd93c | ||
|
|
f6fe495046 | ||
|
|
45ca4d49e5 | ||
|
|
8b6fb829bd | ||
|
|
a15dbca837 | ||
|
|
04b0fb6fcb | ||
|
|
2d15fd6d50 | ||
|
|
fcd50896c0 | ||
|
|
4c2aada5dc | ||
|
|
2dffe6aae4 | ||
|
|
0dfa0ecee6 |
@@ -39,6 +39,6 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
implementation 'com.facebook.react:react-native:+'
|
||||
implementation 'com.madgag.spongycastle:core:1.58.0.0'
|
||||
implementation 'com.github.status-im.status-keycard-java:android:2.0.0'
|
||||
implementation 'org.bouncycastle:bcprov-jdk15on:1.60'
|
||||
implementation 'com.github.status-im.status-keycard-java:android:2.2.1'
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -23,7 +23,7 @@ import im.status.keycard.io.APDUException;
|
||||
|
||||
public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements LifecycleEventListener {
|
||||
private static final String TAG = "StatusKeycard";
|
||||
private static final String CAP_FILENAME = "keycard.cap";
|
||||
private static final String CAP_FILENAME = "keycard_v2.1.cap";
|
||||
private SmartCard smartCard;
|
||||
private final ReactApplicationContext reactContext;
|
||||
|
||||
@@ -42,6 +42,7 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements
|
||||
public void onHostResume() {
|
||||
if (this.smartCard == null) {
|
||||
this.smartCard = new SmartCard(getCurrentActivity(), reactContext);
|
||||
smartCard.start();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,24 +81,11 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void start(final Promise promise) {
|
||||
if (smartCard != null) {
|
||||
if (smartCard.start()) {
|
||||
promise.resolve(true);
|
||||
} else {
|
||||
promise.reject("Error", "Not supported on this device");
|
||||
}
|
||||
} else {
|
||||
promise.reject("Error", "smartCard is not initialized yet");
|
||||
}
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void init(final Promise promise) {
|
||||
public void init(final String pin, final Promise promise) {
|
||||
new Thread(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
SmartCardSecrets s = smartCard.init();
|
||||
SmartCardSecrets s = smartCard.init(pin);
|
||||
|
||||
WritableMap params = Arguments.createMap();
|
||||
params.putString("pin", s.getPin());
|
||||
@@ -131,11 +119,11 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void generateMnemonic(final String pairing, final Promise promise) {
|
||||
public void generateMnemonic(final String pairing, final String words, final Promise promise) {
|
||||
new Thread(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
promise.resolve(smartCard.generateMnemonic(pairing));
|
||||
promise.resolve(smartCard.generateMnemonic(pairing, words));
|
||||
} catch (IOException | APDUException e) {
|
||||
Log.d(TAG, e.getMessage());
|
||||
promise.reject(e);
|
||||
@@ -218,6 +206,34 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements
|
||||
}).start();
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void sign(final String pairing, final String pin, final String hash, final Promise promise) {
|
||||
new Thread(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
promise.resolve(smartCard.sign(pairing, pin, hash));
|
||||
} catch (IOException | APDUException e) {
|
||||
Log.d(TAG, e.getMessage());
|
||||
promise.reject(e);
|
||||
}
|
||||
}
|
||||
}).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;
|
||||
@@ -235,12 +251,12 @@ public class RNStatusKeycardModule extends ReactContextBaseJavaModule implements
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void installAppletAndInitCard(final Promise promise) {
|
||||
public void installAppletAndInitCard(final String pin, final Promise promise) {
|
||||
final ReactContext ctx = this.reactContext;
|
||||
new Thread(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
SmartCardSecrets s = smartCard.installAppletAndInitCard(ctx.getAssets(), CAP_FILENAME);
|
||||
SmartCardSecrets s = smartCard.installAppletAndInitCard(pin, ctx.getAssets(), CAP_FILENAME);
|
||||
|
||||
WritableMap params = Arguments.createMap();
|
||||
params.putString("pin", s.getPin());
|
||||
|
||||
@@ -15,10 +15,14 @@ import android.util.Log;
|
||||
import com.facebook.react.bridge.*;
|
||||
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.spec.InvalidKeySpecException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Scanner;
|
||||
|
||||
import im.status.keycard.applet.RecoverableSignature;
|
||||
import im.status.keycard.globalplatform.GlobalPlatformCommandSet;
|
||||
import im.status.keycard.io.APDUException;
|
||||
import im.status.keycard.io.CardChannel;
|
||||
@@ -32,7 +36,7 @@ import im.status.keycard.applet.Pairing;
|
||||
import im.status.keycard.applet.ApplicationInfo;
|
||||
import im.status.keycard.applet.KeyPath;
|
||||
|
||||
import org.spongycastle.util.encoders.Hex;
|
||||
import org.bouncycastle.util.encoders.Hex;
|
||||
|
||||
public class SmartCard extends BroadcastReceiver implements CardListener {
|
||||
private NFCCardManager cardManager;
|
||||
@@ -42,10 +46,12 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
|
||||
private CardChannel cardChannel;
|
||||
private EventEmitter eventEmitter;
|
||||
private static final String TAG = "SmartCard";
|
||||
private Boolean started = false;
|
||||
|
||||
private static final String WALLET_PATH = "m/44'/0'/0'/0/0";
|
||||
private static final String WALLET_PATH = "m/44'/60'/0'/0/0";
|
||||
private static final String WHISPER_PATH = "m/43'/60'/1581'/0'/0";
|
||||
private static final String ENCRYPTION_PATH = "m/43'/60'/1581'/1'/0";
|
||||
private static final int WORDS_LIST_SIZE = 2048;
|
||||
|
||||
public SmartCard(Activity activity, ReactContext reactContext) {
|
||||
this.cardManager = new NFCCardManager();
|
||||
@@ -65,15 +71,22 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
|
||||
}
|
||||
|
||||
public boolean start() {
|
||||
this.cardManager.start();
|
||||
if (this.nfcAdapter != null) {
|
||||
IntentFilter filter = new IntentFilter(NfcAdapter.ACTION_ADAPTER_STATE_CHANGED);
|
||||
activity.registerReceiver(this, filter);
|
||||
nfcAdapter.enableReaderMode(activity, this.cardManager, NfcAdapter.FLAG_READER_NFC_A | NfcAdapter.FLAG_READER_SKIP_NDEF_CHECK, null);
|
||||
return true;
|
||||
if (!started) {
|
||||
|
||||
this.cardManager.start();
|
||||
started = true;
|
||||
|
||||
if (this.nfcAdapter != null) {
|
||||
IntentFilter filter = new IntentFilter(NfcAdapter.ACTION_ADAPTER_STATE_CHANGED);
|
||||
activity.registerReceiver(this, filter);
|
||||
nfcAdapter.enableReaderMode(activity, this.cardManager, NfcAdapter.FLAG_READER_NFC_A | NfcAdapter.FLAG_READER_SKIP_NDEF_CHECK, null);
|
||||
return true;
|
||||
} else {
|
||||
log("not support in this device");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
log("not support in this device");
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +98,7 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
|
||||
|
||||
@Override
|
||||
public void onDisconnected() {
|
||||
eventEmitter.emit( "keyCardOnDisconnected", null);
|
||||
eventEmitter.emit("keyCardOnDisconnected", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -114,13 +127,13 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
|
||||
}
|
||||
}
|
||||
|
||||
public SmartCardSecrets init() throws IOException, APDUException, NoSuchAlgorithmException, InvalidKeySpecException {
|
||||
public SmartCardSecrets init(final String userPin) throws IOException, APDUException, NoSuchAlgorithmException, InvalidKeySpecException {
|
||||
KeycardCommandSet cmdSet = new KeycardCommandSet(this.cardChannel);
|
||||
cmdSet.select().checkOK();
|
||||
|
||||
eventEmitter.emit("keycardInstallationProgress", 0.90);
|
||||
|
||||
SmartCardSecrets s = SmartCardSecrets.generate();
|
||||
SmartCardSecrets s = SmartCardSecrets.generate(userPin);
|
||||
|
||||
eventEmitter.emit("keycardInstallationProgress", 0.93);
|
||||
|
||||
@@ -133,7 +146,6 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
|
||||
|
||||
public String pair(String pairingPassword) throws IOException, APDUException {
|
||||
KeycardCommandSet cmdSet = new KeycardCommandSet(this.cardChannel);
|
||||
log("Pairing password: " + pairingPassword);
|
||||
Log.i(TAG, "Applet selection successful");
|
||||
|
||||
// First thing to do is selecting the applet on the card.
|
||||
@@ -146,14 +158,11 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
|
||||
cmdSet.autoPair(pairingPassword);
|
||||
|
||||
Pairing pairing = cmdSet.getPairing();
|
||||
log("Pairing index: " + pairing.getPairingIndex());
|
||||
log("Pairing key: " + Hex.toHexString(pairing.getPairingKey()));
|
||||
log("Pairing toBase64: " + pairing.toBase64());
|
||||
|
||||
return pairing.toBase64();
|
||||
}
|
||||
|
||||
public String generateMnemonic(String pairingBase64) throws IOException, APDUException {
|
||||
public String generateMnemonic(String pairingBase64, String words) throws IOException, APDUException {
|
||||
KeycardCommandSet cmdSet = new KeycardCommandSet(this.cardChannel);
|
||||
cmdSet.select().checkOK();
|
||||
|
||||
@@ -164,7 +173,16 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
|
||||
Log.i(TAG, "secure channel opened");
|
||||
|
||||
Mnemonic mnemonic = new Mnemonic(cmdSet.generateMnemonic(KeycardCommandSet.GENERATE_MNEMONIC_12_WORDS).checkOK().getData());
|
||||
mnemonic.fetchBIP39EnglishWordlist();
|
||||
|
||||
Scanner scanner = new Scanner(words);
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
while(scanner.hasNextLine()) {
|
||||
list.add(scanner.nextLine());
|
||||
}
|
||||
scanner.close();
|
||||
|
||||
String [] wordsList = list.toArray(new String[WORDS_LIST_SIZE]);
|
||||
mnemonic.setWordlist(wordsList);
|
||||
|
||||
return mnemonic.toMnemonicPhrase();
|
||||
}
|
||||
@@ -209,23 +227,31 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
|
||||
Log.i(TAG, "The card has no master key");
|
||||
}
|
||||
|
||||
Boolean isPaired = false;
|
||||
|
||||
if (pairingBase64.length() > 0) {
|
||||
Pairing pairing = new Pairing(pairingBase64);
|
||||
cmdSet.setPairing(pairing);
|
||||
try {
|
||||
Pairing pairing = new Pairing(pairingBase64);
|
||||
cmdSet.setPairing(pairing);
|
||||
|
||||
cmdSet.autoOpenSecureChannel();
|
||||
Log.i(TAG, "secure channel opened");
|
||||
cmdSet.autoOpenSecureChannel();
|
||||
Log.i(TAG, "secure channel opened");
|
||||
isPaired = true;
|
||||
|
||||
ApplicationStatus status = new ApplicationStatus(cmdSet.getStatus(KeycardCommandSet.GET_STATUS_P1_APPLICATION).checkOK().getData());
|
||||
ApplicationStatus status = new ApplicationStatus(cmdSet.getStatus(KeycardCommandSet.GET_STATUS_P1_APPLICATION).checkOK().getData());
|
||||
|
||||
Log.i(TAG, "PIN retry counter: " + status.getPINRetryCount());
|
||||
Log.i(TAG, "PUK retry counter: " + status.getPUKRetryCount());
|
||||
Log.i(TAG, "PIN retry counter: " + status.getPINRetryCount());
|
||||
Log.i(TAG, "PUK retry counter: " + status.getPUKRetryCount());
|
||||
|
||||
cardInfo.putInt("pin-retry-counter", status.getPINRetryCount());
|
||||
cardInfo.putInt("puk-retry-counter", status.getPUKRetryCount());
|
||||
cardInfo.putInt("pin-retry-counter", status.getPINRetryCount());
|
||||
cardInfo.putInt("puk-retry-counter", status.getPUKRetryCount());
|
||||
} catch (IOException | IllegalArgumentException e) {
|
||||
Log.i(TAG, "autoOpenSecureChannel failed: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
cardInfo.putBoolean("has-master-key?", info.hasMasterKey());
|
||||
cardInfo.putBoolean("paired?", isPaired);
|
||||
cardInfo.putString("instance-uid", Hex.toHexString(info.getInstanceUID()));
|
||||
cardInfo.putString("secure-channel-pub-key", Hex.toHexString(info.getSecureChannelPubKey()));
|
||||
cardInfo.putString("app-version", info.getAppVersionString());
|
||||
@@ -251,10 +277,8 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
|
||||
KeyPath currentPath = new KeyPath(cmdSet.getStatus(KeycardCommandSet.GET_STATUS_P1_KEY_PATH).checkOK().getData());
|
||||
Log.i(TAG, "Current key path: " + currentPath);
|
||||
|
||||
if (!currentPath.toString().equals("m/44'/0'/0'/0/0")) {
|
||||
cmdSet.deriveKey(path).checkOK();
|
||||
Log.i(TAG, "Derived m/44'/0'/0'/0/0");
|
||||
}
|
||||
cmdSet.deriveKey(path).checkOK();
|
||||
Log.i(TAG, "Derived " + path);
|
||||
}
|
||||
|
||||
public String exportKey(final String pairingBase64, final String pin) throws IOException, APDUException {
|
||||
@@ -288,25 +312,13 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
|
||||
cmdSet.verifyPIN(pin).checkOK();
|
||||
Log.i(TAG, "pin verified");
|
||||
|
||||
|
||||
cmdSet.deriveKey(WALLET_PATH).checkOK();
|
||||
Log.i(TAG, "Derived " + WALLET_PATH);
|
||||
|
||||
byte[] tlv = cmdSet.exportCurrentKey(true).checkOK().getData();
|
||||
byte[] tlv = cmdSet.exportKey(WALLET_PATH, true, true).checkOK().getData();
|
||||
BIP32KeyPair walletKeyPair = BIP32KeyPair.fromTLV(tlv);
|
||||
|
||||
|
||||
cmdSet.deriveKey(WHISPER_PATH).checkOK();
|
||||
Log.i(TAG, "Derived " + WHISPER_PATH);
|
||||
|
||||
byte[] tlv2 = cmdSet.exportCurrentKey(false).checkOK().getData();
|
||||
byte[] tlv2 = cmdSet.exportKey(WHISPER_PATH, false, false).checkOK().getData();
|
||||
BIP32KeyPair whisperKeyPair = BIP32KeyPair.fromTLV(tlv2);
|
||||
|
||||
|
||||
cmdSet.deriveKey(ENCRYPTION_PATH).checkOK();
|
||||
Log.i(TAG, "Derived " + ENCRYPTION_PATH);
|
||||
|
||||
byte[] tlv3 = cmdSet.exportCurrentKey(false).checkOK().getData();
|
||||
byte[] tlv3 = cmdSet.exportKey(ENCRYPTION_PATH, false, false).checkOK().getData();
|
||||
BIP32KeyPair encryptionKeyPair = BIP32KeyPair.fromTLV(tlv3);
|
||||
|
||||
WritableMap data = Arguments.createMap();
|
||||
@@ -355,12 +367,15 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
|
||||
byte[] tlv3 = cmdSet.exportCurrentKey(false).checkOK().getData();
|
||||
BIP32KeyPair encryptionKeyPair = BIP32KeyPair.fromTLV(tlv3);
|
||||
|
||||
ApplicationInfo info = new ApplicationInfo(cmdSet.select().checkOK().getData());
|
||||
|
||||
WritableMap data = Arguments.createMap();
|
||||
data.putString("wallet-address", Hex.toHexString(walletKeyPair.toEthereumAddress()));
|
||||
data.putString("whisper-address", Hex.toHexString(whisperKeyPair.toEthereumAddress()));
|
||||
data.putString("whisper-public-key", Hex.toHexString(whisperKeyPair.getPublicKey()));
|
||||
data.putString("whisper-private-key", Hex.toHexString(whisperKeyPair.getPrivateKey()));
|
||||
data.putString("encryption-public-key", Hex.toHexString(encryptionKeyPair.getPublicKey()));
|
||||
data.putString("instance-uid", Hex.toHexString(info.getInstanceUID()));
|
||||
|
||||
return data;
|
||||
}
|
||||
@@ -370,11 +385,11 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
|
||||
installer.start();
|
||||
}
|
||||
|
||||
public SmartCardSecrets installAppletAndInitCard(AssetManager assets, String capPath) throws IOException, APDUException, NoSuchAlgorithmException, InvalidKeySpecException {
|
||||
public SmartCardSecrets installAppletAndInitCard(final String userPin, AssetManager assets, String capPath) throws IOException, APDUException, NoSuchAlgorithmException, InvalidKeySpecException {
|
||||
Installer installer = new Installer(this.cardChannel, assets, capPath, eventEmitter);
|
||||
installer.start();
|
||||
|
||||
return init();
|
||||
return init(userPin);
|
||||
}
|
||||
|
||||
public int verifyPin(final String pairingBase64, final String pin) throws IOException, APDUException {
|
||||
@@ -459,4 +474,61 @@ public class SmartCard extends BroadcastReceiver implements CardListener {
|
||||
delete();
|
||||
}
|
||||
|
||||
public String sign(final String pairingBase64, final String pin, final String message) 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[] hash = Hex.decode(message);
|
||||
RecoverableSignature signature = new RecoverableSignature(hash, cmdSet.sign(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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package im.status.ethereum.keycard;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Base64;
|
||||
import static android.util.Base64.NO_PADDING;
|
||||
import static android.util.Base64.NO_WRAP;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
|
||||
@@ -28,11 +29,18 @@ public class SmartCardSecrets {
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static SmartCardSecrets generate() throws NoSuchAlgorithmException, InvalidKeySpecException {
|
||||
public static SmartCardSecrets generate(final String userPin) throws NoSuchAlgorithmException, InvalidKeySpecException {
|
||||
String pairingPassword = randomToken(12);
|
||||
long pinNumber = randomLong(PIN_BOUND);
|
||||
long pukNumber = randomLong(PUK_BOUND);
|
||||
String pin = String.format("%06d", pinNumber);
|
||||
|
||||
String pin;
|
||||
if (userPin.isEmpty()) {
|
||||
pin = String.format("%06d", pinNumber);
|
||||
} else {
|
||||
pin = userPin;
|
||||
}
|
||||
|
||||
String puk = String.format("%012d", pukNumber);
|
||||
|
||||
return new SmartCardSecrets(pin, puk, pairingPassword);
|
||||
@@ -56,7 +64,7 @@ public class SmartCardSecrets {
|
||||
}
|
||||
|
||||
public static String randomToken(int length) {
|
||||
return Base64.encodeToString(randomBytes(length), NO_PADDING);
|
||||
return Base64.encodeToString(randomBytes(length), (NO_PADDING | NO_WRAP));
|
||||
}
|
||||
|
||||
public static byte[] randomBytes(int length) {
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
|
||||
{
|
||||
"name": "react-native-status-keycard",
|
||||
"version": "2.3.0",
|
||||
"version": "2.5.0",
|
||||
"description": "React Native library to interact with Status Keycard using NFC connection (Android only)",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user