diff options
author | lloyd <[email protected]> | 2010-03-30 02:24:38 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-03-30 02:24:38 +0000 |
commit | 6d141cd765d840d8bbfdaaa8154494d3c9ecce50 (patch) | |
tree | bf2ce82c1eb28cd4257a16be750faf747a24bdf6 /src/ssl | |
parent | fd61747c28071c67dafbe7a4e8d8e20cb869dc46 (diff) |
Rename pad_amount to block_size, more accurate/descriptive
Diffstat (limited to 'src/ssl')
-rw-r--r-- | src/ssl/rec_read.cpp | 12 | ||||
-rw-r--r-- | src/ssl/rec_wri.cpp | 16 | ||||
-rw-r--r-- | src/ssl/tls_record.h | 4 |
3 files changed, 20 insertions, 12 deletions
diff --git a/src/ssl/rec_read.cpp b/src/ssl/rec_read.cpp index 11dedc41c..4a042c28b 100644 --- a/src/ssl/rec_read.cpp +++ b/src/ssl/rec_read.cpp @@ -19,7 +19,8 @@ void Record_Reader::reset() { cipher.reset(); mac.reset(); - mac_size = pad_amount = 0; + mac_size = 0; + block_size = 0; major = minor = 0; seq_no = 0; } @@ -70,12 +71,12 @@ void Record_Reader::set_keys(const CipherSuite& suite, const SessionKeys& keys, cipher_algo + "/CBC/NoPadding", cipher_key, iv, DECRYPTION) ); - pad_amount = block_size_of(cipher_algo); + block_size = block_size_of(cipher_algo); } else if(have_stream_cipher(cipher_algo)) { cipher.append(get_cipher(cipher_algo, cipher_key, DECRYPTION)); - pad_amount = 0; + block_size = 0; } else throw Invalid_Argument("Record_Reader: Unknown cipher " + cipher_algo); @@ -149,14 +150,15 @@ u32bit Record_Reader::get_record(byte& msg_type, SecureVector<byte> plaintext = cipher.read_all(Pipe::LAST_MESSAGE); u32bit pad_size = 0; - if(pad_amount) + + if(block_size) { byte pad_value = plaintext[plaintext.size()-1]; pad_size = pad_value + 1; if(version == SSL_V3) { - if(pad_value > pad_amount) + if(pad_value > block_size) throw TLS_Exception(BAD_RECORD_MAC, "Record_Reader: Bad padding"); } diff --git a/src/ssl/rec_wri.cpp b/src/ssl/rec_wri.cpp index 0e30da759..dc51a06b0 100644 --- a/src/ssl/rec_wri.cpp +++ b/src/ssl/rec_wri.cpp @@ -28,9 +28,14 @@ void Record_Writer::reset() { cipher.reset(); mac.reset(); + buffer.clear(); + buf_pos = 0; + major = minor = buf_type = 0; - pad_amount = mac_size = buf_pos = 0; + block_size = 0; + mac_size = 0; + seq_no = 0; } @@ -80,12 +85,12 @@ void Record_Writer::set_keys(const CipherSuite& suite, const SessionKeys& keys, cipher_algo + "/CBC/NoPadding", cipher_key, iv, ENCRYPTION) ); - pad_amount = block_size_of(cipher_algo); + block_size = block_size_of(cipher_algo); } else if(have_stream_cipher(cipher_algo)) { cipher.append(get_cipher(cipher_algo, cipher_key, ENCRYPTION)); - pad_amount = 0; + block_size = 0; } else throw Invalid_Argument("Record_Writer: Unknown cipher " + cipher_algo); @@ -199,10 +204,11 @@ void Record_Writer::send_record(byte type, const byte buf[], u32bit length) cipher.start_msg(); cipher.write(buf, length); cipher.write(buf_mac); - if(pad_amount) + + if(block_size) { u32bit pad_val = - (pad_amount - (1 + length + buf_mac.size())) % pad_amount; + (block_size - (1 + length + buf_mac.size())) % block_size; for(u32bit j = 0; j != pad_val + 1; j++) cipher.write(pad_val); diff --git a/src/ssl/tls_record.h b/src/ssl/tls_record.h index 358051b35..c3bfcc14e 100644 --- a/src/ssl/tls_record.h +++ b/src/ssl/tls_record.h @@ -44,7 +44,7 @@ class BOTAN_DLL Record_Writer Socket& socket; Pipe cipher, mac; SecureVector<byte> buffer; - u32bit pad_amount, mac_size, buf_pos; + u32bit block_size, mac_size, buf_pos; u64bit seq_no; byte major, minor, buf_type; }; @@ -80,7 +80,7 @@ class BOTAN_DLL Record_Reader SecureQueue input_queue; Pipe cipher, mac; - u32bit pad_amount, mac_size; + u32bit block_size, mac_size; u64bit seq_no; byte major, minor; }; |