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

Side by Side Diff: crypto/p224.h

Issue 1539353003: Switch to standard integer types in crypto/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 5 years 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/openssl_util.cc ('k') | crypto/p224.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CRYPTO_P224_H_ 5 #ifndef CRYPTO_P224_H_
6 #define CRYPTO_P224_H_ 6 #define CRYPTO_P224_H_
7 7
8 #include <stddef.h>
9 #include <stdint.h>
10
8 #include <string> 11 #include <string>
9 12
10 #include "base/basictypes.h"
11 #include "base/strings/string_piece.h" 13 #include "base/strings/string_piece.h"
12 #include "crypto/crypto_export.h" 14 #include "crypto/crypto_export.h"
13 15
14 namespace crypto { 16 namespace crypto {
15 17
16 // P224 implements an elliptic curve group, commonly known as P224 and defined 18 // P224 implements an elliptic curve group, commonly known as P224 and defined
17 // in FIPS 186-3, section D.2.2. 19 // in FIPS 186-3, section D.2.2.
18 namespace p224 { 20 namespace p224 {
19 21
20 // An element of the field (ℤ/pℤ) is represented with 8, 28-bit limbs in 22 // An element of the field (ℤ/pℤ) is represented with 8, 28-bit limbs in
21 // little endian order. 23 // little endian order.
22 typedef uint32 FieldElement[8]; 24 typedef uint32_t FieldElement[8];
23 25
24 struct CRYPTO_EXPORT Point { 26 struct CRYPTO_EXPORT Point {
25 // SetFromString the value of the point from the 56 byte, external 27 // SetFromString the value of the point from the 56 byte, external
26 // representation. The external point representation is an (x, y) pair of a 28 // representation. The external point representation is an (x, y) pair of a
27 // point on the curve. Each field element is represented as a big-endian 29 // point on the curve. Each field element is represented as a big-endian
28 // number < p. 30 // number < p.
29 bool SetFromString(const base::StringPiece& in); 31 bool SetFromString(const base::StringPiece& in);
30 32
31 // ToString returns an external representation of the Point. 33 // ToString returns an external representation of the Point.
32 std::string ToString() const; 34 std::string ToString() const;
33 35
34 // An Point is represented in Jacobian form (x/z², y/z³). 36 // An Point is represented in Jacobian form (x/z², y/z³).
35 FieldElement x, y, z; 37 FieldElement x, y, z;
36 }; 38 };
37 39
38 // kScalarBytes is the number of bytes needed to represent an element of the 40 // kScalarBytes is the number of bytes needed to represent an element of the
39 // P224 field. 41 // P224 field.
40 static const size_t kScalarBytes = 28; 42 static const size_t kScalarBytes = 28;
41 43
42 // ScalarMult computes *out = in*scalar where scalar is a 28-byte, big-endian 44 // ScalarMult computes *out = in*scalar where scalar is a 28-byte, big-endian
43 // number. 45 // number.
44 void CRYPTO_EXPORT ScalarMult(const Point& in, const uint8* scalar, Point* out); 46 void CRYPTO_EXPORT ScalarMult(const Point& in,
47 const uint8_t* scalar,
48 Point* out);
45 49
46 // ScalarBaseMult computes *out = g*scalar where g is the base point of the 50 // ScalarBaseMult computes *out = g*scalar where g is the base point of the
47 // curve and scalar is a 28-byte, big-endian number. 51 // curve and scalar is a 28-byte, big-endian number.
48 void CRYPTO_EXPORT ScalarBaseMult(const uint8* scalar, Point* out); 52 void CRYPTO_EXPORT ScalarBaseMult(const uint8_t* scalar, Point* out);
49 53
50 // Add computes *out = a+b. 54 // Add computes *out = a+b.
51 void CRYPTO_EXPORT Add(const Point& a, const Point& b, Point* out); 55 void CRYPTO_EXPORT Add(const Point& a, const Point& b, Point* out);
52 56
53 // Negate calculates out = -a; 57 // Negate calculates out = -a;
54 void CRYPTO_EXPORT Negate(const Point& a, Point* out); 58 void CRYPTO_EXPORT Negate(const Point& a, Point* out);
55 59
56 } // namespace p224 60 } // namespace p224
57 61
58 } // namespace crypto 62 } // namespace crypto
59 63
60 #endif // CRYPTO_P224_H_ 64 #endif // CRYPTO_P224_H_
OLDNEW
« no previous file with comments | « crypto/openssl_util.cc ('k') | crypto/p224.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698