Index: crypto/curve25519.h |
=================================================================== |
--- crypto/curve25519.h (revision 0) |
+++ crypto/curve25519.h (revision 0) |
@@ -0,0 +1,44 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CRYPTO_CURVE25519_H |
+#define CRYPTO_CURVE25519_H |
+ |
+#include <string> |
+ |
+#include "base/basictypes.h" |
+#include "crypto/crypto_export.h" |
+ |
+#define crypto_scalarmult_curve25519_BYTES 32 |
+#define crypto_scalarmult_curve25519_SCALARBYTES 32 |
wtc
2013/03/06 00:55:58
In a C++ header, these should be defined as enum c
ramant (doing other things)
2013/03/06 19:01:05
Done.
|
+ |
+namespace crypto { |
+ |
+class CRYPTO_EXPORT Curve25519 { |
+ public: |
+ // ScalarMultiply computes the |shared_key| from |private_key| and |
+ // |peer_public_key|. See "Computing shared secrets" section of |
+ // http://cr.yp.to/ecdh.html. |
+ static int ScalarMultiply(uint8* shared_key, |
+ const uint8* private_key, |
+ const uint8* peer_public_key); |
wtc
2013/03/06 00:55:58
This class should follow the recommendation of our
ramant (doing other things)
2013/03/06 19:01:05
Made ScalarMult* methods look similar to p224's me
|
+ |
+ // ScalarMultiply computes the |public_key| from |private_key| and a basepoint |
+ // as specified in "Computing public keys" section of |
+ // http://cr.yp.to/ecdh.html. |
+ static int ScalarMultiplyBase(uint8* public_key, const uint8* private_key); |
+ |
+ // ConvertToPrivateKey returns |private_key|, generated from |mysecret|, |
+ // suitable for passing to |ScalarMultiplyBase|. If |mysecret_size| is not |
+ // equal to |crypto_scalarmult_curve25519_SCALARBYTES|, then it returns false |
+ // and |private_key| is not updated. See "Computing secret keys" section of |
+ // http://cr.yp.to/ecdh.html. |
+ static bool ConvertToPrivateKey(uint8* mysecret, |
+ size_t mysecret_size, |
+ std::string* private_key); |
wtc
2013/03/06 00:55:58
This function should operate on |mysecret| in plac
ramant (doing other things)
2013/03/06 19:01:05
Done.
|
+}; |
+ |
+} // namespace crypto |
+ |
+#endif // CRYPTO_CURVE25519_H |