OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 // number < p. | 29 // number < p. |
30 bool SetFromString(const base::StringPiece& in); | 30 bool SetFromString(const base::StringPiece& in); |
31 | 31 |
32 // ToString returns an external representation of the Point. | 32 // ToString returns an external representation of the Point. |
33 std::string ToString() const; | 33 std::string ToString() const; |
34 | 34 |
35 // An Point is represented in Jacobian form (x/z², y/z³). | 35 // An Point is represented in Jacobian form (x/z², y/z³). |
36 FieldElement x, y, z; | 36 FieldElement x, y, z; |
37 }; | 37 }; |
38 | 38 |
| 39 // kScalarBytes is the number of bytes needed to represent an element of the |
| 40 // P224 field. |
| 41 static const size_t kScalarBytes = 28; |
| 42 |
39 // ScalarMult computes *out = in*scalar where scalar is a 28-byte, big-endian | 43 // ScalarMult computes *out = in*scalar where scalar is a 28-byte, big-endian |
40 // number. | 44 // number. |
41 void CRYPTO_EXPORT ScalarMult(const Point& in, const uint8* scalar, Point* out); | 45 void CRYPTO_EXPORT ScalarMult(const Point& in, const uint8* scalar, Point* out); |
42 | 46 |
43 // ScalarBaseMult computes *out = g*scalar where g is the base point of the | 47 // ScalarBaseMult computes *out = g*scalar where g is the base point of the |
44 // curve and scalar is a 28-byte, big-endian number. | 48 // curve and scalar is a 28-byte, big-endian number. |
45 void CRYPTO_EXPORT ScalarBaseMult(const uint8* scalar, Point* out); | 49 void CRYPTO_EXPORT ScalarBaseMult(const uint8* scalar, Point* out); |
46 | 50 |
47 // Add computes *out = a+b. | 51 // Add computes *out = a+b. |
48 void CRYPTO_EXPORT Add(const Point& a, const Point& b, Point* out); | 52 void CRYPTO_EXPORT Add(const Point& a, const Point& b, Point* out); |
49 | 53 |
50 // Negate calculates out = -a; | 54 // Negate calculates out = -a; |
51 void CRYPTO_EXPORT Negate(const Point& a, Point* out); | 55 void CRYPTO_EXPORT Negate(const Point& a, Point* out); |
52 | 56 |
53 } // namespace p224 | 57 } // namespace p224 |
54 | 58 |
55 } // namespace crypto | 59 } // namespace crypto |
56 | 60 |
57 #endif // CRYPTO_P224_H_ | 61 #endif // CRYPTO_P224_H_ |
OLD | NEW |