|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
AES/CTR IV custom incrementHello, I am trying to implement AES in CTR mode but with the custom IV increment. CryptoPP implementation increments IV over the whole vector but I would like to have increment only over the lowest 4 bytes (with modulo). E.g. 00 .... AB FF FF FF FE -> 00 .... AB FF FF FF FF -> 00 .... AB 00 00 00 00 Is there any easy way how to do it? Only solution which I currently found is to increment IV by myself after each block and then call Resynchronize and then encrypt another block. Thank you for your help, Jan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the "Crypto++ Users" Google Group. To unsubscribe, send an email to cryptopp-users-unsubscribe@.... More information about Crypto++ and this group is available at http://www.cryptopp.com. -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: AES/CTR IV custom incrementHi, take a look at GCM_Base::GCTR in gcm.h. It does what you want, but is a protected member of GCM_Base, so just copy its code. -------------------------------------------------- From: "Jan" <honza.smrcek@...> Sent: Tuesday, June 16, 2009 2:40 AM To: "Crypto++ Users" <cryptopp-users@...> Subject: AES/CTR IV custom increment > > Hello, > > I am trying to implement AES in CTR mode but with the custom IV > increment. CryptoPP implementation increments IV over the whole vector > but I would like to have increment only over the lowest 4 bytes (with > modulo). > > E.g. 00 .... AB FF FF FF FE -> 00 .... AB FF FF FF FF -> 00 .... AB 00 > 00 00 00 > > Is there any easy way how to do it? Only solution which I currently > found is to increment IV by myself after each block and then call > Resynchronize and then encrypt another block. > > Thank you for your help, > Jan > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the "Crypto++ Users" Google Group. To unsubscribe, send an email to cryptopp-users-unsubscribe@.... More information about Crypto++ and this group is available at http://www.cryptopp.com. -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: AES/CTR IV custom incrementHi, thank you for pointing me. I have tried it to implement it by a new template and new class (inspired by modes.h): class CTR_TPM_ModePolicy : public CTR_ModePolicy { protected: virtual void IncrementCounterBy256() { IncrementCounterByOne (m_counterArray, 3); } }; CRYPTOPP_DLL_TEMPLATE_CLASS AdditiveCipherTemplate<AbstractPolicyHolder<AdditiveCipherAbstractPolicy, CTR_TPM_ModePolicy> >; template <class CIPHER> struct CTR_TPM_Mode : public CipherModeDocumentation { typedef CipherModeFinalTemplate_CipherHolder<CPP_TYPENAME CIPHER::Encryption, ConcretePolicyHolder<Empty, AdditiveCipherTemplate<AbstractPolicyHolder<AdditiveCipherAbstractPolicy, CTR_TPM_ModePolicy> > > > Encryption; typedef Encryption Decryption; }; and then I tried to create proper variable: CTR_TPM_Mode<AES>::Encryption aes(key.data, key.size, iv.data, iv.size); Unfortunately linker (VC++ 8.0 Express) returned few errors: "public: virtual void __thiscall CryptoPP::AdditiveCipherTemplate<class CryptoPP::AbstractPolicyHolder<struct CryptoPP::AdditiveCipherAbstractPolicy,class CryptoPP::CTR_TPM_ModePolicy> >::Resynchronize(unsigned char const *,int)" "protected: virtual void __thiscall CryptoPP::AdditiveCipherTemplate<class CryptoPP::AbstractPolicyHolder<struct CryptoPP::AdditiveCipherAbstractPolicy,class CryptoPP::CTR_TPM_ModePolicy> >::UncheckedSetKey(unsigned char const *,unsigned int,class CryptoPP::NameValuePairs const &)" "public: virtual void __thiscall CryptoPP::AdditiveCipherTemplate<class CryptoPP::AbstractPolicyHolder<struct CryptoPP::AdditiveCipherAbstractPolicy,class CryptoPP::CTR_TPM_ModePolicy> >::ProcessData(unsigned char *,unsigned char const *,unsigned int)" "public: virtual void __thiscall CryptoPP::AdditiveCipherTemplate<class CryptoPP::AbstractPolicyHolder<struct CryptoPP::AdditiveCipherAbstractPolicy,class CryptoPP::CTR_TPM_ModePolicy> >::Seek(unsigned __int64)" "public: virtual void __thiscall CryptoPP::AdditiveCipherTemplate<class CryptoPP::AbstractPolicyHolder<struct CryptoPP::AdditiveCipherAbstractPolicy,class CryptoPP::CTR_TPM_ModePolicy> >::GenerateBlock(unsigned char *,unsigned int)" Do you know what could be origin of them? Best regards, Jan On Jun 16, 7:52 pm, "Wei Dai" <wei...@...> wrote: > Hi, take a look at GCM_Base::GCTR in gcm.h. It does what you want, but is a > protected member of GCM_Base, so just copy its code. > > -------------------------------------------------- > From: "Jan" <honza.smr...@...> > Sent: Tuesday, June 16, 2009 2:40 AM > To: "Crypto++ Users" <cryptopp-users@...> > Subject: AES/CTR IV custom increment > > > > > Hello, > > > I am trying to implement AES in CTR mode but with the custom IV > > increment. CryptoPP implementation increments IV over the whole vector > > but I would like to have increment only over the lowest 4 bytes (with > > modulo). > > > E.g. 00 .... AB FF FF FF FE -> 00 .... AB FF FF FF FF -> 00 .... AB 00 > > 00 00 00 > > > Is there any easy way how to do it? Only solution which I currently > > found is to increment IV by myself after each block and then call > > Resynchronize and then encrypt another block. > > > Thank you for your help, > > Jan You received this message because you are subscribed to the "Crypto++ Users" Google Group. To unsubscribe, send an email to cryptopp-users-unsubscribe@.... More information about Crypto++ and this group is available at http://www.cryptopp.com. -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: AES/CTR IV custom incrementHi Jan, > Do you know what could be origin of them? Verify VC++ 8.0 Express *has not* changed the settings of static linking to dynamic linking. I seem to remember something similar in the academic versions of the compiler. In these versions, only dynamic linking to libraries (any library, not just Crypto++) was supported. Jeff On 6/18/09, Jan <honza.smrcek@...> wrote: > > Hi, > > thank you for pointing me. > > I have tried it to implement it by a new template and new class > (inspired by modes.h): > > class CTR_TPM_ModePolicy : public CTR_ModePolicy > { > protected: > virtual void IncrementCounterBy256() { IncrementCounterByOne > (m_counterArray, 3); } > }; > > CRYPTOPP_DLL_TEMPLATE_CLASS > AdditiveCipherTemplate<AbstractPolicyHolder<AdditiveCipherAbstractPolicy, > CTR_TPM_ModePolicy> >; > > template <class CIPHER> > struct CTR_TPM_Mode : public CipherModeDocumentation > { > typedef CipherModeFinalTemplate_CipherHolder<CPP_TYPENAME > CIPHER::Encryption, ConcretePolicyHolder<Empty, > AdditiveCipherTemplate<AbstractPolicyHolder<AdditiveCipherAbstractPolicy, > CTR_TPM_ModePolicy> > > > Encryption; > typedef Encryption Decryption; > }; > > and then I tried to create proper variable: > > CTR_TPM_Mode<AES>::Encryption aes(key.data, key.size, iv.data, > iv.size); > > Unfortunately linker (VC++ 8.0 Express) returned few errors: > > "public: virtual void __thiscall > CryptoPP::AdditiveCipherTemplate<class > CryptoPP::AbstractPolicyHolder<struct > CryptoPP::AdditiveCipherAbstractPolicy,class > CryptoPP::CTR_TPM_ModePolicy> >::Resynchronize(unsigned char const > *,int)" > "protected: virtual void __thiscall > CryptoPP::AdditiveCipherTemplate<class > CryptoPP::AbstractPolicyHolder<struct > CryptoPP::AdditiveCipherAbstractPolicy,class > CryptoPP::CTR_TPM_ModePolicy> >::UncheckedSetKey(unsigned char const > *,unsigned int,class CryptoPP::NameValuePairs const &)" > "public: virtual void __thiscall > CryptoPP::AdditiveCipherTemplate<class > CryptoPP::AbstractPolicyHolder<struct > CryptoPP::AdditiveCipherAbstractPolicy,class > CryptoPP::CTR_TPM_ModePolicy> >::ProcessData(unsigned char *,unsigned > char const *,unsigned int)" > "public: virtual void __thiscall > CryptoPP::AdditiveCipherTemplate<class > CryptoPP::AbstractPolicyHolder<struct > CryptoPP::AdditiveCipherAbstractPolicy,class > CryptoPP::CTR_TPM_ModePolicy> >::Seek(unsigned __int64)" > "public: virtual void __thiscall > CryptoPP::AdditiveCipherTemplate<class > CryptoPP::AbstractPolicyHolder<struct > CryptoPP::AdditiveCipherAbstractPolicy,class > CryptoPP::CTR_TPM_ModePolicy> >::GenerateBlock(unsigned char > *,unsigned int)" > > Do you know what could be origin of them? > > Best regards, > Jan > > On Jun 16, 7:52 pm, "Wei Dai" <wei...@...> wrote: > > Hi, take a look at GCM_Base::GCTR in gcm.h. It does what you want, but is a > > protected member of GCM_Base, so just copy its code. > > > [SNIP] --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the "Crypto++ Users" Google Group. To unsubscribe, send an email to cryptopp-users-unsubscribe@.... More information about Crypto++ and this group is available at http://www.cryptopp.com. -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: AES/CTR IV custom incrementHi Jeff, I have checked it and it has static linking. I have solution with 5 projects. 4 of them generates dll files and one of them is cryptlib (from CryptoPP solution) that has static linking and it is linked to the one of the dll. Without my new classes it worked fine but with them I get these linker errors. Maybe it is somehow related to the templates, but I don't know how to solve it. Jan On Jun 18, 7:26 pm, Jeffrey Walton <noloa...@...> wrote: > Hi Jan, > > > Do you know what could be origin of them? > > Verify VC++ 8.0 Express *has not* changed the settings of static > linking to dynamic linking. I seem to remember something similar in > the academic versions of the compiler. In these versions, only dynamic > linking to libraries (any library, not just Crypto++) was supported. > > Jeff > > On 6/18/09, Jan <honza.smr...@...> wrote: > > > > > Hi, > > > thank you for pointing me. > > > I have tried it to implement it by a new template and new class > > (inspired by modes.h): > > > class CTR_TPM_ModePolicy : public CTR_ModePolicy > > { > > protected: > > virtual void IncrementCounterBy256() { IncrementCounterByOne > > (m_counterArray, 3); } > > }; > > > CRYPTOPP_DLL_TEMPLATE_CLASS > > AdditiveCipherTemplate<AbstractPolicyHolder<AdditiveCipherAbstractPolicy, > > CTR_TPM_ModePolicy> >; > > > template <class CIPHER> > > struct CTR_TPM_Mode : public CipherModeDocumentation > > { > > typedef CipherModeFinalTemplate_CipherHolder<CPP_TYPENAME > > CIPHER::Encryption, ConcretePolicyHolder<Empty, > > AdditiveCipherTemplate<AbstractPolicyHolder<AdditiveCipherAbstractPolicy, > > CTR_TPM_ModePolicy> > > > Encryption; > > typedef Encryption Decryption; > > }; > > > and then I tried to create proper variable: > > > CTR_TPM_Mode<AES>::Encryption aes(key.data, key.size, iv.data, > > iv.size); > > > Unfortunately linker (VC++ 8.0 Express) returned few errors: > > > "public: virtual void __thiscall > > CryptoPP::AdditiveCipherTemplate<class > > CryptoPP::AbstractPolicyHolder<struct > > CryptoPP::AdditiveCipherAbstractPolicy,class > > CryptoPP::CTR_TPM_ModePolicy> >::Resynchronize(unsigned char const > > *,int)" > > "protected: virtual void __thiscall > > CryptoPP::AdditiveCipherTemplate<class > > CryptoPP::AbstractPolicyHolder<struct > > CryptoPP::AdditiveCipherAbstractPolicy,class > > CryptoPP::CTR_TPM_ModePolicy> >::UncheckedSetKey(unsigned char const > > *,unsigned int,class CryptoPP::NameValuePairs const &)" > > "public: virtual void __thiscall > > CryptoPP::AdditiveCipherTemplate<class > > CryptoPP::AbstractPolicyHolder<struct > > CryptoPP::AdditiveCipherAbstractPolicy,class > > CryptoPP::CTR_TPM_ModePolicy> >::ProcessData(unsigned char *,unsigned > > char const *,unsigned int)" > > "public: virtual void __thiscall > > CryptoPP::AdditiveCipherTemplate<class > > CryptoPP::AbstractPolicyHolder<struct > > CryptoPP::AdditiveCipherAbstractPolicy,class > > CryptoPP::CTR_TPM_ModePolicy> >::Seek(unsigned __int64)" > > "public: virtual void __thiscall > > CryptoPP::AdditiveCipherTemplate<class > > CryptoPP::AbstractPolicyHolder<struct > > CryptoPP::AdditiveCipherAbstractPolicy,class > > CryptoPP::CTR_TPM_ModePolicy> >::GenerateBlock(unsigned char > > *,unsigned int)" > > > Do you know what could be origin of them? > > > Best regards, > > Jan > > > On Jun 16, 7:52 pm, "Wei Dai" <wei...@...> wrote: > > > Hi, take a look at GCM_Base::GCTR in gcm.h. It does what you want, but is a > > > protected member of GCM_Base, so just copy its code. > > > [SNIP] You received this message because you are subscribed to the "Crypto++ Users" Google Group. To unsubscribe, send an email to cryptopp-users-unsubscribe@.... More information about Crypto++ and this group is available at http://www.cryptopp.com. -~----------~----~----~----~------~----~------~--~--- |
| Free embeddable forum powered by Nabble | Forum Help |