Re: AES, ECB mode decrypt error
Catherine Issabel <[email protected]> Thu, 2 Nov 2023 11:21:26 -0700 (PDT)
| Newsgroups | gmane.comp.encryption.cryptopp |
|---|---|
| Message-ID | <[email protected]> |
------=_Part_292_596259116.1698949286223
Content-Type: multipart/alternative;
boundary="----=_Part_293_708127478.1698949286223"
------=_Part_293_708127478.1698949286223
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
$500 million dollars available only for good and trusted receiver or=20
mandate=20
Kindly contact the sender for more information:+1 (336) 345-9681
On Friday, October 13, 2023 at 4:26:19=E2=80=AFAM UTC+1 Jeffrey Walton wrot=
e:
> On Thu, Oct 12, 2023 at 5:55=E2=80=AFPM Dwight Kulkarni <dwi...@realtime-=
7.com>=20
> wrote:
> >
> > Hello,
> >
> > I had Crypto PP code that was previously working and recently stopped=
=20
> working. We moved to a new version of our BSP.
> >
> > Error is:
> > terminate called after throwing an instance of=20
> 'CryptoPP::AlgorithmParametersBase::ParameterNotUsed'
> > what(): AlgorithmParametersBase: parameter "IV" not used
> >
> > Error is traced to this particular function below.
> >
> > I had it running with the Params in ECB mode still passing in the IV.
> > d.SetKey(key, key.size(),params);
> >
> > Then I commented it out with:
> > d.SetKey(key, key.size());
> >
> > Previously, it wasn't throwing an error even if IV is passed in ECB mod=
e.
> >
> > Also, I don't know why it's falling through the catch statement and=20
> kills my program.
> >
> > should I have a generic catch statement Exception e to prevent this ?
> >
> > std::string decrypt_aes(std::string cipherbytes, SecByteBlock key,=20
> SecByteBlock iv) {
> > try {
> > AlgorithmParameters params =3D MakeParameters(Name::FeedbackSize(),=20
> 1/*8-bits*/)
> > (Name::IV(), ConstByteArrayParameter(iv));
> > //CFB_Mode<AES>::Decryption d;
> > ECB_Mode<AES>::Decryption d;
> > std::string recovered;
> > //d.SetKey(key, key.size(),params);
> > d.SetKey(key, key.size());
> > StringSource s(cipherbytes, true, new StreamTransformationFilter(d, new=
=20
> StringSink(recovered), CryptoPP::BlockPaddingSchemeDef::PKCS_PADDING));
> > return recovered;
> > }
> > catch (CryptoPP::Exception e) {
> > std::cerr << e.what() << std::endl;
> > return "";
> > }
> > }
>
> BlockPaddingSchemeDef::PKCS_PADDING is incorrect for ECB mode. ECB
> mode does not use padding. The programmer is responsible for padding
> to block size.
>
> Jeff
>
--=20
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 e=
mail to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/=
cryptopp-users/d2cee403-c881-4d42-a07b-caeacc5c87ffn%40googlegroups.com.
------=_Part_293_708127478.1698949286223
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<br />$500 million dollars available only for good and trusted receiver or =
mandate <br />Kindly contact the sender for more information:+1 (336) 345-9=
681<br /><div class=3D"gmail_quote"><div dir=3D"auto" class=3D"gmail_attr">=
On Friday, October 13, 2023 at 4:26:19=E2=80=AFAM UTC+1 Jeffrey Walton wrot=
e:<br/></div><blockquote class=3D"gmail_quote" style=3D"margin: 0 0 0 0.8ex=
; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">On Thu, Oc=
t 12, 2023 at 5:55=E2=80=AFPM Dwight Kulkarni <<a href data-email-masked=
rel=3D"nofollow">[email protected]</a>> wrote:
<br>>
<br>> Hello,
<br>>
<br>> I had Crypto PP code that was previously working and recently stop=
ped working. We moved to a new version of our BSP.
<br>>
<br>> Error is:
<br>> terminate called after throwing an instance of 'CryptoPP::Algo=
rithmParametersBase::ParameterNotUsed'
<br>> what(): AlgorithmParametersBase: parameter "IV" not u=
sed
<br>>
<br>> Error is traced to this particular function below.
<br>>
<br>> I had it running with the Params in ECB mode still passing in the =
IV.
<br>> d.SetKey(key, key.size(),params);
<br>>
<br>> Then I commented it out with:
<br>> d.SetKey(key, key.size());
<br>>
<br>> Previously, it wasn't throwing an error even if IV is passed i=
n ECB mode.
<br>>
<br>> Also, I don't know why it's falling through the catch stat=
ement and kills my program.
<br>>
<br>> should I have a generic catch statement Exception e to prevent th=
is ?
<br>>
<br>> std::string decrypt_aes(std::string cipherbytes, SecByteBlock key,=
SecByteBlock iv) {
<br>> try {
<br>> AlgorithmParameters params =3D MakeParameters(Name::FeedbackSize()=
, 1/*8-bits*/)
<br>> (Name::IV(), ConstByteArrayParameter(iv));
<br>> //CFB_Mode<AES>::Decryption d;
<br>> ECB_Mode<AES>::Decryption d;
<br>> std::string recovered;
<br>> //d.SetKey(key, key.size(),params);
<br>> d.SetKey(key, key.size());
<br>> StringSource s(cipherbytes, true, new StreamTransformationFilter(d=
, new StringSink(recovered), CryptoPP::BlockPaddingSchemeDef::PKCS_PADDING)=
);
<br>> return recovered;
<br>> }
<br>> catch (CryptoPP::Exception e) {
<br>> std::cerr << e.what() << std::endl;
<br>> return "";
<br>> }
<br>> }
<br>
<br>BlockPaddingSchemeDef::PKCS_PADDING is incorrect for ECB mode. ECB
<br>mode does not use padding. The programmer is responsible for padding
<br>to block size.
<br>
<br>Jeff
<br></blockquote></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;Crypto++ Users" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:[email protected]">cryp=
[email protected]</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/d/msgid/cryptopp-users/d2cee403-c881-4d42-a07b-caeacc5c87ffn%40googlegro=
ups.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.com/d=
/msgid/cryptopp-users/d2cee403-c881-4d42-a07b-caeacc5c87ffn%40googlegroups.=
com</a>.<br />
------=_Part_293_708127478.1698949286223--
------=_Part_292_596259116.1698949286223--