I use Rclone, which uses Secretbox to authenticate and encrypt data. Secretbox uses the Poly1305 authentication algorithm and the Xsalsa20 symmetric flow cipher. This whole process takes some time (very short time, because it is a very fast cryptographic algorithms). I wonder how fast the Poly1305 algorithm and the Xsalsa20 cipher are. Simply what is the ratio of these algorithms, for example 1: 8 ... I would like to ask you if you have ever thought about this question and you can answer me in some way or help me in some way.

  • $\begingroup$ Just use source code and put some timing? $\endgroup$
    – kelalaka
    Jun 19 '20 at 13:08
  • $\begingroup$ Rclone is written in Go and I don't know GO, I found its cryptographic function rewritten in C with the Libsodium library implemented on the Windows operating system, but the Libsodium library offers Secretbox implementation as a black box, so it takes input and discards the output and performs authentication data and encryption at the same time and it is not possible to find the mentioned time in the Libsodium library, I added the clock () function to it, but it only measures the total time of encryption and decryption, not the performance of individual algorithms Poly1305 and Xsalsa20. $\endgroup$ Jun 19 '20 at 13:15
  • 1
    $\begingroup$ So bench.cr.yp.to has benchmarks for XSalsa20 claiming 0.7cpb (CPU cycles per byte) on modern Cascade Lake CPUs. However it appears they don't benchmark anything with Poly1305 (under the AEAD ciphers) so it's hard to draw a conclusion from that but a starting point for anybody finding Polyval benchmarks. $\endgroup$
    – SEJPM
    Jun 19 '20 at 13:22
  • $\begingroup$ BearSSL's benchmarks include Poly1305: bearssl.org/speed.html It's on a substantially older CPU, but was about 1.7 cycles/byte if I didn't do my math wrong. The benchmark there for ChaCha20 is about 1/5 as fast as Poly1305, and ChaCha20 tends to be a bit faster than (X)Salsa20, so I'd guess a Cascade Lake or similarly new CPU would put Poly1305 at around .14cpb if things scale linearly. Which they probably don't. But AFAIK Poly1305 is typically very fast since it's quite SIMD friendly. $\endgroup$ Jun 19 '20 at 14:12
  • $\begingroup$ On the other hand, the question "how fast do these two cryptoalgorithms run compared to each other" is quite CPU (and implementation and message size) specific (and even more so for two algorithms as different as Xsalsa20 and Poly1305). I don't see how you can get even a moderately precise answer other than "testing it in your environment" $\endgroup$
    – poncho
    Jun 19 '20 at 14:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.