Index: crypto/curve25519.h |
=================================================================== |
--- crypto/curve25519.h (revision 0) |
+++ crypto/curve25519.h (revision 0) |
@@ -0,0 +1,45 @@ |
+// 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" |
+ |
+namespace crypto { |
+ |
+// Curve25519 implements an elliptic curve group, commonly known as Curve25519 |
+// and defined in http://cr.yp.to/ecdh.html. |
+namespace curve25519 { |
+ |
+static const size_t kCryptoScalarMultCurve25519Bytes = 32; |
+static const size_t kCryptoScalarMultCurve25519ScalarBytes = 32; |
wtc
2013/03/06 19:21:07
Shorten these constants to just kBytes and kScalar
ramant (doing other things)
2013/03/06 20:03:12
Done.
|
+ |
+// ScalarMultiply computes the |shared_key| from |private_key| and |
wtc
2013/03/06 19:21:07
Typo: ScalarMultiply => ScalarMult
ramant (doing other things)
2013/03/06 20:03:12
Done.
|
+// |peer_public_key|. See "Computing shared secrets" section of |
+// http://cr.yp.to/ecdh.html. |
+void CRYPTO_EXPORT ScalarMult(const uint8* private_key, |
+ const uint8* peer_public_key, |
+ uint8* shared_key); |
+ |
+// ScalarMultiply computes the |public_key| from |private_key| and a basepoint |
wtc
2013/03/06 19:21:07
Typo: ScalarMultiply => ScalarBaseMult
ramant (doing other things)
2013/03/06 20:03:12
Done.
|
+// as specified in "Computing public keys" section of |
+// http://cr.yp.to/ecdh.html. |
+void CRYPTO_EXPORT ScalarBaseMult(const uint8* private_key, uint8* public_key); |
+ |
+// ConvertToPrivateKey converts |secret| into a private key, suitable |
+// for passing to |ScalarBaseMult|. If |secret_size| is not equal to |
+// |kCryptoScalarMultCurve25519ScalarBytes|, then it returns false and |
+// |private_key| is not updated. See "Computing secret keys" section of |
+// http://cr.yp.to/ecdh.html. |
+bool CRYPTO_EXPORT ConvertToPrivateKey(uint8* secret, size_t secret_size); |
wtc
2013/03/06 19:21:07
Although it is a good idea to require the caller t
ramant (doing other things)
2013/03/06 20:03:12
Made it consistent with rest of the code. Removed
|
+ |
+} // namespace curve25519 |
+ |
+} // namespace crypto |
+ |
+#endif // CRYPTO_CURVE25519_H |