Re: AES, ECB mode decrypt error
Arik Agazarian <[email protected]> Mon, 16 Oct 2023 14:20:32 +0100
| Newsgroups | gmane.comp.encryption.cryptopp |
|---|---|
| Message-ID | <CAOLESwkdoM5==WadKBwinSmgSP8mLVKWTxA2w36-D5e2qu_vZA@mail.gmail.com> |
--0000000000000f30590607d54628 Content-Type: text/plain; charset="UTF-8" We are looking for Genuine Recipients of Bitcoin Deals: We still have Over $100M Worth Bitcoins now ready to be processed: First Trial :$5m Note: We can start small (Amount: $1,000,000 is the least) Don't message me if you're not ready Ratio is 45/45/10 Bitcoin is clean and spendable 100% ( traceable on blockchain network) Are you interested? Telegram sender: @Arik_loader On Thu, Oct 12, 2023, 10:55 PM Dwight Kulkarni <[email protected]> wrote: > Hello, > > I had Crypto PP code that was previously working and recently stopped > working. We moved to a new version of our BSP. > > Error is: > terminate called after throwing an instance of > '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 mode. > > Also, I don't know why it's falling through the catch statement and kills > my program. > > should I have a generic catch statement Exception e to prevent this ? > > std::string decrypt_aes(std::string cipherbytes, SecByteBlock key, > SecByteBlock iv) { > try { > AlgorithmParameters params = MakeParameters(Name::FeedbackSize(), 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 > StringSink(recovered), CryptoPP::BlockPaddingSchemeDef::PKCS_PADDING)); > return recovered; > } > catch (CryptoPP::Exception e) { > std::cerr << e.what() << std::endl; > return ""; > } > } > > -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/cryptopp-users/c1d3f2e2-46d1-425a-b20a-e189e7b6d41en%40googlegroups.com > <https://groups.google.com/d/msgid/cryptopp-users/c1d3f2e2-46d1-425a-b20a-e189e7b6d41en%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/cryptopp-users/CAOLESwkdoM5%3D%3DWadKBwinSmgSP8mLVKWTxA2w36-D5e2qu_vZA%40mail.gmail.com. --0000000000000f30590607d54628 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"auto"><div dir=3D"auto">We are looking for Genuine Recipients o= f Bitcoin Deals: We still have Over $100M Worth Bitcoins now ready to be pr= ocessed: First Trial :$5m Note: We can start small (Amount: $1,000,000 is t= he least) Don't message me if you're not ready Ratio is 45/45/10 Bi= tcoin is clean and spendable 100% ( traceable on blockchain network) Are yo= u interested? Telegram sender: @Arik_loader</div><div dir=3D"auto"><br></di= v></div><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr= ">On Thu, Oct 12, 2023, 10:55 PM Dwight Kulkarni <<a href=3D"mailto:dwig= [email protected]">[email protected]</a>> wrote:<br></div><blockquot= e class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc sol= id;padding-left:1ex">Hello,<div><br></div><div>I had Crypto PP code that wa= s previously working and recently stopped working. We moved to a new versio= n of our BSP.</div><div><br></div><div>Error is:</div><div>terminate called= after throwing an instance of 'CryptoPP::AlgorithmParametersBase::Para= meterNotUsed'<br>=C2=A0 what(): =C2=A0AlgorithmParametersBase: paramete= r "IV" not used<br></div><div><br></div><div>Error is traced to t= his particular function below.=C2=A0</div><div><br></div><div>I had it runn= ing with the Params in ECB mode still passing in the IV.</div><div><span st= yle=3D"color:rgb(106,153,85);font-family:"Droid Sans Mono","= monospace",monospace">d.SetKey(key, key.size(),params);</span><br></di= v><div><span style=3D"color:rgb(106,153,85);font-family:"Droid Sans Mo= no","monospace",monospace"><br></span></div><div>Then I comm= ented it out with:</div><div><span style=3D"font-family:"Droid Sans Mo= no","monospace",monospace;color:rgb(156,220,254)">d</span><s= pan style=3D"color:rgb(204,204,204);font-family:"Droid Sans Mono"= ,"monospace",monospace">.</span><span style=3D"font-family:"= Droid Sans Mono","monospace",monospace;color:rgb(220,220,170= )">SetKey</span><span style=3D"color:rgb(204,204,204);font-family:"Dro= id Sans Mono","monospace",monospace">(</span><span style=3D"= font-family:"Droid Sans Mono","monospace",monospace;col= or:rgb(156,220,254)">key</span><span style=3D"color:rgb(204,204,204);font-f= amily:"Droid Sans Mono","monospace",monospace">, </span= ><span style=3D"font-family:"Droid Sans Mono","monospace&quo= t;,monospace;color:rgb(156,220,254)">key</span><span style=3D"color:rgb(204= ,204,204);font-family:"Droid Sans Mono","monospace",mon= ospace">.</span><span style=3D"font-family:"Droid Sans Mono",&quo= t;monospace",monospace;color:rgb(220,220,170)">size</span><span style= =3D"color:rgb(204,204,204);font-family:"Droid Sans Mono","mo= nospace",monospace">());</span><br></div><div><br></div><div>Previousl= y, it wasn't throwing an error even if IV is passed in ECB mode.=C2=A0<= /div><div><br></div><div>Also, I don't know why it's falling throug= h the catch statement and kills my program.</div><div><br></div><div>should= I have a generic catch statement Exception e=C2=A0 to prevent this ?</div>= <div><br></div><div style=3D"color:rgb(204,204,204);font-family:"Droid= Sans Mono","monospace",monospace"><span style=3D"color:rgb(= 78,201,176)">std</span>::<span style=3D"color:rgb(78,201,176)">string</span= > <span style=3D"color:rgb(220,220,170)">decrypt_aes</span>(<span style=3D"= color:rgb(78,201,176)">std</span>::<span style=3D"color:rgb(78,201,176)">st= ring</span> <span style=3D"color:rgb(156,220,254)">cipherbytes</span>, <spa= n style=3D"color:rgb(78,201,176)">SecByteBlock</span> <span style=3D"color:= rgb(156,220,254)">key</span>, <span style=3D"color:rgb(78,201,176)">SecByte= Block</span> <span style=3D"color:rgb(156,220,254)">iv</span>) {</div><div = style=3D"color:rgb(204,204,204);font-family:"Droid Sans Mono",&qu= ot;monospace",monospace"> </div><div style=3D"color:rgb(204,204,204= );font-family:"Droid Sans Mono","monospace",monospace">= <span style=3D"color:rgb(197,134,192)">try</span> {</div><div style=3D"= color:rgb(204,204,204);font-family:"Droid Sans Mono","monosp= ace",monospace"> <span style=3D"color:rgb(78,201,176)">Algorith= mParameters</span> <span style=3D"color:rgb(156,220,254)">params</span> <sp= an style=3D"color:rgb(212,212,212)">=3D</span> <span style=3D"color:rgb(220= ,220,170)">MakeParameters</span>(<span style=3D"color:rgb(78,201,176)">Name= </span>::<span style=3D"color:rgb(220,220,170)">FeedbackSize</span>(), <spa= n style=3D"color:rgb(181,206,168)">1</span><span style=3D"color:rgb(106,153= ,85)">/*8-bits*/</span>)</div><div style=3D"color:rgb(204,204,204);font-fam= ily:"Droid Sans Mono","monospace",monospace"> = <span style=3D"color:rgb(220,220,170)">(</span>= <span style=3D"color:rgb(78,201,176)">Name</span>::<span style=3D"color:rgb= (220,220,170)">IV</span>(), <span style=3D"color:rgb(78,201,176)">ConstByte= ArrayParameter</span>(<span style=3D"color:rgb(156,220,254)">iv</span>)<spa= n style=3D"color:rgb(220,220,170)">)</span>;</div><div style=3D"color:rgb(2= 04,204,204);font-family:"Droid Sans Mono","monospace",m= onospace"><span style=3D"color:rgb(106,153,85)"> //CFB_Mode<AES&g= t;::Decryption d;</span></div><div style=3D"color:rgb(204,204,204);font-fam= ily:"Droid Sans Mono","monospace",monospace"> <s= pan style=3D"color:rgb(78,201,176)">ECB_Mode</span><<span style=3D"color= :rgb(78,201,176)">AES</span>>::<span style=3D"color:rgb(78,201,176)">Dec= ryption</span> <span style=3D"color:rgb(156,220,254)">d</span>;</div><div s= tyle=3D"color:rgb(204,204,204);font-family:"Droid Sans Mono",&quo= t;monospace",monospace"> <span style=3D"color:rgb(78,201,176)">= std</span>::<span style=3D"color:rgb(78,201,176)">string</span> <span style= =3D"color:rgb(156,220,254)">recovered</span>;</div><div style=3D"color:rgb(= 204,204,204);font-family:"Droid Sans Mono","monospace",= monospace"><span style=3D"color:rgb(106,153,85)"> //d.SetKey(key, ke= y.size(),params);</span></div><div style=3D"color:rgb(204,204,204);font-fam= ily:"Droid Sans Mono","monospace",monospace"> <s= pan style=3D"color:rgb(156,220,254)">d</span>.<span style=3D"color:rgb(220,= 220,170)">SetKey</span>(<span style=3D"color:rgb(156,220,254)">key</span>, = <span style=3D"color:rgb(156,220,254)">key</span>.<span style=3D"color:rgb(= 220,220,170)">size</span>());</div><div style=3D"color:rgb(204,204,204);fon= t-family:"Droid Sans Mono","monospace",monospace"> = <span style=3D"color:rgb(78,201,176)">StringSource</span> <span style=3D= "color:rgb(156,220,254)">s</span>(<span style=3D"color:rgb(156,220,254)">ci= pherbytes</span>, <span style=3D"color:rgb(86,156,214)">true</span>, <span = style=3D"color:rgb(197,134,192)">new</span> <span style=3D"color:rgb(78,201= ,176)">StreamTransformationFilter</span>(<span style=3D"color:rgb(156,220,2= 54)">d</span>, <span style=3D"color:rgb(197,134,192)">new</span> <span styl= e=3D"color:rgb(78,201,176)">StringSink</span>(<span style=3D"color:rgb(156,= 220,254)">recovered</span>), <span style=3D"color:rgb(78,201,176)">CryptoPP= </span>::<span style=3D"color:rgb(78,201,176)">BlockPaddingSchemeDef</span>= ::<span style=3D"color:rgb(79,193,255)">PKCS_PADDING</span>));</div><div st= yle=3D"color:rgb(204,204,204);font-family:"Droid Sans Mono","= ;monospace",monospace"> <span style=3D"color:rgb(197,134,192)">= return</span> <span style=3D"color:rgb(156,220,254)">recovered</span>;</div= ><div style=3D"color:rgb(204,204,204);font-family:"Droid Sans Mono&quo= t;,"monospace",monospace"> }</div><div style=3D"color:rgb(204,= 204,204);font-family:"Droid Sans Mono","monospace",mono= space"> <span style=3D"color:rgb(197,134,192)">catch</span> (<span style= =3D"color:rgb(78,201,176)">CryptoPP</span>::<span style=3D"color:rgb(78,201= ,176)">Exception</span> <span style=3D"color:rgb(156,220,254)">e</span>) {<= /div><div style=3D"color:rgb(204,204,204);font-family:"Droid Sans Mono= ","monospace",monospace"> <span style=3D"color:rgb(78= ,201,176)">std</span>::<span style=3D"color:rgb(156,220,254)">cerr</span> <= span style=3D"color:rgb(220,220,170)"><<</span> <span style=3D"color:= rgb(156,220,254)">e</span>.<span style=3D"color:rgb(220,220,170)">what</spa= n>() <span style=3D"color:rgb(220,220,170)"><<</span> <span style=3D"= color:rgb(78,201,176)">std</span>::<span style=3D"color:rgb(220,220,170)">e= ndl</span>;</div><div style=3D"color:rgb(204,204,204);font-family:"Dro= id Sans Mono","monospace",monospace"> <span style=3D"= color:rgb(197,134,192)">return</span> <span style=3D"color:rgb(206,145,120)= ">""</span>;</div><div style=3D"color:rgb(204,204,204);font-famil= y:"Droid Sans Mono","monospace",monospace"> }</div><= div><span style=3D"color:rgb(204,204,204);font-family:"Droid Sans Mono= ","monospace",monospace">}</span>=C2=A0</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]" targ= et=3D"_blank" rel=3D"noreferrer">[email protected]= m</a>.<br> To view this discussion on the web visit <a href=3D"https://groups.google.c= om/d/msgid/cryptopp-users/c1d3f2e2-46d1-425a-b20a-e189e7b6d41en%40googlegro= ups.com?utm_medium=3Demail&utm_source=3Dfooter" target=3D"_blank" rel= =3D"noreferrer">https://groups.google.com/d/msgid/cryptopp-users/c1d3f2e2-4= 6d1-425a-b20a-e189e7b6d41en%40googlegroups.com</a>.<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/CAOLESwkdoM5%3D%3DWadKBwinSmgSP8mLVKWTxA2w36-D5e2= qu_vZA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">https://gro= ups.google.com/d/msgid/cryptopp-users/CAOLESwkdoM5%3D%3DWadKBwinSmgSP8mLVKW= TxA2w36-D5e2qu_vZA%40mail.gmail.com</a>.<br /> --0000000000000f30590607d54628--