Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
708 views
in Technique[技术] by (71.8m points)

encryption - 使用Minecraft加密破坏了AES-128-CFB-8的前16个字节[重复](First 16 bytes of AES-128-CFB-8 are corrupted using Minecraft encryption [duplicate])

I have been trying for some time to decrypt with Crypto++, but it does not work.

(我已经尝试了一段时间,使用Crypto ++进行解密,但是它不起作用。)

The first 16 bytes of decrypted messages are not the intended text.

(解密消息的前16个字节不是预期的文本。)

I have already tried to solve the problem and have not found any way.

(我已经尝试解决该问题,但没有找到任何方法。)

My old post can be found here .

(我的旧帖子可以在这里找到。)

Important to mention: I use one and the same key for the shared secret and for the IV.

(值得一提的是:我为共享机密和IV使用了一个相同的密钥。)

Maybe someone knows about the Minecraft protocol ( this section) or can mention the error of the code.

(也许有人知道Minecraft 协议节),或者可以提及代码错误。)

std::vector<unsigned char> data;
std::string sendString;
for (unsigned char c : data) {
    sendString += c;
}

std::string sDecryptedSharedSecret = "aaaaaaaaaaaaaaaa";

byte IV[AES::BLOCKSIZE];
memcpy(IV, sDecryptedSharedSecret.c_str(), 16);

/* De/Encryptor */
CFB_Mode<AES>::Decryption AESDecryptor((byte*)sDecryptedSharedSecret.c_str(), (unsigned int)16, IV, 1);

/* Encrypt Data */
std::string sSource(sendString);
std::string sTarget("");
try {
    StringSource(sSource, true,
        new StreamTransformationFilter(AESDecryptor,
            new StringSink(sTarget)
        )
    );
}
catch (Exception) {
      std::cout << "Something went wrong
";
}

std::cout << sTarget << std::endl;
  ask by DerCoder translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If the following plaintext:

(如果是以下明文:)

The quick brown fox jumps over the lazy dog 

is encrypted with AES-CFB8 and the following key / IV:

(使用AES-CFB8和以下密钥/ IV加密:)

0x61616161616161616161616161616161 

(or Utf-8 decoded: aaaaaaaaaaaaaaaa ), the following ciphertext results:

((或Utf-8解码: aaaaaaaaaaaaaaaa ),则以下密文结果:)

0x05DEDD51C250E99EB8CD5C201C1DC7104AFB6573541CA91A10455D715BDA809D2739AD3EBC00F504E56EE4

With

(用)

std::vector<unsigned char> data {0x05, 0xDE, 0xDD, 0x51, 0xC2, 0x50, 0xE9, 0x9E, 0xB8, 0xCD, 0x5C, 0x20, 0x1C, 0x1D, 0xC7, 0x10, 0x4A, 0xFB, 0x65, 0x73, 0x54, 0x1C, 0xA9, 0x1A, 0x10, 0x45, 0x5D, 0x71, 0x5B, 0xDA, 0x80, 0x9D, 0x27, 0x39, 0xAD, 0x3E, 0xBC, 0x00, 0xF5, 0x04, 0xE5, 0x6E, 0xE4};

this ciphertext can be successfully decrypted with the posted code.

(可以使用发布的代码成功解密此密文。)

Ie the code obviously works and is not the cause of the problem.

(也就是说,代码显然可以正常工作,而不是引起问题的原因。)


Possible explanations for the problem could be in the context of CFB8 :

(该问题的可能解释可能是在CFB8的背景下进行的:)

  • If data contains only one additional byte (or even more bytes) preceding the actual ciphertext, this would produce the wrong decryption of the entire first block (16 bytes) of the actual ciphertext which can be easily illustrated by adding an arbitrary byte at the beginning in the example above.

    (如果data实际密文之前仅包含一个额外的字节(甚至更多字节),则会对实际密文的整个第一块(16个字节)产生错误的解密,可以通过在开头添加任意字节来轻松说明在上面的示例中。)

    A similar effect has a modified or missing byte (or even more bytes) at the beginning, which can be demonstrated analogously.

    (类似的效果在开始时会有一个修改或丢失的字节(甚至更多的字节),可以类似地进行演示。)

    Since CFB is a stream cipher (ie plaintext and ciphertext have the same length), this can be tested (at least in case of additional or missing bytes) by comparing the length of plaintext and ciphertext.

    (由于CFB是流密码 (即,明文和密文具有相同的长度),因此可以通过比较明文和密文的长度来进行测试(至少在附加或丢失字节的情况下)。)

    Maybe additional characters (eg whitespace characters like a line break or similar) are accidentally included.

    (也许偶然地包含了其他字符(例如,诸如换行符或类似字符的空白字符)。)

  • Also a bad IV produces an improperly decrypted complete first block, which is also easy to illustrate with your code and the example above.

    (错误的IV还会产生未正确解密的完整的第一块,这也很容易用您的代码和上面的示例进行说明。)

    How sure are you that key and IV are identical?

    (您如何确定密钥和IV是否相同?)

    By the way, there are a number of mode-dependent constraints regarding key and IV (eg never use a key / IV pair more than once), see eg here .

    (顺便说一下,关于密钥和IV有许多与模式有关的约束(例如,永远不要使用密钥/ IV对超过一次),请参见此处 。)


For further considerations it would probably be useful, if you post an example of a ciphertext, whose first block is decrypted wrongly, including plaintext and key in a suitable encoding (hexadecimal or Base64), analogous to my example.

(为了进一步考虑,如果发布一个密文示例,该密文的第一个块被错误地解密,其中包括采用合适编码(十六进制或Base64)的明文和密钥,这与我的示例类似,则可能有用。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...