On Monday, May 8, 2017 at 4:08:07 PM UTC-4, Mehmet TUFEKCI wrote:
>
> Hi everyone!
>
> Can someone help me how can I add AESX to Crypto++ library? I tried to use 
> DES-XEX codes in des.cpp. I added aes.cpp like:
>
> NAMESPACE_BEGIN(CryptoPP)
>
>  
>
> void AES_X::Base::UncheckedSetKey(const byte *key, unsigned int length, 
>
> const NameValuePairs &)
>
> {
>
>    AssertValidKeyLength(length);
>
>  
>
>    if (!m_aes.get())
>
>        m_aes.reset(new RijndaelEncryption);
>
>  
>
>    memcpy(m_x1, key + (IsForwardTransformation() ? 0 : 16), BLOCKSIZE);
>
>    memcpy(m_x3, key + (IsForwardTransformation() ? 16 : 0), BLOCKSIZE);
>
>  } 
>
>  void AES_X::Base::ProcessAndXorBlock(const byte *inBlock, const byte 
>
> *xorBlock, byte *outBlock) const
>
> {
>
>    xorbuf(outBlock, inBlock, m_x1, BLOCKSIZE);
>
>    m_aes->ProcessAndXorBlock(outBlock, xorBlock, outBlock);
>
>    xorbuf(outBlock, m_x3, BLOCKSIZE);
>
> }
>
>  
>
> NAMESPACE_END
>
> And aes.h is like:
>
> NAMESPACE_BEGIN(CryptoPP)
>
>  
>
> struct AES_X_Info : public FixedBlockSize<16>, public FixedKeyLength<16>
>
> {
>
>     CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return 
>
>   "AES_X";}
>
> };
>
>  
>
>  
>
> class AES_X : public AES_X_Info, public BlockCipherDocumentation
>
> {
>
>  
>
>    class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<AES_X_Info>
>
> {
>
>  public:
>
>     void UncheckedSetKey(const byte *userKey, unsigned int length, const 
> NameValuePairs &params);
>
>     void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, 
> byte *outBlock) const;
>
>  
>
> protected:
>
>     FixedSizeSecBlock<byte, BLOCKSIZE> m_x1, m_x3;
>
>     // VS2005 workaround: calling modules compiled with /clr gets 
> unresolved external symbol DES::Base::ProcessAndXorBlock
>
>     // if we use DES::Encryption here directly without value_ptr.
>
>     value_ptr<RijndaelEncryption> m_aes;
>
> };
>
>  
>
>  public:
>
>   typedef BlockCipherFinal<ENCRYPTION, Base> Encryption;
>
>    typedef BlockCipherFinal<DECRYPTION, Base> Decryption;
>
> };
>
>  
>
>  
>
>  typedef AES_X::Encryption AES_X_Encryption;
>
>  typedef AES_X::Decryption AES_X_Decryption;
>
>  
>
>  
>
>  DOCUMENTED_TYPEDEF(Rijndael, AES);
>
>  
>
>  typedef RijndaelEncryption AESEncryption;
>
>  typedef RijndaelDecryption AESDecryption;
>
>  
>
>  NAMESPACE_END
>
> If I put m_aes->ProcessAndXorBlock(outBlock, xorBlock, outBlock); in 
> aes.cpp it gives segmentation fault. Please tell me
>
It looks like your are hijacking the typedef. You probably should not do 
that.

This look suspicious (to me):

    value_ptr<RijndaelEncryption> m_aes;

My guess is the object is not initialized.

What does your debugger tell you? Is m_aes initialized, or is it garbage?

Jeff

-- 
-- 
You received this message because you are subscribed to the "Crypto++ Users" 
Google Group.
To unsubscribe, send an email to cryptopp-users-unsubscr...@googlegroups.com.
More information about Crypto++ and this group is available at 
http://www.cryptopp.com.
--- 
You received this message because you are subscribed to the Google Groups 
"Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cryptopp-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to