51 #define EPIPE_NO_MUX __einfo_error ( EINFO_EPIPE_NO_MUX ) 52 #define EINFO_EPIPE_NO_MUX \ 53 __einfo_uniqify ( EINFO_EPIPE, 0x01, \ 54 "No USB multiplexer" ) 55 #define EINPROGRESS_PAIRING __einfo_error ( EINFO_EINPROGRESS_PAIRING ) 56 #define EINFO_EINPROGRESS_PAIRING \ 57 __einfo_uniqify ( EINFO_EINPROGRESS, 0x01, \ 58 "Pairing in progress" ) 59 #define ENOTCONN_DISABLED __einfo_error ( EINFO_ENOTCONN_DISABLED ) 60 #define EINFO_ENOTCONN_DISABLED \ 61 __einfo_uniqify ( EINFO_ENOTCONN, IPHONE_LINK_DISABLED, \ 62 "Personal Hotspot disabled" ) 63 #define ENOTCONN_STATUS( status ) \ 64 EUNIQ ( EINFO_ENOTCONN, ( (status) & 0x1f ), \ 71 { .
name =
"iphone.in" };
75 { .
name =
"iphone.out" };
191 '1',
'9',
'7',
'8',
'1',
'2',
'1',
'0',
192 '2',
'2',
'0',
'0',
'0',
'0',
'Z' ),
195 '2',
'9',
'9',
'9',
'0',
'1',
'0',
'1',
196 '0',
'0',
'0',
'0',
'0',
'0',
'Z' ) )
229 'i',
'P',
'h',
'o',
'n',
'e' ) ) ) )
238 0x02, 0x81, 0x81, 0x00, 0xc9, 0xc0, 0xdd, 0xa6, 0xd5, 0xf9, 0x05, 0x3e,
239 0x1d, 0xcb, 0x67, 0x08, 0xa8, 0x50, 0x27, 0x63, 0x95, 0x87, 0x42, 0x7e,
240 0xfb, 0xff, 0x55, 0x55, 0xb8, 0xc0, 0x6f, 0x13, 0xcb, 0xf7, 0xc5, 0x1b,
241 0xda, 0x44, 0x3c, 0xbc, 0x1a, 0xe1, 0x15, 0x1e, 0xab, 0x56, 0x74, 0x02,
242 0x8b, 0xb3, 0xcd, 0x42, 0x56, 0xcd, 0x9c, 0xc3, 0x15, 0xe2, 0x33, 0x97,
243 0x6d, 0x77, 0xdd, 0x20, 0x3a, 0x74, 0xb1, 0x4c, 0xee, 0xeb, 0xe8, 0xaa,
244 0x20, 0x71, 0x5a, 0xa2, 0x5b, 0xf8, 0x1a, 0xcb, 0xd2, 0x7b, 0x96, 0xb6,
245 0x42, 0xb4, 0x7c, 0x7a, 0x13, 0xec, 0x55, 0xd3, 0x36, 0x8b, 0xe3, 0x17,
246 0xc5, 0xc4, 0xcc, 0xe0, 0x27, 0x8c, 0xed, 0xa1, 0x4c, 0x8a, 0x50, 0x4a,
247 0x1c, 0xc4, 0x58, 0xf6, 0xcd, 0xcc, 0xc3, 0x5f, 0xe6, 0x3c, 0xff, 0x97,
248 0x51, 0xed, 0xf5, 0xaa, 0x89, 0xcc, 0x3f, 0x63, 0x67, 0x46, 0x9f, 0xbf,
249 0x02, 0x03, 0x01, 0x00, 0x01
252 0x02, 0x81, 0x81, 0x00, 0xcd, 0x96, 0x81, 0x78, 0xbb, 0x2e, 0x64, 0xda,
253 0xd3, 0x7e, 0xd7, 0x3a, 0xac, 0x3f, 0x00, 0xe5, 0x41, 0x65, 0x56, 0xac,
254 0x2d, 0x77, 0xc0, 0x1a, 0xad, 0x32, 0xca, 0x0c, 0x72, 0xae, 0xdb, 0x57,
255 0xc1, 0xc7, 0x79, 0xef, 0xc6, 0x71, 0x9f, 0xad, 0x82, 0x14, 0x94, 0x4b,
256 0xf9, 0xd8, 0x78, 0xf1, 0xca, 0x99, 0xf5, 0x71, 0x07, 0x88, 0xd7, 0x55,
257 0xc7, 0xcb, 0x36, 0x5d, 0xdb, 0x84, 0x46, 0xac, 0x05, 0xea, 0xf1, 0xe1,
258 0xbe, 0x91, 0x50, 0x85, 0x1e, 0x64, 0xab, 0x02, 0x82, 0xab, 0xba, 0x42,
259 0x06, 0x5a, 0xe3, 0xc3, 0x25, 0xd0, 0x95, 0x04, 0x54, 0xb4, 0x44, 0x40,
260 0x5a, 0x42, 0x06, 0x04, 0x7d, 0x3b, 0x9e, 0xaf, 0x2e, 0xe9, 0xc8, 0xad,
261 0x46, 0x3a, 0xff, 0xe2, 0x39, 0xc8, 0x48, 0x0a, 0x49, 0xaa, 0xfe, 0x1f,
262 0x6c, 0x91, 0x5d, 0x1d, 0xd6, 0xb0, 0x04, 0xd1, 0x6c, 0xb2, 0x43, 0xaf,
263 0x02, 0x03, 0x01, 0x00, 0x01
283 0x02, 0x81, 0x80, 0x1d, 0x60, 0xb7, 0x25, 0xdf, 0x0c, 0x76, 0xc5, 0xf7,
284 0xc2, 0xb1, 0x8b, 0x22, 0x2f, 0x21, 0xbd, 0x2f, 0x7d, 0xd5, 0xa1, 0xf6,
285 0x01, 0xd5, 0x24, 0x39, 0x55, 0xd4, 0x16, 0xd6, 0xe1, 0x8a, 0x53, 0x26,
286 0xf2, 0x3e, 0xc1, 0xc9, 0x4c, 0x33, 0x2e, 0x17, 0x16, 0xec, 0xa7, 0x9e,
287 0x3e, 0x1d, 0x4a, 0x66, 0xa7, 0x64, 0x07, 0x48, 0x3d, 0x7a, 0xf3, 0xb6,
288 0xdd, 0xf8, 0x56, 0x04, 0x0d, 0x0f, 0xef, 0xf8, 0xbd, 0xbc, 0x73, 0xe2,
289 0xc2, 0xae, 0x1b, 0x87, 0x90, 0x18, 0x2a, 0x68, 0xff, 0xae, 0x49, 0xdf,
290 0x7c, 0xff, 0xe8, 0x44, 0xa8, 0x3e, 0x4e, 0x4f, 0xf5, 0xfa, 0x51, 0x96,
291 0xb8, 0x08, 0xf3, 0x18, 0xd6, 0x52, 0xdf, 0x3a, 0x8a, 0xed, 0xda, 0xcd,
292 0xb4, 0x06, 0x99, 0x41, 0xcb, 0x23, 0x17, 0xaf, 0xc3, 0x3e, 0xfe, 0xdf,
293 0x97, 0xf3, 0xd6, 0x18, 0x7e, 0x03, 0xaf, 0x62, 0xb2, 0xc8, 0xc9
296 0x02, 0x81, 0x80, 0x45, 0xbd, 0xc0, 0xbe, 0x0c, 0x01, 0x79, 0x05, 0x22,
297 0xa9, 0xec, 0xa9, 0x62, 0xb5, 0x1c, 0xc0, 0xa8, 0xa6, 0x8f, 0xf8, 0x68,
298 0x94, 0x2e, 0xfe, 0xdd, 0xb2, 0x55, 0x08, 0x53, 0xff, 0x2d, 0x39, 0x5f,
299 0xeb, 0x23, 0x5a, 0x4b, 0x9f, 0x4f, 0xe3, 0xb4, 0x34, 0xf6, 0xf9, 0xaf,
300 0x0f, 0xd8, 0x37, 0x6d, 0xdb, 0x3c, 0x7f, 0xd3, 0x66, 0x80, 0x66, 0x01,
301 0x18, 0xd6, 0xa0, 0x90, 0x4f, 0x17, 0x09, 0xb8, 0x68, 0x44, 0xf0, 0xde,
302 0x16, 0x4a, 0x8a, 0x0d, 0xa7, 0x5f, 0xb5, 0x4c, 0x53, 0xcc, 0x21, 0xdd,
303 0x4f, 0x05, 0x64, 0xa5, 0xc5, 0xac, 0x2c, 0xd8, 0x0a, 0x7b, 0xf5, 0xa4,
304 0x63, 0x32, 0xb0, 0x2c, 0xf8, 0xef, 0x8c, 0xf8, 0x2c, 0xba, 0x1c, 0x2c,
305 0xc7, 0x0a, 0xf3, 0xe9, 0x8f, 0xfb, 0x0a, 0x61, 0x1b, 0x3a, 0xdd, 0x9f,
306 0x74, 0x7d, 0xb3, 0x42, 0x59, 0x52, 0x07, 0x59, 0x8e, 0xb7, 0x41
314 #define icert_key_suffix a 315 #define icert_key_variable( prefix ) _C2 ( prefix, icert_key_suffix ) 316 #define icert_public icert_key_variable ( icert_public_ ) 317 #define icert_private icert_key_variable ( icert_private_ ) 320 static const char icert_begin[] =
"-----BEGIN CERTIFICATE-----\n";
323 static const char icert_end[] =
"\n-----END CERTIFICATE-----\n";
376 DBGC (
icert,
"ICERT %p could not build subjectPublicKeyInfo: " 391 DBGC (
icert,
"ICERT %p could not build tbsCertificate: %s\n",
404 DBGC (
icert,
"ICERT %p could not build signature: %s\n",
411 DBGC (
icert,
"ICERT %p could not sign: %s\n",
413 goto err_pubkey_sign;
425 DBGC (
icert,
"ICERT %p could not build certificate: %s\n",
432 DBGC (
icert,
"ICERT %p invalid certificate: %s\n",
483 DBGC (
icert,
"ICERT %p could not build private key: %s\n",
492 DBGC (
icert,
"ICERT %p could not build public key: %s\n",
542 size_t encencoded_len;
554 ( encoded_len - 1 ) +
569 DBGC2 (
icert,
"ICERT %p \"%s\" certificate:\n%s",
575 *encenc =
malloc ( encencoded_len );
578 goto err_alloc_encenc;
652 vers =
iob_put ( iobuf,
sizeof ( *vers ) );
655 memset ( vers, 0,
sizeof ( *vers ) );
684 tcp->tcp.
hlen = ( (
sizeof (
tcp->tcp ) / 4 ) << 4 );
712 syn =
iob_put ( iobuf,
sizeof ( *syn ) );
715 memset ( syn, 0,
sizeof ( *syn ) );
777 if (
len <
sizeof ( *log ) ) {
778 DBGC (
imux,
"IMUX %p malformed log message:\n",
imux );
788 msg_len = (
len -
sizeof ( *hdr ) );
824 if (
len <
sizeof ( *
tcp ) ) {
825 DBGC (
imux,
"IMUX %p malformed TCP message:\n",
imux );
832 DBGC (
imux,
"IMUX %p ignoring unexpected TCP port %d:\n",
888 DBGC (
imux,
"IMUX %p bulk IN failed: %s\n",
894 if (
len <
sizeof ( *
hdr ) ) {
906 switch (
hdr->protocol ) {
917 DBGC (
imux,
"IMUX %p unknown message type %d:\n",
945 DBGC (
imux,
"IMUX %p bulk OUT failed: %s\n",
1009 DBGC (
imux,
"IMUX %p retrying pairing: %s\n",
1139 DBGC (
imux,
"IMUX %p could not describe: %s\n",
1146 DBGC (
imux,
"IMUX %p could not open: %s\n",
1210 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" 1211 "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" " 1212 "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n" 1213 "<plist version=\"1.0\">\n" 1215 "<key>Label</key>\n" 1216 "<string>iPXE</string>\n" 1217 "<key>Request</key>\n";
1326 if ( (
msg[
len - 1 ] !=
'\0' ) && (
msg[
len - 1 ] !=
'\n' ) ) {
1374 DBGC (
ipair,
"IPAIR %p missing closing tag %s in:\n%s\n",
1427 "<string>GetValue</string>\n" 1429 "<string>DevicePublicKey</string>\n" 1457 DBGC (
ipair,
"IPAIR %p unexpected public key message:\n%s\n",
1465 decoded =
malloc ( max_len );
1473 DBGC (
ipair,
"IPAIR %p invalid outer public key:\n%s\n",
1482 DBGC (
ipair,
"IPAIR %p invalid inner public key:\n%s\n",
1547 "<string>Pair</string>\n" 1548 "<key>PairRecord</key>\n" 1550 "<key>RootCertificate</key>\n" 1552 "<key>HostCertificate</key>\n" 1554 "<key>DeviceCertificate</key>\n" 1556 "<key>SystemBUID</key>\n" 1557 "<string>%s</string>\n" 1558 "<key>HostID</key>\n" 1559 "<string>%s</string>\n" 1561 "<key>ProtocolVersion</key>\n" 1562 "<string>2</string>\n" 1563 "<key>PairingOptions</key>\n" 1565 "<key>ExtendedPairingErrors</key>\n" 1595 if (
strcmp (
error,
"PairingDialogResponsePending" ) != 0 ) {
1632 DBGC (
ipair,
"IPAIR %p unexpected pairing response:\n%s\n",
1658 "<string>StartSession</string>\n" 1659 "<key>SystemBUID</key>\n" 1660 "<string>%s</string>\n" 1661 "<key>HostID</key>\n" 1662 "<string>%s</string>\n" 1692 DBGC (
ipair,
"IPAIR %p unknown host: requesting pairing\n",
ipair );
1719 DBGC (
ipair,
"IPAIR %p unexpected session response:\n%s\n",
1724 DBGC (
ipair,
"IPAIR %p starting session \"%s\"\n",
ipair, session );
1729 DBGC (
ipair,
"IPAIR %p could not start TLS: %s\n",
1902 DBGC (
iphone,
"IPHONE %p bulk IN failed: %s\n",
2011 sizeof (
status ) ) ) != 0 ) {
2012 DBGC (
iphone,
"IPHONE %p could not get link status: %s\n",
2074 DBGC (
iphone,
"IPHONE %p could not open: %s\n",
2184 DBGC (
iphone,
"IPHONE %p could not describe: %s\n",
2192 DBGC (
iphone,
"IPHONE %p could not fetch MAC address: %s\n",
Transport Layer Security Protocol.
static void ipair_close(struct ipair *ipair, int rc)
Shut down pairing client.
#define iob_pull(iobuf, len)
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.
iPhone USB Ethernet driver
#define EINVAL
Invalid argument.
An object interface operation.
uint32_t tcp_ack
Pseudo-TCP acknowledgement number.
struct arbelprm_rc_send_wqe rc
static void imux_rx_log(struct imux *imux, struct imux_header *hdr, size_t len)
Receive log message.
static void digest_update(struct digest_algorithm *digest, void *ctx, const void *data, size_t len)
void xfer_window_changed(struct interface *intf)
Report change of flow control window.
void intf_close(struct interface *intf, int rc)
Close an object interface.
static void privkey_put(struct private_key *key)
Drop reference to private key.
void intf_restart(struct interface *intf, int rc)
Shut down and restart an object interface.
#define iob_put(iobuf, len)
void(* complete)(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete transfer.
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
void intf_shutdown(struct interface *intf, int rc)
Shut down an object interface.
#define SHA256_DIGEST_SIZE
int printf(const char *fmt,...)
Write a formatted string to the console.
static int imux_tx_syn(struct imux *imux)
Transmit pseudo-TCP SYN.
int xfer_deliver_iob(struct interface *intf, struct io_buffer *iobuf)
Deliver datagram as I/O buffer without metadata.
static const char icert_end[]
PEM certificate suffix.
void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
static void * usb_func_get_drvdata(struct usb_function *func)
Get USB function driver private data.
static LIST_HEAD(imuxes)
List of USB multiplexers.
#define ASN1_SHORT(tag,...)
Construct a short ASN.1 value.
static void start_timer_nodelay(struct retry_timer *timer)
Start timer with no delay.
int(* tx)(struct ipair *ipair)
Transmit message.
static int iphone_check_pair(struct iphone *iphone)
Check pairing status.
static void iphone_check_link(struct net_device *netdev)
Check link status.
#define IMUX_IN_MAX_FILL
Multiplexer bulk IN maximum fill level.
int(* open)(struct net_device *netdev)
Open network device.
struct stp_switch root
Root switch.
static struct asn1_cursor icert_name_ipxe
"iPXE" subject name
#define IPHONE_IN_PAD
Bulk IN padding.
#define list_add(new, head)
Add a new entry to the head of a list.
uint32_t next
Next descriptor address.
static void imux_rx_syn(struct imux *imux)
Receive pseudo-TCP SYN+ACK.
#define SHA256_CTX_SIZE
SHA-256 context size.
struct refcnt refcnt
Reference count.
#define ASN1_BOOLEAN
ASN.1 boolean.
#define ref_init(refcnt, free)
Initialise a reference counter.
static int ipair_create(struct interface *xfer, unsigned int flags)
Create a pairing client.
struct golan_inbox_hdr hdr
Message header.
static struct interface_operation ipair_xfer_operations[]
Pairing client interface operations.
static int ipair_tx(struct ipair *ipair, const char *fmt,...)
Transmit XML message.
#define iob_push(iobuf, len)
static void ipair_expired(struct retry_timer *timer, int over __unused)
Pairing transmission timer.
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
static struct asn1_cursor icert_leaf_exts
Extensions used in constructed leaf certificates.
static void imux_rx_version(struct imux *imux)
Receive version message.
static void digest_final(struct digest_algorithm *digest, void *ctx, void *out)
static const uint8_t icert_public_a [] __unused
Public key(s) used for pairing.
uint32_t type
Operating system type.
#define sprintf(buf, fmt,...)
Write a formatted string to a buffer.
int(* action)(struct imux *imux)
Pending action.
#define EPIPE
Broken pipe.
static void process_init(struct process *process, struct process_descriptor *desc, struct refcnt *refcnt)
Initialise process and add to process list.
struct arbelprm_completion_with_error error
struct interface tcp
Pseudo-TCP lockdown socket interface.
int asn1_prepend_raw(struct asn1_builder *builder, const void *data, size_t len)
Prepend raw data to ASN.1 builder.
static int ipair_rx_pair(struct ipair *ipair, char *msg)
Receive Pair message.
uint16_t out_seq
Output sequence.
static struct x509_root icert_root
Root of trust for iPhone certificates.
const void * data
Start of data.
struct interface xfer
Data transfer interface.
#define ENOENT
No such file or directory.
void intf_plug_plug(struct interface *a, struct interface *b)
Plug two object interfaces together.
int usb_stream(struct usb_endpoint *ep, struct io_buffer *iobuf, int terminate)
Enqueue USB stream transfer.
static const uint8_t icert_root_exts_data[]
Extensions used in constructed root certificate.
struct io_buffer * xfer_alloc_iob(struct interface *intf, size_t len)
Allocate I/O buffer.
#define IMUX_WINDOW
Advertised TCP window.
static const char ipair_prefix[]
Common prefix for all pairing messages.
int base64_decode(const char *encoded, void *data, size_t len)
Base64-decode string.
static struct usb_endpoint_driver_operations imux_out_operations
Bulk OUT endpoint operations.
int x509_is_valid(struct x509_certificate *cert, struct x509_root *root)
Check if X.509 certificate is valid.
static const char ipair_host_id[]
Arbitrary host ID used for pairing.
struct x509_certificate * device
Device certificate.
static int ipair_rx_session_error(struct ipair *ipair, char *error)
Receive StartSession message error.
A data structure for storing profiling information.
uint16_t device
Device ID.
static int ipair_rx_session(struct ipair *ipair, char *msg)
Receive StartSession message.
int open
Endpoint is open.
static void profile_stop(struct profiler *profiler)
Stop profiling.
void process_del(struct process *process)
Remove process from process list.
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
size_t xfer_window(struct interface *intf)
Check flow control window.
#define ASN1_SET
ASN.1 set.
static void imux_rx_tcp(struct imux *imux, struct io_buffer *iobuf)
Receive pseudo-TCP message.
int usb_control(struct usb_device *usb, unsigned int request, unsigned int value, unsigned int index, void *data, size_t len)
Issue USB control transaction.
#define IMUX_PORT_LOCAL
Local port number.
static int ipair_rx(struct ipair *ipair, char *msg, size_t len)
Receive XML message payload.
static int icert_certs(struct icert *icert, struct asn1_cursor *key)
Construct certificates.
#define ECANCELED
Operation canceled.
static void iphone_remove(struct usb_function *func)
Remove device.
static const char icert_begin[]
PEM certificate prefix.
Data transfer interfaces.
size_t len
Length of data.
An iPhone pairing client.
static const uint8_t icert_sha256_rsa[]
"SHA-256 with RSA algorithm" identifier used in constructed certificates
#define IPHONE_IN_MTU
Bulk IN buffer size.
uint32_t start
Starting offset.
static struct net_device_operations iphone_operations
iPhone network device operations
static const uint8_t icert_name_ipxe_data[]
"iPXE" subject name
static struct asn1_cursor icert_name_iphone
"iPhone" subject name
static struct interface_descriptor imux_tcp_desc
Pseudo-TCP socket interface descriptor.
struct usb_endpoint out
Bulk OUT endpoint.
static void iphone_poll(struct net_device *netdev)
Poll for completed and received packets.
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
struct x509_certificate * host
Host certificate.
struct asn1_builder builder
ASN.1 object builder.
#define list_del(list)
Delete an entry from a list.
char * strstr(const char *haystack, const char *needle)
Find substring.
static size_t base64_encoded_len(size_t raw_len)
Calculate length of base64-encoded data.
#define ENOMEM
Not enough space.
#define iob_disown(iobuf)
Disown an I/O buffer.
static size_t base64_decoded_max_len(const char *encoded)
Calculate maximum length of base64-decoded string.
static int iphone_open(struct net_device *netdev)
Open network device.
struct refcnt refcnt
Reference counter.
Standalone length has been received.
static struct asn1_cursor icert_root_exts
Extensions used in constructed root certificate.
static int imux_deliver(struct imux *imux, struct io_buffer *iobuf, struct xfer_metadata *meta __unused)
Transmit packet via pseudo-TCP socket.
static int netdev_is_open(struct net_device *netdev)
Check whether or not network device is open.
#define ASN1_OID_BASICCONSTRAINTS
ASN.1 OID for id-ce-basicConstraints (2.5.29.19)
#define EINPROGRESS_PAIRING
static struct asn1_cursor icert_name_root
"Root" subject name
struct usb_port * port
USB port.
int link_rc
Link status code.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
#define container_of(ptr, type, field)
Get containing structure.
static int imux_tx_version(struct imux *imux)
Transmit version message.
static const uint8_t icert_name_root_data[]
"Root" subject name
#define ASN1_CURSOR(value)
Define an ASN.1 cursor for a static value.
static uint8_t icert_root_fingerprint[SHA256_DIGEST_SIZE]
iPhone root certificate fingerprint
static int ipair_deliver(struct ipair *ipair, struct io_buffer *iobuf, struct xfer_metadata *meta __unused)
Handle received data.
void * priv
Driver private data.
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
struct digest_algorithm * digest
Fingerprint digest algorithm.
static void usb_refill_init(struct usb_endpoint *ep, size_t reserve, size_t len, unsigned int max)
Initialise USB endpoint refill.
static int icert_encode(struct icert *icert, struct x509_certificate *cert, char **encenc)
Construct doubly base64-encoded certificate.
static struct net_device * netdev
struct usb_driver imux_driver __usb_driver
USB multiplexer driver.
char * strcpy(char *dest, const char *src)
Copy string.
static const uint8_t icert_name_iphone_data[]
"iPhone" subject name
#define ENOTCONN_STATUS(status)
static void usb_func_set_drvdata(struct usb_function *func, void *priv)
Set USB function driver private data.
static void profile_start(struct profiler *profiler)
Start profiling.
#define ASN1_OID_COMMON_NAME
ASN.1 OID for commonName (2.5.4.3)
void unregister_netdev(struct net_device *netdev)
Unregister network device.
static const uint8_t icert_validity[]
Validity period in constructed certificates.
#define ASN1_NULL
ASN.1 null.
static int imux_probe(struct usb_function *func, struct usb_configuration_descriptor *config)
Probe device.
int usbnet_refill(struct usbnet_device *usbnet)
Refill USB network device bulk IN and interrupt endpoints.
#define ASN1_GENERALIZED_TIME
ASN.1 generalized time.
#define EPROTO
Protocol error.
void process_add(struct process *process)
Add process to process list.
static struct io_buffer * imux_alloc_iob(struct imux *imux __unused, size_t len)
Allocate I/O buffer for pseudo-TCP socket.
static struct interface_descriptor ipair_xfer_desc
Pairing client interface descriptor.
static void digest_init(struct digest_algorithm *digest, void *ctx)
int asn1_grow(struct asn1_builder *builder, size_t extra)
Grow ASN.1 builder.
static void usb_poll(struct usb_bus *bus)
Poll USB bus.
An object interface descriptor.
static const char ipair_system_buid[]
Arbitrary system BUID used for pairing.
char * strerror(int errno)
Retrieve string representation of error number.
struct refcnt refcnt
Reference counter.
static void(* free)(struct refcnt *refcnt))
void * zalloc(size_t size)
Allocate cleared memory.
static void iphone_in_complete(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete bulk IN transfer.
static int iphone_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Transmit packet.
int register_netdev(struct net_device *netdev)
Register network device.
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
#define INTF_OP(op_type, object_type, op_func)
Define an object interface operation.
static struct profiler iphone_in_profiler __profiler
Bulk IN completion profiler.
#define USB_CLASS_ID(base, subclass, protocol)
Construct USB class ID.
void netdev_link_err(struct net_device *netdev, int rc)
Mark network device as having a specific link state.
struct usb_endpoint in
Bulk IN endpoint.
int xfer_deliver(struct interface *intf, struct io_buffer *iobuf, struct xfer_metadata *meta)
Deliver datagram.
size_t strlen(const char *src)
Get length of string.
REQUIRE_OBJECT(rsa_sha256)
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
struct usb_device * usb
USB device.
static struct usb_endpoint_driver_operations iphone_out_operations
Bulk OUT endpoint operations.
struct usb_bus * bus
USB bus.
uint16_t in_seq
Input sequence.
static int iphone_out_transmit(struct iphone *iphone, struct io_buffer *iobuf)
Transmit packet.
static void imux_out_complete(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete bulk OUT transfer.
An iPhone USB multiplexer.
struct usb_device * usb
USB device.
int asn1_wrap(struct asn1_builder *builder, unsigned int type)
Wrap ASN.1 builder.
#define ASN1_SEQUENCE
ASN.1 sequence.
static const uint8_t icert_rsa[]
"RSA algorithm" identifier used in constructed certificates
void * malloc(size_t size)
Allocate memory.
static struct usb_endpoint_driver_operations iphone_in_operations
Bulk IN endpoint operations.
void * memmove(void *dest, const void *src, size_t len) __nonnull
void x509_fingerprint(struct x509_certificate *cert, struct digest_algorithm *digest, void *fingerprint)
Calculate X.509 certificate fingerprint.
struct usbnet_device usbnet
USB network device.
static int ipair_tx_pubkey(struct ipair *ipair)
Transmit DevicePublicKey message.
#define ASN1_UTF8_STRING
ASN.1 UTF-8 string.
#define ASN1_INTEGER
ASN.1 integer.
struct x509_certificate * root
Root certificate.
static int process_running(struct process *process)
Check if process is running.
Network device operations.
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
struct device * dev
Underlying hardware device.
static int imux_tx_tcp(struct imux *imux, struct io_buffer *iobuf)
Transmit pseudo-TCP message.
#define EPERM
Operation not permitted.
struct usb_device * usb
USB device.
static const char ipair_suffix[]
Common suffix for all pairing messages.
Network device management.
void start_timer_fixed(struct retry_timer *timer, unsigned long timeout)
Start timer with a specified timeout.
static void iphone_expired(struct retry_timer *timer, int over __unused)
Periodically update link status.
An X.509 root certificate list.
#define IPAIR_RETRY_DELAY
Pairing retry delay.
struct icert icert
Pairing certificates.
RSA public-key cryptography.
#define iob_reserve(iobuf, len)
static int ipair_tag(struct ipair *ipair, const char *msg, const char *tag, char **start, char **end)
Locate XML tag.
#define INTF_DESC(object_type, intf, operations)
Define an object interface descriptor.
static void imux_close(struct imux *imux, int rc)
Close USB multiplexer.
A USB configuration descriptor.
const char * x509_name(struct x509_certificate *cert)
Get X.509 certificate display name.
#define ASN1_OID
ASN.1 object identifier.
void stop_timer(struct retry_timer *timer)
Stop timer.
uint32_t tcp_seq
Pseudo-TCP sequence number.
struct digest_algorithm sha256_algorithm
SHA-256 algorithm.
void netdev_tx_complete_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Complete network transmission.
#define IMUX_PORT_LOCKDOWND
Lockdown daemon port number.
struct process process
Polling process.
unsigned int flags
Pairing flags.
static int ipair_tx_session(struct ipair *ipair)
Transmit StartSession message.
static void imux_remove(struct usb_function *func)
Remove device.
An iPhone network device.
#define USB_ANY_ID
Match-anything ID.
__builtin_va_list va_list
int strcmp(const char *first, const char *second)
Compare strings.
Universal Serial Bus (USB)
size_t digestsize
Digest size.
static int ipair_rx_pubkey(struct ipair *ipair, char *msg)
Receive DevicePublicKey message.
static void ipair_free(struct refcnt *refcnt)
Free pairing client.
#define IMUX_IN_MTU
Multiplexer bulk IN buffer size.
static void usbnet_init(struct usbnet_device *usbnet, struct usb_function *func, struct usb_endpoint_driver_operations *intr, struct usb_endpoint_driver_operations *in, struct usb_endpoint_driver_operations *out)
Initialise USB network device.
int pem_asn1(userptr_t data, size_t len, size_t offset, struct asn1_cursor **cursor)
Extract ASN.1 object from PEM data.
static void x509_put(struct x509_certificate *cert)
Drop reference to X.509 certificate.
void * data
Start of data.
#define PROC_DESC(object_type, process, _step)
Define a process descriptor.
static int imux_tx(struct imux *imux, struct io_buffer *iobuf)
Transmit message.
static struct usb_device_id imux_ids[]
USB multiplexer device IDs.
struct usb_hub * hub
USB hub.
static int ipair_tx_pair(struct ipair *ipair)
Transmit Pair message.
struct private_key * key
"Private" key
#define IPHONE_IN_MAX_FILL
Bulk IN maximum fill level.
int asn1_prepend(struct asn1_builder *builder, unsigned int type, const void *data, size_t len)
Prepend data to ASN.1 builder.
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
u8 rx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets from the AP.
struct pubkey_algorithm rsa_algorithm
RSA public-key algorithm.
userptr_t virt_to_user(volatile const void *addr)
Convert virtual address to user pointer.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
#define ASN1_OID_RSAENCRYPTION
ASN.1 OID for rsaEncryption (1.2.840.113549.1.1.1)
A message digest algorithm.
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.
uint32_t end
Ending offset.
uint16_t port
Pseudo-TCP local port number.
uint8_t data[48]
Additional event data.
int(* rx)(struct ipair *ipair, char *msg)
Receive message.
struct refcnt refcnt
Reference counter.
#define REF_INIT(free_fn)
Initialise a static reference counter.
static void imux_in_complete(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete bulk IN transfer.
struct retry_timer timer
Link status check timer.
int ssize_t const char * fmt
#define IPHONE_LINK_CHECK_INTERVAL
Link check interval.
REQUIRING_SYMBOL(iphone_driver)
static struct asn1_cursor * asn1_built(struct asn1_builder *builder)
Get cursor for built object.
int usbnet_describe(struct usbnet_device *usbnet, struct usb_configuration_descriptor *config)
Describe USB network device interfaces.
static void privkey_init(struct private_key *key)
Initialise empty private key.
#define IPHONE_GET_MAC
Get MAC address.
static struct process_descriptor imux_process_desc
Multiplexer process descriptor.
static const uint8_t icert_leaf_exts_data[]
Extensions used in constructed leaf certificates.
#define ASN1_EXPLICIT_TAG(number)
ASN.1 explicit tag.
static void imux_shutdown(struct imux *imux)
Shut down USB multiplexer.
#define va_start(ap, last)
static struct usb_endpoint_driver_operations imux_in_operations
Bulk IN endpoint operations.
static int ipair_rx_pair_error(struct ipair *ipair, char *error)
Receive Pair message error.
struct asn1_cursor raw
Raw certificate.
struct usbnet_device usbnet
USB network device.
void usbnet_close(struct usbnet_device *usbnet)
Close USB network device.
static size_t pubkey_max_len(struct pubkey_algorithm *pubkey, const struct asn1_cursor *key)
USB endpoint driver operations.
static void intf_init(struct interface *intf, struct interface_descriptor *desc, struct refcnt *refcnt)
Initialise an object interface.
struct device dev
Generic device.
static void iphone_close(struct net_device *netdev)
Close network device.
struct usb_bus * bus
USB bus.
#define IPHONE_GET_LINK
Get link status.
static int pubkey_sign(struct pubkey_algorithm *pubkey, const struct asn1_cursor *key, struct digest_algorithm *digest, const void *value, void *signature)
uint64_t tag
Identity tag.
#define ASN1_OCTET_STRING
ASN.1 octet string.
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
static int iphone_probe(struct usb_function *func, struct usb_configuration_descriptor *config)
Probe device.
void ref_no_free(struct refcnt *refcnt __unused)
Do not free reference-counted object.
TLS session has been started.
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
#define NULL
NULL pointer (VOID *)
size_t len
Length of data.
static void imux_step(struct imux *imux)
Multiplexer process.
unsigned int flags
State flags.
static const uint8_t icert_tbs_prefix[]
"TBSCertificate" prefix in constructed certificates
static void ipair_window_changed(struct ipair *ipair)
Handle window change notification.
static struct usb_device_id iphone_ids[]
iPhone device IDs
struct usb_bus * bus
USB bus.
#define ASN1_BIT_STRING
ASN.1 bit string.
struct net_device * netdev
Network device.
An iPhone pairing certificate set.
static void icert_free(struct icert *icert)
Free pairing certificates.
struct retry_timer timer
Pairing timer.
int add_tls(struct interface *xfer, const char *name, struct x509_root *root, struct private_key *key)
Add TLS on an interface.
static int imux_start_pair(struct imux *imux)
Open pairing client.
size_t base64_encode(const void *raw, size_t raw_len, char *data, size_t len)
Base64-encode data.
static const uint8_t icert_nul[]
Single zero byte used in constructed certificates.
#define ASN1_OID_KEYUSAGE
ASN.1 OID for id-ce-keyUsage (2.5.29.15)
#define ref_put(refcnt)
Drop reference to object.
struct list_head list
List of USB multiplexers.
struct usb_device_id * ids
USB ID table.
u8 tx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets to the AP.
int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
Write a formatted string to a buffer.
struct list_head list
List of iPhone network devices.
void * memset(void *dest, int character, size_t len) __nonnull
static struct interface_operation imux_tcp_operations[]
Pseudo-TCP socket interface operations.
static void iphone_out_complete(struct usb_endpoint *ep, struct io_buffer *iobuf, int rc)
Complete bulk OUT transfer.
#define ASN1_OID_SHA256WITHRSAENCRYPTION
ASN.1 OID for sha256WithRSAEncryption (1.2.840.113549.1.1.11)
int usbnet_open(struct usbnet_device *usbnet)
Open USB network device.