Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f8966f1a8 | ||
|
|
3acea10750 |
@@ -19,6 +19,7 @@ import java.util.Arrays;
|
||||
public class KeycardCommandSet {
|
||||
static final byte INS_INIT = (byte) 0xFE;
|
||||
static final byte INS_GET_STATUS = (byte) 0xF2;
|
||||
static final byte INS_SET_NDEF = (byte) 0xF3;
|
||||
static final byte INS_VERIFY_PIN = (byte) 0x20;
|
||||
static final byte INS_CHANGE_PIN = (byte) 0x21;
|
||||
static final byte INS_UNBLOCK_PIN = (byte) 0x22;
|
||||
@@ -683,15 +684,20 @@ public class KeycardCommandSet {
|
||||
* @throws IOException communication error
|
||||
*/
|
||||
public APDUResponse setNDEF(byte[] ndef) throws IOException {
|
||||
if ((ndef.length - 2) != ((ndef[0] << 8) | ndef[1])) {
|
||||
byte[] tmp = new byte[ndef.length + 2];
|
||||
tmp[0] = (byte) (ndef.length >> 8);
|
||||
tmp[1] = (byte) (ndef.length & 0xff);
|
||||
System.arraycopy(ndef, 0, tmp, 2, ndef.length);
|
||||
ndef = tmp;
|
||||
}
|
||||
if ((info.getAppVersion() >> 8) > 2) {
|
||||
if ((ndef.length - 2) != ((ndef[0] << 8) | ndef[1])) {
|
||||
byte[] tmp = new byte[ndef.length + 2];
|
||||
tmp[0] = (byte) (ndef.length >> 8);
|
||||
tmp[1] = (byte) (ndef.length & 0xff);
|
||||
System.arraycopy(ndef, 0, tmp, 2, ndef.length);
|
||||
ndef = tmp;
|
||||
}
|
||||
|
||||
return storeData(ndef, STORE_DATA_P1_NDEF);
|
||||
return storeData(ndef, STORE_DATA_P1_NDEF);
|
||||
} else {
|
||||
APDUCommand setNDEF = secureChannel.protectedCommand(0x80, INS_SET_NDEF, 0, 0, ndef);
|
||||
return secureChannel.transmit(apduChannel, setNDEF);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -41,28 +41,11 @@ public class Mnemonic {
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the official BIP39 english wordlist from GitHub.
|
||||
* Returns the official BIP39 english wordlist as fetched from https://raw.githubusercontent.com/bitcoin/bips/master/bip-0039/english.txt on 23 Oct 2019.
|
||||
*
|
||||
* @throws IOException network error
|
||||
*/
|
||||
public void fetchBIP39EnglishWordlist() throws IOException {
|
||||
URL remoteList = new URL("https://raw.githubusercontent.com/bitcoin/bips/master/bip-0039/english.txt");
|
||||
Scanner scanner = new Scanner(remoteList.openStream());
|
||||
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
|
||||
while(scanner.hasNextLine()) {
|
||||
list.add(scanner.nextLine());
|
||||
}
|
||||
|
||||
scanner.close();
|
||||
|
||||
if (list.size() != WORDLIST_SIZE) {
|
||||
throw new IllegalArgumentException("The list must contain exactly 2048 entries");
|
||||
}
|
||||
|
||||
this.wordlist = new String[WORDLIST_SIZE];
|
||||
list.toArray(this.wordlist);
|
||||
public void fetchBIP39EnglishWordlist() {
|
||||
this.wordlist = MnemonicEnglishDictionary.words;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user