aboutsummaryrefslogtreecommitdiff
path: root/ecdsa_fpga_curve.h
diff options
context:
space:
mode:
authorPavel V. Shatov (Meister) <meisterpaul1@yandex.ru>2021-04-11 17:42:52 +0300
committerPavel V. Shatov (Meister) <meisterpaul1@yandex.ru>2021-04-11 17:42:52 +0300
commit1e16303d718986e0e991444a7cdcab3c5c89b1f4 (patch)
tree25f885054c06e870ad46e5a8d1f9756795111170 /ecdsa_fpga_curve.h
parentc5ee836423777703920593143f140bd0036caad4 (diff)
Updated curve math layer to do multiplication using the Montgomery ladder
method. Also added optional debugging output to help debug microcoded versions of double and add routines.
Diffstat (limited to 'ecdsa_fpga_curve.h')
-rw-r--r--ecdsa_fpga_curve.h70
1 files changed, 39 insertions, 31 deletions
diff --git a/ecdsa_fpga_curve.h b/ecdsa_fpga_curve.h
index 00448eb..e9f2fe6 100644
--- a/ecdsa_fpga_curve.h
+++ b/ecdsa_fpga_curve.h
@@ -6,7 +6,7 @@
//
// Authors: Pavel Shatov
//
-// Copyright (c) 2015-2016, 2018 NORDUnet A/S
+// Copyright (c) 2015-2016, 2018, 2021 NORDUnet A/S
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
@@ -139,14 +139,33 @@ extern FPGA_BUFFER ECDSA_N;
#ifdef USE_MICROCODE
#define fpga_curve_base_scalar_multiply fpga_curve_base_scalar_multiply_microcode
-#define fpga_curve_add_jacobian fpga_curve_add_jacobian_microcode_wrapper
-#define fpga_curve_double_jacobian fpga_curve_double_jacobian_microcode_wrapper
+
+#define fpga_curve_add_jacobian_2_shim fpga_curve_add_jacobian_microcode_2_wrapper
+#define fpga_curve_double_jacobian_shim fpga_curve_double_jacobian_microcode_wrapper
+
+void fpga_curve_double_jacobian_microcode_wrapper (const FPGA_BUFFER *px,
+ const FPGA_BUFFER *py,
+ const FPGA_BUFFER *pz,
+ FPGA_BUFFER *rx,
+ FPGA_BUFFER *ry,
+ FPGA_BUFFER *rz);
+
+void fpga_curve_add_jacobian_microcode_2_wrapper(const FPGA_BUFFER *px,
+ const FPGA_BUFFER *py,
+ const FPGA_BUFFER *pz,
+ const FPGA_BUFFER *qx,
+ const FPGA_BUFFER *qy,
+ const FPGA_BUFFER *qz,
+ FPGA_BUFFER *rx,
+ FPGA_BUFFER *ry,
+ FPGA_BUFFER *rz);
#else
#define fpga_curve_base_scalar_multiply fpga_curve_base_scalar_multiply_abstract
-#define fpga_curve_add_jacobian fpga_curve_add_jacobian_abstract
-#define fpga_curve_double_jacobian fpga_curve_double_jacobian_abstract
+
+#define fpga_curve_add_jacobian_2_shim fpga_curve_add_jacobian_abstract_2
+#define fpga_curve_double_jacobian_shim fpga_curve_double_jacobian_abstract
#endif
@@ -156,20 +175,23 @@ extern FPGA_BUFFER ECDSA_N;
//------------------------------------------------------------------------------
void fpga_curve_init ();
-void fpga_curve_base_scalar_multiply_abstract (const FPGA_BUFFER *k,
- FPGA_BUFFER *qx,
- FPGA_BUFFER *qy);
+void fpga_curve_base_scalar_multiply_abstract (const FPGA_BUFFER *k,
+ FPGA_BUFFER *qx,
+ FPGA_BUFFER *qy);
void fpga_curve_base_scalar_multiply_microcode (const FPGA_BUFFER *k,
FPGA_BUFFER *qx,
FPGA_BUFFER *qy);
-void fpga_curve_add_jacobian_abstract (const FPGA_BUFFER *px,
- const FPGA_BUFFER *py,
- const FPGA_BUFFER *pz,
- FPGA_BUFFER *rx,
- FPGA_BUFFER *ry,
- FPGA_BUFFER *rz);
+void fpga_curve_add_jacobian_abstract_2 (const FPGA_BUFFER *px,
+ const FPGA_BUFFER *py,
+ const FPGA_BUFFER *pz,
+ const FPGA_BUFFER *qx,
+ const FPGA_BUFFER *qy,
+ const FPGA_BUFFER *qz,
+ FPGA_BUFFER *rx,
+ FPGA_BUFFER *ry,
+ FPGA_BUFFER *rz);
void fpga_curve_double_jacobian_abstract (const FPGA_BUFFER *px,
const FPGA_BUFFER *py,
@@ -178,24 +200,10 @@ void fpga_curve_double_jacobian_abstract (const FPGA_BUFFER *px,
FPGA_BUFFER *ry,
FPGA_BUFFER *rz);
-void fpga_curve_add_jacobian_microcode ();
-
-void fpga_curve_double_jacobian_microcode ();
-
-void fpga_curve_add_jacobian_microcode_wrapper (const FPGA_BUFFER *px,
- const FPGA_BUFFER *py,
- const FPGA_BUFFER *pz,
- FPGA_BUFFER *rx,
- FPGA_BUFFER *ry,
- FPGA_BUFFER *rz);
+void fpga_curve_add_jacobian_microcode_2 ();
-
-void fpga_curve_double_jacobian_microcode_wrapper (const FPGA_BUFFER *px,
- const FPGA_BUFFER *py,
- const FPGA_BUFFER *pz,
- FPGA_BUFFER *rx,
- FPGA_BUFFER *ry,
- FPGA_BUFFER *rz);
+void fpga_curve_double_jacobian_microcode_r0 ();
+void fpga_curve_double_jacobian_microcode_r1 ();
//------------------------------------------------------------------------------