diff options
author | lloyd <[email protected]> | 2011-12-27 20:00:54 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2011-12-27 20:00:54 +0000 |
commit | cd9b85ed4124af2ceb9a91def5dc57ac23938f77 (patch) | |
tree | 680ad4e491c8741d94cc9eca0811606a2833f8f7 /src | |
parent | 4f8d9afee56cb65f0fde306d9af8a2d0aea37c53 (diff) |
Session deserialization
Diffstat (limited to 'src')
-rw-r--r-- | src/tls/tls_magic.h | 2 | ||||
-rw-r--r-- | src/tls/tls_session_state.cpp | 29 | ||||
-rw-r--r-- | src/tls/tls_session_state.h | 2 |
3 files changed, 27 insertions, 6 deletions
diff --git a/src/tls/tls_magic.h b/src/tls/tls_magic.h index 7913b576c..070fe4dd6 100644 --- a/src/tls/tls_magic.h +++ b/src/tls/tls_magic.h @@ -26,7 +26,7 @@ enum Version_Code { TLS_V11 = 0x0302 }; -enum Connection_Side { CLIENT, SERVER }; +enum Connection_Side { CLIENT = 1, SERVER = 2 }; enum Record_Type { CONNECTION_CLOSED = 0, diff --git a/src/tls/tls_session_state.cpp b/src/tls/tls_session_state.cpp index 1423ac09d..05d5d2dbb 100644 --- a/src/tls/tls_session_state.cpp +++ b/src/tls/tls_session_state.cpp @@ -9,7 +9,6 @@ #include <botan/der_enc.h> #include <botan/ber_dec.h> #include <botan/asn1_str.h> -#include <botan/bigint.h> #include <ctime> namespace Botan { @@ -39,7 +38,29 @@ TLS_Session_Params::TLS_Session_Params(const MemoryRegion<byte>& session_id, TLS_Session_Params::TLS_Session_Params(const byte ber[], size_t ber_len) { - // todo + BER_Decoder decoder(ber, ber_len); + + byte side_code = 0; + ASN1_String sni_hostname_str; + ASN1_String srp_identity_str; + + BER_Decoder(ber, ber_len) + .decode_and_check(static_cast<size_t>(TLS_SESSION_PARAM_STRUCT_VERSION), + "Unknown version in session structure") + .decode(session_id, OCTET_STRING) + .decode_integer_type(session_start_time) + .decode_integer_type(version) + .decode_integer_type(ciphersuite) + .decode_integer_type(compression_method) + .decode_integer_type(side_code) + .decode(master_secret, OCTET_STRING) + .decode(peer_certificate, OCTET_STRING) + .decode(sni_hostname_str) + .decode(srp_identity_str); + + sni_hostname = sni_hostname_str.value(); + srp_identity = srp_identity_str.value(); + connection_side = static_cast<Connection_Side>(side_code); } SecureVector<byte> TLS_Session_Params::BER_encode() const @@ -48,11 +69,11 @@ SecureVector<byte> TLS_Session_Params::BER_encode() const .start_cons(SEQUENCE) .encode(static_cast<size_t>(TLS_SESSION_PARAM_STRUCT_VERSION)) .encode(session_id, OCTET_STRING) - .encode(BigInt(session_start_time)) + .encode(static_cast<size_t>(session_start_time)) .encode(static_cast<size_t>(version)) .encode(static_cast<size_t>(ciphersuite)) .encode(static_cast<size_t>(compression_method)) - .encode(static_cast<size_t>((connection_side == SERVER) ? 1 : 2)) + .encode(static_cast<size_t>(connection_side)) .encode(master_secret, OCTET_STRING) .encode(peer_certificate, OCTET_STRING) .encode(ASN1_String(sni_hostname, UTF8_STRING)) diff --git a/src/tls/tls_session_state.h b/src/tls/tls_session_state.h index 20cbb7f83..f42a7ac11 100644 --- a/src/tls/tls_session_state.h +++ b/src/tls/tls_session_state.h @@ -60,7 +60,7 @@ struct BOTAN_DLL TLS_Session_Params */ SecureVector<byte> BER_encode() const; - time_t session_start_time; + u64bit session_start_time; MemoryVector<byte> session_id; SecureVector<byte> master_secret; |