Fix myTeamSpeak sign-in for accounts with add-on items
The server returns every item class the account holds, not only the requested ones, and add-on items come unencrypted. Decrypting them failed the integrity check and aborted the whole import. Only decrypt the classes that were asked for. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -184,25 +184,41 @@ public final class MyTeamSpeak {
|
||||
return items;
|
||||
}
|
||||
|
||||
/** The encrypted items of one {@code Sync_ItemClasses_Data}; tombstones carry none. */
|
||||
/**
|
||||
* The encrypted items of one {@code Sync_ItemClasses_Data}; tombstones carry none.
|
||||
* The server answers with every class the account holds, whatever was asked for,
|
||||
* and not all of them are encrypted (add-on flags come in the clear), so only the
|
||||
* wanted classes are kept.
|
||||
*/
|
||||
private static void collectFrames(ProtobufReader itemClass, List<byte[]> frames) throws IOException {
|
||||
int classId = 0;
|
||||
List<byte[]> blobs = new ArrayList<>();
|
||||
while (itemClass.next()) {
|
||||
if (itemClass.fieldNumber() != 3) {
|
||||
itemClass.skip();
|
||||
continue;
|
||||
}
|
||||
ProtobufReader detail = itemClass.readMessage();
|
||||
byte[] blob = null;
|
||||
boolean deleted = false;
|
||||
while (detail.next()) {
|
||||
switch (detail.fieldNumber()) {
|
||||
case 3 -> blob = detail.readBytes();
|
||||
case 4 -> deleted = detail.readBool();
|
||||
default -> detail.skip();
|
||||
switch (itemClass.fieldNumber()) {
|
||||
case 1 -> classId = (int) itemClass.readVarint();
|
||||
case 3 -> {
|
||||
byte[] blob = itemBlob(itemClass.readMessage());
|
||||
if (blob != null) blobs.add(blob);
|
||||
}
|
||||
default -> itemClass.skip();
|
||||
}
|
||||
if (!deleted && blob != null && blob.length > 0) frames.add(blob);
|
||||
}
|
||||
for (int wanted : ITEM_CLASSES) {
|
||||
if (wanted == classId) frames.addAll(blobs);
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[] itemBlob(ProtobufReader detail) throws IOException {
|
||||
byte[] blob = null;
|
||||
boolean deleted = false;
|
||||
while (detail.next()) {
|
||||
switch (detail.fieldNumber()) {
|
||||
case 3 -> blob = detail.readBytes();
|
||||
case 4 -> deleted = detail.readBool();
|
||||
default -> detail.skip();
|
||||
}
|
||||
}
|
||||
return !deleted && blob != null && blob.length > 0 ? blob : null;
|
||||
}
|
||||
|
||||
/** Ends the session rather than leave it for the server to expire; nothing to do if that fails. */
|
||||
|
||||
@@ -68,10 +68,16 @@ class MyTeamSpeakTest {
|
||||
.string(2, "5d831e3c-d5aa-0e66-7af2-a0feb13af048")
|
||||
.bytes(3, MyTsCryptoTest.itemFrame());
|
||||
ProtobufWriter tombstone = new ProtobufWriter().string(1, "gone").varint(4, 1);
|
||||
// Sent though not asked for, and in the clear.
|
||||
ProtobufWriter addOn = new ProtobufWriter()
|
||||
.string(1, "38aa56e2-55ae-b37a-a7db-7a11832a9812")
|
||||
.bytes(3, new ProtobufWriter().string(2, "38aa56e2-55ae-b37a-a7db-7a11832a9812")
|
||||
.varint(6, 4).toByteArray());
|
||||
return new ProtobufWriter()
|
||||
.varint(1, 301)
|
||||
.message(2, new ProtobufWriter().varint(1, 0).string(2, "v").message(3, bookmark).message(3, tombstone))
|
||||
.message(2, new ProtobufWriter().varint(1, 1).varint(4, 1))
|
||||
.message(2, new ProtobufWriter().varint(1, 4).string(2, "v").message(3, addOn))
|
||||
.string(3, "g")
|
||||
.toByteArray();
|
||||
} catch (java.security.GeneralSecurityException e) {
|
||||
|
||||
Reference in New Issue
Block a user