diff options
author | Daniel Seither <[email protected]> | 2015-06-20 18:39:40 +0200 |
---|---|---|
committer | Daniel Seither <[email protected]> | 2015-06-20 19:05:07 +0200 |
commit | bd5427214f0acba796f43bd6289f860fbed73519 (patch) | |
tree | 38f783fa532670fe7de910108f06e480f4bc3c8e | |
parent | 9dc9dd03af7f0f175c05ab9886f5e71d3d3a760d (diff) |
lib/pk_pad: Convert &vec[0] to vec.data()
-rw-r--r-- | src/lib/pk_pad/eme.cpp | 4 | ||||
-rw-r--r-- | src/lib/pk_pad/eme_oaep/oaep.cpp | 16 | ||||
-rw-r--r-- | src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.cpp | 6 | ||||
-rw-r--r-- | src/lib/pk_pad/emsa_pssr/pssr.cpp | 8 | ||||
-rw-r--r-- | src/lib/pk_pad/emsa_raw/emsa_raw.cpp | 2 | ||||
-rw-r--r-- | src/lib/pk_pad/emsa_x931/emsa_x931.cpp | 2 | ||||
-rw-r--r-- | src/lib/pk_pad/mgf1/mgf1.cpp | 2 |
7 files changed, 20 insertions, 20 deletions
diff --git a/src/lib/pk_pad/eme.cpp b/src/lib/pk_pad/eme.cpp index dc4c36082..9398b4c83 100644 --- a/src/lib/pk_pad/eme.cpp +++ b/src/lib/pk_pad/eme.cpp @@ -26,7 +26,7 @@ secure_vector<byte> EME::encode(const secure_vector<byte>& msg, size_t key_bits, RandomNumberGenerator& rng) const { - return pad(&msg[0], msg.size(), key_bits, rng); + return pad(msg.data(), msg.size(), key_bits, rng); } /* @@ -44,7 +44,7 @@ secure_vector<byte> EME::decode(const byte msg[], size_t msg_len, secure_vector<byte> EME::decode(const secure_vector<byte>& msg, size_t key_bits) const { - return unpad(&msg[0], msg.size(), key_bits); + return unpad(msg.data(), msg.size(), key_bits); } } diff --git a/src/lib/pk_pad/eme_oaep/oaep.cpp b/src/lib/pk_pad/eme_oaep/oaep.cpp index 46bcc04ee..871f40142 100644 --- a/src/lib/pk_pad/eme_oaep/oaep.cpp +++ b/src/lib/pk_pad/eme_oaep/oaep.cpp @@ -45,19 +45,19 @@ secure_vector<byte> OAEP::pad(const byte in[], size_t in_length, secure_vector<byte> out(key_length); - rng.randomize(&out[0], m_Phash.size()); + rng.randomize(out.data(), m_Phash.size()); - buffer_insert(out, m_Phash.size(), &m_Phash[0], m_Phash.size()); + buffer_insert(out, m_Phash.size(), m_Phash.data(), m_Phash.size()); out[out.size() - in_length - 1] = 0x01; buffer_insert(out, out.size() - in_length, in, in_length); mgf1_mask(*m_hash, - &out[0], m_Phash.size(), + out.data(), m_Phash.size(), &out[m_Phash.size()], out.size() - m_Phash.size()); mgf1_mask(*m_hash, &out[m_Phash.size()], out.size() - m_Phash.size(), - &out[0], m_Phash.size()); + out.data(), m_Phash.size()); return out; } @@ -91,10 +91,10 @@ secure_vector<byte> OAEP::unpad(const byte in[], size_t in_length, mgf1_mask(*m_hash, &input[m_Phash.size()], input.size() - m_Phash.size(), - &input[0], m_Phash.size()); + input.data(), m_Phash.size()); mgf1_mask(*m_hash, - &input[0], m_Phash.size(), + input.data(), m_Phash.size(), &input[m_Phash.size()], input.size() - m_Phash.size()); bool waiting_for_delim = true; @@ -123,12 +123,12 @@ secure_vector<byte> OAEP::unpad(const byte in[], size_t in_length, // If we never saw any non-zero byte, then it's not valid input bad_input |= waiting_for_delim; - bad_input |= !same_mem(&input[m_Phash.size()], &m_Phash[0], m_Phash.size()); + bad_input |= !same_mem(&input[m_Phash.size()], m_Phash.data(), m_Phash.size()); if(bad_input) throw Decoding_Error("Invalid OAEP encoding"); - return secure_vector<byte>(&input[delim_idx + 1], &input[input.size()]); + return secure_vector<byte>(input.begin() + delim_idx + 1, input.end()); } /* diff --git a/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.cpp b/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.cpp index f73c8b7d9..2c2fbd2e8 100644 --- a/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.cpp +++ b/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.cpp @@ -46,7 +46,7 @@ secure_vector<byte> emsa3_encoding(const secure_vector<byte>& msg, set_mem(&T[1], P_LENGTH, 0xFF); T[P_LENGTH+1] = 0x00; buffer_insert(T, P_LENGTH+2, hash_id, hash_id_length); - buffer_insert(T, output_length-msg.size(), &msg[0], msg.size()); + buffer_insert(T, output_length-msg.size(), msg.data(), msg.size()); return T; } @@ -71,7 +71,7 @@ EMSA_PKCS1v15::encoding_of(const secure_vector<byte>& msg, throw Encoding_Error("EMSA_PKCS1v15::encoding_of: Bad input length"); return emsa3_encoding(msg, output_bits, - &m_hash_id[0], m_hash_id.size()); + m_hash_id.data(), m_hash_id.size()); } bool EMSA_PKCS1v15::verify(const secure_vector<byte>& coded, @@ -84,7 +84,7 @@ bool EMSA_PKCS1v15::verify(const secure_vector<byte>& coded, try { return (coded == emsa3_encoding(raw, key_bits, - &m_hash_id[0], m_hash_id.size())); + m_hash_id.data(), m_hash_id.size())); } catch(...) { diff --git a/src/lib/pk_pad/emsa_pssr/pssr.cpp b/src/lib/pk_pad/emsa_pssr/pssr.cpp index 691d15964..a4744f8f4 100644 --- a/src/lib/pk_pad/emsa_pssr/pssr.cpp +++ b/src/lib/pk_pad/emsa_pssr/pssr.cpp @@ -72,7 +72,7 @@ secure_vector<byte> PSSR::encoding_of(const secure_vector<byte>& msg, EM[output_length - HASH_SIZE - SALT_SIZE - 2] = 0x01; buffer_insert(EM, output_length - 1 - HASH_SIZE - SALT_SIZE, salt); - mgf1_mask(*hash, &H[0], HASH_SIZE, &EM[0], output_length - HASH_SIZE - 1); + mgf1_mask(*hash, H.data(), HASH_SIZE, EM.data(), output_length - HASH_SIZE - 1); EM[0] &= 0xFF >> (8 * ((output_bits + 7) / 8) - output_bits); buffer_insert(EM, output_length - 1 - HASH_SIZE, H); EM[output_length-1] = 0xBC; @@ -113,13 +113,13 @@ bool PSSR::verify(const secure_vector<byte>& const_coded, if(TOP_BITS > 8 - high_bit(coded[0])) return false; - byte* DB = &coded[0]; + byte* DB = coded.data(); const size_t DB_size = coded.size() - HASH_SIZE - 1; const byte* H = &coded[DB_size]; const size_t H_size = HASH_SIZE; - mgf1_mask(*hash, &H[0], H_size, &DB[0], DB_size); + mgf1_mask(*hash, H, H_size, DB, DB_size); DB[0] &= 0xFF >> TOP_BITS; size_t salt_offset = 0; @@ -139,7 +139,7 @@ bool PSSR::verify(const secure_vector<byte>& const_coded, hash->update(&DB[salt_offset], DB_size - salt_offset); secure_vector<byte> H2 = hash->final(); - return same_mem(&H[0], &H2[0], HASH_SIZE); + return same_mem(H, H2.data(), HASH_SIZE); } PSSR::PSSR(HashFunction* h) : diff --git a/src/lib/pk_pad/emsa_raw/emsa_raw.cpp b/src/lib/pk_pad/emsa_raw/emsa_raw.cpp index 8b5fd71fa..dcce888f2 100644 --- a/src/lib/pk_pad/emsa_raw/emsa_raw.cpp +++ b/src/lib/pk_pad/emsa_raw/emsa_raw.cpp @@ -62,7 +62,7 @@ bool EMSA_Raw::verify(const secure_vector<byte>& coded, if(raw[i]) same_modulo_leading_zeros = false; - if(!same_mem(&coded[0], &raw[leading_zeros_expected], coded.size())) + if(!same_mem(coded.data(), raw.data() + leading_zeros_expected, coded.size())) same_modulo_leading_zeros = false; return same_modulo_leading_zeros; diff --git a/src/lib/pk_pad/emsa_x931/emsa_x931.cpp b/src/lib/pk_pad/emsa_x931/emsa_x931.cpp index cda3b22dd..6b86a25f9 100644 --- a/src/lib/pk_pad/emsa_x931/emsa_x931.cpp +++ b/src/lib/pk_pad/emsa_x931/emsa_x931.cpp @@ -35,7 +35,7 @@ secure_vector<byte> emsa2_encoding(const secure_vector<byte>& msg, output[0] = (empty_input ? 0x4B : 0x6B); output[output_length - 3 - HASH_SIZE] = 0xBA; set_mem(&output[1], output_length - 4 - HASH_SIZE, 0xBB); - buffer_insert(output, output_length - (HASH_SIZE + 2), &msg[0], msg.size()); + buffer_insert(output, output_length - (HASH_SIZE + 2), msg.data(), msg.size()); output[output_length-2] = hash_id; output[output_length-1] = 0xCC; diff --git a/src/lib/pk_pad/mgf1/mgf1.cpp b/src/lib/pk_pad/mgf1/mgf1.cpp index f947c5dd2..950961f89 100644 --- a/src/lib/pk_pad/mgf1/mgf1.cpp +++ b/src/lib/pk_pad/mgf1/mgf1.cpp @@ -25,7 +25,7 @@ void mgf1_mask(HashFunction& hash, secure_vector<byte> buffer = hash.final(); size_t xored = std::min<size_t>(buffer.size(), out_len); - xor_buf(out, &buffer[0], xored); + xor_buf(out, buffer.data(), xored); out += xored; out_len -= xored; |