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
3 // found in the LICENSE file.
11 #include "base/basictypes.h"
12 #include "base/string_piece.h"
13 #include "crypto/crypto_export.h"
17 // P224 implements an elliptic curve group, commonly known as P224 and defined
18 // in FIPS 186-3, section D.2.2.
21 // An element of the field (ℤ/pℤ) is represented with 8, 28-bit limbs in
22 // little endian order.
23 typedef uint32 FieldElement
[8];
25 struct CRYPTO_EXPORT Point
{
26 // SetFromString the value of the point from the 56 byte, external
27 // representation. The external point representation is an (x, y) pair of a
28 // point on the curve. Each field element is represented as a big-endian
30 bool SetFromString(const base::StringPiece
& in
);
32 // ToString returns an external representation of the Point.
33 std::string
ToString() const;
35 // An Point is represented in Jacobian form (x/z², y/z³).
39 // ScalarMult computes *out = in*scalar where scalar is a 28-byte, big-endian
41 void CRYPTO_EXPORT
ScalarMult(const Point
& in
, const uint8
* scalar
, Point
* out
);
43 // ScalarBaseMult computes *out = g*scalar where g is the base point of the
44 // curve and scalar is a 28-byte, big-endian number.
45 void CRYPTO_EXPORT
ScalarBaseMult(const uint8
* scalar
, Point
* out
);
47 // Add computes *out = a+b.
48 void CRYPTO_EXPORT
Add(const Point
& a
, const Point
& b
, Point
* out
);
50 // Negate calculates out = -a;
51 void CRYPTO_EXPORT
Negate(const Point
& a
, Point
* out
);
57 #endif // CRYPTO_P224_H_