dont specify host port

This commit is contained in:
Alex Janka 2024-02-22 10:47:30 +11:00
parent 7a49efe6f6
commit 72525381c9
2 changed files with 5 additions and 12 deletions

View file

@ -50,9 +50,6 @@ impl AccessorySocket {
socket.set_linger(Some(Duration::from_secs(10)))?; socket.set_linger(Some(Duration::from_secs(10)))?;
let address: SocketAddr = format!("{ip}:{port}").parse()?; let address: SocketAddr = format!("{ip}:{port}").parse()?;
let host: SocketAddr = "192.168.50.187:12345".parse()?;
socket.bind(&host.into())?;
socket.connect(&address.into())?; socket.connect(&address.into())?;
Ok(Self { Ok(Self {
@ -199,11 +196,10 @@ impl AccessorySocket {
let mut buf = [0; 1024]; let mut buf = [0; 1024];
log::info!("about to read");
let mut read_num = self.socket.read(&mut buf)?; let mut read_num = self.socket.read(&mut buf)?;
log::info!("read {read_num} bytes");
while read_num == 0 { while read_num == 0 {
log::info!("read 0 bytes - about to reconnect");
std::thread::sleep(std::time::Duration::from_millis(200)); std::thread::sleep(std::time::Duration::from_millis(200));
self.socket.flush()?; self.socket.flush()?;
@ -222,7 +218,6 @@ impl AccessorySocket {
self.socket.flush()?; self.socket.flush()?;
read_num = self.socket.read(&mut buf)?; read_num = self.socket.read(&mut buf)?;
log::info!("read {read_num} bytes");
} }
let mut headers = [httparse::EMPTY_HEADER; 4]; let mut headers = [httparse::EMPTY_HEADER; 4];

View file

@ -147,14 +147,11 @@ impl DevicePairingData {
buf buf
}; };
// 8. Use Ed25519 togenerate iOSDeviceSignature by signing iOSDeviceInfo with its long-term secret key, iOSDeviceLTSK // 8. Use Ed25519 togenerate iOSDeviceSignature by signing iOSDeviceInfo with its long-term secret key, iOSDeviceLTSK
let mut keypair = self.ios_device_ltsk.to_vec(); let signing_key = ed25519_dalek::SigningKey::from_bytes(&self.ios_device_ltsk);
keypair.extend_from_slice(&self.ios_device_ltpk);
let signing_key = ed25519_dalek::SigningKey::from_keypair_bytes(&keypair.try_into()?)?;
let signature = signing_key.sign(&ios_device_info); let signature = signing_key.sign(&ios_device_info);
// 9. Construct sub-TLV // 9. Construct sub-TLV
let mut encrypted_tlv = //tlv8::encode(&); let mut encrypted_tlv = ([
([
( (
TlvType::Identifier.into(), TlvType::Identifier.into(),
self.ios_pairing_id.encode_value(), self.ios_pairing_id.encode_value(),
@ -163,7 +160,8 @@ impl DevicePairingData {
TlvType::Signature.into(), TlvType::Signature.into(),
(&signature.to_bytes()).encode_value(), (&signature.to_bytes()).encode_value(),
), ),
]).encode(); ])
.encode();
// 10. Encrypt sub-TLV: encryptedData, authTag = ChaCha20-Poly1305(SessionKey, Nonce=”PV-Msg03”, AAD=<none>, Msg=<Sub-TLV>) // 10. Encrypt sub-TLV: encryptedData, authTag = ChaCha20-Poly1305(SessionKey, Nonce=”PV-Msg03”, AAD=<none>, Msg=<Sub-TLV>)
let nonce: [u8; 12] = [0; 4] let nonce: [u8; 12] = [0; 4]