[openssl/openssl] 490878: SM4 optimization for ARM by ASIMD

Tomas Mraz noreply at reply.github.openssl.org
Tue Apr 12 08:38:04 UTC 2022


  Branch: refs/heads/master
  Home:   https://github.openssl.org/openssl/openssl
  Commit: 4908787f21f4f5fa24b721ed3ebbc4d3e93ef70c
      https://github.openssl.org/openssl/openssl/commit/4908787f21f4f5fa24b721ed3ebbc4d3e93ef70c
  Author: Daniel Hu <Daniel.Hu at arm.com>
  Date:   2022-04-12 (Tue, 12 Apr 2022)

  Changed paths:
    M crypto/evp/e_sm4.c
    A crypto/sm4/asm/vpsm4-armv8.pl
    M crypto/sm4/build.info
    M include/crypto/sm4_platform.h
    M providers/implementations/ciphers/cipher_sm4_gcm_hw.c
    M providers/implementations/ciphers/cipher_sm4_hw.c

  Log Message:
  -----------
  SM4 optimization for ARM by ASIMD

This patch optimizes SM4 for ARM processor using ASIMD instruction

It will improve performance if both of following conditions are met:
1) Input data equal to or more than 4 blocks
2) Cipher mode allows parallelism, including ECB,CTR,GCM or CBC decryption

This patch implements SM4 SBOX lookup in vector registers, with the
benefit of constant processing time over existing C implementation.

It is only enabled for micro-architecture N1/V1. In the ideal scenario,
performance can reach up to 2.7X

When either of above two conditions is not met, e.g. single block input
or CFB/OFB mode, CBC encryption, performance could drop about 50%.

The assembly code has been reviewed internally by ARM engineer
Fangming.Fang at arm.com

Signed-off-by: Daniel Hu <Daniel.Hu at arm.com>

Reviewed-by: Paul Dale <pauli at openssl.org>
Reviewed-by: Tomas Mraz <tomas at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17951)




More information about the openssl-commits mailing list