Skip to content

signalius/iap2

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

Who need it?

This code is often needed when you want to connect your iPhone to RaspberryPi. It establishes a Bluetooth or USB connection and make authorization. Further communication like AirPlay should be performed using other code, such as WirelessCarPlay.

What has been changed compared to the original version?

This is the fork of wiomoc/iap2 repository. I rebuilt the MFI chip support so that you don't need to use an overlay and so that it is compatible with the newer MFI343S00177. If you want to connect the MFI chip to RaspberryPi, you can use the PCB: MFI Rpi HAT. The code has been tested on RaspberryPi 5 and Zero 2W with Debian Trixie OS.

How to use it?

First you have to enable i2c

raspi-config

Check if MFI chip is visible in RPi:

# List all i2c interfaces
i2cdetect -l 
# Check interface number 1
i2cdetect -y 1 

You should see 10 or 11 on the i2c address list. Then you have to edit file iap2/mfi_auth_coprocessor.py and set apropriate i2c bus and address.

Then you can test if MFI chip is working

$ python3 iap2/mfi_auth_coprocessor.py

After running this command, you should see something like this on your screen: ....

CERT 3082038806092a864886f70d010702a08203.....
RESP 8e5b19eb4d5317672c6efa108732b9ebe901.....

CERT is a certificate informations, and RESP is a calculated challenge reponse. If you want to decode CERT to the test you have to convert hex string to binary file and then you can use openssl to decode it:

echo "3082025b06092a86...." | xxd -r -p > cert.bin
openssl pkcs7 -inform DER -in cert.bin -print_certs -text -noout

Result

Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number:
            47:7b:98:41:ac:7f:73:1a:f7:ce:40:25:2c:f8:b5:f4
        Signature Algorithm: ecdsa-with-SHA256
        Issuer: C=US, O=Apple Inc., OU=Apple Certification Authority, CN=Apple Accessories Certification Authority - 00000002
        Validity
            Not Before: Dec  3 19:44:24 2022 GMT
            Not After : Dec 31 23:59:59 2049 GMT
        Subject: C=US, O=Apple Inc., OU=Apple Accessories, CN=IPA_477B9841AC7F731AF7CE40252CF8B5F4
        Subject Public Key Info:
            Public Key Algorithm: id-ecPublicKey
                Public-Key: (256 bit)
                pub:
                    04:60:65:cf:d7:8d:28:a7:51:92:c1:f0:78:28:a0:
                    e5:7b:6e:a2:f9:86:18:fc:ed:34:b6:7a:8e:b6:a4:
                    09:28:a5:47:93:82:13:8c:c8:f8:cf:fc:28:44:e3:
                    88:6c:f3:99:92:13:14:ef:3f:09:e4:3d:a1:c9:56:
                    1d:96:a1:9c:ed
                ASN1 OID: prime256v1
                NIST CURVE: P-256
        X509v3 extensions:
            1.2.840.113635.100.6.36: critical
                . ................................
    Signature Algorithm: ecdsa-with-SHA256
    Signature Value:
        30:45:02:20:43:94:af:61:ae:38:63:eb:8b:aa:b6:d1:4a:e9:
        35:0b:fe:6f:60:f1:58:a5:72:1c:b0:e0:45:4a:81:e0:8c:47:
        02:21:00:ac:15:ae:79:13:a8:f7:de:10:c3:e5:32:04:d8:f5:
        d7:c7:47:4c:9a:e6:d1:9c:1f:65:fc:22:ab:71:1e:de:47

Run the software

Just run whole code like this

$ python3 -m iap2

When you establish connection from your iPhone to RaspberryPi using bluetooth you should see on console a lot of communication messages and your iPhone should show question about CarPlay.

More details

More details about this code: blogpost

MFI RaspberryPi HAT: MFI Rpi HAT

WirelessCarPlay repository WirelessCarPlay

About

IAP2 communication by Bluetooth or USB

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 100.0%