Skip to content

Commit

Permalink
Merge branch 'release/v0.0.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
robertclarkson committed Aug 22, 2022
2 parents 708cb3b + 8cd624f commit 5a4fb4e
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 18 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Quickly program a blank NFC card (NTAG424DNA) to act as your own personal Boltca
The boltcard can be used with Lightning PoS terminals that have NFC support, or Breez wallet PoS App.

## Current Version
v0.0.6
v0.0.7

## Setup & Run instructions for Linux with Android

Expand Down Expand Up @@ -41,6 +41,12 @@ Download the compiled APK from the [latest release](https://github.com/boltcard/
6. When the keys are loaded, Hold the NFC card to the phone to run the key change on the card. Do not move the card until the key change has completed.
Warning! If you lose the new keys then you will be unable to reprogram the card again

# Dependencies / Security considerations

We rely on the Taplinx 2.0 Android library supplied by NXP.

React native libraries are also used to make building the UI easier.

## Useful commands

* adb logcat -s "lightningnfcapp"
Expand Down
26 changes: 20 additions & 6 deletions android/app/src/main/java/com/lightningnfcapp/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ else if (type == CardType.NTAG424DNA) {
INdefMessage ndefRead = ntag424DNA.readNDEF();

//Check if auth works to see if key0 is zero.
String key0Changed = null;
String key0Changed = "unsure";
try {
key0Changed="no";
ntag424DNA.isoSelectApplicationByDFName(NTAG424DNA_APP_NAME);
Expand All @@ -400,13 +400,27 @@ else if (type == CardType.NTAG424DNA) {
key0Changed="yes";
}

//check PICC encryption to see if key1 is zero
String key1Changed = "unsure";
String key2Changed = "unsure";

String bolturl = this.decodeHex(ndefRead.toByteArray()).substring(5);
//if we dont have a p and a c we cant check the keys
if(bolturl.indexOf("p=")==-1 || bolturl.indexOf("c=")==-1) {
WritableMap params = Arguments.createMap();
params.putString("cardReadInfo", cardDataBuilder);
params.putString("ndef", bolturl);
params.putString("key0Changed", key0Changed);
params.putString("key1Changed", key1Changed);
params.putString("key2Changed", key2Changed);
params.putString("cardUID", UID.substring(2));
sendEvent("CardHasBeenRead", params);
return;
}
//check PICC encryption to see if key1 is zero
String pParam = bolturl.split("p=")[1].substring(0, 32);
String cParam = bolturl.split("c=")[1].substring(0, 16);
String pDecrypt = this.decrypt(this.hexStringToByteArray(pParam));
String key1Changed = "yes";
if(pDecrypt.startsWith("0xC7"+UID.substring(2))) {
String UIDwithout0x = UID.substring(2);
if(pDecrypt.startsWith("0xC7"+UIDwithout0x)) {
key1Changed = "no";
}

Expand All @@ -417,8 +431,8 @@ else if (type == CardType.NTAG424DNA) {
byte[] msg = sv2; //Arrays.copyOfRange(ndefRead.toByteArray(), 0, cmacPos-1);

//Check CMAC to see if key2 is zero.
String key2Changed = null;
try {
String cParam = bolturl.split("c=")[1].substring(0, 16);
int cmacSize = 16;
BlockCipher cipher = new AESFastEngine();
Mac cmac = new CMac(cipher, cmacSize * 8);
Expand Down
2 changes: 1 addition & 1 deletion src/screens/HelpScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function HelpScreen({ navigation }) {
<ScrollView>
<Card style={{marginBottom:20, marginHorizontal:10}}>
<Card.Content>
<Title>v0.0.6</Title>
<Title>v0.0.7</Title>
</Card.Content>
</Card>
<Card style={{marginBottom:20, marginHorizontal:10}}>
Expand Down
28 changes: 18 additions & 10 deletions src/screens/WriteNFCScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,40 @@ export default function WriteNFCScreen(props) {
}, [])
);
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Text>Please enter your node's domain and path</Text>
<Text>For boltcard server be sure to add /ln to the end of the domain</Text>
<View style={{flexDirection:'row'}}>
<Text style={{lineHeight:60}}>lnurlw://</Text>
<View style={{ flex: 1, flexDirection:'column', justifyContent: 'center', alignItems: 'center' }}>
<View>
<Text style={{textAlign:'center'}}>Please enter your node's domain and path</Text>
<Text style={{textAlign:'center'}}>For boltcard server be sure to add /ln to the end of the domain</Text>
</View>
<View style={{flexDirection:'column', flex: 3, padding: 20}}>
<Text style={{textAlign:'center', marginTop:30}}>lnurlw://</Text>
<TextInput
style={styles.input}
value={nodeURL}
multiline = {true}
numberOfLines = {4}
autoCapitalize='none'
onChangeText={(text) => updateNodeUrl(text)}
placeholder="yourboltcard.domain.com/ln"
/>

</View>
<Text>Then scan to write NFC card</Text>
<Text style={{color: writeOutput == "success" ? 'green' : 'red'}}>{writeOutput}</Text>
{ writeOutput.indexOf("91AE") != -1 && <Text style={{color: writeOutput == "success" ? 'green' : 'red'}}>This card's write key may have been changed</Text>}
<View style={{flex:1}}>
<Text style={{textAlign:'center'}}>Scan when ready to write NFC card</Text>
<Text style={{textAlign:'center', color: writeOutput == "success" ? 'green' : 'red'}}>{writeOutput}</Text>
{ writeOutput.indexOf("91AE") != -1 && <Text style={{color: writeOutput == "success" ? 'green' : 'red'}}>This card's write key may have been changed</Text>}
</View>
</View>
);
}
const styles = StyleSheet.create({
input: {
height: 40,
height: 160,
margin: 12,
borderWidth: 1,
flexWrap: 'wrap',
padding: 10,
fontFamily: 'monospace',
textAlignVertical: 'top'
},
});

0 comments on commit 5a4fb4e

Please sign in to comment.