NetBSD Problem Report #61073
From zakinko@snowrabbit.org Wed Nov 25 05:55:00 2026
Return-Path: <zakinko@snowrabbit.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature RSA-PSS (2048 bits)
client-signature RSA-PSS (2048 bits))
(Client CN "mail.netbsd.org", Issuer "YR1" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 3A9631A923B
for <gnats-bugs@gnats.NetBSD.org>; Wed, 25 Nov 2026 05:55:00 +0000 (UTC)
Message-Id: <20261125055456.D83C7C9300@bambi.snowrabbit.org>
Date: Wed, 25 Nov 2026 14:54:56 +0900 (JST)
From: Showta Ishizaki <zakinko@snowrabbit.org>
To: gnats-bugs@NetBSD.org
Cc: Showta Ishizaki <zakinko@snowrabbit.org>
Subject: libcrypto does not use the Poly1305 assembler, nor some of the aarch64 and riscv64 one
X-From4GNATS: "Showta Ishizaki via gnats" <gnats-admin@NetBSD.org>
>Number: 61073
>Category: lib
>Synopsis: libcrypto does not use the Poly1305 assembler, nor some of the aarch64 and riscv64 one
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: lib-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Nov 25 06:00:00 +0000 2026
>Last-Modified: Wed Nov 25 19:55:02 +0000 2026
>Originator: Showta Ishizaki
>Release: NetBSD 11.1
>Organization:
>Environment:
NetBSD techne.fml.org 11.1 NetBSD 11.1 (GENERIC) #0: Mon Nov 2 16:34:32 UTC 2026 mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64
>Description:
Comparing the openssl in pkgsrc with the one in base on 11.1/amd64,
chacha20-poly1305 in base is well under half the speed, while chacha20
and aes-gcm are about the same.
The arch poly1305.inc files add -DPOLY1305_ASM to POLY1305_CPPFLAGS, but
poly1305.inc reads POLY1305CPPFLAGS. The assembler is linked in and
never called. lib/59329 has POLY1305_ASM in its list of missing flags.
Going through the other arch files against what Configure picks for
3.5.7 turned up some more on aarch64 and riscv64.
On aarch64 "make regen" sends the output of sha512-armv8.pl to
/dev/stdout. That script chooses SHA-256 or SHA-512 by the name of its
output, so sha512-armv8.S has the SHA-256 code in it, and SHA512_ASM was
removed in October 2024 for want of the SHA-512 one. regen also passes
over md5-aarch64.pl, as it only looks for *arm*. BSAES_ASM,
OPENSSL_SM3_ASM and ECP_SM2P256_ASM are not defined although the
assembler is built, and the C half of the SM2 code is missing.
On riscv64 sm3-riscv64-zvksh.S is built, but not sm3_riscv.c, which
calls it, nor OPENSSL_SM3_ASM.
>How-To-Repeat:
On 11.1/amd64, base is 3.5.7 and pkgsrc 4.1.0:
$ /usr/bin/openssl speed -bytes 16384 -evp chacha20-poly1305
ChaCha20-Poly1305 726829.08k
$ /usr/pkg/bin/openssl speed -bytes 16384 -evp chacha20-poly1305
ChaCha20-Poly1305 2063429.17k
$ /usr/bin/openssl speed -bytes 16384 -evp chacha20
ChaCha20 3696410.03k
$ /usr/pkg/bin/openssl speed -bytes 16384 -evp chacha20
ChaCha20 3792185.30k
$ /usr/bin/openssl speed -bytes 16384 -evp aes-128-gcm
AES-128-GCM 4249309.75k
$ /usr/pkg/bin/openssl speed -bytes 16384 -evp aes-128-gcm
AES-128-GCM 4254140.98k
>Fix:
The diff below is against -current. It fixes the name and passes the
flag to all files, the way AESCPPFLAGS is since lib/59329, because
crypto/evp and the ciphers provider look at it too. powerpc and
powerpc64 also need poly1305_ppc.c, which is where poly1305_init() is.
The aarch64 regen is written the same way as in the amd64 Makefile.
I built libcrypto before and after and ran both with the same program:
the digests, the Poly1305 MAC, the AES, SM4 and ChaCha20-Poly1305 modes
and SM2 signatures. That was done on amd64, i386, aarch64, riscv64,
sparc64, mipsn64el, macppc and powerpc64, and the results are identical.
I also checked that the assembler is reached with the diff and not
without it. On sparc64 the library without it was the one in 11.1, and
there I could see the difference for ChaCha20-Poly1305 only. The macppc
was a G4 under qemu, so it was the floating point code that ran; on
powerpc64 I did not get to the VSX code. On amd64 and i386, where the
speed means something, Poly1305 went from about 680 to 1560 MB/s and
from 605 to 1370.
The .S files are not in the diff: with it applied, make regen in
arch/aarch64 writes sha256-armv8.S and md5-aarch64.S, rewrites
sha512-armv8.S, and leaves the others as they are.
--- crypto/external/apache2/openssl/lib/libcrypto/arch/aarch64/Makefile
+++ crypto/external/apache2/openssl/lib/libcrypto/arch/aarch64/Makefile
@@ -6,9 +6,15 @@ CRYPTODIST=${NETBSDSRCDIR}/crypto
.include "${NETBSDSRCDIR}/crypto/Makefile.openssl"
regen:
- for i in $$(find ${OPENSSLSRC} -name \*arm\*.pl); do \
+ for i in $$(find ${OPENSSLSRC} -name \*arm\*.pl) \
+ $$(find ${OPENSSLSRC} -name \*aarch64\*.pl); do \
case $$i in \
(*/charmap.pl|*/arm-xlate.pl|*/*v4*|*/bsaes-armv7.pl);; \
+ (*/sha512-armv8.pl) \
+ perl -I${OPENSSLSRC}/crypto/perlasm \
+ -I${OPENSSLSRC}/crypto/bn/asm $$i linux64 sha256-armv8.S; \
+ perl -I${OPENSSLSRC}/crypto/perlasm \
+ -I${OPENSSLSRC}/crypto/bn/asm $$i linux64 sha512-armv8.S;; \
(*) perl -I${OPENSSLSRC}/crypto/perlasm \
-I${OPENSSLSRC}/crypto/bn/asm $$i linux64 /dev/stdout \
> $$(basename $$i .pl).S;; \
--- crypto/external/apache2/openssl/lib/libcrypto/arch/aarch64/aes.inc
+++ crypto/external/apache2/openssl/lib/libcrypto/arch/aarch64/aes.inc
@@ -1,5 +1,5 @@
.PATH.S: ${.PARSEDIR}
-AESCPPFLAGS = -DVPAES_ASM
+AESCPPFLAGS = -DVPAES_ASM -DBSAES_ASM
AES_SRCS += aes_core.c aes_cbc.c vpaes-armv8.S aesv8-armx.S aes-gcm-armv8_64.S
AES_SRCS += aes-gcm-armv8-unroll8_64.S bsaes-armv8.S
--- crypto/external/apache2/openssl/lib/libcrypto/arch/aarch64/ec.inc
+++ crypto/external/apache2/openssl/lib/libcrypto/arch/aarch64/ec.inc
@@ -1,7 +1,8 @@
.PATH.S: ${.PARSEDIR}
-ECCPPFLAGS+=-DECP_NISTZ256_ASM
+ECCPPFLAGS+=-DECP_NISTZ256_ASM -DECP_SM2P256_ASM
EC_SRCS += ecp_nistz256-armv8.S ecp_sm2p256-armv8.S sm3-armv8.S sm4-armv8.S
EC_SRCS += vpsm4-armv8.S vpsm4_ex-armv8.S
+EC_SRCS += ecp_sm2p256.c ecp_sm2p256_table.c
ECNI = yes
.if ${MACHINE_ARCH} == "aarch64eb"
--- /dev/null
+++ crypto/external/apache2/openssl/lib/libcrypto/arch/aarch64/md5.inc
@@ -0,0 +1,4 @@
+.PATH.S: ${.PARSEDIR}
+MD5_SRCS = md5-aarch64.S
+MD5CPPFLAGS = -DMD5_ASM
+.include "../../md5.inc"
--- crypto/external/apache2/openssl/lib/libcrypto/arch/aarch64/poly1305.inc
+++ crypto/external/apache2/openssl/lib/libcrypto/arch/aarch64/poly1305.inc
@@ -1,6 +1,6 @@
.PATH.S: ${.PARSEDIR}
POLY1305_SRCS = poly1305-armv8.S
-POLY1305_CPPFLAGS+=-DPOLY1305_ASM
+POLY1305CPPFLAGS+=-DPOLY1305_ASM
.include "../../poly1305.inc"
--- crypto/external/apache2/openssl/lib/libcrypto/arch/aarch64/sha.inc
+++ crypto/external/apache2/openssl/lib/libcrypto/arch/aarch64/sha.inc
@@ -1,5 +1,5 @@
.PATH.S: ${.PARSEDIR}
-SHA_SRCS = sha1-armv8.S sha512-armv8.S keccak1600-armv8.S
-SHACPPFLAGS = -DSHA1_ASM -DSHA256_ASM -DKECCAK1600_ASM
+SHA_SRCS = sha1-armv8.S sha256-armv8.S sha512-armv8.S keccak1600-armv8.S
+SHACPPFLAGS = -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM
KECCAKNI = yes
.include "../../sha.inc"
--- /dev/null
+++ crypto/external/apache2/openssl/lib/libcrypto/arch/aarch64/sm3.inc
@@ -0,0 +1,2 @@
+SM3CPPFLAGS = -DOPENSSL_SM3_ASM
+.include "../../sm3.inc"
--- crypto/external/apache2/openssl/lib/libcrypto/arch/i386/poly1305.inc
+++ crypto/external/apache2/openssl/lib/libcrypto/arch/i386/poly1305.inc
@@ -1,6 +1,6 @@
.PATH.S: ${.PARSEDIR}
POLY1305_SRCS = poly1305-x86.S
-POLY1305_CPPFLAGS+=-DPOLY1305_ASM
+POLY1305CPPFLAGS+=-DPOLY1305_ASM
.include "../../poly1305.inc"
--- crypto/external/apache2/openssl/lib/libcrypto/arch/mips/poly1305.inc
+++ crypto/external/apache2/openssl/lib/libcrypto/arch/mips/poly1305.inc
@@ -5,7 +5,7 @@
.PATH.S: ${.PARSEDIR}
POLY1305_SRCS = poly1305-mips64.S
-POLY1305_CPPFLAGS+=-DPOLY1305_ASM
+POLY1305CPPFLAGS+=-DPOLY1305_ASM
.endif
--- crypto/external/apache2/openssl/lib/libcrypto/arch/powerpc/poly1305.inc
+++ crypto/external/apache2/openssl/lib/libcrypto/arch/powerpc/poly1305.inc
@@ -1,6 +1,6 @@
.PATH.S: ${.PARSEDIR}
-POLY1305_SRCS = poly1305-ppc.S poly1305-ppcfp.S
-POLY1305_CPPFLAGS+=-DPOLY1305_ASM
+POLY1305_SRCS = poly1305_ppc.c poly1305-ppc.S poly1305-ppcfp.S
+POLY1305CPPFLAGS+=-DPOLY1305_ASM
.include "../../poly1305.inc"
--- crypto/external/apache2/openssl/lib/libcrypto/arch/powerpc64/poly1305.inc
+++ crypto/external/apache2/openssl/lib/libcrypto/arch/powerpc64/poly1305.inc
@@ -1,6 +1,6 @@
.PATH.S: ${.PARSEDIR}
-POLY1305_SRCS = poly1305-ppc.S poly1305-ppcfp.S
-POLY1305_CPPFLAGS+=-DPOLY1305_ASM
+POLY1305_SRCS = poly1305_ppc.c poly1305-ppc.S poly1305-ppcfp.S
+POLY1305CPPFLAGS+=-DPOLY1305_ASM
.include "../../poly1305.inc"
--- /dev/null
+++ crypto/external/apache2/openssl/lib/libcrypto/arch/riscv64/sm3.inc
@@ -0,0 +1,3 @@
+SM3_SRCS += sm3_riscv.c
+SM3CPPFLAGS = -DOPENSSL_SM3_ASM
+.include "../../sm3.inc"
--- crypto/external/apache2/openssl/lib/libcrypto/arch/sparc/poly1305.inc
+++ crypto/external/apache2/openssl/lib/libcrypto/arch/sparc/poly1305.inc
@@ -2,7 +2,7 @@
.PATH.S: ${.PARSEDIR}
POLY1305_SRCS = poly1305-sparcv9.S
-POLY1305_CPPFLAGS+=-DPOLY1305_ASM
+POLY1305CPPFLAGS+=-DPOLY1305_ASM
AFLAGS.poly1305-sparcv9.S+= -Wa,-Av9
.endif
--- crypto/external/apache2/openssl/lib/libcrypto/arch/sparc64/poly1305.inc
+++ crypto/external/apache2/openssl/lib/libcrypto/arch/sparc64/poly1305.inc
@@ -1,6 +1,6 @@
.PATH.S: ${.PARSEDIR}
POLY1305_SRCS = poly1305-sparcv9.S
-POLY1305_CPPFLAGS+=-DPOLY1305_ASM
+POLY1305CPPFLAGS+=-DPOLY1305_ASM
.include "../../poly1305.inc"
--- crypto/external/apache2/openssl/lib/libcrypto/arch/x86_64/poly1305.inc
+++ crypto/external/apache2/openssl/lib/libcrypto/arch/x86_64/poly1305.inc
@@ -1,6 +1,6 @@
.PATH.S: ${.PARSEDIR}
POLY1305_SRCS = poly1305-x86_64.S
-POLY1305_CPPFLAGS+=-DPOLY1305_ASM
+POLY1305CPPFLAGS+=-DPOLY1305_ASM
.include "../../poly1305.inc"
--- crypto/external/apache2/openssl/lib/libcrypto/poly1305.inc
+++ crypto/external/apache2/openssl/lib/libcrypto/poly1305.inc
@@ -7,6 +7,8 @@ poly1305.c \
SRCS += ${POLY1305_SRCS}
+CPPFLAGS+=${POLY1305CPPFLAGS}
+
.for cryptosrc in ${POLY1305_SRCS}
CPPFLAGS.${cryptosrc} += -I${OPENSSLSRC}/crypto/poly1305 ${POLY1305CPPFLAGS}
.endfor
>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/61073 CVS commit: src/crypto/external/apache2/openssl/lib/libcrypto
Date: Wed, 25 Nov 2026 14:51:17 -0500
Module Name: src
Committed By: christos
Date: Wed Nov 25 19:51:17 UTC 2026
Modified Files:
src/crypto/external/apache2/openssl/lib/libcrypto: poly1305.inc
src/crypto/external/apache2/openssl/lib/libcrypto/arch/aarch64:
Makefile aes.inc ec.inc poly1305.inc sha.inc sha512-armv8.S
src/crypto/external/apache2/openssl/lib/libcrypto/arch/i386:
poly1305.inc
src/crypto/external/apache2/openssl/lib/libcrypto/arch/mips:
poly1305.inc
src/crypto/external/apache2/openssl/lib/libcrypto/arch/powerpc:
poly1305.inc
src/crypto/external/apache2/openssl/lib/libcrypto/arch/powerpc64:
poly1305.inc
src/crypto/external/apache2/openssl/lib/libcrypto/arch/sparc:
poly1305.inc
src/crypto/external/apache2/openssl/lib/libcrypto/arch/sparc64:
poly1305.inc
src/crypto/external/apache2/openssl/lib/libcrypto/arch/x86_64:
poly1305.inc
Log Message:
PR/61073: Showta Ishizaki: libcrypto does not use the Poly1305 assembler,
nor some of the aarch64 and riscv64 one
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
src/crypto/external/apache2/openssl/lib/libcrypto/poly1305.inc
cvs rdiff -u -r1.1 -r1.2 \
src/crypto/external/apache2/openssl/lib/libcrypto/arch/aarch64/Makefile \
src/crypto/external/apache2/openssl/lib/libcrypto/arch/aarch64/poly1305.inc \
src/crypto/external/apache2/openssl/lib/libcrypto/arch/aarch64/sha.inc
cvs rdiff -u -r1.2 -r1.3 \
src/crypto/external/apache2/openssl/lib/libcrypto/arch/aarch64/aes.inc \
src/crypto/external/apache2/openssl/lib/libcrypto/arch/aarch64/sha512-armv8.S
cvs rdiff -u -r1.5 -r1.6 \
src/crypto/external/apache2/openssl/lib/libcrypto/arch/aarch64/ec.inc
cvs rdiff -u -r1.1 -r1.2 \
src/crypto/external/apache2/openssl/lib/libcrypto/arch/i386/poly1305.inc
cvs rdiff -u -r1.1 -r1.2 \
src/crypto/external/apache2/openssl/lib/libcrypto/arch/mips/poly1305.inc
cvs rdiff -u -r1.1 -r1.2 \
src/crypto/external/apache2/openssl/lib/libcrypto/arch/powerpc/poly1305.inc
cvs rdiff -u -r1.1 -r1.2 \
src/crypto/external/apache2/openssl/lib/libcrypto/arch/powerpc64/poly1305.inc
cvs rdiff -u -r1.1 -r1.2 \
src/crypto/external/apache2/openssl/lib/libcrypto/arch/sparc/poly1305.inc
cvs rdiff -u -r1.1 -r1.2 \
src/crypto/external/apache2/openssl/lib/libcrypto/arch/sparc64/poly1305.inc
cvs rdiff -u -r1.1 -r1.2 \
src/crypto/external/apache2/openssl/lib/libcrypto/arch/x86_64/poly1305.inc
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/61073 CVS commit: src/crypto/external/apache2/openssl/lib/libcrypto/arch
Date: Wed, 25 Nov 2026 14:53:07 -0500
Module Name: src
Committed By: christos
Date: Wed Nov 25 19:53:07 UTC 2026
Added Files:
src/crypto/external/apache2/openssl/lib/libcrypto/arch/aarch64:
md5-aarch64.S md5.inc sha256-armv8.S sm3.inc
src/crypto/external/apache2/openssl/lib/libcrypto/arch/riscv64: sm3.inc
Log Message:
PR/61073: Showta Ishizaki: libcrypto does not use the Poly1305 assembler,
nor some of the aarch64 and riscv64 one
To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 \
src/crypto/external/apache2/openssl/lib/libcrypto/arch/aarch64/md5-aarch64.S \
src/crypto/external/apache2/openssl/lib/libcrypto/arch/aarch64/md5.inc \
src/crypto/external/apache2/openssl/lib/libcrypto/arch/aarch64/sha256-armv8.S \
src/crypto/external/apache2/openssl/lib/libcrypto/arch/aarch64/sm3.inc
cvs rdiff -u -r0 -r1.1 \
src/crypto/external/apache2/openssl/lib/libcrypto/arch/riscv64/sm3.inc
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.