Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: crypto/curve25519_nss.cc

Issue 1882433002: Removing NSS files and USE_OPENSSL flag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « crypto/curve25519-donna.c ('k') | crypto/ec_private_key.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 #include <stdint.h>
8
9 #include "crypto/secure_util.h"
10
11 // Curve25519 is specified in terms of byte strings, not numbers, so all
12 // implementations take and return the same sequence of bits. So the byte
13 // order is implicitly specified as in, say, SHA1.
14 //
15 // Prototype for |curve25519_donna| function in
16 // third_party/curve25519-donna/curve25519-donna.c
17 extern "C" int curve25519_donna(uint8_t*, const uint8_t*, const uint8_t*);
18
19 namespace crypto {
20
21 namespace curve25519 {
22
23 bool ScalarMult(const uint8_t* private_key,
24 const uint8_t* peer_public_key,
25 uint8_t* shared_key) {
26 curve25519_donna(shared_key, private_key, peer_public_key);
27
28 // The all-zero output results when the input is a point of small order.
29 static const uint8_t kZeros[32] = {0};
30 return !SecureMemEqual(shared_key, kZeros, 32);
31 }
32
33 // kBasePoint is the base point (generator) of the elliptic curve group.
34 // It is little-endian version of '9' followed by 31 zeros.
35 // See "Computing public keys" section of http://cr.yp.to/ecdh.html.
36 static const uint8_t kBasePoint[32] = {9};
37
38 void ScalarBaseMult(const uint8_t* private_key, uint8_t* public_key) {
39 curve25519_donna(public_key, private_key, kBasePoint);
40 }
41
42 } // namespace curve25519
43
44 } // namespace crypto
OLDNEW
« no previous file with comments | « crypto/curve25519-donna.c ('k') | crypto/ec_private_key.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698