| 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> |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 // |private_key| is invalid, nullptr is returned. | 35 // |private_key| is invalid, nullptr is returned. |
| 36 static P256KeyExchange* New(base::StringPiece private_key); | 36 static P256KeyExchange* New(base::StringPiece private_key); |
| 37 | 37 |
| 38 // |NewPrivateKey| returns a private key, suitable for passing to |New|. | 38 // |NewPrivateKey| returns a private key, suitable for passing to |New|. |
| 39 // If |NewPrivateKey| can't generate a private key, it returns an empty | 39 // If |NewPrivateKey| can't generate a private key, it returns an empty |
| 40 // string. | 40 // string. |
| 41 static std::string NewPrivateKey(); | 41 static std::string NewPrivateKey(); |
| 42 | 42 |
| 43 // KeyExchange interface. | 43 // KeyExchange interface. |
| 44 KeyExchange* NewKeyPair(QuicRandom* rand) const override; | 44 KeyExchange* NewKeyPair(QuicRandom* rand) const override; |
| 45 bool CalculateSharedKey(const base::StringPiece& peer_public_value, | 45 bool CalculateSharedKey(base::StringPiece peer_public_value, |
| 46 std::string* shared_key) const override; | 46 std::string* shared_key) const override; |
| 47 base::StringPiece public_value() const override; | 47 base::StringPiece public_value() const override; |
| 48 QuicTag tag() const override; | 48 QuicTag tag() const override; |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 enum { | 51 enum { |
| 52 // A P-256 field element consists of 32 bytes. | 52 // A P-256 field element consists of 32 bytes. |
| 53 kP256FieldBytes = 32, | 53 kP256FieldBytes = 32, |
| 54 // A P-256 point in uncompressed form consists of 0x04 (to denote | 54 // A P-256 point in uncompressed form consists of 0x04 (to denote |
| 55 // that the point is uncompressed) followed by two, 32-byte field | 55 // that the point is uncompressed) followed by two, 32-byte field |
| (...skipping 17 matching lines...) Expand all Loading... |
| 73 scoped_ptr<crypto::ECPrivateKey> key_pair_; | 73 scoped_ptr<crypto::ECPrivateKey> key_pair_; |
| 74 #endif | 74 #endif |
| 75 // The public key stored as an uncompressed P-256 point. | 75 // The public key stored as an uncompressed P-256 point. |
| 76 uint8_t public_key_[kUncompressedP256PointBytes]; | 76 uint8_t public_key_[kUncompressedP256PointBytes]; |
| 77 | 77 |
| 78 DISALLOW_COPY_AND_ASSIGN(P256KeyExchange); | 78 DISALLOW_COPY_AND_ASSIGN(P256KeyExchange); |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 } // namespace net | 81 } // namespace net |
| 82 #endif // NET_QUIC_CRYPTO_P256_KEY_EXCHANGE_H_ | 82 #endif // NET_QUIC_CRYPTO_P256_KEY_EXCHANGE_H_ |
| OLD | NEW |