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 #include "crypto/curve25519.h" | |
| 6 | |
| 7 // Prototype for |curve25519_donna| function in | |
| 8 // third_party/curve25519-donna/curve25519-donna.c | |
| 9 extern "C" int curve25519_donna(uint8*, const uint8*, const uint8*); | |
| 10 | |
| 11 namespace crypto { | |
| 12 | |
| 13 namespace curve25519 { | |
| 14 | |
| 15 void ScalarMult(const uint8* private_key, | |
| 16 const uint8* peer_public_key, | |
| 17 uint8* shared_key) { | |
| 18 curve25519_donna(shared_key, private_key, peer_public_key); | |
|
wtc
2013/03/06 21:26:44
agl: |shared_key| is the x coordinate of the resul
agl
2013/03/06 21:47:50
Curve25519 is specified in terms of byte strings,
ramant (doing other things)
2013/03/08 00:10:15
Done.
ramant (doing other things)
2013/03/08 00:10:15
Added agl's comments to the file. Hope that is ok.
| |
| 19 } | |
| 20 | |
| 21 // kBasePoint is the base point (generator) of the elliptic curve group. | |
| 22 static const unsigned char kBasePoint[32] = {9}; | |
|
Ryan Sleevi
2013/03/06 21:18:32
Can you provide more comments explaining the sourc
agl
2013/03/06 21:47:50
It's defined as a magic value by the API. (It happ
ramant (doing other things)
2013/03/08 00:10:15
Done.
| |
| 23 | |
| 24 void ScalarBaseMult(const uint8* private_key, uint8* public_key) { | |
| 25 curve25519_donna(public_key, private_key, kBasePoint); | |
| 26 } | |
| 27 | |
| 28 void ConvertToPrivateKey(uint8* secret) { | |
| 29 // This makes |secret| a valid scalar, as specified on | |
| 30 // http://cr.yp.to/ecdh.html | |
| 31 secret[0] &= 248; | |
| 32 secret[31] &= 127; | |
| 33 secret[31] |= 64; | |
|
Ryan Sleevi
2013/03/06 21:18:32
Does our version not support curve25519_clamp?
At
agl
2013/03/06 21:47:50
_clamp has been removed from the API as I recall.
ramant (doing other things)
2013/03/08 00:10:15
Added a reference to the section in the paper.
Do
| |
| 34 } | |
| 35 | |
| 36 } // namespace curve25519 | |
| 37 | |
| 38 } // namespace crypto | |
| OLD | NEW |