Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CRYPTO_CURVE25519_H | |
| 6 #define CRYPTO_CURVE25519_H | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "crypto/crypto_export.h" | |
| 12 | |
| 13 namespace crypto { | |
| 14 | |
| 15 // Curve25519 implements an elliptic curve group, commonly known as Curve25519 | |
| 16 // and defined in http://cr.yp.to/ecdh.html. | |
| 17 namespace curve25519 { | |
| 18 | |
| 19 static const size_t kCryptoScalarMultCurve25519Bytes = 32; | |
| 20 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.
| |
| 21 | |
| 22 // 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.
| |
| 23 // |peer_public_key|. See "Computing shared secrets" section of | |
| 24 // http://cr.yp.to/ecdh.html. | |
| 25 void CRYPTO_EXPORT ScalarMult(const uint8* private_key, | |
| 26 const uint8* peer_public_key, | |
| 27 uint8* shared_key); | |
| 28 | |
| 29 // 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.
| |
| 30 // as specified in "Computing public keys" section of | |
| 31 // http://cr.yp.to/ecdh.html. | |
| 32 void CRYPTO_EXPORT ScalarBaseMult(const uint8* private_key, uint8* public_key); | |
| 33 | |
| 34 // ConvertToPrivateKey converts |secret| into a private key, suitable | |
| 35 // for passing to |ScalarBaseMult|. If |secret_size| is not equal to | |
| 36 // |kCryptoScalarMultCurve25519ScalarBytes|, then it returns false and | |
| 37 // |private_key| is not updated. See "Computing secret keys" section of | |
| 38 // http://cr.yp.to/ecdh.html. | |
| 39 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
| |
| 40 | |
| 41 } // namespace curve25519 | |
| 42 | |
| 43 } // namespace crypto | |
| 44 | |
| 45 #endif // CRYPTO_CURVE25519_H | |
| OLD | NEW |