Brauche Hilfe bei Fehlersuche!



  • Hallo zusammen!

    Ich versuche gerade ein simples Programm zu testen, auf dem ich dann weiter aufbauen will später. Leider bekomme ich dieses schon nicht zum laufen (was wohl daran liegt, dass mein letztes C++ Projekt ein paar Jahre zurück liegt). Wo liegt mein Fehler?
    Nutze CryptoPP...

    #include <iostream>
    
    // Crypto++ Includes
    #include <cryptopp/cryptlib.h>
    #include <cryptopp/modes.h>
    #include <cryptopp/filters.h>
    
    using namespace CryptoPP;
    
    int main(int argc, char* argv[]) {
    
        // Key and IV setup
        byte key[ AES::DEFAULT_KEYLENGTH ]; 
        byte iv[ AES::BLOCKSIZE ];
    
        ::memset( key, 0x01, AES::DEFAULT_KEYLENGTH );
        ::memset(  iv, 0x01, AES::BLOCKSIZE );
    
        // Message M
        std::string PlainText = "Hello World";
    
        // Cipher Text Sink
        std::string CipherText;
    
        // Encryptor
        ECB_Mode<AES>::Encryption Encryptor( key, sizeof(key), iv );
    
        // Encryption
        StringSource( PlainText, true,
            new StreamTransformationFilter( Encryptor,
                new StringSink( CipherText )
            )
        );
    
        // Recovered Text Sink
        std::string RecoveredText;
    
        // Decryptor
        ECB_Mode<AES>::Decryption Decryptor( key, sizeof(key), iv );
    
        // Decryption
        StringSource( CipherText, true,
            new StreamTransformationFilter( Decryptor,
                new StringSink( RecoveredText )
            )
        );
    
        std::cout << "Algorithm:" << std::endl;
        std::cout << "  " << Encryptor.AlgorithmName() << std::endl;
        std::cout << "Minimum Key Size:" << std::endl;
        std::cout << "  " << Encryptor.MinKeyLength() << " bytes" << std::endl;
        std::cout << std::endl;
    
        std::cout << "Plain Text (" << PlainText.length() << " bytes)" << std::endl;
        std::cout << "  '" << PlainText << "'" << std::endl;
        std::cout << std::endl;
    
        std::cout << "Recovered Text:" << std::endl;
        std::cout << "  '" << RecoveredText << "'" << std::endl;
        std::cout << std::endl;
    
        return 0;
    }
    

    Beim compilieren kommt folgendes:

    g++ -c -o crypt.o crypt.cpp
    crypt.cpp: In function int main(int, char**)': crypt.cpp:16: error:AES' has not been declared
    crypt.cpp:16: error: DEFAULT_KEYLENGTH' undeclared (first use this function) crypt.cpp:16: error: (Each undeclared identifier is reported only once for each function it appears in.) crypt.cpp:17: error:AES' has not been declared
    crypt.cpp:17: error: BLOCKSIZE' undeclared (first use this function) crypt.cpp:19: error:key' undeclared (first use this function)
    crypt.cpp:19: error: AES' has not been declared crypt.cpp:20: error:iv' undeclared (first use this function)
    crypt.cpp:20: error: AES' has not been declared crypt.cpp:29: error:AES' undeclared (first use this function)
    crypt.cpp:29: error: template argument 1 is invalid
    crypt.cpp:29: error: Encryption' does not name a type crypt.cpp:33: error:Encryptor' undeclared (first use this function)
    crypt.cpp:42: error: template argument 1 is invalid
    crypt.cpp:42: error: Decryption' does not name a type crypt.cpp:46: error:Decryptor' undeclared (first use this function)
    make: *** [crypt.o] Error 1



  • evtl. hilft ein

    #include <cryptopp/aes.h>
    


  • Wie aus den Fehlermeldungen erkennbar ist, sind einige Bezeichner noch undeklariert. Wahrscheinlich hast du vergessen, einen Header einzubinden.

    Wenn du meinst, die Headerdateien sollten stimmen, so schau doch in ihnen nach, ob die entsprechenden Bezeichner auch irgendwo deklariert sind.


Anmelden zum Antworten