summaryrefslogtreecommitdiff
path: root/board/cr50/dcrypto/p256_ec.c
diff options
context:
space:
mode:
Diffstat (limited to 'board/cr50/dcrypto/p256_ec.c')
-rw-r--r--board/cr50/dcrypto/p256_ec.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/board/cr50/dcrypto/p256_ec.c b/board/cr50/dcrypto/p256_ec.c
new file mode 100644
index 0000000000..cb33a15774
--- /dev/null
+++ b/board/cr50/dcrypto/p256_ec.c
@@ -0,0 +1,39 @@
+/* Copyright 2015 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "dcrypto.h"
+
+#include <stdint.h>
+
+#include "cryptoc/p256.h"
+
+/* p256_base_point_mul sets {out_x,out_y} = nG, where n is < the
+ * order of the group. */
+int DCRYPTO_p256_base_point_mul(p256_int *out_x, p256_int *out_y,
+ const p256_int *n)
+{
+ if (p256_is_zero(n) != 0) {
+ p256_clear(out_x);
+ p256_clear(out_y);
+ return 0;
+ }
+
+ return dcrypto_p256_base_point_mul(n, out_x, out_y);
+}
+
+/* DCRYPTO_p256_point_mul sets {out_x,out_y} = n*{in_x,in_y}, where n is <
+ * the order of the group. */
+int DCRYPTO_p256_point_mul(p256_int *out_x, p256_int *out_y,
+ const p256_int *n, const p256_int *in_x,
+ const p256_int *in_y)
+{
+ if (p256_is_zero(n) != 0) {
+ p256_clear(out_x);
+ p256_clear(out_y);
+ return 0;
+ }
+
+ return dcrypto_p256_point_mul(n, in_x, in_y, out_x, out_y);
+}