OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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 NET_QUIC_CRYPTO_P256_KEY_EXCHANGE_H_ | 5 #ifndef NET_QUIC_CRYPTO_P256_KEY_EXCHANGE_H_ |
6 #define NET_QUIC_CRYPTO_P256_KEY_EXCHANGE_H_ | 6 #define NET_QUIC_CRYPTO_P256_KEY_EXCHANGE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/strings/string_piece.h" | 14 #include "base/strings/string_piece.h" |
15 #include "net/base/net_export.h" | 15 #include "net/base/net_export.h" |
16 #include "net/quic/crypto/key_exchange.h" | 16 #include "net/quic/crypto/key_exchange.h" |
17 | 17 |
18 #if defined(USE_OPENSSL) | |
19 #include "crypto/openssl_util.h" | 18 #include "crypto/openssl_util.h" |
20 #include "crypto/scoped_openssl_types.h" | 19 #include "crypto/scoped_openssl_types.h" |
Ryan Sleevi
2016/04/18 14:23:30
Fix sorting
svaldez
2016/04/18 15:09:35
Done.
| |
21 #else | |
22 #include "crypto/ec_private_key.h" | |
23 #include "crypto/scoped_nss_types.h" | |
24 #endif | |
25 | 20 |
26 namespace net { | 21 namespace net { |
27 | 22 |
28 // P256KeyExchange implements a KeyExchange using elliptic-curve | 23 // P256KeyExchange implements a KeyExchange using elliptic-curve |
29 // Diffie-Hellman on NIST P-256. | 24 // Diffie-Hellman on NIST P-256. |
30 class NET_EXPORT_PRIVATE P256KeyExchange : public KeyExchange { | 25 class NET_EXPORT_PRIVATE P256KeyExchange : public KeyExchange { |
31 public: | 26 public: |
32 ~P256KeyExchange() override; | 27 ~P256KeyExchange() override; |
33 | 28 |
34 // New creates a new key exchange object from a private key. If | 29 // New creates a new key exchange object from a private key. If |
(...skipping 17 matching lines...) Expand all Loading... | |
52 // A P-256 field element consists of 32 bytes. | 47 // A P-256 field element consists of 32 bytes. |
53 kP256FieldBytes = 32, | 48 kP256FieldBytes = 32, |
54 // A P-256 point in uncompressed form consists of 0x04 (to denote | 49 // A P-256 point in uncompressed form consists of 0x04 (to denote |
55 // that the point is uncompressed) followed by two, 32-byte field | 50 // that the point is uncompressed) followed by two, 32-byte field |
56 // elements. | 51 // elements. |
57 kUncompressedP256PointBytes = 1 + 2 * kP256FieldBytes, | 52 kUncompressedP256PointBytes = 1 + 2 * kP256FieldBytes, |
58 // The first byte in an uncompressed P-256 point. | 53 // The first byte in an uncompressed P-256 point. |
59 kUncompressedECPointForm = 0x04, | 54 kUncompressedECPointForm = 0x04, |
60 }; | 55 }; |
61 | 56 |
62 #if defined(USE_OPENSSL) | |
63 // P256KeyExchange takes ownership of |private_key|, and expects | 57 // P256KeyExchange takes ownership of |private_key|, and expects |
64 // |public_key| consists of |kUncompressedP256PointBytes| bytes. | 58 // |public_key| consists of |kUncompressedP256PointBytes| bytes. |
65 P256KeyExchange(EC_KEY* private_key, const uint8_t* public_key); | 59 P256KeyExchange(EC_KEY* private_key, const uint8_t* public_key); |
66 | 60 |
67 crypto::ScopedEC_KEY private_key_; | 61 crypto::ScopedEC_KEY private_key_; |
68 #else | |
69 // P256KeyExchange takes ownership of |key_pair|, and expects | |
70 // |public_key| consists of |kUncompressedP256PointBytes| bytes. | |
71 P256KeyExchange(crypto::ECPrivateKey* key_pair, const uint8_t* public_key); | |
72 | |
73 scoped_ptr<crypto::ECPrivateKey> key_pair_; | |
74 #endif | |
75 // The public key stored as an uncompressed P-256 point. | 62 // The public key stored as an uncompressed P-256 point. |
76 uint8_t public_key_[kUncompressedP256PointBytes]; | 63 uint8_t public_key_[kUncompressedP256PointBytes]; |
77 | 64 |
78 DISALLOW_COPY_AND_ASSIGN(P256KeyExchange); | 65 DISALLOW_COPY_AND_ASSIGN(P256KeyExchange); |
79 }; | 66 }; |
80 | 67 |
81 } // namespace net | 68 } // namespace net |
82 #endif // NET_QUIC_CRYPTO_P256_KEY_EXCHANGE_H_ | 69 #endif // NET_QUIC_CRYPTO_P256_KEY_EXCHANGE_H_ |
OLD | NEW |