On Fri, May 12, 2023 at 9:09 AM Dwight Kulkarni <dwi...@realtime-7.com> wrote:
>
> See below benchmark test results:
>
> root@imx8mpevk:~/p2p_sockets# ./cryptest.exe b 2 1.8
>  [...]
> <TR><TD>AES/CTR (128-bit key)<TD>C++<TD>63<TD>27.3<TD>0.886<TD>1595
> <TR><TD>AES/CTR (192-bit key)<TD>C++<TD>55<TD>31.3<TD>0.882<TD>1587
> <TR><TD>AES/CTR (256-bit key)<TD>C++<TD>49<TD>35.2<TD>0.910<TD>1637
> <TR><TD>AES/CBC (128-bit key)<TD>C++<TD>56<TD>30.4<TD>0.732<TD>1317
> <TR><TD>AES/CBC (192-bit key)<TD>C++<TD>50<TD>34.4<TD>0.728<TD>1311
> <TR><TD>AES/CBC (256-bit key)<TD>C++<TD>45<TD>38.3<TD>0.756<TD>1361
> <TR><TD>AES/OFB (128-bit key)<TD>C++<TD>59<TD>29.0<TD>0.933<TD>1679
> <TR><TD>AES/CFB (128-bit key)<TD>C++<TD>63<TD>27.1<TD>1.135<TD>2043
> <TR><TD>AES/ECB (128-bit key)<TD>C++<TD>63<TD>27.4<TD>0.329<TD>592
>  [...]

For completeness, AES/CFB is 27.1 cycles-per-byte (cpb). Cycles per
byte is what I am interested in when comparing benchmarks. The other
number you are probably interested in is 63, which is 63
megabytes-per-second (MB/s).

These numbers are software-only implementations. And the provider is
"C++", which is software only.

Here is what an aarch64 machine looks like, from an early Pine64 board:

<TR><TD>AES/CTR (128-bit key)<TD>ARMv8<TD>428<TD>2.67<TD>1.174<TD>1408
<TR><TD>AES/CTR (192-bit key)<TD>ARMv8<TD>376<TD>3.05<TD>1.190<TD>1428
<TR><TD>AES/CTR (256-bit key)<TD>ARMv8<TD>343<TD>3.33<TD>1.230<TD>1476
<TR><TD>AES/CBC (128-bit key)<TD>ARMv8<TD>280<TD>4.08<TD>0.994<TD>1192
<TR><TD>AES/CBC (192-bit key)<TD>ARMv8<TD>245<TD>4.67<TD>1.007<TD>1208
<TR><TD>AES/CBC (256-bit key)<TD>ARMv8<TD>218<TD>5.26<TD>1.047<TD>1256
<TR><TD>AES/XTS (256-bit key)<TD>ARMv8<TD>225<TD>5.09<TD>1.728<TD>2074
<TR><TD>AES/XTS (384-bit key)<TD>ARMv8<TD>210<TD>5.46<TD>1.765<TD>2117
<TR><TD>AES/XTS (512-bit key)<TD>ARMv8<TD>199<TD>5.76<TD>1.854<TD>2225
<TR><TD>AES/OFB (128-bit key)<TD>ARMv8<TD>226<TD>5.06<TD>1.152<TD>1383
<TR><TD>AES/CFB (128-bit key)<TD>ARMv8<TD>249<TD>4.60<TD>1.414<TD>1697
<TR><TD>AES/ECB (128-bit key)<TD>ARMv8<TD>604<TD>1.90<TD>0.525<TD>630

AES/CFB is 4.6 cpb. The provider is "ARMv8." 249 is 249 MB/s.

Modern aarch64 machines can usually get down to 2.5 cpb or so for CFB
mode. This is from a MacMini M1:

<TR><TD>AES/CTR (128-bit key)<TD>ARMv8<TD>9316<TD>0.33<TD>0.109<TD>349
<TR><TD>AES/CTR (192-bit key)<TD>ARMv8<TD>8194<TD>0.37<TD>0.117<TD>376
<TR><TD>AES/CTR (256-bit key)<TD>ARMv8<TD>7303<TD>0.42<TD>0.129<TD>412
<TR><TD>AES/CBC (128-bit key)<TD>ARMv8<TD>1083<TD>2.82<TD>0.097<TD>310
<TR><TD>AES/CBC (192-bit key)<TD>ARMv8<TD>938<TD>3.25<TD>0.106<TD>339
<TR><TD>AES/CBC (256-bit key)<TD>ARMv8<TD>834<TD>3.66<TD>0.118<TD>379
<TR><TD>AES/XTS (256-bit key)<TD>ARMv8<TD>1807<TD>1.69<TD>0.181<TD>578
<TR><TD>AES/XTS (384-bit key)<TD>ARMv8<TD>1768<TD>1.73<TD>0.203<TD>650
<TR><TD>AES/XTS (512-bit key)<TD>ARMv8<TD>1712<TD>1.78<TD>0.227<TD>726
<TR><TD>AES/OFB (128-bit key)<TD>ARMv8<TD>1133<TD>2.69<TD>0.106<TD>340
<TR><TD>AES/CFB (128-bit key)<TD>ARMv8<TD>1121<TD>2.72<TD>0.117<TD>374
<TR><TD>AES/ECB (128-bit key)<TD>ARMv8<TD>10883<TD>0.28<TD>0.072<TD>232

AES/CFB is running at 2.7 cpb. 1121 is 1.12 GB/s.

There's something unusual about your setup. You will need to determine
why it is not providing ARMv8 acceleration, or why the library is not
picking it up.

Since your benchmarks are missing AES/XTR results, I know you are
using an old version of the library. Maybe you should update to
Crypto++ 8.7 for starters.

Jeff

> On Thursday, May 11, 2023 at 5:30:26 PM UTC-4 Jeffrey Walton wrote:
>>
>> On Thu, May 11, 2023 at 4:24 PM Dwight Kulkarni <dwi...@realtime-7.com> 
>> wrote:
>> >
>> > I created a 5 MB message and encrypted it. The message takes 3 seconds to 
>> > encrypt. I needed something around 200 ms, even if the encryption is 
>> > weaker.
>> >
>> > My code is below, should I be setting any flags when compiling the library 
>> > to make it fast ?
>> >
>> > Got message str at: 05/11/2023 20:21:31.346
>> > in encrypt aes
>> > Encrypted at: 05/11/2023 20:21:33.027
>> >
>> > message_bytes = encrypt_aes(message_bytes, key, iv);
>> > cout << " Encrypted at: " << get_curr_datetime_str() << endl;
>> >
>> >
>> > std::string encrypt_aes(std::string message, SecByteBlock key, 
>> > SecByteBlock iv) {
>> > try {
>> > cout <<" in encrypt aes " <<endl;
>> > AlgorithmParameters params = MakeParameters(Name::FeedbackSize(), 
>> > 1/*8-bits*/)
>> > (Name::IV(), ConstByteArrayParameter(iv));
>> > CFB_Mode<AES>::Encryption e;
>> > std::string cipher;
>> > e.SetKey(key, key.size(), params);
>> > StringSource ss(message, true, new StreamTransformationFilter(e, new 
>> > StringSink(cipher)));
>> > cout << " returning cipher " << endl;
>> > return cipher;
>> > }
>> > catch (CryptoPP::Exception e) {
>> > std::cerr << e.what() << std::endl;
>> > return "";
>> > }
>> > }
>>
>> You should probably avoid multiple resizes on cipher object. Add something 
>> like:
>>
>> std::string cipher;
>> cipher.reserve(message.size()+16);
>>
>> Otherwise, please run the benchmarks and report back:
>>
>> cryptest.exe b2 3 <cpufreq in GHz>
>>
>> Also see https://cryptopp.com/wiki/Benchmarks .

-- 
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 cryptopp-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/cryptopp-users/CAH8yC8nfFfA%3DuHj_4yTeLBfiLmCzEQQi369dy4ofOqgOTciwKQ%40mail.gmail.com.

Reply via email to