Can someone help me how can I add AESX to Crypto++ library?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Can someone help me how can I add AESX to Crypto++ library?

Mehmet TUFEKCI

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 where is my problem?

Thanks in advance..

--
--
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to [hidden email].
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can someone help me how can I add AESX to Crypto++ library?

Jeffrey Walton-3


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 [hidden email].
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can someone help me how can I add AESX to Crypto++ library?

Mehmet TUFEKCI


8 Mayıs 2017 Pazartesi 23:22:38 UTC+3 tarihinde Jeffrey Walton yazdı:


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

Jeff;

I don't use debugger. But it is used like that in DES_XEX. How to initialize m_aes?

Thanks.. 

--
--
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to [hidden email].
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can someone help me how can I add AESX to Crypto++ library?

Mehmet TUFEKCI
In reply to this post by Jeffrey Walton-3


8 Mayıs 2017 Pazartesi 23:22:38 UTC+3 tarihinde Jeffrey Walton yazdı:


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

In des.h it is used for DESX;

class DES_XEX3 : public DES_XEX3_Info, public BlockCipherDocumentation
{
class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<DES_XEX3_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<DES::Encryption> m_des;
};

--
--
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to [hidden email].
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can someone help me how can I add AESX to Crypto++ library?

Jeffrey Walton-3
In reply to this post by Mehmet TUFEKCI
>> 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?
>
> I don't use debugger.

Well, I guess that leaves you a few choices...

First, you can use another tool to help diagnose the problem. Second,
you can load your code up with printf's to isolate your problem.
Third, you can hire someone to do the work for you. Fourth, you can
keep guessing at the problem.

If you want to hire someone, then you might find
https://www.cryptopp.com/wiki/Consulting helpful.

Jeff

--
--
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to [hidden email].
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can someone help me how can I add AESX to Crypto++ library?

Mehmet TUFEKCI


9 Mayıs 2017 Salı 00:53:37 UTC+3 tarihinde Jeffrey Walton yazdı:
>> 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?
>
> I don't use debugger.

Well, I guess that leaves you a few choices...

First, you can use another tool to help diagnose the problem. Second,
you can load your code up with printf's to isolate your problem.
Third, you can hire someone to do the work for you. Fourth, you can
keep guessing at the problem.

If you want to hire someone, then you might find
<a onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.cryptopp.com%2Fwiki%2FConsulting\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFE5j-ksiOG422Ke8eqK-s0f7hv7Q&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.cryptopp.com%2Fwiki%2FConsulting\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFE5j-ksiOG422Ke8eqK-s0f7hv7Q&#39;;return true;" href="https://www.cryptopp.com/wiki/Consulting" target="_blank" rel="nofollow">https://www.cryptopp.com/wiki/Consulting helpful.

Jeff

Jeff;

Which tool do you advise?  I run code without value_ptr<RijndaelEncryption> m_aes; but the results are not true. I just want to run rijndael.cpp's ProcessAndXorBlock() between 2 xorbuf. I think it is an easy problem, isn't it?

Thanks..

--
--
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to [hidden email].
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Loading...