• Tianjia Zhang's avatar
    crypto: x86/sm4 - add AES-NI/AVX2/x86_64 implementation · 5b2efa2b
    Tianjia Zhang authored
    Like the implementation of AESNI/AVX, this patch adds an accelerated
    implementation of AESNI/AVX2. In terms of code implementation, by
    reusing AESNI/AVX mode-related codes, the amount of code is greatly
    reduced. From the benchmark data, it can be seen that when the block
    size is 1024, compared to AVX acceleration, the performance achieved
    by AVX2 has increased by about 70%, it is also 7.7 times of the pure
    software implementation of sm4-generic.
    
    The main algorithm implementation comes from SM4 AES-NI work by
    libgcrypt and Markku-Juhani O. Saarinen at:
    https://github.com/mjosaarinen/sm4ni
    
    This optimization supports the four modes of SM4, ECB, CBC, CFB,
    and CTR. Since CBC and CFB do not support multiple block parallel
    encryption, the optimization effect is not obvious.
    
    Benchmark on Intel i5-6200U 2.30GHz, performance data of three
    implementation methods, pure software sm4-generic, aesni/avx
    acceleration, and aesni/avx2 acceleration, the data comes f...
    5b2efa2b
sm4_aesni_avx2_glue.c 4.6 KB