diff options
author | lloyd <[email protected]> | 2010-09-15 13:44:42 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-09-15 13:44:42 +0000 |
commit | 180c5358cb31e9c003cada3705bb30cf01732878 (patch) | |
tree | 951038dfaf2c33bcee5e27c4b1d2980eb35494a3 /src | |
parent | a9d0f37596e5413cae45f32740738c5c68abcce1 (diff) |
Update all uses of MemoryRegion::append to use either push_back or operator+=
Diffstat (limited to 'src')
31 files changed, 142 insertions, 147 deletions
diff --git a/src/asn1/alg_id.cpp b/src/asn1/alg_id.cpp index 94709ba16..b48db3e50 100644 --- a/src/asn1/alg_id.cpp +++ b/src/asn1/alg_id.cpp @@ -42,7 +42,7 @@ AlgorithmIdentifier::AlgorithmIdentifier(const OID& alg_id, oid = alg_id; if(option == USE_NULL_PARAM) - parameters.append(DER_NULL, sizeof(DER_NULL)); + parameters += std::make_pair(DER_NULL, sizeof(DER_NULL)); } /* @@ -55,7 +55,7 @@ AlgorithmIdentifier::AlgorithmIdentifier(const std::string& alg_id, oid = OIDS::lookup(alg_id); if(option == USE_NULL_PARAM) - parameters.append(DER_NULL, sizeof(DER_NULL)); + parameters += std::make_pair(DER_NULL, sizeof(DER_NULL)); } /* diff --git a/src/asn1/asn1_oid.cpp b/src/asn1/asn1_oid.cpp index 6c420ff0d..820492e18 100644 --- a/src/asn1/asn1_oid.cpp +++ b/src/asn1/asn1_oid.cpp @@ -130,20 +130,20 @@ void OID::encode_into(DER_Encoder& der) const throw Invalid_Argument("OID::encode_into: OID is invalid"); MemoryVector<byte> encoding; - encoding.append(40 * id[0] + id[1]); + encoding.push_back(40 * id[0] + id[1]); for(u32bit j = 2; j != id.size(); ++j) { if(id[j] == 0) - encoding.append(0); + encoding.push_back(0); else { u32bit blocks = high_bit(id[j]) + 6; blocks = (blocks - (blocks % 7)) / 7; for(u32bit k = 0; k != blocks - 1; ++k) - encoding.append(0x80 | ((id[j] >> 7*(blocks-k-1)) & 0x7F)); - encoding.append(id[j] & 0x7F); + encoding.push_back(0x80 | ((id[j] >> 7*(blocks-k-1)) & 0x7F)); + encoding.push_back(id[j] & 0x7F); } } der.add_object(OBJECT_ID, UNIVERSAL, encoding); diff --git a/src/asn1/ber_dec.cpp b/src/asn1/ber_dec.cpp index f2873c177..860003440 100644 --- a/src/asn1/ber_dec.cpp +++ b/src/asn1/ber_dec.cpp @@ -106,7 +106,8 @@ u32bit find_eoc(DataSource* ber) const u32bit got = ber->peek(&buffer[0], buffer.size(), data.size()); if(got == 0) break; - data.append(&buffer[0], got); + + data += std::make_pair(&buffer[0], got); } DataSource_Memory source(data); @@ -171,7 +172,7 @@ BER_Decoder& BER_Decoder::raw_bytes(MemoryRegion<byte>& out) out.clear(); byte buf; while(source->read_byte(buf)) - out.append(buf); + out.push_back(buf); return (*this); } diff --git a/src/asn1/der_enc.cpp b/src/asn1/der_enc.cpp index 0ce633c7a..affb40372 100644 --- a/src/asn1/der_enc.cpp +++ b/src/asn1/der_enc.cpp @@ -28,16 +28,16 @@ SecureVector<byte> encode_tag(ASN1_Tag type_tag, ASN1_Tag class_tag) SecureVector<byte> encoded_tag; if(type_tag <= 30) - encoded_tag.append(static_cast<byte>(type_tag | class_tag)); + encoded_tag.push_back(static_cast<byte>(type_tag | class_tag)); else { u32bit blocks = high_bit(type_tag) + 6; blocks = (blocks - (blocks % 7)) / 7; - encoded_tag.append(class_tag | 0x1F); + encoded_tag.push_back(class_tag | 0x1F); for(u32bit k = 0; k != blocks - 1; ++k) - encoded_tag.append(0x80 | ((type_tag >> 7*(blocks-k-1)) & 0x7F)); - encoded_tag.append(type_tag & 0x7F); + encoded_tag.push_back(0x80 | ((type_tag >> 7*(blocks-k-1)) & 0x7F)); + encoded_tag.push_back(type_tag & 0x7F); } return encoded_tag; @@ -50,13 +50,13 @@ SecureVector<byte> encode_length(u32bit length) { SecureVector<byte> encoded_length; if(length <= 127) - encoded_length.append(static_cast<byte>(length)); + encoded_length.push_back(static_cast<byte>(length)); else { const u32bit top_byte = significant_bytes(length); - encoded_length.append(static_cast<byte>(0x80 | top_byte)); + encoded_length.push_back(static_cast<byte>(0x80 | top_byte)); for(u32bit j = 4-top_byte; j != 4; ++j) - encoded_length.append(get_byte(j, length)); + encoded_length.push_back(get_byte(j, length)); } return encoded_length; } @@ -70,24 +70,21 @@ SecureVector<byte> DER_Encoder::DER_Sequence::get_contents() { const ASN1_Tag real_class_tag = ASN1_Tag(class_tag | CONSTRUCTED); - SecureVector<byte> encoded_tag = encode_tag(type_tag, real_class_tag); - if(type_tag == SET) { std::sort(set_contents.begin(), set_contents.end()); for(u32bit j = 0; j != set_contents.size(); ++j) - contents.append(set_contents[j]); + contents += set_contents[j]; set_contents.clear(); } - SecureVector<byte> encoded_length = encode_length(contents.size()); - - SecureVector<byte> retval; - retval.append(encoded_tag); - retval.append(encoded_length); - retval.append(contents); + SecureVector<byte> result; + result += encode_tag(type_tag, real_class_tag); + result += encode_length(contents.size()); + result += contents; contents.clear(); - return retval; + + return result; } /* @@ -98,7 +95,7 @@ void DER_Encoder::DER_Sequence::add_bytes(const byte data[], u32bit length) if(type_tag == SET) set_contents.push_back(SecureVector<byte>(data, length)); else - contents.append(data, length); + contents += std::make_pair(data, length); } /* @@ -191,7 +188,7 @@ DER_Encoder& DER_Encoder::raw_bytes(const byte bytes[], u32bit length) if(subsequences.size()) subsequences[subsequences.size()-1].add_bytes(bytes, length); else - contents.append(bytes, length); + contents += std::make_pair(bytes, length); return (*this); } @@ -314,8 +311,8 @@ DER_Encoder& DER_Encoder::encode(const byte bytes[], u32bit length, if(real_type == BIT_STRING) { SecureVector<byte> encoded; - encoded.append(0); - encoded.append(bytes, length); + encoded.push_back(0); + encoded += std::make_pair(bytes, length); return add_object(type_tag, class_tag, encoded); } else @@ -347,13 +344,10 @@ DER_Encoder& DER_Encoder::encode(const ASN1_Object& obj) DER_Encoder& DER_Encoder::add_object(ASN1_Tag type_tag, ASN1_Tag class_tag, const byte rep[], u32bit length) { - SecureVector<byte> encoded_tag = encode_tag(type_tag, class_tag); - SecureVector<byte> encoded_length = encode_length(length); - SecureVector<byte> buffer; - buffer.append(encoded_tag); - buffer.append(encoded_length); - buffer.append(rep, length); + buffer += encode_tag(type_tag, class_tag); + buffer += encode_length(length); + buffer += std::make_pair(rep, length); return raw_bytes(buffer); } diff --git a/src/cert/cvc/asn1_eac_tm.cpp b/src/cert/cvc/asn1_eac_tm.cpp index b048d3aa5..0eaca49d6 100644 --- a/src/cert/cvc/asn1_eac_tm.cpp +++ b/src/cert/cvc/asn1_eac_tm.cpp @@ -23,15 +23,15 @@ SecureVector<byte> enc_two_digit(u32bit in) SecureVector<byte> result; in %= 100; if (in < 10) - result.append(0x00); + result.push_back(0x00); else { u32bit y_first_pos = round_down<u32bit>(in, 10) / 10; - result.append(static_cast<byte>(y_first_pos)); + result.push_back(static_cast<byte>(y_first_pos)); } u32bit y_sec_pos = in % 10; - result.append(static_cast<byte>(y_sec_pos)); + result.push_back(static_cast<byte>(y_sec_pos)); return result; } @@ -300,9 +300,9 @@ u32bit EAC_Time::get_day() const SecureVector<byte> EAC_Time::encoded_eac_time() const { SecureVector<byte> result; - result.append(enc_two_digit(year)); - result.append(enc_two_digit(month)); - result.append(enc_two_digit(day)); + result += enc_two_digit(year); + result += enc_two_digit(month); + result += enc_two_digit(day); return result; } diff --git a/src/cert/cvc/cvc_ado.cpp b/src/cert/cvc/cvc_ado.cpp index 8c38e90ae..38f51e8dc 100644 --- a/src/cert/cvc/cvc_ado.cpp +++ b/src/cert/cvc/cvc_ado.cpp @@ -87,12 +87,8 @@ void EAC1_1_ADO::decode_info(DataSource& source, .end_cons() .get_contents(); - SecureVector<byte> enc_car = DER_Encoder() - .encode(car) - .get_contents(); - res_tbs_bits = enc_cert; - res_tbs_bits.append(enc_car); + res_tbs_bits += DER_Encoder().encode(car).get_contents(); res_sig = decode_concatenation(concat_sig); } diff --git a/src/cert/cvc/cvc_cert.cpp b/src/cert/cvc/cvc_cert.cpp index 9cc2bb7e5..536520b37 100644 --- a/src/cert/cvc/cvc_cert.cpp +++ b/src/cert/cvc/cvc_cert.cpp @@ -106,10 +106,10 @@ EAC1_1_CVC make_cvc_cert(PK_Signer& signer, { OID chat_oid(OIDS::lookup("CertificateHolderAuthorizationTemplate")); MemoryVector<byte> enc_chat_val; - enc_chat_val.append(holder_auth_templ); + enc_chat_val.push_back(holder_auth_templ); MemoryVector<byte> enc_cpi; - enc_cpi.append(0x00); + enc_cpi.push_back(0x00); MemoryVector<byte> tbs = DER_Encoder() .encode(enc_cpi, OCTET_STRING, ASN1_Tag(41), APPLICATION) // cpi .encode(car) diff --git a/src/cert/cvc/cvc_self.cpp b/src/cert/cvc/cvc_self.cpp index fbd042676..f1d539923 100644 --- a/src/cert/cvc/cvc_self.cpp +++ b/src/cert/cvc/cvc_self.cpp @@ -136,7 +136,7 @@ EAC1_1_Req create_cvc_req(Private_Key const& key, MemoryVector<byte> enc_public_key = eac_1_1_encoding(priv_key, sig_algo.oid); MemoryVector<byte> enc_cpi; - enc_cpi.append(0x00); + enc_cpi.push_back(0x00); MemoryVector<byte> tbs = DER_Encoder() .encode(enc_cpi, OCTET_STRING, ASN1_Tag(41), APPLICATION) .raw_bytes(enc_public_key) @@ -166,8 +166,10 @@ EAC1_1_ADO create_ado_req(Private_Key const& key, std::string padding_and_hash = padding_and_hash_from_oid(req.signature_algorithm().oid); PK_Signer signer(*priv_key, padding_and_hash); SecureVector<byte> tbs_bits = req.BER_encode(); - tbs_bits.append(DER_Encoder().encode(car).get_contents()); - MemoryVector<byte> signed_cert = EAC1_1_ADO::make_signed(signer, tbs_bits, rng); + tbs_bits += DER_Encoder().encode(car).get_contents(); + + MemoryVector<byte> signed_cert = + EAC1_1_ADO::make_signed(signer, tbs_bits, rng); DataSource_Memory source(signed_cert); return EAC1_1_ADO(source); diff --git a/src/cert/cvc/ecdsa_sig.cpp b/src/cert/cvc/ecdsa_sig.cpp index 6a44f6803..dba2ece8d 100644 --- a/src/cert/cvc/ecdsa_sig.cpp +++ b/src/cert/cvc/ecdsa_sig.cpp @@ -38,7 +38,7 @@ MemoryVector<byte> ECDSA_Signature::get_concatenation() const SecureVector<byte> sv_s = BigInt::encode_1363(m_s, enc_len); SecureVector<byte> result(sv_r); - result.append(sv_s); + result += sv_s; return result; } diff --git a/src/cert/x509/x509_ext.cpp b/src/cert/x509/x509_ext.cpp index 3e51d1fa2..bb4bc1775 100644 --- a/src/cert/x509/x509_ext.cpp +++ b/src/cert/x509/x509_ext.cpp @@ -223,12 +223,12 @@ MemoryVector<byte> Key_Usage::encode_inner() const const u32bit unused_bits = low_bit(constraints) - 1; SecureVector<byte> der; - der.append(BIT_STRING); - der.append(2 + ((unused_bits < 8) ? 1 : 0)); - der.append(unused_bits % 8); - der.append((constraints >> 8) & 0xFF); + der.push_back(BIT_STRING); + der.push_back(2 + ((unused_bits < 8) ? 1 : 0)); + der.push_back(unused_bits % 8); + der.push_back((constraints >> 8) & 0xFF); if(constraints & 0xFF) - der.append(constraints & 0xFF); + der.push_back(constraints & 0xFF); return der; } diff --git a/src/cms/cms_algo.cpp b/src/cms/cms_algo.cpp index 8c6806699..458e8e3f5 100644 --- a/src/cms/cms_algo.cpp +++ b/src/cms/cms_algo.cpp @@ -35,7 +35,7 @@ SecureVector<byte> do_rfc3217_wrap(RandomNumberGenerator& rng, void write(const byte data[], u32bit length) { - buf.append(data, length); + buf += std::make_pair(data, length); } void end_msg() { @@ -43,7 +43,8 @@ SecureVector<byte> do_rfc3217_wrap(RandomNumberGenerator& rng, send(buf[buf.size()-j-1]); buf.clear(); } - Flip_Bytes(const SecureVector<byte>& prefix) { buf.append(prefix); } + + Flip_Bytes(const SecureVector<byte>& prefix) : buf(prefix) {} private: SecureVector<byte> buf; }; @@ -98,10 +99,10 @@ SecureVector<byte> CMS_Encoder::wrap_key(RandomNumberGenerator& rng, throw Encoding_Error("CMS: 128-bit KEKs must be used with " + cipher); SecureVector<byte> lcekpad; - lcekpad.append((byte)cek.length()); - lcekpad.append(cek.bits_of()); + lcekpad.push_back((byte)cek.length()); + lcekpad += cek.bits_of(); while(lcekpad.size() % 8) - lcekpad.append(rng.next_byte()); + lcekpad.push_back(rng.next_byte()); return do_rfc3217_wrap(rng, cipher, kek, lcekpad); } #endif diff --git a/src/constructs/tss/tss.cpp b/src/constructs/tss/tss.cpp index 644e8d857..e5c245873 100644 --- a/src/constructs/tss/tss.cpp +++ b/src/constructs/tss/tss.cpp @@ -138,20 +138,20 @@ RTSS_Share::split(byte M, byte N, // Create RTSS header in each share for(byte i = 0; i != N; ++i) { - shares[i].contents.append(identifier, 16); - shares[i].contents.append(rtss_hash_id(hash.name())); - shares[i].contents.append(M); - shares[i].contents.append(get_byte(0, S_len)); - shares[i].contents.append(get_byte(1, S_len)); + shares[i].contents += std::make_pair(identifier, 16); + shares[i].contents += rtss_hash_id(hash.name()); + shares[i].contents += M; + shares[i].contents += get_byte(0, S_len); + shares[i].contents += get_byte(1, S_len); } // Choose sequential values for X starting from 1 for(byte i = 0; i != N; ++i) - shares[i].contents.append(i+1); + shares[i].contents.push_back(i+1); // secret = S || H(S) SecureVector<byte> secret(S, S_len); - secret.append(hash.process(S, S_len)); + secret += hash.process(S, S_len); for(size_t i = 0; i != secret.size(); ++i) { @@ -171,7 +171,7 @@ RTSS_Share::split(byte M, byte N, X_i = gfp_mul(X_i, X); } - shares[j].contents.append(sum); + shares[j].contents.push_back(sum); } } @@ -241,7 +241,7 @@ RTSS_Share::reconstruct(const std::vector<RTSS_Share>& shares) r ^= gfp_mul(V[k], r2); } - secret.append(r); + secret.push_back(r); } if(secret.size() != secret_len + hash->OUTPUT_LENGTH) diff --git a/src/filters/filter.cpp b/src/filters/filter.cpp index d7e17e82a..a9a307dbc 100644 --- a/src/filters/filter.cpp +++ b/src/filters/filter.cpp @@ -38,7 +38,7 @@ void Filter::send(const byte input[], u32bit length) } if(nothing_attached) - write_queue.append(input, length); + write_queue += std::make_pair(input, length); else write_queue.clear(); } diff --git a/src/filters/pk_filts/pk_filts.cpp b/src/filters/pk_filts/pk_filts.cpp index 9de0da679..7e566e4fa 100644 --- a/src/filters/pk_filts/pk_filts.cpp +++ b/src/filters/pk_filts/pk_filts.cpp @@ -14,7 +14,7 @@ namespace Botan { */ void PK_Encryptor_Filter::write(const byte input[], u32bit length) { - buffer.append(input, length); + buffer += std::make_pair(input, length); } /* @@ -31,7 +31,7 @@ void PK_Encryptor_Filter::end_msg() */ void PK_Decryptor_Filter::write(const byte input[], u32bit length) { - buffer.append(input, length); + buffer += std::make_pair(input, length); } /* diff --git a/src/kdf/kdf2/kdf2.cpp b/src/kdf/kdf2/kdf2.cpp index 8106ba07d..14cc29a31 100644 --- a/src/kdf/kdf2/kdf2.cpp +++ b/src/kdf/kdf2/kdf2.cpp @@ -29,7 +29,7 @@ SecureVector<byte> KDF2::derive(u32bit out_len, SecureVector<byte> hash_result = hash->final(); u32bit added = std::min<u32bit>(hash_result.size(), out_len); - output.append(&hash_result[0], added); + output += std::make_pair(&hash_result[0], added); out_len -= added; ++counter; diff --git a/src/kdf/x942_prf/prf_x942.cpp b/src/kdf/x942_prf/prf_x942.cpp index d9ee09d20..35402ad28 100644 --- a/src/kdf/x942_prf/prf_x942.cpp +++ b/src/kdf/x942_prf/prf_x942.cpp @@ -69,7 +69,8 @@ SecureVector<byte> X942_PRF::derive(u32bit key_len, ); SecureVector<byte> digest = hash.final(); - key.append(digest, std::min(digest.size(), key_len - key.size())); + const u32bit needed = std::min(digest.size(), key_len - key.size()); + key += std::make_pair(&digest[0], needed); ++counter; } diff --git a/src/math/bigint/big_code.cpp b/src/math/bigint/big_code.cpp index 1e35edcc9..25c27bd33 100644 --- a/src/math/bigint/big_code.cpp +++ b/src/math/bigint/big_code.cpp @@ -112,10 +112,9 @@ BigInt BigInt::decode(const byte buf[], u32bit length, Base base) const char buf0_with_leading_0[2] = { '0', buf[0] }; binary = hex_decode(buf0_with_leading_0, 2); - binary.append(hex_decode(reinterpret_cast<const char*>(&buf[1]), - length - 1, - false)); - + binary += hex_decode(reinterpret_cast<const char*>(&buf[1]), + length - 1, + false); } else binary = hex_decode(reinterpret_cast<const char*>(buf), diff --git a/src/pk_pad/emsa3/emsa3.cpp b/src/pk_pad/emsa3/emsa3.cpp index 21ef072ef..0fa9d5429 100644 --- a/src/pk_pad/emsa3/emsa3.cpp +++ b/src/pk_pad/emsa3/emsa3.cpp @@ -109,7 +109,7 @@ EMSA3::~EMSA3() */ void EMSA3_Raw::update(const byte input[], u32bit length) { - message.append(input, length); + message += std::make_pair(input, length); } /* diff --git a/src/pk_pad/emsa_raw/emsa_raw.cpp b/src/pk_pad/emsa_raw/emsa_raw.cpp index 696c6bc5c..4d32ef7a9 100644 --- a/src/pk_pad/emsa_raw/emsa_raw.cpp +++ b/src/pk_pad/emsa_raw/emsa_raw.cpp @@ -14,7 +14,7 @@ namespace Botan { */ void EMSA_Raw::update(const byte input[], u32bit length) { - message.append(input, length); + message += std::make_pair(input, length); } /* diff --git a/src/pubkey/dlies/dlies.cpp b/src/pubkey/dlies/dlies.cpp index f53aa71f9..80cf60ae3 100644 --- a/src/pubkey/dlies/dlies.cpp +++ b/src/pubkey/dlies/dlies.cpp @@ -47,7 +47,7 @@ SecureVector<byte> DLIES_Encryptor::enc(const byte in[], u32bit length, out.copy(my_key.size(), in, length); SecureVector<byte> vz = my_key; - vz.append(ka.derive_key(0, other_key).bits_of()); + vz += ka.derive_key(0, other_key).bits_of(); const u32bit K_LENGTH = length + mac_keylen; OctetString K = kdf->derive_key(K_LENGTH, vz); @@ -120,7 +120,7 @@ SecureVector<byte> DLIES_Decryptor::dec(const byte msg[], u32bit length) const SecureVector<byte> T(msg + my_key.size() + CIPHER_LEN, mac->OUTPUT_LENGTH); SecureVector<byte> vz(msg, my_key.size()); - vz.append(ka.derive_key(0, v).bits_of()); + vz += ka.derive_key(0, v).bits_of(); const u32bit K_LENGTH = C.size() + mac_keylen; OctetString K = kdf->derive_key(K_LENGTH, vz); diff --git a/src/pubkey/pubkey.cpp b/src/pubkey/pubkey.cpp index dc91ca908..725cdacf7 100644 --- a/src/pubkey/pubkey.cpp +++ b/src/pubkey/pubkey.cpp @@ -301,8 +301,7 @@ bool PK_Verifier::check_signature(const byte sig[], u32bit length) { BigInt sig_part; ber_sig.decode(sig_part); - real_sig.append(BigInt::encode_1363(sig_part, - op->message_part_size())); + real_sig += BigInt::encode_1363(sig_part, op->message_part_size()); ++count; } diff --git a/src/ssl/c_kex.cpp b/src/ssl/c_kex.cpp index fafb67d3d..2a5dea7b3 100644 --- a/src/ssl/c_kex.cpp +++ b/src/ssl/c_kex.cpp @@ -82,10 +82,10 @@ SecureVector<byte> Client_Key_Exchange::serialize() const if(include_length) { u16bit key_size = key_material.size(); - buf.append(get_byte(0, key_size)); - buf.append(get_byte(1, key_size)); + buf.push_back(get_byte(0, key_size)); + buf.push_back(get_byte(1, key_size)); } - buf.append(key_material); + buf += key_material; return buf; } diff --git a/src/ssl/cert_req.cpp b/src/ssl/cert_req.cpp index 7a32af03b..9cd6bd5c1 100644 --- a/src/ssl/cert_req.cpp +++ b/src/ssl/cert_req.cpp @@ -37,9 +37,9 @@ SecureVector<byte> Certificate_Req::serialize() const { SecureVector<byte> buf; - buf.append(types.size()); + buf.push_back(types.size()); for(u32bit i = 0; i != types.size(); i++) - buf.append(types[i]); + buf.push_back(types[i]); DER_Encoder encoder; for(u32bit i = 0; i != names.size(); i++) @@ -48,9 +48,9 @@ SecureVector<byte> Certificate_Req::serialize() const SecureVector<byte> der_names = encoder.get_contents(); u16bit names_size = der_names.size(); - buf.append(get_byte(0, names_size)); - buf.append(get_byte(1, names_size)); - buf.append(der_names); + buf.push_back(get_byte(0, names_size)); + buf.push_back(get_byte(1, names_size)); + buf += der_names; return buf; } @@ -109,8 +109,8 @@ SecureVector<byte> Certificate::serialize() const SecureVector<byte> raw_cert = certs[i].BER_encode(); u32bit cert_size = raw_cert.size(); for(u32bit j = 0; j != 3; j++) - buf.append(get_byte(j+1, cert_size)); - buf.append(raw_cert); + buf.push_back(get_byte(j+1, cert_size)); + buf += raw_cert; } u32bit buf_size = buf.size() - 3; diff --git a/src/ssl/cert_ver.cpp b/src/ssl/cert_ver.cpp index d1d39f74e..7c6725572 100644 --- a/src/ssl/cert_ver.cpp +++ b/src/ssl/cert_ver.cpp @@ -51,9 +51,9 @@ SecureVector<byte> Certificate_Verify::serialize() const SecureVector<byte> buf; u16bit sig_len = signature.size(); - buf.append(get_byte(0, sig_len)); - buf.append(get_byte(1, sig_len)); - buf.append(signature); + buf.push_back(get_byte(0, sig_len)); + buf.push_back(get_byte(1, sig_len)); + buf += signature; return buf; } diff --git a/src/ssl/finished.cpp b/src/ssl/finished.cpp index 6648a2c3e..86eee7fe3 100644 --- a/src/ssl/finished.cpp +++ b/src/ssl/finished.cpp @@ -86,10 +86,10 @@ SecureVector<byte> Finished::compute_verify(const MemoryRegion<byte>& secret, SecureVector<byte> input; if(side == CLIENT) - input.append(TLS_CLIENT_LABEL, sizeof(TLS_CLIENT_LABEL)); + input += std::make_pair(TLS_CLIENT_LABEL, sizeof(TLS_CLIENT_LABEL)); else - input.append(TLS_SERVER_LABEL, sizeof(TLS_SERVER_LABEL)); - input.append(hash.final()); + input += std::make_pair(TLS_SERVER_LABEL, sizeof(TLS_SERVER_LABEL)); + input += hash.final(); return prf.derive_key(12, secret, input); } diff --git a/src/ssl/handshake_hash.cpp b/src/ssl/handshake_hash.cpp index fb9f5f9f4..a9e1d8e13 100644 --- a/src/ssl/handshake_hash.cpp +++ b/src/ssl/handshake_hash.cpp @@ -24,8 +24,8 @@ SecureVector<byte> HandshakeHash::final() sha1.update(data); SecureVector<byte> output; - output.append(md5.final()); - output.append(sha1.final()); + output += md5.final(); + output += sha1.final(); return output; } @@ -58,8 +58,8 @@ SecureVector<byte> HandshakeHash::final_ssl3(const MemoryRegion<byte>& secret) sha1.update(inner_sha1); SecureVector<byte> output; - output.append(md5.final()); - output.append(sha1.final()); + output += md5.final(); + output += sha1.final(); return output; } diff --git a/src/ssl/handshake_hash.h b/src/ssl/handshake_hash.h index df50e4dfe..4c145c6c6 100644 --- a/src/ssl/handshake_hash.h +++ b/src/ssl/handshake_hash.h @@ -21,13 +21,13 @@ class BOTAN_DLL HandshakeHash { public: void update(const byte in[], u32bit length) - { data.append(in, length); } + { data += std::make_pair(in, length); } void update(const MemoryRegion<byte>& in) - { update(&in[0], in.size()); } + { data += in; } void update(byte in) - { update(&in, 1); } + { data.push_back(in); } SecureVector<byte> final(); SecureVector<byte> final_ssl3(const MemoryRegion<byte>&); diff --git a/src/ssl/hello.cpp b/src/ssl/hello.cpp index 9ee3f87b9..887d13f1f 100644 --- a/src/ssl/hello.cpp +++ b/src/ssl/hello.cpp @@ -25,7 +25,7 @@ void HandshakeMessage::send(Record_Writer& writer, HandshakeHash& hash) const send_buf[2] = get_byte(2, buf_size); send_buf[3] = get_byte(3, buf_size); - send_buf.append(buf); + send_buf += buf; hash.update(send_buf); @@ -82,25 +82,26 @@ SecureVector<byte> Client_Hello::serialize() const { SecureVector<byte> buf; - buf.append(static_cast<byte>(c_version >> 8)); - buf.append(static_cast<byte>(c_version )); - buf.append(c_random); - buf.append(static_cast<byte>(sess_id.size())); - buf.append(sess_id); + buf.push_back(static_cast<byte>(c_version >> 8)); + buf.push_back(static_cast<byte>(c_version )); + buf += c_random; + + buf.push_back(static_cast<byte>(sess_id.size())); + buf += sess_id; u16bit suites_size = 2*suites.size(); - buf.append(get_byte(0, suites_size)); - buf.append(get_byte(1, suites_size)); + buf.push_back(get_byte(0, suites_size)); + buf.push_back(get_byte(1, suites_size)); for(u32bit i = 0; i != suites.size(); i++) { - buf.append(get_byte(0, suites[i])); - buf.append(get_byte(1, suites[i])); + buf.push_back(get_byte(0, suites[i])); + buf.push_back(get_byte(1, suites[i])); } - buf.append(static_cast<byte>(comp_algos.size())); + buf.push_back(static_cast<byte>(comp_algos.size())); for(u32bit i = 0; i != comp_algos.size(); i++) - buf.append(comp_algos[i]); + buf.push_back(comp_algos[i]); return buf; } @@ -260,16 +261,17 @@ SecureVector<byte> Server_Hello::serialize() const { SecureVector<byte> buf; - buf.append(static_cast<byte>(s_version >> 8)); - buf.append(static_cast<byte>(s_version )); - buf.append(s_random); - buf.append(static_cast<byte>(sess_id.size())); - buf.append(sess_id); + buf.push_back(static_cast<byte>(s_version >> 8)); + buf.push_back(static_cast<byte>(s_version )); + buf += s_random; + + buf.push_back(static_cast<byte>(sess_id.size())); + buf += sess_id; - buf.append(get_byte(0, suite)); - buf.append(get_byte(1, suite)); + buf.push_back(get_byte(0, suite)); + buf.push_back(get_byte(1, suite)); - buf.append(comp_algo); + buf.push_back(comp_algo); return buf; } diff --git a/src/ssl/s_kex.cpp b/src/ssl/s_kex.cpp index 220ef2e0b..6e4749491 100644 --- a/src/ssl/s_kex.cpp +++ b/src/ssl/s_kex.cpp @@ -75,9 +75,9 @@ SecureVector<byte> Server_Key_Exchange::serialize() const { SecureVector<byte> buf = serialize_params(); u16bit sig_len = signature.size(); - buf.append(get_byte(0, sig_len)); - buf.append(get_byte(1, sig_len)); - buf.append(signature); + buf.push_back(get_byte(0, sig_len)); + buf.push_back(get_byte(1, sig_len)); + buf += signature; return buf; } @@ -92,9 +92,9 @@ SecureVector<byte> Server_Key_Exchange::serialize_params() const SecureVector<byte> param = BigInt::encode(params[j]); u16bit param_size = param.size(); - buf.append(get_byte(0, param_size)); - buf.append(get_byte(1, param_size)); - buf.append(param); + buf.push_back(get_byte(0, param_size)); + buf.push_back(get_byte(1, param_size)); + buf += param; } return buf; } diff --git a/src/ssl/tls_session_key.cpp b/src/ssl/tls_session_key.cpp index 138d0a77c..341ce7bb0 100644 --- a/src/ssl/tls_session_key.cpp +++ b/src/ssl/tls_session_key.cpp @@ -79,14 +79,14 @@ SymmetricKey SessionKeys::ssl3_keygen(u32bit prf_gen, SSL3_PRF prf; SecureVector<byte> salt; - salt.append(client_random); - salt.append(server_random); + salt += client_random; + salt += server_random; master_sec = prf.derive_key(48, pre_master, salt); salt.clear(); - salt.append(server_random); - salt.append(client_random); + salt += server_random; + salt += client_random; return prf.derive_key(prf_gen, master_sec, salt); } @@ -109,16 +109,16 @@ SymmetricKey SessionKeys::tls1_keygen(u32bit prf_gen, TLS_PRF prf; SecureVector<byte> salt; - salt.append(MASTER_SECRET_MAGIC, sizeof(MASTER_SECRET_MAGIC)); - salt.append(client_random); - salt.append(server_random); + salt += std::make_pair(MASTER_SECRET_MAGIC, sizeof(MASTER_SECRET_MAGIC)); + salt += client_random; + salt += server_random; master_sec = prf.derive_key(48, pre_master, salt); salt.clear(); - salt.append(KEY_GEN_MAGIC, sizeof(KEY_GEN_MAGIC)); - salt.append(server_random); - salt.append(client_random); + salt += std::make_pair(KEY_GEN_MAGIC, sizeof(KEY_GEN_MAGIC)); + salt += server_random; + salt += client_random; return prf.derive_key(prf_gen, master_sec, salt); } diff --git a/src/sym_algo/symkey.cpp b/src/sym_algo/symkey.cpp index 160149b01..63b3e75b7 100644 --- a/src/sym_algo/symkey.cpp +++ b/src/sym_algo/symkey.cpp @@ -117,8 +117,8 @@ bool operator!=(const OctetString& s1, const OctetString& s2) OctetString operator+(const OctetString& k1, const OctetString& k2) { SecureVector<byte> out; - out.append(k1.bits_of()); - out.append(k2.bits_of()); + out += k1.bits_of(); + out += k2.bits_of(); return OctetString(out); } |