Categorygithub.com/ericlagergren/hctr2
repositorypackage
0.0.0-20221115064610-9bd35110e87b
Repository: https://github.com/ericlagergren/hctr2.git
Documentation: pkg.go.dev

# README

hctr2

Go Reference

Length-preserving encryption algorithm https://eprint.iacr.org/2021/1441.pdf

Installation

go get github.com/ericlagergren/hctr2@latest

Performance

The performance of HCTR2 is primarily determined by the XCTR and POLYVAL implementations. This module provides ARMv8 and x86-64 assembly XCTR implementations and uses a hardware-accelerated POLYVAL implementation (see github.com/ericlagergren/polyval).

Results

CPUISAFrequencyCycles per byteAPI
M1ARMv83.2 GHz0.8NewAES
M1ARMv83.2 GHz3.2New
M1x862.5 GHz0.7NewAES
RK3399ARMv81.8 GHz2.7NewAES
RK3399ARMv81.8 GHz6.1New
Skylakex863.9 GHz1.4NewAES
Skylakex863.9 GHz6.1New

For reference, here are the numbers for the reference C implementation.

CPUISAFrequencyCycles per byteAPI
RK3399ARMv81.8 GHz1.8simd
Skylakex863.9 GHz1.2simd

Notes

  • The table is computed for 8192-byte messages.
  • The table is for encryption (decryption is equivalent).
  • The New API uses the stdlib's crypto/aes package.
  • The NewAES API uses this package's assembly XCTR implementation.
  • CPU frequencies are approximate and always assume the maximum available frequency. E.g., benchmarks for big.LITTLE CPUs are assumed to only use the big cores.

Security

Disclosure

This project uses full disclosure. If you find a security bug in an implementation, please e-mail me or create a GitHub issue.

Disclaimer

You should only use cryptography libraries that have been reviewed by cryptographers or cryptography engineers. While I am a cryptography engineer, I'm not your cryptography engineer, and I have not had this project reviewed by any other cryptographers.