Browse code

rtmpcrypt: Do the xtea decryption in little endian mode

The XTEA algorithm operates on 32 bit numbers, not on byte sequences.
The XTEA implementation in libavutil is written assuming big endian
numbers, while the rtmpe signature encryption assumes little endian.

This fixes rtmpe communication with rtmpe servers that use signature
type 8 (XTEA), e.g. crunchyroll.

CC: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
(cherry picked from commit e7728319b92dbb4fb949155e33de7ff5358ddff3)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>

Martin Storsjö authored on 2015/11/12 04:42:02
Showing 1 changed files
... ...
@@ -184,9 +184,14 @@ int ff_rtmpe_compute_secret_key(URLContext *h, const uint8_t *serverdata,
184 184
 static void rtmpe8_sig(const uint8_t *in, uint8_t *out, int key_id)
185 185
 {
186 186
     struct AVXTEA ctx;
187
+    uint8_t tmpbuf[8];
187 188
 
188 189
     av_xtea_init(&ctx, rtmpe8_keys[key_id]);
189
-    av_xtea_crypt(&ctx, out, in, 1, NULL, 0);
190
+    AV_WB32(tmpbuf, AV_RL32(in));
191
+    AV_WB32(tmpbuf + 4, AV_RL32(in + 4));
192
+    av_xtea_crypt(&ctx, tmpbuf, tmpbuf, 1, NULL, 0);
193
+    AV_WL32(out, AV_RB32(tmpbuf));
194
+    AV_WL32(out + 4, AV_RB32(tmpbuf + 4));
190 195
 }
191 196
 
192 197
 static void rtmpe9_sig(const uint8_t *in, uint8_t *out, int key_id)