Skip to content

Commit 29ec357

Browse files
committed
Skip authentication for Mad Catz devices
See code comments.
1 parent 8fc930c commit 29ec357

File tree

4 files changed

+30
-28
lines changed

4 files changed

+30
-28
lines changed

auth/auth.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -486,18 +486,25 @@ static void gip_auth_exchange_rsa(struct work_struct *work)
486486
__func__, err);
487487
}
488488

489+
int gip_auth_send_complete(struct gip_client *client)
490+
{
491+
struct gip_auth_header_control hdr = {};
492+
493+
hdr.context = GIP_AUTH_CTX_CONTROL;
494+
hdr.control = GIP_AUTH_CTRL_COMPLETE;
495+
496+
return gip_send_authenticate(client, &hdr, sizeof(hdr), false);
497+
}
498+
EXPORT_SYMBOL_GPL(gip_auth_send_complete);
499+
489500
static void gip_auth_complete_handshake(struct work_struct *work)
490501
{
491502
struct gip_auth *auth = container_of(work, typeof(*auth),
492503
work_complete);
493-
struct gip_auth_header_control hdr = {};
494504
u8 random[GIP_AUTH_RANDOM_LEN * 2];
495505
u8 key[GIP_AUTH_SESSION_KEY_LEN];
496506
int err;
497507

498-
hdr.context = GIP_AUTH_CTX_CONTROL;
499-
hdr.control = GIP_AUTH_CTRL_COMPLETE;
500-
501508
memcpy(random, auth->random_host, sizeof(auth->random_host));
502509
memcpy(random + sizeof(auth->random_host), auth->random_client,
503510
sizeof(auth->random_client));
@@ -517,9 +524,9 @@ static void gip_auth_complete_handshake(struct work_struct *work)
517524
dev_dbg(&auth->client->dev, "%s: key=%*phD\n", __func__,
518525
(int)sizeof(key), key);
519526

520-
err = gip_send_authenticate(auth->client, &hdr, sizeof(hdr), false);
527+
err = gip_auth_send_complete(auth->client);
521528
if (err) {
522-
dev_err(&auth->client->dev, "%s: send pkt failed: %d\n",
529+
dev_err(&auth->client->dev, "%s: send complete failed: %d\n",
523530
__func__, err);
524531
return;
525532
}

auth/auth.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,6 @@ struct gip_auth {
4444
u8 master_secret[GIP_AUTH_SECRET_LEN];
4545
};
4646

47+
int gip_auth_send_complete(struct gip_client *client);
4748
int gip_auth_process_pkt(struct gip_auth *auth, void *data, u32 len);
4849
int gip_auth_start_handshake(struct gip_auth *auth, struct gip_client *client);

driver/madcatz_glam.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ struct gip_glam_pkt_input {
4848
struct gip_glam {
4949
struct gip_client *client;
5050
struct gip_battery battery;
51-
struct gip_auth auth;
5251
struct gip_input input;
5352
};
5453

@@ -95,14 +94,6 @@ static int gip_glam_op_battery(struct gip_client *client,
9594
return 0;
9695
}
9796

98-
static int gip_glam_op_authenticate(struct gip_client *client,
99-
void *data, u32 len)
100-
{
101-
struct gip_glam *glam = dev_get_drvdata(&client->dev);
102-
103-
return gip_auth_process_pkt(&glam->auth, data, len);
104-
}
105-
10697
static int gip_glam_op_guide_button(struct gip_client *client, bool down)
10798
{
10899
struct gip_glam *glam = dev_get_drvdata(&client->dev);
@@ -172,7 +163,14 @@ static int gip_glam_probe(struct gip_client *client)
172163
if (err)
173164
return err;
174165

175-
err = gip_auth_start_handshake(&glam->auth, client);
166+
/*
167+
* The Drum Kit sends auth chunks without specifying the
168+
* acknowledgment option while still expecting an acknowledgment.
169+
* The Windows driver handles this by sending an acknowledgment
170+
* after 100 ms when no further chunks are received.
171+
* We skip the handshake instead, as it is not required.
172+
*/
173+
err = gip_auth_send_complete(client);
176174
if (err)
177175
return err;
178176

@@ -194,7 +192,6 @@ static struct gip_driver gip_glam_driver = {
194192
.class = "MadCatz.Xbox.Drums.Glam",
195193
.ops = {
196194
.battery = gip_glam_op_battery,
197-
.authenticate = gip_glam_op_authenticate,
198195
.guide_button = gip_glam_op_guide_button,
199196
.input = gip_glam_op_input,
200197
},

driver/madcatz_strat.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ struct gip_strat_pkt_input {
3939
struct gip_strat {
4040
struct gip_client *client;
4141
struct gip_battery battery;
42-
struct gip_auth auth;
4342
struct gip_input input;
4443
};
4544

@@ -86,14 +85,6 @@ static int gip_strat_op_battery(struct gip_client *client,
8685
return 0;
8786
}
8887

89-
static int gip_strat_op_authenticate(struct gip_client *client,
90-
void *data, u32 len)
91-
{
92-
struct gip_strat *strat = dev_get_drvdata(&client->dev);
93-
94-
return gip_auth_process_pkt(&strat->auth, data, len);
95-
}
96-
9788
static int gip_strat_op_guide_button(struct gip_client *client, bool down)
9889
{
9990
struct gip_strat *strat = dev_get_drvdata(&client->dev);
@@ -169,7 +160,14 @@ static int gip_strat_probe(struct gip_client *client)
169160
if (err)
170161
return err;
171162

172-
err = gip_auth_start_handshake(&strat->auth, client);
163+
/*
164+
* The Stratocaster sends auth chunks without specifying the
165+
* acknowledgment option while still expecting an acknowledgment.
166+
* The Windows driver handles this by sending an acknowledgment
167+
* after 100 ms when no further chunks are received.
168+
* We skip the handshake instead, as it is not required.
169+
*/
170+
err = gip_auth_send_complete(client);
173171
if (err)
174172
return err;
175173

@@ -191,7 +189,6 @@ static struct gip_driver gip_strat_driver = {
191189
.class = "MadCatz.Xbox.Guitar.Stratocaster",
192190
.ops = {
193191
.battery = gip_strat_op_battery,
194-
.authenticate = gip_strat_op_authenticate,
195192
.guide_button = gip_strat_op_guide_button,
196193
.input = gip_strat_op_input,
197194
},

0 commit comments

Comments
 (0)