OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_SPAKE_H_ | 5 #ifndef CRYPTO_P224_SPAKE_H_ |
6 #define CRYPTO_P224_SPAKE_H_ | 6 #define CRYPTO_P224_SPAKE_H_ |
7 | 7 |
8 #include <base/strings/string_piece.h> | 8 #include <base/strings/string_piece.h> |
9 #include <crypto/p224.h> | 9 #include <crypto/p224.h> |
10 #include <crypto/sha2.h> | 10 #include <crypto/sha2.h> |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 // ProcessMessage processes a message which must have been generated by a | 61 // ProcessMessage processes a message which must have been generated by a |
62 // call to GetMessage() by the other party. | 62 // call to GetMessage() by the other party. |
63 Result ProcessMessage(const base::StringPiece& message); | 63 Result ProcessMessage(const base::StringPiece& message); |
64 | 64 |
65 // In the event that ProcessMessage() returns kResultFailed, error will | 65 // In the event that ProcessMessage() returns kResultFailed, error will |
66 // return a human readable error message. | 66 // return a human readable error message. |
67 const std::string& error() const; | 67 const std::string& error() const; |
68 | 68 |
69 // The key established as result of the key exchange. Must be called | 69 // The key established as result of the key exchange. Must be called |
70 // at then end after ProcessMessage() returns kResultSuccess. | 70 // at then end after ProcessMessage() returns kResultSuccess. |
71 const std::string& GetKey(); | 71 const std::string& GetKey() const; |
| 72 |
| 73 // The key established as result of the key exchange. Can be called after |
| 74 // the first ProcessMessage() |
| 75 const std::string& GetUnverifiedKey() const; |
72 | 76 |
73 private: | 77 private: |
74 // The authentication state machine is very simple and each party proceeds | 78 // The authentication state machine is very simple and each party proceeds |
75 // through each of these states, in order. | 79 // through each of these states, in order. |
76 enum State { | 80 enum State { |
77 kStateInitial, | 81 kStateInitial, |
78 kStateRecvDH, | 82 kStateRecvDH, |
79 kStateSendHash, | 83 kStateSendHash, |
80 kStateRecvHash, | 84 kStateRecvHash, |
81 kStateDone, | 85 kStateDone, |
(...skipping 23 matching lines...) Expand all Loading... |
105 // expected_authenticator_ is used to store the hash value expected from the | 109 // expected_authenticator_ is used to store the hash value expected from the |
106 // other party. | 110 // other party. |
107 uint8 expected_authenticator_[kSHA256Length]; | 111 uint8 expected_authenticator_[kSHA256Length]; |
108 | 112 |
109 std::string key_; | 113 std::string key_; |
110 }; | 114 }; |
111 | 115 |
112 } // namespace crypto | 116 } // namespace crypto |
113 | 117 |
114 #endif // CRYPTO_P224_SPAKE_H_ | 118 #endif // CRYPTO_P224_SPAKE_H_ |
OLD | NEW |