Commit 723c99982c
Unsigned
Layout: unified · split
internal/episode_url.go +11 −5
| @@ -37,7 +37,7 @@ type result struct { | |||
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | func decodeTobeparsed(blob string) string { | 39 | func decodeTobeparsed(blob string) string { |
| 40 | key := []byte("SimtVuagFbGR2K7P") | 40 | key := []byte("Xot36i3lK3:v1") |
| 41 | hash := sha256.Sum256(key) | 41 | hash := sha256.Sum256(key) |
| 42 | 42 | ||
| 43 | data, err := base64.StdEncoding.DecodeString(blob) | 43 | data, err := base64.StdEncoding.DecodeString(blob) |
| @@ -46,13 +46,19 @@ func decodeTobeparsed(blob string) string { | |||
| 46 | return "" | 46 | return "" |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | if len(data) < 28 { | 49 | if len(data) < 29 { |
| 50 | Log(fmt.Sprint("Data too short to contain IV and ciphertext")) | 50 | Log("Data too short to contain tobeparsed payload") |
| 51 | return "" | 51 | return "" |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | iv := data[:12] | 54 | // The payload format is: 1-byte header, 12-byte IV, ciphertext, 16-byte trailer. |
| 55 | ct := data[12:] | 55 | iv := data[1:13] |
| 56 | ctLen := len(data) - 13 - 16 | ||
| 57 | if ctLen <= 0 { | ||
| 58 | Log("Ciphertext length is invalid in tobeparsed payload") | ||
| 59 | return "" | ||
| 60 | } | ||
| 61 | ct := data[13 : 13+ctLen] | ||
| 56 | 62 | ||
| 57 | ctrIV := make([]byte, 16) | 63 | ctrIV := make([]byte, 16) |
| 58 | copy(ctrIV, iv) | 64 | copy(ctrIV, iv) |