Crypto++ AES GCM Access violation reading location at ChannelMessageEnd

Viewed 26

I am currently using CryptoPP Sample code for implementing AES GCM and it gives me Unhandled exception at 0x00007FF9DCF1AC87 (ucrtbased.dll) in sadnibbahours.exe: 0xC0000005: Access violation reading location 0x0000012D00000001 in the delete_scalar.cpp file, the encryption part throws the exception specifically in this part of the code in the ChannelMessageEnd part

 GCM< AES >::Encryption e;
            e.SetKeyWithIV(key, sizeof(key), iv, sizeof(iv));
            // Not required for GCM mode (but required for CCM mode)
            // e.SpecifyDataLengths( adata.size(), pdata.size(), 0 );

            AuthenticatedEncryptionFilter ef(e,
                new StringSink(cipher), false, TAG_SIZE
            ); // AuthenticatedEncryptionFilter

            // AuthenticatedEncryptionFilter::ChannelPut
            //  defines two channels: "" (empty) and "AAD"
            //   channel "" is encrypted and authenticated
            //   channel "AAD" is authenticated
           ef.ChannelPut("AAD", (const byte*)adata.data(), adata.size());
            ef.ChannelMessageEnd("AAD");

            // Authenticated data *must* be pushed before
            //  Confidential/Authenticated data. Otherwise
            //  we must catch the BadState exception
            

          ef.ChannelPut("", (const byte*)pdata.data(), pdata.size());
          ef.ChannelMessageEnd("");

            // Pretty print
            StringSource(cipher, true,
                new HexEncoder(new StringSink(encoded), true, 16, " "));
0 Answers
Related