Commit 6736bd2cb6 for openssl.org

commit 6736bd2cb606aeaf8f0960816152cb27fa710258
Author: knut st. osmundsen <bird-nasm@anduin.net>
Date:   Tue Jun 9 08:49:39 2026 +0200

    Fix nasm version check for sm3 & sm4 perlasm files

    Make the check correctly handle versions such as '3.00rc8'.
    It was incorrectly expecting major.minor.patch.

    Reviewed-by: Norbert Pocs <norbertp@openssl.org>
    Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
    MergeDate: Mon Jul 13 15:48:03 2026
    (Merged from https://github.com/openssl/openssl/pull/31420)

diff --git a/crypto/sm3/asm/sm3-x86_64.pl b/crypto/sm3/asm/sm3-x86_64.pl
index d3c9d0541a..2f6ddf5616 100755
--- a/crypto/sm3/asm/sm3-x86_64.pl
+++ b/crypto/sm3/asm/sm3-x86_64.pl
@@ -35,8 +35,8 @@ if (`$ENV{CC} -Wa,-v -c -o /dev/null -x assembler /dev/null 2>&1`
 }

 if (!$avx2_sm3_ni && $win64 && ($flavour =~ /nasm/ || $ENV{ASM} =~ /nasm/) &&
-	   `nasm -v 2>&1` =~ /NASM version ([2-9])\.([0-9]+)\.([0-9]+)/) {
-    my ($major, $minor, $patch) = ($1, $2, $3);
+	   `nasm -v 2>&1` =~ /NASM version ([2-9])\.([0-9]+)(?:\.([0-9]+))?/) {
+    my ($major, $minor, $patch) = ($1, $2, defined($3) ? $3 : 0);
     $avx2_sm3_ni = ($major > 2) || ($major == 2 && $minor > 10); # minimal avx2 supported version, binary translation for SM3 instructions (sub sm3op) is used
 	$avx2_sm3_ni_native = ($major > 2) || ($major == 2 && $minor > 16) || ($major == 2 && $minor == 16 && $patch >= 2); # support added at NASM 2.16.02
 }
diff --git a/crypto/sm4/asm/sm4-x86_64.pl b/crypto/sm4/asm/sm4-x86_64.pl
index 9fc40fb96a..f5b485968e 100644
--- a/crypto/sm4/asm/sm4-x86_64.pl
+++ b/crypto/sm4/asm/sm4-x86_64.pl
@@ -35,8 +35,8 @@ if (`$ENV{CC} -Wa,-v -c -o /dev/null -x assembler /dev/null 2>&1`
 }

 if (!$avx2_sm4_ni && $win64 && ($flavour =~ /nasm/ || $ENV{ASM} =~ /nasm/) &&
-       `nasm -v 2>&1` =~ /NASM version ([2-9])\.([0-9]+)\.([0-9]+)/) {
-    my ($major, $minor, $patch) = ($1, $2, $3);
+       `nasm -v 2>&1` =~ /NASM version ([2-9])\.([0-9]+)(?:\.([0-9]+))?/) {
+    my ($major, $minor, $patch) = ($1, $2, defined($3) ? $3 : 0);
     $avx2_sm4_ni = ($major > 2) || ($major == 2 && $minor > 10); # minimal avx2 supported version, binary translation for SM4 instructions (sub sm4op) is used
     $avx2_sm4_ni_native = ($major > 2) || ($major == 2 && $minor > 16) || ($major == 2 && $minor == 16 && $patch >= 2); # support added at NASM 2.16.02
 }