提交 cc714218 编写于 作者: H h00416433 提交者: public tcshversion

TicketNo:DTS2020052516463

Description:use openssl asm mode
Team:OTHERS
Feature or Bugfix:Bugfix
Binary Source:No
PrivateCode(Yes/No):No

Change-Id: Id449bd200b5e2ef817ac329fc6874190bc245ad4
Reviewed-on: http://mgit-tm.rnd.huawei.com/9083098Reviewed-by: Nhouyuezhou 00386575 <hou@huawei.com>
Tested-by: Npublic jenkins <public_jenkins@notesmail.huawei.com>
Reviewed-by: Nlinyibin 00246405 <linyibin@huawei.com>
上级 766adc8e
...@@ -132,10 +132,6 @@ Makefile ...@@ -132,10 +132,6 @@ Makefile
##### Generic patterns ##### Generic patterns
# Auto generated assembly language source files # Auto generated assembly language source files
*.s
!/crypto/*/asm/*.s
/crypto/arm*.S
/crypto/*/*.S
*.asm *.asm
!/crypto/*/asm/*.asm !/crypto/*/asm/*.asm
......
...@@ -3,6 +3,7 @@ import("//build/harmonyos.gni") ...@@ -3,6 +3,7 @@ import("//build/harmonyos.gni")
config("crypto_config") { config("crypto_config") {
include_dirs = [ include_dirs = [
"./", "./",
"./crypto",
"./crypto/include", "./crypto/include",
"./include", "./include",
"./crypto/modes", "./crypto/modes",
...@@ -10,14 +11,17 @@ config("crypto_config") { ...@@ -10,14 +11,17 @@ config("crypto_config") {
"./crypto/ec/curve448/arch_32", "./crypto/ec/curve448/arch_32",
] ]
cflags = [ cflags = [
"-DNDEBUG",
"-DOPENSSL_PIC",
"-Wall", "-Wall",
"-pthread", "-pthread",
"-fPIC", "-fPIC",
"-Wa,--noexecstack",
"-Qunused-arguments",
"-O3",
"-DOPENSSL_USE_NODELETE", "-DOPENSSL_USE_NODELETE",
"-DOPENSSL_PIC",
"-DOPENSSLDIR=\"\"", "-DOPENSSLDIR=\"\"",
"-DENGINESDIR=\"\"", "-DENGINESDIR=\"\"",
"-DNDEBUG",
"-DOPENSSL_NO_BF", "-DOPENSSL_NO_BF",
"-DOPENSSL_NO_CAMELLIA", "-DOPENSSL_NO_CAMELLIA",
"-DOPENSSL_NO_CAST", "-DOPENSSL_NO_CAST",
...@@ -28,6 +32,38 @@ config("crypto_config") { ...@@ -28,6 +32,38 @@ config("crypto_config") {
"-DOPENSSL_NO_RIPEMD", "-DOPENSSL_NO_RIPEMD",
"-DOPENSSL_NO_RMD160", "-DOPENSSL_NO_RMD160",
] ]
if (target_cpu == "arm") {
cflags += [
"-DOPENSSL_CPUID_OBJ",
"-DOPENSSL_BN_ASM_MONT",
"-DOPENSSL_BN_ASM_GF2m",
"-DSHA1_ASM",
"-DSHA256_ASM",
"-DSHA512_ASM",
"-DKECCAK1600_ASM",
"-DAES_ASM",
"-DBSAES_ASM",
"-DGHASH_ASM",
"-DECP_NISTZ256_ASM",
"-DPOLY1305_ASM",
]
} else if (target_cpu == "arm64") {
cflags += [
"-DOPENSSL_CPUID_OBJ",
"-DOPENSSL_BN_ASM_MONT",
"-DSHA1_ASM",
"-DSHA256_ASM",
"-DSHA512_ASM",
"-DKECCAK1600_ASM",
"-DVPAES_ASM",
"-DECP_NISTZ256_ASM",
"-DPOLY1305_ASM",
]
} else {
cflags += [
"-DOPENSSL_NO_ASM",
]
}
} }
config("crypto_config_public") { config("crypto_config_public") {
...@@ -44,7 +80,6 @@ harmonyos_source_set("crypto_source") { ...@@ -44,7 +80,6 @@ harmonyos_source_set("crypto_source") {
sources = [ sources = [
"crypto/aes/aes_cbc.c", "crypto/aes/aes_cbc.c",
"crypto/aes/aes_cfb.c", "crypto/aes/aes_cfb.c",
"crypto/aes/aes_core.c",
"crypto/aes/aes_ecb.c", "crypto/aes/aes_ecb.c",
"crypto/aes/aes_ige.c", "crypto/aes/aes_ige.c",
"crypto/aes/aes_misc.c", "crypto/aes/aes_misc.c",
...@@ -181,7 +216,6 @@ harmonyos_source_set("crypto_source") { ...@@ -181,7 +216,6 @@ harmonyos_source_set("crypto_source") {
"crypto/bn/bn_x931p.c", "crypto/bn/bn_x931p.c",
"crypto/buffer/buf_err.c", "crypto/buffer/buf_err.c",
"crypto/buffer/buffer.c", "crypto/buffer/buffer.c",
"crypto/chacha/chacha_enc.c",
"crypto/cmac/cm_ameth.c", "crypto/cmac/cm_ameth.c",
"crypto/cmac/cm_pmeth.c", "crypto/cmac/cm_pmeth.c",
"crypto/cmac/cmac.c", "crypto/cmac/cmac.c",
...@@ -415,7 +449,6 @@ harmonyos_source_set("crypto_source") { ...@@ -415,7 +449,6 @@ harmonyos_source_set("crypto_source") {
"crypto/mdc2/mdc2_one.c", "crypto/mdc2/mdc2_one.c",
"crypto/mdc2/mdc2dgst.c", "crypto/mdc2/mdc2dgst.c",
"crypto/mem.c", "crypto/mem.c",
"crypto/mem_clr.c",
"crypto/mem_dbg.c", "crypto/mem_dbg.c",
"crypto/mem_sec.c", "crypto/mem_sec.c",
"crypto/modes/cbc128.c", "crypto/modes/cbc128.c",
...@@ -525,7 +558,6 @@ harmonyos_source_set("crypto_source") { ...@@ -525,7 +558,6 @@ harmonyos_source_set("crypto_source") {
"crypto/seed/seed_cfb.c", "crypto/seed/seed_cfb.c",
"crypto/seed/seed_ecb.c", "crypto/seed/seed_ecb.c",
"crypto/seed/seed_ofb.c", "crypto/seed/seed_ofb.c",
"crypto/sha/keccak1600.c",
"crypto/sha/sha1_one.c", "crypto/sha/sha1_one.c",
"crypto/sha/sha1dgst.c", "crypto/sha/sha1dgst.c",
"crypto/sha/sha256.c", "crypto/sha/sha256.c",
...@@ -647,6 +679,53 @@ harmonyos_source_set("crypto_source") { ...@@ -647,6 +679,53 @@ harmonyos_source_set("crypto_source") {
"crypto/x509v3/v3err.c", "crypto/x509v3/v3err.c",
] ]
if (target_cpu == "arm") {
sources += [
"crypto/armcap.c",
"crypto/ec/ecp_nistz256.c",
"crypto/aes/asm/arm32/aes-armv4.S",
"crypto/aes/asm/arm32/aesv8-armx.S",
"crypto/aes/asm/arm32/bsaes-armv7.S",
"crypto/armv4cpuid.S",
"crypto/bn/armv4-gf2m.S",
"crypto/bn/armv4-mont.S",
"crypto/chacha/chacha-armv4.S",
"crypto/ec/ecp_nistz256-armv4.S",
"crypto/modes/asm/arm32/ghash-armv4.S",
"crypto/modes/asm/arm32/ghashv8-armx.S",
"crypto/poly1305/poly1305-armv4.S",
"crypto/sha/keccak1600-armv4.S",
"crypto/sha/sha1-armv4-large.S",
"crypto/sha/sha256-armv4.S",
"crypto/sha/sha512-armv4.S",
]
} else if (target_cpu == "arm64") {
sources += [
"crypto/aes/aes_core.c",
"crypto/armcap.c",
"crypto/ec/ecp_nistz256.c",
"crypto/aes/asm/arm64/aesv8-armx.S",
"crypto/aes/asm/arm64/vpaes-armv8.S",
"crypto/arm64cpuid.S",
"crypto/bn/armv8-mont.S",
"crypto/chacha/chacha-armv8.S",
"crypto/ec/ecp_nistz256-armv8.S",
"crypto/modes/asm/arm64/ghashv8-armx.S",
"crypto/poly1305/poly1305-armv8.S",
"crypto/sha/keccak1600-armv8.S",
"crypto/sha/sha1-armv8.S",
"crypto/sha/sha256-armv8.S",
"crypto/sha/sha512-armv8.S",
]
} else {
sources += [
"crypto/aes/aes_core.c",
"crypto/chacha/chacha_enc.c",
"crypto/mem_clr.c",
"crypto/sha/keccak1600.c",
]
}
configs = [ configs = [
":crypto_config", ":crypto_config",
":crypto_config_public", ":crypto_config_public",
......
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
* Description: This README describes how to generate the .S files.
* Create: 2020-05-30
*/
these files used in Build.gn, such as:
"crypto/aes/asm/arm32/aes-armv4.S",
"crypto/aes/asm/arm32/aesv8-armx.S",
"crypto/aes/asm/arm32/bsaes-armv7.S",
"crypto/armv4cpuid.S",
"crypto/bn/armv4-gf2m.S",
"crypto/bn/armv4-mont.S",
"crypto/chacha/chacha-armv4.S",
"crypto/ec/ecp_nistz256-armv4.S",
"crypto/modes/asm/arm32/ghash-armv4.S",
"crypto/modes/asm/arm32/ghashv8-armx.S",
"crypto/poly1305/poly1305-armv4.S",
"crypto/sha/keccak1600-armv4.S",
"crypto/sha/sha1-armv4-large.S",
"crypto/sha/sha256-armv4.S",
"crypto/sha/sha512-armv4.S",
"crypto/aes/asm/arm64/aesv8-armx.S",
"crypto/aes/asm/arm64/vpaes-armv8.S",
"crypto/arm64cpuid.S",
"crypto/bn/armv8-mont.S",
"crypto/chacha/chacha-armv8.S",
"crypto/ec/ecp_nistz256-armv8.S",
"crypto/modes/asm/arm64/ghashv8-armx.S",
"crypto/poly1305/poly1305-armv8.S",
"crypto/sha/keccak1600-armv8.S",
"crypto/sha/sha1-armv8.S",
"crypto/sha/sha256-armv8.S",
"crypto/sha/sha512-armv8.S",
are generated by perl executing .pl files. you can also execute the script of create_asm_file.sh to generate it.
\ No newline at end of file
#!/bin/sh
# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
# Description: This script is used to generate .S files.
# Create: 2020-05-30
mkdir crypto/aes/asm/arm32
mkdir crypto/modes/asm/arm32
# for arm32:
perl crypto/aes/asm/aes-armv4.pl void crypto/aes/asm/arm32/aes-armv4.S
perl crypto/aes/asm/aesv8-armx.pl void crypto/aes/asm/arm32/aesv8-armx.S
perl crypto/aes/asm/bsaes-armv7.pl void crypto/aes/asm/arm32/bsaes-armv7.S
perl crypto/armv4cpuid.pl void crypto/armv4cpuid.S
perl crypto/bn/asm/armv4-gf2m.pl void crypto/bn/armv4-gf2m.S
perl crypto/bn/asm/armv4-mont.pl void crypto/bn/armv4-mont.S
perl crypto/chacha/asm/chacha-armv4.pl void crypto/chacha/chacha-armv4.S
perl crypto/ec/asm/ecp_nistz256-armv4.pl void crypto/ec/ecp_nistz256-armv4.S
perl crypto/modes/asm/ghash-armv4.pl void crypto/modes/asm/arm32/ghash-armv4.S
perl crypto/modes/asm/ghashv8-armx.pl void crypto/modes/asm/arm32/ghashv8-armx.S
perl crypto/poly1305/asm/poly1305-armv4.pl void crypto/poly1305/poly1305-armv4.S
perl crypto/sha/asm/keccak1600-armv4.pl void crypto/sha/keccak1600-armv4.S
perl crypto/sha/asm/sha1-armv4-large.pl void crypto/sha/sha1-armv4-large.S
perl crypto/sha/asm/sha256-armv4.pl void crypto/sha/sha256-armv4.S
perl crypto/sha/asm/sha512-armv4.pl void crypto/sha/sha512-armv4.S
mkdir crypto/aes/asm/arm64
mkdir crypto/modes/asm/arm64
# for arm64:
perl crypto/aes/asm/aesv8-armx.pl linux64 crypto/aes/asm/arm64/aesv8-armx.S
perl crypto/aes/asm/vpaes-armv8.pl linux64 crypto/aes/asm/arm64/vpaes-armv8.S
perl crypto/arm64cpuid.pl linux64 crypto/arm64cpuid.S
perl crypto/bn/asm/armv8-mont.pl linux64 crypto/bn/armv8-mont.S
perl crypto/chacha/asm/chacha-armv8.pl linux64 crypto/chacha/chacha-armv8.S
perl crypto/ec/asm/ecp_nistz256-armv8.pl linux64 crypto/ec/ecp_nistz256-armv8.S
perl crypto/modes/asm/ghashv8-armx.pl linux64 crypto/modes/asm/arm64/ghashv8-armx.S
perl crypto/poly1305/asm/poly1305-armv8.pl linux64 crypto/poly1305/poly1305-armv8.S
perl crypto/sha/asm/keccak1600-armv8.pl linux64 crypto/sha/keccak1600-armv8.S
perl crypto/sha/asm/sha1-armv8.pl linux64 crypto/sha/sha1-armv8.S
perl crypto/sha/asm/sha512-armv8.pl linux64 crypto/sha/sha256-armv8.S
perl crypto/sha/asm/sha512-armv8.pl linux64 crypto/sha/sha512-armv8.S
\ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
// Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
//
// Licensed under the OpenSSL license (the "License"). You may not use
// this file except in compliance with the License. You can obtain a copy
// in the file LICENSE in the source distribution or at
// https://www.openssl.org/source/license.html
#include "arm_arch.h"
.text
.arch armv8-a+crypto
.align 5
.globl _armv7_neon_probe
.type _armv7_neon_probe,%function
_armv7_neon_probe:
orr v15.16b, v15.16b, v15.16b
ret
.size _armv7_neon_probe,.-_armv7_neon_probe
.globl _armv7_tick
.type _armv7_tick,%function
_armv7_tick:
#ifdef __APPLE__
mrs x0, CNTPCT_EL0
#else
mrs x0, CNTVCT_EL0
#endif
ret
.size _armv7_tick,.-_armv7_tick
.globl _armv8_aes_probe
.type _armv8_aes_probe,%function
_armv8_aes_probe:
aese v0.16b, v0.16b
ret
.size _armv8_aes_probe,.-_armv8_aes_probe
.globl _armv8_sha1_probe
.type _armv8_sha1_probe,%function
_armv8_sha1_probe:
sha1h s0, s0
ret
.size _armv8_sha1_probe,.-_armv8_sha1_probe
.globl _armv8_sha256_probe
.type _armv8_sha256_probe,%function
_armv8_sha256_probe:
sha256su0 v0.4s, v0.4s
ret
.size _armv8_sha256_probe,.-_armv8_sha256_probe
.globl _armv8_pmull_probe
.type _armv8_pmull_probe,%function
_armv8_pmull_probe:
pmull v0.1q, v0.1d, v0.1d
ret
.size _armv8_pmull_probe,.-_armv8_pmull_probe
.globl _armv8_sha512_probe
.type _armv8_sha512_probe,%function
_armv8_sha512_probe:
.long 0xcec08000 // sha512su0 v0.2d,v0.2d
ret
.size _armv8_sha512_probe,.-_armv8_sha512_probe
.globl OPENSSL_cleanse
.type OPENSSL_cleanse,%function
.align 5
OPENSSL_cleanse:
cbz x1,.Lret // len==0?
cmp x1,#15
b.hi .Lot // len>15
nop
.Little:
strb wzr,[x0],#1 // store byte-by-byte
subs x1,x1,#1
b.ne .Little
.Lret: ret
.align 4
.Lot: tst x0,#7
b.eq .Laligned // inp is aligned
strb wzr,[x0],#1 // store byte-by-byte
sub x1,x1,#1
b .Lot
.align 4
.Laligned:
str xzr,[x0],#8 // store word-by-word
sub x1,x1,#8
tst x1,#-8
b.ne .Laligned // len>=8
cbnz x1,.Little // len!=0?
ret
.size OPENSSL_cleanse,.-OPENSSL_cleanse
.globl CRYPTO_memcmp
.type CRYPTO_memcmp,%function
.align 4
CRYPTO_memcmp:
eor w3,w3,w3
cbz x2,.Lno_data // len==0?
cmp x2,#16
b.ne .Loop_cmp
ldp x8,x9,[x0]
ldp x10,x11,[x1]
eor x8,x8,x10
eor x9,x9,x11
orr x8,x8,x9
mov x0,#1
cmp x8,#0
csel x0,xzr,x0,eq
ret
.align 4
.Loop_cmp:
ldrb w4,[x0],#1
ldrb w5,[x1],#1
eor w4,w4,w5
orr w3,w3,w4
subs x2,x2,#1
b.ne .Loop_cmp
.Lno_data:
neg w0,w3
lsr w0,w0,#31
ret
.size CRYPTO_memcmp,.-CRYPTO_memcmp
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
...@@ -57,9 +57,6 @@ extern "C" { ...@@ -57,9 +57,6 @@ extern "C" {
#ifndef OPENSSL_NO_ASAN #ifndef OPENSSL_NO_ASAN
# define OPENSSL_NO_ASAN # define OPENSSL_NO_ASAN
#endif #endif
#ifndef OPENSSL_NO_ASM
# define OPENSSL_NO_ASM
#endif
#ifndef OPENSSL_NO_CRYPTO_MDEBUG #ifndef OPENSSL_NO_CRYPTO_MDEBUG
# define OPENSSL_NO_CRYPTO_MDEBUG # define OPENSSL_NO_CRYPTO_MDEBUG
#endif #endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册