selecting blockcipher+mode in an easier way.

Johannes Winkler <[email protected]> Thu, 4 Jan 2024 08:19:17 -0800 (PST)
Newsgroups gmane.comp.encryption.cryptopp
Message-ID <[email protected]>
------=_Part_9338_456397803.1704385157627
Content-Type: multipart/alternative; 
	boundary="----=_Part_9339_1996009417.1704385157627"

------=_Part_9339_1996009417.1704385157627
Content-Type: text/plain; charset="UTF-8"

Hello,

I am working on a GUI programme for crypto++. When selecting block ciphers 
dynamically (from GUI), there is a problem to choose the cipher dynamically 
in code.

Here is an example:
let's do AES-CFB-Encryption
CryptoPP::CFB_Mode<CryptoPP::AES>::Encryption obj;

However, if I want to switch to Twofish-OFB-Decryption
CryptoPP::OFB_Mode<CryptoPP::Twofish>::Decryption obj;
I have to change 3 spots in this line. Unfortunately, I cannot put 
CryptoPP::AES in a variable. Is there a possibility to choose the algorithm 
like
CryptoPP::A<B>::C obj; with A=CBC_Mode, B=AES, C=Decryption
Or a string-based approach like Cipher("AES-CBC-Decryption")

Currently, I have a if-else tree with 6 algorithms, 5 modes, 
Encrypt/Decrypt, therefore, 6x5x2=60 branches, which is annoying. Is there 
a better solution?

PS.: I posted the same issue on stack overflow 
https://stackoverflow.com/questions/77758291/crypto-variable-dependend-blockcipher-algorithm-and-mode

greetings from Austria 

-- 
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/ae7fcc45-1e8b-46e7-8f58-4317b4c68795n%40googlegroups.com.

------=_Part_9339_1996009417.1704385157627
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hello,<div><br /></div><div>I am working on a GUI programme for crypto++. W=
hen selecting block ciphers dynamically (from GUI), there is a problem to c=
hoose the cipher dynamically in code.</div><div><br /></div><div>Here is an=
 example:</div><div>let's do AES-CFB-Encryption</div><div><span style=3D"ca=
ret-color: rgb(12, 13, 14); color: rgb(12, 13, 14); font-family: ui-monospa=
ce, &quot;Cascadia Mono&quot;, &quot;Segoe UI Mono&quot;, &quot;Liberation =
Mono&quot;, Menlo, Monaco, Consolas, monospace; font-size: 13px; background=
-color: rgb(227, 230, 232);">CryptoPP::CFB_Mode&lt;CryptoPP::AES&gt;::Encry=
ption obj;</span><br /></div><div><div><br /></div><div>However, if I want =
to switch to Twofish-OFB-Decryption</div><div><span style=3D"caret-color: r=
gb(12, 13, 14); color: rgb(12, 13, 14); font-family: ui-monospace, &quot;Ca=
scadia Mono&quot;, &quot;Segoe UI Mono&quot;, &quot;Liberation Mono&quot;, =
Menlo, Monaco, Consolas, monospace; font-size: 13px; background-color: rgb(=
227, 230, 232);">CryptoPP::OFB_Mode&lt;CryptoPP::Twofish&gt;::Decryption ob=
j;</span><br /></div><div></div></div><div>I have to change 3 spots in this=
 line. Unfortunately, I cannot put=C2=A0<span style=3D"caret-color: rgb(12,=
 13, 14); color: rgb(12, 13, 14); font-family: ui-monospace, &quot;Cascadia=
 Mono&quot;, &quot;Segoe UI Mono&quot;, &quot;Liberation Mono&quot;, Menlo,=
 Monaco, Consolas, monospace; font-size: 13px; background-color: rgb(227, 2=
30, 232);">CryptoPP::AES</span>=C2=A0in a variable. Is there a possibility =
to choose the algorithm like</div><div><div><span style=3D"caret-color: rgb=
(12, 13, 14); color: rgb(12, 13, 14); font-family: ui-monospace, &quot;Casc=
adia Mono&quot;, &quot;Segoe UI Mono&quot;, &quot;Liberation Mono&quot;, Me=
nlo, Monaco, Consolas, monospace; font-size: 13px; background-color: rgb(22=
7, 230, 232);">CryptoPP::A&lt;B&gt;::C obj;</span>=C2=A0with A=3DCBC_Mode, =
B=3DAES, C=3DDecryption<br /></div><div>Or a string-based approach like=C2=
=A0<span style=3D"caret-color: rgb(12, 13, 14); color: rgb(12, 13, 14); fon=
t-family: ui-monospace, &quot;Cascadia Mono&quot;, &quot;Segoe UI Mono&quot=
;, &quot;Liberation Mono&quot;, Menlo, Monaco, Consolas, monospace; font-si=
ze: 13px; background-color: rgb(227, 230, 232);">Cipher("AES-CBC-Decryption=
")</span></div><br /></div><div>Currently, I have a if-else tree with 6 alg=
orithms, 5 modes, Encrypt/Decrypt, therefore, 6x5x2=3D60 branches, which is=
 annoying. Is there a better solution?</div><div><br /></div><div>PS.: I po=
sted the same issue on stack overflow https://stackoverflow.com/questions/7=
7758291/crypto-variable-dependend-blockcipher-algorithm-and-mode</div><div>=
<br /></div><div>greetings from Austria=C2=A0</div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;Crypto++ Users&quot; 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/ae7fcc45-1e8b-46e7-8f58-4317b4c68795n%40googlegro=
ups.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.com/d=
/msgid/cryptopp-users/ae7fcc45-1e8b-46e7-8f58-4317b4c68795n%40googlegroups.=
com</a>.<br />

------=_Part_9339_1996009417.1704385157627--

------=_Part_9338_456397803.1704385157627--