2015-06-24 25 views
9

Ho un'applicazione Windows 7, che utilizza Stollmann SDK per collegare correttamente PC con Android. Il bidirezionale scambio di Bluetooth indirizzo MAC, hash e randomizer è effettuata fuori banda tramite NFC:Bluetooth Secure Simple Pairing (SSP) tramite codice QR come canale Out of Band (OOB)

application with qr code

Il codice sorgente dell'applicazione di Windows, purtroppo, non può essere condivisa qui. Sul lato Android non è necessaria alcuna app e l'abbinamento semplice sicuro viene eseguito dal sistema operativo (per HandoverManager?) Una volta ricevuto un messaggio NDEF con application/vnd.bluetooth.ep.oob.

Ora sto cercando di creare an Android app, che utilizzerebbe unidirezionale di autenticazione per eseguire OOB accoppiamento tramite codice a barre a scansione (invece di NFC).

Un codice QR personalizzato viene visualizzato sullo schermo del PC (generato da ZXing.Net) e contiene indirizzo MAC Bluetooth, hash e randomizzatore.

Tuttavia OOB legame sembra non essere ancora implementato in Android -

BluetoothAdapter.java:

/** 
* Read the local Out of Band Pairing Data 
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} 
* 
* @return Pair<byte[], byte[]> of Hash and Randomizer 
* 
* @hide 
*/ 
public Pair<byte[], byte[]> readOutOfBandData() { 
    if (getState() != STATE_ON) return null; 
    //TODO(BT 
    /* 
    try { 
     byte[] hash; 
     byte[] randomizer; 

     byte[] ret = mService.readOutOfBandData(); 

     if (ret == null || ret.length != 32) return null; 

     hash = Arrays.copyOfRange(ret, 0, 16); 
     randomizer = Arrays.copyOfRange(ret, 16, 32); 

     if (DBG) { 
      Log.d(TAG, "readOutOfBandData:" + Arrays.toString(hash) + 
       ":" + Arrays.toString(randomizer)); 
     } 
     return new Pair<byte[], byte[]>(hash, randomizer); 

    } catch (RemoteException e) {Log.e(TAG, "", e);}*/ 
    return null; 
} 

BluetoothDevice.java:

/** 
* Start the bonding (pairing) process with the remote device using the 
* Out Of Band mechanism. 
* 
* <p>This is an asynchronous call, it will return immediately. Register 
* for {@link #ACTION_BOND_STATE_CHANGED} intents to be notified when 
* the bonding process completes, and its result. 
* 
* <p>Android system services will handle the necessary user interactions 
* to confirm and complete the bonding process. 
* 
* <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN}. 
* 
* @param hash - Simple Secure pairing hash 
* @param randomizer - The random key obtained using OOB 
* @return false on immediate error, true if bonding will begin 
* 
* @hide 
*/ 
public boolean createBondOutOfBand(byte[] hash, byte[] randomizer) { 
    //TODO(BT) 
    /* 
    try { 
     return sService.createBondOutOfBand(this, hash, randomizer); 
    } catch (RemoteException e) {Log.e(TAG, "", e);}*/ 
    return false; 
} 

/** 
* Set the Out Of Band data for a remote device to be used later 
* in the pairing mechanism. Users can obtain this data through other 
* trusted channels 
* 
* <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN}. 
* 
* @param hash Simple Secure pairing hash 
* @param randomizer The random key obtained using OOB 
* @return false on error; true otherwise 
* 
* @hide 
*/ 
public boolean setDeviceOutOfBandData(byte[] hash, byte[] randomizer) { 
    //TODO(BT) 
    /* 
    try { 
    return sService.setDeviceOutOfBandData(this, hash, randomizer); 
    } catch (RemoteException e) {Log.e(TAG, "", e);} */ 
    return false; 
} 

La mia domanda:

Dal OOB Blu l'accoppiamento dei denti funziona bene su NFC su Android - pensi che ci sia un modo (hacker) di fare lo stesso tramite il codice QR?

Forse (pazza idea) alimentando HandoverManager con un messaggio NDEF falso?

+0

Non so se è possibile, ma amo la tua pazza idea. Ecco uno sparo al buio che non ho il tempo di testare adesso, ma l'NFC invia una trasmissione quando viene attivata? https://play.google.com/store/apps/details?id=lt.andro.broadcastlogger&hl=en –

+0

Ciao @Alexandee Farbar. Hai avuto una risposta alla tua domanda? – ymerdrengene

risposta

1

Non è possibile simulare la trasmissione NFC effettivamente registrata dall'app di servizio NFC quando rileva il tag NFC. Poiché questa è una trasmissione protetta, le app non di sistema non possono trasmettere l'intento.

+0

Ok, ha senso che la mia app non possa iniettare qualche "evento" di sistema o intenzione ... ma forse posso semplicemente chiamare HandoverManager e passargli il mio messaggio NDEF? Anche lo scopo della mia domanda è trovare un modo per eseguire "Secure Simple Pairing" su un codice QR (come canale OOB). Questo non deve essere un falso messaggio NFC - forse c'è un modo migliore. –

+1

Ci scusiamo per la mia risposta incompleta. La classe IMHO HandOverManager potrebbe non essere accessibile direttamente poiché è in un pacchetto di servizi nfc, puoi provare a utilizzare Reflection. – 7383

+1

Controlla che potrebbe esserti utile. https://github.com/Mobisocial/EasyNFC/blob/master/src/main/java/mobisocial/nfc/addon/BluetoothConnector.java – 7383