iPXE
|
iPhone USB Ethernet driver More...
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <ipxe/netdevice.h>
#include <ipxe/ethernet.h>
#include <ipxe/if_ether.h>
#include <ipxe/profile.h>
#include <ipxe/base64.h>
#include <ipxe/sha256.h>
#include <ipxe/rsa.h>
#include <ipxe/x509.h>
#include <ipxe/pem.h>
#include <ipxe/xfer.h>
#include <ipxe/tls.h>
#include <ipxe/usb.h>
#include "iphone.h"
Go to the source code of this file.
Macros | |
#define | EPIPE_NO_MUX __einfo_error ( EINFO_EPIPE_NO_MUX ) |
#define | EINFO_EPIPE_NO_MUX |
#define | EINPROGRESS_PAIRING __einfo_error ( EINFO_EINPROGRESS_PAIRING ) |
#define | EINFO_EINPROGRESS_PAIRING |
#define | ENOTCONN_DISABLED __einfo_error ( EINFO_ENOTCONN_DISABLED ) |
#define | EINFO_ENOTCONN_DISABLED |
#define | ENOTCONN_STATUS(status) |
#define | icert_key_suffix a |
Key pair selection. More... | |
#define | icert_key_variable(prefix) _C2 ( prefix, icert_key_suffix ) |
#define | icert_public icert_key_variable ( icert_public_ ) |
#define | icert_private icert_key_variable ( icert_private_ ) |
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
static int | ipair_create (struct interface *xfer, unsigned int flags) |
Create a pairing client. More... | |
static | LIST_HEAD (imuxes) |
List of USB multiplexers. More... | |
static | LIST_HEAD (iphones) |
List of iPhone network devices. More... | |
static void | icert_free (struct icert *icert) |
Free pairing certificates. More... | |
static int | icert_cert (struct icert *icert, struct asn1_cursor *subject, struct asn1_cursor *issuer, struct asn1_cursor *private, struct asn1_cursor *public, struct asn1_cursor *exts, struct x509_certificate **cert) |
Construct certificate. More... | |
static int | icert_certs (struct icert *icert, struct asn1_cursor *key) |
Construct certificates. More... | |
static int | icert_encode (struct icert *icert, struct x509_certificate *cert, char **encenc) |
Construct doubly base64-encoded certificate. More... | |
static int | imux_tx (struct imux *imux, struct io_buffer *iobuf) |
Transmit message. More... | |
static int | imux_tx_version (struct imux *imux) |
Transmit version message. More... | |
static int | imux_tx_tcp (struct imux *imux, struct io_buffer *iobuf) |
Transmit pseudo-TCP message. More... | |
static int | imux_tx_syn (struct imux *imux) |
Transmit pseudo-TCP SYN. More... | |
static int | imux_start_pair (struct imux *imux) |
Open pairing client. More... | |
static void | imux_rx_version (struct imux *imux) |
Receive version message. More... | |
static void | imux_rx_log (struct imux *imux, struct imux_header *hdr, size_t len) |
Receive log message. More... | |
static void | imux_rx_syn (struct imux *imux) |
Receive pseudo-TCP SYN+ACK. More... | |
static void | imux_rx_tcp (struct imux *imux, struct io_buffer *iobuf) |
Receive pseudo-TCP message. More... | |
static void | imux_in_complete (struct usb_endpoint *ep, struct io_buffer *iobuf, int rc) |
Complete bulk IN transfer. More... | |
static void | imux_out_complete (struct usb_endpoint *ep, struct io_buffer *iobuf, int rc) |
Complete bulk OUT transfer. More... | |
static void | imux_shutdown (struct imux *imux) |
Shut down USB multiplexer. More... | |
static void | imux_close (struct imux *imux, int rc) |
Close USB multiplexer. More... | |
static struct io_buffer * | imux_alloc_iob (struct imux *imux __unused, size_t len) |
Allocate I/O buffer for pseudo-TCP socket. More... | |
static int | imux_deliver (struct imux *imux, struct io_buffer *iobuf, struct xfer_metadata *meta __unused) |
Transmit packet via pseudo-TCP socket. More... | |
static void | imux_step (struct imux *imux) |
Multiplexer process. More... | |
static int | imux_probe (struct usb_function *func, struct usb_configuration_descriptor *config) |
Probe device. More... | |
static void | imux_remove (struct usb_function *func) |
Remove device. More... | |
static int | ipair_tx_pubkey (struct ipair *ipair) |
Transmit DevicePublicKey message. More... | |
static int | ipair_rx_pubkey (struct ipair *ipair, char *msg) |
Receive DevicePublicKey message. More... | |
static int | ipair_tx_pair (struct ipair *ipair) |
Transmit Pair message. More... | |
static int | ipair_rx_pair (struct ipair *ipair, char *msg) |
Receive Pair message. More... | |
static int | ipair_tx_session (struct ipair *ipair) |
Transmit StartSession message. More... | |
static int | ipair_rx_session (struct ipair *ipair, char *msg) |
Receive StartSession message. More... | |
static void | ipair_free (struct refcnt *refcnt) |
Free pairing client. More... | |
static void | ipair_close (struct ipair *ipair, int rc) |
Shut down pairing client. More... | |
static int | ipair_tx (struct ipair *ipair, const char *fmt,...) |
Transmit XML message. More... | |
static int | ipair_rx (struct ipair *ipair, char *msg, size_t len) |
Receive XML message payload. More... | |
static int | ipair_tag (struct ipair *ipair, const char *msg, const char *tag, char **start, char **end) |
Locate XML tag. More... | |
static int | ipair_key (struct ipair *ipair, const char *msg, const char *key, const char *type, char **start, char **end) |
Locate XML property list dictionary value. More... | |
static int | ipair_rx_pair_error (struct ipair *ipair, char *error) |
Receive Pair message error. More... | |
static int | ipair_rx_session_error (struct ipair *ipair, char *error) |
Receive StartSession message error. More... | |
static void | ipair_window_changed (struct ipair *ipair) |
Handle window change notification. More... | |
static int | ipair_deliver (struct ipair *ipair, struct io_buffer *iobuf, struct xfer_metadata *meta __unused) |
Handle received data. More... | |
static void | ipair_expired (struct retry_timer *timer, int over __unused) |
Pairing transmission timer. More... | |
static void | iphone_in_complete (struct usb_endpoint *ep, struct io_buffer *iobuf, int rc) |
Complete bulk IN transfer. More... | |
static int | iphone_out_transmit (struct iphone *iphone, struct io_buffer *iobuf) |
Transmit packet. More... | |
static void | iphone_out_complete (struct usb_endpoint *ep, struct io_buffer *iobuf, int rc) |
Complete bulk OUT transfer. More... | |
static int | iphone_check_pair (struct iphone *iphone) |
Check pairing status. More... | |
static void | iphone_check_link (struct net_device *netdev) |
Check link status. More... | |
static void | iphone_expired (struct retry_timer *timer, int over __unused) |
Periodically update link status. More... | |
static int | iphone_open (struct net_device *netdev) |
Open network device. More... | |
static void | iphone_close (struct net_device *netdev) |
Close network device. More... | |
static int | iphone_transmit (struct net_device *netdev, struct io_buffer *iobuf) |
Transmit packet. More... | |
static void | iphone_poll (struct net_device *netdev) |
Poll for completed and received packets. More... | |
static int | iphone_probe (struct usb_function *func, struct usb_configuration_descriptor *config) |
Probe device. More... | |
static void | iphone_remove (struct usb_function *func) |
Remove device. More... | |
REQUIRING_SYMBOL (iphone_driver) | |
REQUIRE_OBJECT (rsa_sha256) | |
Variables | |
static struct profiler iphone_in_profiler | __profiler |
Bulk IN completion profiler. More... | |
static uint8_t | icert_root_fingerprint [SHA256_DIGEST_SIZE] |
iPhone root certificate fingerprint More... | |
static struct x509_root | icert_root |
Root of trust for iPhone certificates. More... | |
static const uint8_t | icert_nul [] = { 0x00 } |
Single zero byte used in constructed certificates. More... | |
static const uint8_t | icert_rsa [] |
"RSA algorithm" identifier used in constructed certificates More... | |
static const uint8_t | icert_sha256_rsa [] |
"SHA-256 with RSA algorithm" identifier used in constructed certificates More... | |
static const uint8_t | icert_root_exts_data [] |
Extensions used in constructed root certificate. More... | |
static struct asn1_cursor | icert_root_exts |
Extensions used in constructed root certificate. More... | |
static const uint8_t | icert_leaf_exts_data [] |
Extensions used in constructed leaf certificates. More... | |
static struct asn1_cursor | icert_leaf_exts |
Extensions used in constructed leaf certificates. More... | |
static const uint8_t | icert_tbs_prefix [] |
"TBSCertificate" prefix in constructed certificates More... | |
static const uint8_t | icert_validity [] |
Validity period in constructed certificates. More... | |
static const uint8_t | icert_name_root_data [] |
"Root" subject name More... | |
static struct asn1_cursor | icert_name_root |
"Root" subject name More... | |
static const uint8_t | icert_name_ipxe_data [] |
"iPXE" subject name More... | |
static struct asn1_cursor | icert_name_ipxe |
"iPXE" subject name More... | |
static const uint8_t | icert_name_iphone_data [] |
"iPhone" subject name More... | |
static struct asn1_cursor | icert_name_iphone |
"iPhone" subject name More... | |
static const uint8_t icert_public_a [] | __unused |
Public key(s) used for pairing. More... | |
static const char | icert_begin [] = "-----BEGIN CERTIFICATE-----\n" |
PEM certificate prefix. More... | |
static const char | icert_end [] = "\n-----END CERTIFICATE-----\n" |
PEM certificate suffix. More... | |
static struct usb_endpoint_driver_operations | imux_in_operations |
Bulk IN endpoint operations. More... | |
static struct usb_endpoint_driver_operations | imux_out_operations |
Bulk OUT endpoint operations. More... | |
static struct interface_operation | imux_tcp_operations [] |
Pseudo-TCP socket interface operations. More... | |
static struct interface_descriptor | imux_tcp_desc |
Pseudo-TCP socket interface descriptor. More... | |
static struct process_descriptor | imux_process_desc |
Multiplexer process descriptor. More... | |
static struct usb_device_id | imux_ids [] |
USB multiplexer device IDs. More... | |
struct usb_driver imux_driver | __usb_driver |
USB multiplexer driver. More... | |
static const char | ipair_prefix [] |
Common prefix for all pairing messages. More... | |
static const char | ipair_suffix [] |
Common suffix for all pairing messages. More... | |
static const char | ipair_system_buid [] = "E4DB92D2-248A-469A-AC34-92045D07E695" |
Arbitrary system BUID used for pairing. More... | |
static const char | ipair_host_id [] = "93CEBC27-8457-4804-9108-F42549DF6143" |
Arbitrary host ID used for pairing. More... | |
static struct interface_operation | ipair_xfer_operations [] |
Pairing client interface operations. More... | |
static struct interface_descriptor | ipair_xfer_desc |
Pairing client interface descriptor. More... | |
static struct usb_endpoint_driver_operations | iphone_in_operations |
Bulk IN endpoint operations. More... | |
static struct usb_endpoint_driver_operations | iphone_out_operations |
Bulk OUT endpoint operations. More... | |
static struct net_device_operations | iphone_operations |
iPhone network device operations More... | |
static struct usb_device_id | iphone_ids [] |
iPhone device IDs More... | |
iPhone USB Ethernet driver
Definition in file iphone.c.
#define EPIPE_NO_MUX __einfo_error ( EINFO_EPIPE_NO_MUX ) |
#define EINFO_EPIPE_NO_MUX |
#define EINPROGRESS_PAIRING __einfo_error ( EINFO_EINPROGRESS_PAIRING ) |
#define EINFO_EINPROGRESS_PAIRING |
#define ENOTCONN_DISABLED __einfo_error ( EINFO_ENOTCONN_DISABLED ) |
#define EINFO_ENOTCONN_DISABLED |
#define ENOTCONN_STATUS | ( | status | ) |
#define icert_key_suffix a |
#define icert_key_variable | ( | prefix | ) | _C2 ( prefix, icert_key_suffix ) |
#define icert_public icert_key_variable ( icert_public_ ) |
#define icert_private icert_key_variable ( icert_private_ ) |
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
static |
Create a pairing client.
xfer | Data transfer interface |
flags | Initial state flags |
rc | Return status code |
Definition at line 1844 of file iphone.c.
References ENOMEM, flags, ipair::flags, intf_init(), intf_plug_plug(), ipair_expired(), ipair_free(), ipair_rx_pubkey(), ipair_tx_pubkey(), ipair_xfer_desc, rc, ref_init, ref_put, ipair::refcnt, ipair::rx, start_timer_nodelay(), ipair::timer, ipair::tx, ipair::xfer, and zalloc().
Referenced by imux_start_pair().
|
static |
List of USB multiplexers.
|
static |
List of iPhone network devices.
|
static |
Free pairing certificates.
icert | Pairing certificates |
Definition at line 330 of file iphone.c.
References icert::device, icert::host, icert::key, memset(), privkey_put(), icert::root, and x509_put().
Referenced by icert_certs(), and ipair_free().
|
static |
Construct certificate.
icert | Pairing certificates |
subject | Subject name |
issuer | Issuer name |
private | Private key |
public | Public key |
exts | Certificate extensions |
cert | Certificate to fill in |
rc | Return status code |
On success, the caller is responsible for eventually calling x509_put() on the allocated encoded certificate.
Definition at line 354 of file iphone.c.
References ASN1_BIT_STRING, asn1_grow(), asn1_prepend_raw(), ASN1_SEQUENCE, asn1_wrap(), assert(), asn1_cursor::data, asn1_builder::data, DBGC, DBGC_HDA, digest_final(), digest_init(), digest_update(), free, icert_nul, icert_rsa, icert_sha256_rsa, icert_tbs_prefix, icert_validity, len, asn1_cursor::len, asn1_builder::len, NULL, pubkey_max_len(), pubkey_sign(), raw, rc, rsa_algorithm, sha256_algorithm, SHA256_CTX_SIZE, SHA256_DIGEST_SIZE, and strerror().
Referenced by icert_certs().
|
static |
Construct certificates.
icert | Certificate set |
pubkey | Device public key |
rc | Return status code |
Definition at line 457 of file iphone.c.
References asn1_built(), ASN1_INTEGER, asn1_prepend(), asn1_prepend_raw(), ASN1_SEQUENCE, asn1_wrap(), assert(), private_key::builder, data, DBGC, icert::device, x509_root::digest, digest_algorithm::digestsize, ENOMEM, error, free, icert::host, icert_cert(), icert_free(), icert_leaf_exts, icert_name_iphone, icert_name_ipxe, icert_name_root, icert_nul, icert_private, icert_public, icert_root, icert_root_exts, icert_root_fingerprint, icert::key, key, NULL, privkey_init(), rc, icert::root, strerror(), x509_fingerprint(), and zalloc().
Referenced by ipair_rx_pubkey().
|
static |
Construct doubly base64-encoded certificate.
icert | Pairing certificates |
cert | X.509 certificate |
encenc | Doubly base64-encoded certificate to construct |
rc | Return status code |
On success, the caller is responsible for eventually calling free() on the allocated doubly encoded encoded certificate.
Definition at line 540 of file iphone.c.
References assert(), base64_encode(), base64_encoded_len(), asn1_cursor::data, DBGC2, ENOMEM, free, icert_begin, icert_end, asn1_cursor::len, malloc(), NULL, x509_certificate::raw, rc, strcpy(), and x509_name().
Referenced by ipair_tx_pair().
Transmit message.
imux | USB multiplexer |
iobuf | I/O buffer |
rc | Return status code |
Definition at line 610 of file iphone.c.
References assert(), io_buffer::data, DBGCP, DBGCP_HDA, free_iob(), hdr, htonl, htons, imux::in_seq, iob_len(), len, usbnet_device::out, imux::out_seq, rc, usb_stream(), and imux::usbnet.
Referenced by imux_tx_tcp(), and imux_tx_version().
|
static |
Transmit version message.
imux | USB multiplexer |
rc | Return status code |
Definition at line 643 of file iphone.c.
References alloc_iob(), ENOMEM, imux_header_version::hdr, htonl, imux_tx(), IMUX_VERSION, iob_disown, iob_put, memset(), imux_header::protocol, and rc.
Referenced by imux_probe().
Transmit pseudo-TCP message.
imux | USB multiplexer |
iobuf | I/O buffer |
rc | Return status code |
Definition at line 672 of file iphone.c.
References tcp_header::ack, assert(), io_buffer::data, tcp_header::dest, tcp_header::hlen, htonl, htons, IMUX_PORT_LOCKDOWND, IMUX_TCP, imux_tx(), IMUX_WINDOW, iob_disown, iob_len(), len, imux::port, rc, tcp_header::seq, tcp_header::src, imux_header_tcp::tcp, imux::tcp_ack, imux::tcp_seq, and tcp_header::win.
Referenced by imux_deliver(), and imux_tx_syn().
|
static |
Transmit pseudo-TCP SYN.
imux | USB multiplexer |
rc | Return status code |
Definition at line 703 of file iphone.c.
References alloc_iob(), ENOMEM, tcp_header::flags, imux_tx_tcp(), iob_disown, iob_put, memset(), rc, imux_header_tcp::tcp, imux::tcp_seq, and TCP_SYN.
Referenced by imux_close(), and imux_rx_version().
|
static |
Open pairing client.
imux | USB multiplexer |
rc | Return status code |
Definition at line 734 of file iphone.c.
References EPIPE, imux::flags, intf_restart(), ipair_create(), rc, and imux::tcp.
Referenced by imux_rx_syn().
|
static |
Receive version message.
imux | USB multiplexer |
Definition at line 752 of file iphone.c.
References imux::action, imux_tx_syn(), and imux::out_seq.
Referenced by imux_in_complete().
|
static |
Receive log message.
imux | USB multiplexer |
hdr | Message header |
len | Length of message |
Definition at line 768 of file iphone.c.
References container_of, DBGC, DBGC_HDA, hdr, len, imux_header_log::level, memmove(), imux_header_log::msg, and tmp.
Referenced by imux_in_complete().
|
static |
Receive pseudo-TCP SYN+ACK.
imux | USB multiplexer |
Definition at line 803 of file iphone.c.
References imux::action, imux_start_pair(), and imux::tcp_ack.
Referenced by imux_rx_tcp().
Receive pseudo-TCP message.
imux | USB multiplexer |
iobuf | I/O buffer |
Definition at line 818 of file iphone.c.
References io_buffer::data, DBGC, DBGC2_HDA, DBGC_HDA, tcp_header::dest, error, tcp_header::flags, free_iob(), htons, imux_rx_syn(), iob_disown, iob_len(), iob_pull, len, ntohl, ntohs, imux::port, rc, tcp_header::seq, imux_header_tcp::tcp, imux::tcp, imux::tcp_ack, TCP_RST, TCP_SYN, and xfer_deliver_iob().
Referenced by imux_in_complete().
|
static |
Complete bulk IN transfer.
ep | USB endpoint |
iobuf | I/O buffer |
rc | Completion status code |
Definition at line 876 of file iphone.c.
References container_of, io_buffer::data, DBGC, DBGC_HDA, DBGCP, DBGCP_HDA, free_iob(), hdr, htonl, IMUX_LOG, imux_rx_log(), imux_rx_tcp(), imux_rx_version(), IMUX_TCP, IMUX_VERSION, usbnet_device::in, imux::in_seq, iob_disown, iob_len(), len, ntohl, ntohs, usb_endpoint::open, rc, strerror(), and imux::usbnet.
|
static |
Complete bulk OUT transfer.
ep | USB endpoint |
iobuf | I/O buffer |
rc | Completion status code |
Definition at line 939 of file iphone.c.
References container_of, DBGC, error, free_iob(), usbnet_device::out, rc, strerror(), and imux::usbnet.
|
static |
Shut down USB multiplexer.
imux | USB multiplexer |
Definition at line 964 of file iphone.c.
References ECANCELED, intf_shutdown(), imux::process, process_del(), process_running(), imux::tcp, imux::usbnet, and usbnet_close().
Referenced by imux_close(), imux_probe(), and imux_remove().
|
static |
Close USB multiplexer.
imux | USB multiplexer |
rc | Reason for close |
Definition at line 982 of file iphone.c.
References imux::action, DBGC, imux::flags, imux_shutdown(), imux_tx_syn(), intf_restart(), IPAIR_REQUEST, iphone::list, list_for_each_entry, imux::port, imux::rc, rc, start_timer_nodelay(), strerror(), imux::tcp, iphone::timer, imux::usb, and iphone::usb.
Referenced by imux_step().
Allocate I/O buffer for pseudo-TCP socket.
imux | USB multiplexer |
len | I/O buffer payload length |
iobuf | I/O buffer |
Definition at line 1025 of file iphone.c.
References alloc_iob(), iob_reserve, len, NULL, and imux_header_tcp::tcp.
|
static |
Transmit packet via pseudo-TCP socket.
imux | USB multiplexer |
iobuf | I/O buffer |
meta | Data transfer metadata |
rc | Return status code |
Definition at line 1049 of file iphone.c.
References tcp_header::flags, imux_tx_tcp(), iob_disown, iob_push, memset(), imux_header_tcp::tcp, and TCP_ACK.
|
static |
Multiplexer process.
imux | USB multiplexer |
Definition at line 1078 of file iphone.c.
References imux::action, imux::bus, imux_close(), NULL, imux::process, process_running(), rc, usb_poll(), imux::usbnet, and usbnet_refill().
|
static |
Probe device.
func | USB function |
config | Configuration descriptor |
rc | Return status code |
Definition at line 1113 of file iphone.c.
References imux::action, imux::bus, usb_hub::bus, DBGC, EINPROGRESS_PAIRING, ENOMEM, usb_port::hub, IMUX_IN_MAX_FILL, IMUX_IN_MTU, imux_in_operations, imux_out_operations, IMUX_PORT_LOCAL, imux_process_desc, imux_shutdown(), imux_tcp_desc, imux_tx_version(), usbnet_device::in, intf_init(), imux::list, list_add, list_del, NULL, imux::port, usb_device::port, imux::process, process_add(), process_init(), imux::rc, rc, ref_init, ref_put, imux::refcnt, strerror(), imux::tcp, imux::usb, usb_function::usb, usb_func_set_drvdata(), usb_refill_init(), imux::usbnet, usbnet_describe(), usbnet_init(), usbnet_open(), and zalloc().
|
static |
Remove device.
func | USB function |
Definition at line 1174 of file iphone.c.
References imux_shutdown(), imux::list, list_del, ref_put, imux::refcnt, and usb_func_get_drvdata().
|
static |
Transmit DevicePublicKey message.
ipair | Pairing client |
rc | Return status code |
Definition at line 1421 of file iphone.c.
References ipair_prefix, ipair_suffix, ipair_tx(), and rc.
Referenced by ipair_create().
|
static |
Receive DevicePublicKey message.
ipair | Pairing client |
msg | XML message |
rc | Return status code |
Definition at line 1444 of file iphone.c.
References base64_decode(), base64_decoded_max_len(), data, DBGC, DBGC2_HDA, end, ENOMEM, ipair::flags, free, ipair::icert, icert_certs(), ipair_key(), IPAIR_REQUEST, ipair_rx_pair(), ipair_rx_session(), ipair_tx_pair(), ipair_tx_session(), key, len, malloc(), msg(), next, pem_asn1(), rc, ipair::rx, start_timer_nodelay(), ipair::timer, ipair::tx, and virt_to_user().
Referenced by ipair_create().
|
static |
Transmit Pair message.
ipair | Pairing client |
rc | Return status code |
Definition at line 1527 of file iphone.c.
References device, icert::device, free, icert::host, ipair::icert, icert_encode(), ipair_host_id, ipair_prefix, ipair_suffix, ipair_system_buid, ipair_tx(), rc, root, and icert::root.
Referenced by ipair_rx_pair_error(), ipair_rx_pubkey(), and ipair_rx_session_error().
|
static |
Receive Pair message.
ipair | Pairing client |
msg | XML message |
rc | Return status code |
Definition at line 1616 of file iphone.c.
References DBGC, end, error, ipair_key(), ipair_rx_pair_error(), ipair_rx_session(), ipair_tx_session(), msg(), rc, ipair::rx, start_timer_nodelay(), ipair::timer, and ipair::tx.
Referenced by ipair_rx_pair_error(), ipair_rx_pubkey(), and ipair_rx_session_error().
|
static |
Transmit StartSession message.
ipair | Pairing client |
rc | Return status code |
Definition at line 1652 of file iphone.c.
References ipair_host_id, ipair_prefix, ipair_suffix, ipair_system_buid, ipair_tx(), and rc.
Referenced by ipair_rx_pair(), and ipair_rx_pubkey().
|
static |
Receive StartSession message.
ipair | Pairing client |
msg | XML message |
rc | Return status code |
Definition at line 1703 of file iphone.c.
References add_tls(), DBGC, end, error, ipair::flags, ipair::icert, icert_root, ipair_key(), ipair_rx_session_error(), IPAIR_TLS, icert::key, msg(), rc, strerror(), and ipair::xfer.
Referenced by ipair_rx_pair(), and ipair_rx_pubkey().
|
static |
Free pairing client.
refcnt | Reference counter |
Definition at line 1242 of file iphone.c.
References container_of, free, ipair::icert, and icert_free().
Referenced by ipair_create().
|
static |
Shut down pairing client.
ipair | Pairing client |
rc | Reason for close |
Definition at line 1255 of file iphone.c.
References intf_shutdown(), rc, stop_timer(), ipair::timer, and ipair::xfer.
Referenced by ipair_deliver(), ipair_expired(), and ipair_window_changed().
|
static |
Transmit XML message.
ipair | Pairing client |
fmt | Format string |
... | Arguments |
rc | Return status code |
Definition at line 1273 of file iphone.c.
References DBGC2, ENOMEM, fmt, hdr, htonl, iob_disown, iob_put, len, memset(), msg(), NULL, rc, va_end, va_start, vsnprintf(), ipair::xfer, xfer_alloc_iob(), and xfer_deliver_iob().
Referenced by ipair_tx_pair(), ipair_tx_pubkey(), and ipair_tx_session().
Receive XML message payload.
ipair | Pairing client |
msg | Message payload |
len | Length of message |
rc | Return status code |
Definition at line 1317 of file iphone.c.
References DBGC, DBGC2, DBGC_HDA, EPROTO, len, msg(), NULL, rc, ipair::rx, and rx.
Referenced by ipair_deliver().
|
static |
Locate XML tag.
ipair | Pairing client |
msg | XML message |
tag | Tag name |
start | Start of tag content |
end | End of tag content |
rc | Return status code |
Definition at line 1359 of file iphone.c.
References DBGC, end, ENOENT, msg(), sprintf, start, strlen(), strstr(), and tag.
Referenced by ipair_key().
|
static |
Locate XML property list dictionary value.
ipair | Pairing client |
msg | XML message |
key | Key name |
type | Key type |
start | Start of value content |
end | End of value content |
rc | Return status code |
Definition at line 1393 of file iphone.c.
References end, ipair_tag(), key, memcmp(), msg(), rc, start, and type.
Referenced by ipair_rx_pair(), ipair_rx_pubkey(), and ipair_rx_session().
|
static |
Receive Pair message error.
ipair | Pairing client |
error | Pairing error |
rc | Return status code |
Definition at line 1592 of file iphone.c.
References DBGC, EPERM, error, IPAIR_RETRY_DELAY, ipair_rx_pair(), ipair_tx_pair(), ipair::rx, start_timer_fixed(), strcmp(), ipair::timer, and ipair::tx.
Referenced by ipair_rx_pair().
|
static |
Receive StartSession message error.
ipair | Pairing client |
error | Pairing error |
rc | Return status code |
Definition at line 1679 of file iphone.c.
References DBGC, EPERM, error, ipair_rx_pair(), ipair_tx_pair(), ipair::rx, start_timer_nodelay(), strcmp(), ipair::timer, and ipair::tx.
Referenced by ipair_rx_session().
|
static |
Handle window change notification.
ipair | Pairing client |
Definition at line 1745 of file iphone.c.
References assert(), DBGC, icert::device, ipair::flags, icert::host, ipair::icert, icert_root, ipair_close(), IPAIR_TLS, NULL, icert::root, x509_is_valid(), ipair::xfer, and xfer_window().
|
static |
Handle received data.
ipair | Pairing client |
iobuf | I/O buffer |
meta | Data transfer metadata |
rc | Return status code |
Definition at line 1772 of file iphone.c.
References io_buffer::data, error, ipair::flags, free_iob(), hdr, iob_len(), iob_pull, ipair_close(), ipair_rx(), IPAIR_RX_LEN, and rc.
|
static |
Pairing transmission timer.
timer | Retransmission timer |
over | Failure indicator |
Definition at line 1809 of file iphone.c.
References assert(), container_of, ipair_close(), NULL, rc, ipair::tx, and tx.
Referenced by ipair_create().
|
static |
Complete bulk IN transfer.
ep | USB endpoint |
iobuf | I/O buffer |
rc | Completion status code |
Definition at line 1888 of file iphone.c.
References container_of, io_buffer::data, DBGC, DBGC_HDA, EINVAL, error, free_iob(), usbnet_device::in, iob_disown, iob_len(), iob_pull, IPHONE_IN_PAD, netdev, iphone::netdev, netdev_rx(), netdev_rx_err(), usb_endpoint::open, profile_start(), profile_stop(), rc, strerror(), and iphone::usbnet.
Transmit packet.
iphone | iPhone device |
iobuf | I/O buffer |
rc | Return status code |
Definition at line 1940 of file iphone.c.
References usbnet_device::out, profile_start(), profile_stop(), rc, usb_stream(), and iphone::usbnet.
Referenced by iphone_transmit().
|
static |
Complete bulk OUT transfer.
ep | USB endpoint |
iobuf | I/O buffer |
rc | Completion status code |
Definition at line 1962 of file iphone.c.
References container_of, netdev, iphone::netdev, netdev_tx_complete_err(), usbnet_device::out, rc, and iphone::usbnet.
|
static |
Check pairing status.
iphone | iPhone device |
rc | Return status code |
Definition at line 1982 of file iphone.c.
References EPIPE_NO_MUX, imux::list, list_for_each_entry, imux::rc, imux::usb, and iphone::usb.
Referenced by iphone_check_link().
|
static |
Check link status.
netdev | Network device |
Definition at line 1999 of file iphone.c.
References DBGC, ENOTCONN_STATUS, iphone_check_pair(), IPHONE_GET_LINK, IPHONE_LINK_UP, net_device::link_rc, netdev, netdev_link_err(), net_device::priv, rc, status, strerror(), iphone::usb, and usb_control().
Referenced by iphone_expired(), and iphone_probe().
|
static |
Periodically update link status.
timer | Link status timer |
over | Failure indicator |
Definition at line 2050 of file iphone.c.
References container_of, iphone_check_link(), IPHONE_LINK_CHECK_INTERVAL, netdev, iphone::netdev, netdev_is_open(), and start_timer_fixed().
Referenced by iphone_probe().
|
static |
Open network device.
netdev | Network device |
rc | Return status code |
Definition at line 2068 of file iphone.c.
References DBGC, netdev, net_device::priv, rc, start_timer_nodelay(), strerror(), iphone::timer, iphone::usbnet, usbnet_close(), and usbnet_open().
|
static |
Close network device.
netdev | Network device |
Definition at line 2094 of file iphone.c.
References netdev, net_device::priv, stop_timer(), iphone::timer, iphone::usbnet, and usbnet_close().
|
static |
Transmit packet.
netdev | Network device |
iobuf | I/O buffer |
rc | Return status code |
Definition at line 2111 of file iphone.c.
References iphone_out_transmit(), netdev, net_device::priv, and rc.
|
static |
Poll for completed and received packets.
netdev | Network device |
Definition at line 2128 of file iphone.c.
References iphone::bus, netdev, netdev_rx_err(), NULL, net_device::priv, rc, usb_poll(), iphone::usbnet, and usbnet_refill().
|
static |
Probe device.
func | USB function |
config | Configuration descriptor |
rc | Return status code |
Definition at line 2155 of file iphone.c.
References alloc_etherdev(), iphone::bus, usb_hub::bus, DBGC, net_device::dev, usb_function::dev, ENOMEM, ETH_ALEN, usb_port::hub, net_device::hw_addr, usbnet_device::in, iphone_check_link(), iphone_expired(), IPHONE_GET_MAC, IPHONE_IN_MAX_FILL, IPHONE_IN_MTU, iphone_in_operations, iphone_operations, iphone_out_operations, iphone::list, list_add, list_del, memset(), usb_function::name, netdev, iphone::netdev, netdev_init(), netdev_nullify(), netdev_put(), NULL, usb_device::port, net_device::priv, rc, net_device::refcnt, register_netdev(), strerror(), iphone::timer, unregister_netdev(), iphone::usb, usb_function::usb, usb_control(), usb_func_set_drvdata(), usb_refill_init(), iphone::usbnet, usbnet_describe(), and usbnet_init().
|
static |
Remove device.
func | USB function |
Definition at line 2226 of file iphone.c.
References iphone::list, list_del, netdev, iphone::netdev, netdev_nullify(), netdev_put(), unregister_netdev(), and usb_func_get_drvdata().
REQUIRING_SYMBOL | ( | iphone_driver | ) |
REQUIRE_OBJECT | ( | rsa_sha256 | ) |
|
static |
|
static |
iPhone root certificate fingerprint
Definition at line 91 of file iphone.c.
Referenced by icert_certs().
|
static |
Root of trust for iPhone certificates.
Definition at line 94 of file iphone.c.
Referenced by icert_certs(), ipair_rx_session(), and ipair_window_changed().
|
static |
Single zero byte used in constructed certificates.
Definition at line 102 of file iphone.c.
Referenced by icert_cert(), and icert_certs().
|
static |
"RSA algorithm" identifier used in constructed certificates
Definition at line 105 of file iphone.c.
Referenced by icert_cert().
|
static |
"SHA-256 with RSA algorithm" identifier used in constructed certificates
Definition at line 113 of file iphone.c.
Referenced by icert_cert().
|
static |
Extensions used in constructed root certificate.
|
static |
Extensions used in constructed root certificate.
Definition at line 137 of file iphone.c.
Referenced by icert_certs().
|
static |
Extensions used in constructed leaf certificates.
|
static |
Extensions used in constructed leaf certificates.
Definition at line 170 of file iphone.c.
Referenced by icert_certs().
|
static |
"TBSCertificate" prefix in constructed certificates
Definition at line 174 of file iphone.c.
Referenced by icert_cert().
|
static |
Validity period in constructed certificates.
Definition at line 186 of file iphone.c.
Referenced by icert_cert().
|
static |
"Root" subject name
|
static |
"Root" subject name
Definition at line 208 of file iphone.c.
Referenced by icert_certs().
|
static |
"iPXE" subject name
|
static |
"iPXE" subject name
Definition at line 220 of file iphone.c.
Referenced by icert_certs().
|
static |
"iPhone" subject name
|
static |
"iPhone" subject name
Definition at line 233 of file iphone.c.
Referenced by icert_certs().
|
static |
Public key(s) used for pairing.
"Private" key(s) used for pairing
Yes, this publicly visible "private" key completely obviates any nominal security provided by the pairing process. Looked at another way, this modifies the iPhone to behave like every other USB tethering device: if the cable is physically connected and tethering is enabled then the device will Just Work.
Unlike Android, the iPhone seems to have no meaningful permissions model: any device that is trusted to use the phone for tethering seems to also be trusted to use the iPhone for any other purpose (e.g. accessing files, reading messages, etc). Apple should probably fix this at some point, e.g. via defining extended key usages in the root and host certificates.
|
static |
|
static |
|
static |
Bulk IN endpoint operations.
Definition at line 928 of file iphone.c.
Referenced by imux_probe().
|
static |
Bulk OUT endpoint operations.
Definition at line 955 of file iphone.c.
Referenced by imux_probe().
|
static |
Pseudo-TCP socket interface operations.
|
static |
Pseudo-TCP socket interface descriptor.
Definition at line 1070 of file iphone.c.
Referenced by imux_probe().
|
static |
Multiplexer process descriptor.
Definition at line 1103 of file iphone.c.
Referenced by imux_probe().
|
static |
USB multiplexer device IDs.
struct usb_driver iphone_driver __usb_driver |
USB multiplexer driver.
iPhone driver
|
static |
Common prefix for all pairing messages.
Definition at line 1209 of file iphone.c.
Referenced by ipair_tx_pair(), ipair_tx_pubkey(), and ipair_tx_session().
|
static |
Common suffix for all pairing messages.
Definition at line 1220 of file iphone.c.
Referenced by ipair_tx_pair(), ipair_tx_pubkey(), and ipair_tx_session().
|
static |
Arbitrary system BUID used for pairing.
Definition at line 1225 of file iphone.c.
Referenced by ipair_tx_pair(), and ipair_tx_session().
|
static |
Arbitrary host ID used for pairing.
Definition at line 1228 of file iphone.c.
Referenced by ipair_tx_pair(), and ipair_tx_session().
|
static |
Pairing client interface operations.
|
static |
Pairing client interface descriptor.
Definition at line 1834 of file iphone.c.
Referenced by ipair_create().
|
static |
Bulk IN endpoint operations.
Definition at line 1929 of file iphone.c.
Referenced by iphone_probe().
|
static |
Bulk OUT endpoint operations.
Definition at line 1972 of file iphone.c.
Referenced by iphone_probe().
|
static |
iPhone network device operations
Definition at line 2141 of file iphone.c.
Referenced by iphone_probe().
|
static |
iPhone device IDs