]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Add gf2m specialization for Elbrus2000
authorGleb Popov <6yearold@gmail.com>
Mon, 1 Sep 2025 17:54:47 +0000 (20:54 +0300)
committerAndrew Dinh <andrewd@openssl.org>
Fri, 31 Jul 2026 16:48:53 +0000 (23:48 +0700)
Reviewed-by: Andrew Dinh <andrewd@openssl.org>
Reviewed-by: Igor Ustinov <igus@openssl.foundation>
MergeDate: Fri Jul 31 16:49:36 2026
(Merged from https://github.com/openssl/openssl/pull/31269)

crypto/bn/asm/e2kv6-gf2m.c [new file with mode: 0644]
crypto/bn/build.info

diff --git a/crypto/bn/asm/e2kv6-gf2m.c b/crypto/bn/asm/e2kv6-gf2m.c
new file mode 100644 (file)
index 0000000..83c2729
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2026 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (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 <e2kintrin.h>
+
+#include "../bn_local.h"
+
+void bn_GF2m_mul_2x2(BN_ULONG *r, const BN_ULONG a1, const BN_ULONG a0,
+    const BN_ULONG b1, const BN_ULONG b0)
+{
+    BN_ULONG m1, m0;
+
+    r[3] = __builtin_e2k_clmulh(a1, b1);
+    r[2] = __builtin_e2k_clmull(a1, b1);
+
+    r[1] = __builtin_e2k_clmulh(a0, b0);
+    r[0] = __builtin_e2k_clmull(a0, b0);
+
+    m1 = __builtin_e2k_clmulh(a0 ^ a1, b0 ^ b1);
+    m0 = __builtin_e2k_clmull(a0 ^ a1, b0 ^ b1);
+
+    r[2] ^= __builtin_e2k_plog(0x96, m1, r[1], r[3]);
+    r[1] = __builtin_e2k_plog(0x96, r[3], r[2], __builtin_e2k_plog(0x96, r[0], m1, m0));
+}
index 01e98e45443cb382dc9e97660ffc908c94f877c4..c895354346b4877764c12095b8519f9d1c804957 100644 (file)
@@ -90,6 +90,11 @@ IF[{- !$disabled{asm} -}]
   $BNASM_c64xplus_ec2m=c64xplus-gf2m.s
   $BNDEF_c64xplus_ec2m=OPENSSL_BN_ASM_GF2m
 
+  $BNASM_e2kv6=asm/e2kv6-gf2m.c
+  $BNDEF_e2kv6=OPENSSL_BN_ASM_GF2m
+  $BNASM_e2kv7=asm/e2kv6-gf2m.c
+  $BNDEF_e2kv7=OPENSSL_BN_ASM_GF2m
+
   # Now that we have defined all the arch specific variables, use the
   # appropriate ones, and define the appropriate macros
   IF[$BNASM_{- $target{asm_arch} -}]