日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

[m3u8]關(guān)于AES

 fgh315 2019-02-14
>>> from Crypto.Cipher import AES >>> from Crypto import Random >>> >>> key = b'Sixteen byte key' >>> iv = Random.new().read(AES.block_size) >>> cipher = AES.new(key, AES.MODE_CFB, iv) >>> msg = iv + cipher.encrypt(b'Attack at dawn')

>>> from Crypto.Cipher import AES >>> from Crypto import Random >>> >>> key = b'Sixteen byte key' >>> iv = Random.new().read(AES.block_size) >>> cipher = AES.new(key, AES.MODE_CFB, iv) >>> msg = iv + cipher.encrypt(b'Attack at dawn')

這里的key是16位的byte,iv也是16位byte,上文中的iv是字符串“0xae98961dd802f860ae9b67dd75136a18”,需要轉(zhuǎn)碼

from binascii import unhexlifyiv = unhexlify('ae98961dd802f860ae9b67dd75136a18')

from binascii import unhexlifyiv = unhexlify('ae98961dd802f860ae9b67dd75136a18')

注意去掉字符串前面的0x前綴。

解析m3u8文件有開源的庫,這里推薦:
https://github.com/globocom/m3u8.git

采用cipher.decrypt()得到的ts文件和源文件一樣大,但是不能直接播放。。。so,肯定是哪里出問題了。。。。

突然發(fā)現(xiàn)openssl直接有提供aes-128帶key和iv的解碼cmd工具,用這個試試:

openssl enc -d -aes-128-cbc -iv {iv的十六進(jìn)制字符串} -K {key的十六進(jìn)制字符串} -in {輸入ts文件} -out {輸出ts文件}

openssl enc -d -aes-128-cbc -iv {iv的十六進(jìn)制字符串} -K {key的十六進(jìn)制字符串} -in {輸入ts文件} -out {輸出ts文件}

通過OpenSSL這個直接輸出的ts文件可以播放,淚流滿面。。。。。。

在網(wǎng)上搜了一下這倆的實現(xiàn):
Implement OpenSSL AES Encryption in Python
文章中提到:
The only non-standard (and most difficult) part is the derivation of the IV and the key from the password.

關(guān)于IV和key的不是標(biāo)準(zhǔn)部分…

OpenSSL puts and expects the salt in the first 8 bytes of the encrypted payload.

點開EVP_BytesToKey函數(shù),有詳細(xì)的說明。

難道說openssl需要讀取加密的ts文件頭8字節(jié)作為salt?

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多