Вопрос Как пофиксить CryptoPP::InvalidKeyLength

Начинающий
Статус
Оффлайн
Регистрация
8 Июн 2024
Сообщения
16
Реакции[?]
3
Поинты[?]
3K
Возникло необработанное исключение по адресу 0x00007FFD92FDB699 в res.exe: исключение Microsoft C++: CryptoPP::InvalidKeyLength по адресу памяти 0x000000E876CF74B0.

Код:
__forceinline std::string encrypt(const std::string& str, const std::string& cipher_key, const std::string& iv_key)
{
    std::string str_out;

    CryptoPP::CFB_Mode<CryptoPP::AES>::Encryption encryption((BYTE*)cipher_key.c_str(), cipher_key.length(), (BYTE*)iv_key.c_str());

    CryptoPP::StringSource encryptor(str, true,
        new CryptoPP::StreamTransformationFilter(encryption,
            new CryptoPP::Base64Encoder(
                new CryptoPP::StringSink(str_out),
                false
            )
        )
    );
    return str_out;
}
__forceinline std::string decrypt(const std::string& str, const std::string& cipher_key, const std::string& iv_key)
{
    std::string str_out;

    CryptoPP::CFB_Mode<CryptoPP::AES>::Decryption decryption((BYTE*)cipher_key.c_str(), cipher_key.length(), (BYTE*)iv_key.c_str());

    CryptoPP::StringSource decryptor(str, true,
        new CryptoPP::Base64Decoder(
            new CryptoPP::StreamTransformationFilter(decryption,
                new CryptoPP::StringSink(str_out)
            )
        )
    );
    return str_out;
}
Код:
    std::string tempory_cipher_key;
    std::string tempory_iv_key;
    std::vector<std::string> vector_tempory_key;
    auto unprotect_request = DownloadString((string)("https://") + Global::server.server + (string)("/client/session.php"));
    //std::cout << unprotect_request.c_str() << endl;
    for (std::size_t pos = 0; pos < unprotect_request.size(); pos += 64)
        tempory_cipher_key = vector_tempory_key.emplace_back(unprotect_request.data() + pos, unprotect_request.data() + min(pos + 32, unprotect_request.size()));

    for (std::size_t pos = 0; pos < unprotect_request.size(); pos += 32)
        tempory_iv_key = vector_tempory_key.emplace_back(unprotect_request.data() + pos, unprotect_request.data() + min(pos + 32, unprotect_request.size()));

    std::string protect_request = aes::encrypt(unprotect_request, tempory_cipher_key, tempory_iv_key);
    std::string protect_key = aes::encrypt(Globals::client_side.client_key, tempory_cipher_key, tempory_iv_key);
    std::string protect_version = aes::encrypt(Globals::client_side.version, tempory_cipher_key, tempory_iv_key);
    unprotect_request = aes::encrypt(unprotect_request.c_str(), ("r09y7LrY1C4yqONI641qMQe7GA5mQvdf"), ("H1ggF9foFGLerr8q")); // static keys
    auto accepted_request = DownloadString((string)xorstr_("http://123аап.beget.tech/client/versions_check.php?a=") + unprotect_request + (string)xorstr_("&b=") + protect_request + (string)xorstr_("&c=") + protect_key + (string)xorstr_("&d=") + protect_version + (string)xorstr_("&prod=") + "loader");
 
//    std::string fghddfgh = aes::decrypt(aes::decrypt(accepted_request, tempory_cipher_key, tempory_iv_key), tempory_cipher_key, tempory_iv_key);

    return aes::decrypt(aes::decrypt(accepted_request, tempory_cipher_key, tempory_iv_key), tempory_cipher_key, tempory_iv_key);
Раньше вроде работало, недавно решил скомпилить и вот , в душе не ебу что случилось помогите пж)
 
Последнее редактирование:
Начинающий
Статус
Оффлайн
Регистрация
31 Мар 2024
Сообщения
111
Реакции[?]
23
Поинты[?]
26K
Возникло необработанное исключение по адресу 0x00007FFD92FDB699 в res.exe: исключение Microsoft C++: CryptoPP::InvalidKeyLength по адресу памяти 0x000000E876CF74B0.

Код:
__forceinline std::string encrypt(const std::string& str, const std::string& cipher_key, const std::string& iv_key)
{
    std::string str_out;

    CryptoPP::CFB_Mode<CryptoPP::AES>::Encryption encryption((BYTE*)cipher_key.c_str(), cipher_key.length(), (BYTE*)iv_key.c_str());

    CryptoPP::StringSource encryptor(str, true,
        new CryptoPP::StreamTransformationFilter(encryption,
            new CryptoPP::Base64Encoder(
                new CryptoPP::StringSink(str_out),
                false
            )
        )
    );
    return str_out;
}
__forceinline std::string decrypt(const std::string& str, const std::string& cipher_key, const std::string& iv_key)
{
    std::string str_out;

    CryptoPP::CFB_Mode<CryptoPP::AES>::Decryption decryption((BYTE*)cipher_key.c_str(), cipher_key.length(), (BYTE*)iv_key.c_str());

    CryptoPP::StringSource decryptor(str, true,
        new CryptoPP::Base64Decoder(
            new CryptoPP::StreamTransformationFilter(decryption,
                new CryptoPP::StringSink(str_out)
            )
        )
    );
    return str_out;
}
Код:
    std::string tempory_cipher_key;
    std::string tempory_iv_key;
    std::vector<std::string> vector_tempory_key;
    auto unprotect_request = DownloadString((string)("https://") + Global::server.server + (string)("/client/session.php"));
    //std::cout << unprotect_request.c_str() << endl;
    for (std::size_t pos = 0; pos < unprotect_request.size(); pos += 64)
        tempory_cipher_key = vector_tempory_key.emplace_back(unprotect_request.data() + pos, unprotect_request.data() + min(pos + 32, unprotect_request.size()));

    for (std::size_t pos = 0; pos < unprotect_request.size(); pos += 32)
        tempory_iv_key = vector_tempory_key.emplace_back(unprotect_request.data() + pos, unprotect_request.data() + min(pos + 32, unprotect_request.size()));

    std::string protect_request = aes::encrypt(unprotect_request, tempory_cipher_key, tempory_iv_key);
    std::string protect_key = aes::encrypt(Globals::client_side.client_key, tempory_cipher_key, tempory_iv_key);
    std::string protect_version = aes::encrypt(Globals::client_side.version, tempory_cipher_key, tempory_iv_key);
    unprotect_request = aes::encrypt(unprotect_request.c_str(), ("r09y7LrY1C4yqONI641qMQe7GA5mQvdf"), ("H1ggF9foFGLerr8q")); // static keys
    auto accepted_request = DownloadString((string)xorstr_("http://123аап.beget.tech/client/versions_check.php?a=") + unprotect_request + (string)xorstr_("&b=") + protect_request + (string)xorstr_("&c=") + protect_key + (string)xorstr_("&d=") + protect_version + (string)xorstr_("&prod=") + "loader");

//    std::string fghddfgh = aes::decrypt(aes::decrypt(accepted_request, tempory_cipher_key, tempory_iv_key), tempory_cipher_key, tempory_iv_key);

    return aes::decrypt(aes::decrypt(accepted_request, tempory_cipher_key, tempory_iv_key), tempory_cipher_key, tempory_iv_key);
Раньше вроде работало, недавно решил скомпилить и вот , в душе не ебу что случилось помогите пж)
Надо знать то как работает AES256 шифрование
У тебя ключ должен быть 32 байта размером, а IV - 16 байт
 
Начинающий
Статус
Оффлайн
Регистрация
8 Июн 2024
Сообщения
16
Реакции[?]
3
Поинты[?]
3K
Сверху Снизу