Retrieve the authenticated user's e-mail from GAIA during SAML enrollment
[chromium-blink-merge.git] / crypto / p224.h
blob2efecfab559a0c8f467832154832dae3c7e0566a
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
3 // found in the LICENSE file.
5 #ifndef CRYPTO_P224_H_
6 #define CRYPTO_P224_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/strings/string_piece.h"
12 #include "crypto/crypto_export.h"
14 namespace crypto {
16 // P224 implements an elliptic curve group, commonly known as P224 and defined
17 // in FIPS 186-3, section D.2.2.
18 namespace p224 {
20 // An element of the field (ℤ/pℤ) is represented with 8, 28-bit limbs in
21 // little endian order.
22 typedef uint32 FieldElement[8];
24 struct CRYPTO_EXPORT Point {
25 // SetFromString the value of the point from the 56 byte, external
26 // 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
28 // number < p.
29 bool SetFromString(const base::StringPiece& in);
31 // ToString returns an external representation of the Point.
32 std::string ToString() const;
34 // An Point is represented in Jacobian form (x/z², y/z³).
35 FieldElement x, y, z;
38 // kScalarBytes is the number of bytes needed to represent an element of the
39 // P224 field.
40 static const size_t kScalarBytes = 28;
42 // ScalarMult computes *out = in*scalar where scalar is a 28-byte, big-endian
43 // number.
44 void CRYPTO_EXPORT ScalarMult(const Point& in, const uint8* scalar, Point* out);
46 // ScalarBaseMult computes *out = g*scalar where g is the base point of the
47 // curve and scalar is a 28-byte, big-endian number.
48 void CRYPTO_EXPORT ScalarBaseMult(const uint8* scalar, Point* out);
50 // Add computes *out = a+b.
51 void CRYPTO_EXPORT Add(const Point& a, const Point& b, Point* out);
53 // Negate calculates out = -a;
54 void CRYPTO_EXPORT Negate(const Point& a, Point* out);
56 } // namespace p224
58 } // namespace crypto
60 #endif // CRYPTO_P224_H_