Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
XuXiangJun committed Oct 10, 2024
1 parent e4229d1 commit 5906592
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ private boolean checkCharEncode(byte[] data) {
return true;
}
}
// all bytes are in 0..127
return false;
}

Expand Down Expand Up @@ -177,7 +178,7 @@ private void generate() {

if (mWillEncrypt) {
if (mSecurityVer == 2) {
aesIV = new byte[18];
aesIV = new byte[20];
random.nextBytes(aesIV);
}
TouchAES aes = new TouchAES(mAesKey, aesIV);
Expand Down Expand Up @@ -264,27 +265,27 @@ private void generate() {
int count = 0;
while (is.available() > 0) {
int expectLength;
boolean tailIsCrc;
boolean crcInPacket;
if (sequence < SEQUENCE_FIRST + 1) {
// First packet
tailIsCrc = false;
crcInPacket = true;
expectLength = 6;
} else {
if (offset < reservedBeginPosition) {
// Password data
tailIsCrc = !passwordEncode;
crcInPacket = passwordEncode;
expectLength = passwordPaddingFactor;
} else if (offset < ivBeginPosition) {
// Reserved data
tailIsCrc = !reservedEncode;
crcInPacket = reservedEncode;
expectLength = reservedPaddingFactor;
} else if (offset < ssidBeginPosition) {
// aes iv data
tailIsCrc = false;
expectLength = 6;
crcInPacket = true;
expectLength = 5;
} else {
// SSID data
tailIsCrc = !ssidEncode;
crcInPacket = ssidEncode;
expectLength = ssidPaddingFactor;
}
}
Expand All @@ -301,7 +302,7 @@ private void generate() {
if (expectLength < buf.length) {
buf[buf.length - 1] = (byte) seqCrc;
}
addDataFor6Bytes(buf, sequence, seqCrc, tailIsCrc);
addDataFor6Bytes(buf, sequence, seqCrc, !crcInPacket);
++sequence;
++count;
} // end while
Expand Down

0 comments on commit 5906592

Please sign in to comment.