我想解密fmp4段。此段是用HLS Apple (https://developer.apple.com/documentation/http_live_streaming/about_apple_s_http_live_streaming_tools)加密的。
方法是AES-128
IV为1d48fc5de84b5a3e9a428f055e03c2e
我有一个密钥和IV (你可以得到密钥,并在谷歌驱动器https://drive.google.com/drive/folders/1xF-C9EXFvT8qjI--sBB6QMPn8cNW7L-D?usp=sharing段)
要解密,我使用Poco库。
这是我的密码:
Poco::Crypto::Cipher::ByteVec readKey(const std::string& uri) {
Poco::Crypto::Cipher::ByteVec key;
auto stream = Stream::makeStream(uri);
if (stream->open(uri, {})) {
key.resize(KEY_SIZE);
stream->read((char*)&key[0], KEY_SIZE);
}
return key;
}
std::vector<uint8_t> _key = readKey("./unit-tests/resources/cipher-stream/file.key");
std::string ivSrc = "1d48fc5dee84b5a3e9a428f055e03c2e";
Poco::Crypto::Cipher::ByteVec iv {ivSrc.begin(), ivSrc.end()};
Poco::Crypto::CipherKey key("aes-128-cbc", _key, iv);
Poco::Crypto::Cipher::Ptr cipher = Poco::Crypto::CipherFactory::defaultFactory().createCipher(key);
Poco::FileInputStream src("./unit-tests/resources/cipher-stream/fileSequence1.m4s");
Poco::FileOutputStream dst("./unit-tests/resources/cipher-stream/fileSequence1_dec.m4s");
Poco::Crypto::CryptoOutputStream decryptor(dst, cipher->createDecryptor());
Poco::StreamCopier::copyStream(src, decryptor);
// decryptor.close();
src.close();
dst.close();问题描述:解密后的得到了失真的数据。您可以在文件的开头看到这个。请看下面的图片。在图像文件的右侧是扭曲的。您可以在左侧看到的正确数据。

发布于 2021-07-26 15:28:02
您使用了错误的IV;这将导致第一个块(16个字节)被破坏。您的IV 十六进制值为1d48fc5de84b5a3e9a428f055e03c2e,但您将其解释为ASCII。它使用字符串的前16个字节,而忽略其余的字节。
我已经很久没有使用Poco了,我不记得有一个十六进制解析器在手边,但这正是您所需要的。或者直接用十六进制编写IV,而不是作为ASCII字符串。
https://stackoverflow.com/questions/68532250
复制相似问题