diff options
author | lloyd <[email protected]> | 2010-09-13 20:53:31 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-09-13 20:53:31 +0000 |
commit | 4fe8a34f1869805d9115f39cad53d1fd7f7eb6c4 (patch) | |
tree | 2ff6c30d1a7d5f2244b6f1b459a5ea10b6d43fe0 /src/pk_pad | |
parent | 36bfef27271eadffefbc6891a9d7fa7eed7b1e10 (diff) |
Remove more uses of vector to pointer implicit conversions
Diffstat (limited to 'src/pk_pad')
-rw-r--r-- | src/pk_pad/eme.cpp | 4 | ||||
-rw-r--r-- | src/pk_pad/eme1/eme1.cpp | 18 | ||||
-rw-r--r-- | src/pk_pad/emsa2/emsa2.cpp | 4 | ||||
-rw-r--r-- | src/pk_pad/emsa3/emsa3.cpp | 8 |
4 files changed, 20 insertions, 14 deletions
diff --git a/src/pk_pad/eme.cpp b/src/pk_pad/eme.cpp index 74bba5ac1..320f19034 100644 --- a/src/pk_pad/eme.cpp +++ b/src/pk_pad/eme.cpp @@ -26,7 +26,7 @@ SecureVector<byte> EME::encode(const MemoryRegion<byte>& msg, u32bit key_bits, RandomNumberGenerator& rng) const { - return pad(msg, msg.size(), key_bits, rng); + return pad(&msg[0], msg.size(), key_bits, rng); } /* @@ -44,7 +44,7 @@ SecureVector<byte> EME::decode(const byte msg[], u32bit msg_len, SecureVector<byte> EME::decode(const MemoryRegion<byte>& msg, u32bit key_bits) const { - return unpad(msg, msg.size(), key_bits); + return unpad(&msg[0], msg.size(), key_bits); } } diff --git a/src/pk_pad/eme1/eme1.cpp b/src/pk_pad/eme1/eme1.cpp index b695fc2c4..4352231c9 100644 --- a/src/pk_pad/eme1/eme1.cpp +++ b/src/pk_pad/eme1/eme1.cpp @@ -28,11 +28,15 @@ SecureVector<byte> EME1::pad(const byte in[], u32bit in_length, rng.randomize(&out[0], HASH_LENGTH); - out.copy(HASH_LENGTH, Phash, Phash.size()); + out.copy(HASH_LENGTH, &Phash[0], Phash.size()); out[out.size() - in_length - 1] = 0x01; out.copy(out.size() - in_length, in, in_length); - mgf->mask(out, HASH_LENGTH, out + HASH_LENGTH, out.size() - HASH_LENGTH); - mgf->mask(out + HASH_LENGTH, out.size() - HASH_LENGTH, out, HASH_LENGTH); + + mgf->mask(&out[0], HASH_LENGTH, + &out[HASH_LENGTH], out.size() - HASH_LENGTH); + + mgf->mask(&out[HASH_LENGTH], out.size() - HASH_LENGTH, + &out[0], HASH_LENGTH); return out; } @@ -64,8 +68,10 @@ SecureVector<byte> EME1::unpad(const byte in[], u32bit in_length, SecureVector<byte> tmp(key_length); tmp.copy(key_length - in_length, in, in_length); - mgf->mask(tmp + HASH_LENGTH, tmp.size() - HASH_LENGTH, tmp, HASH_LENGTH); - mgf->mask(tmp, HASH_LENGTH, tmp + HASH_LENGTH, tmp.size() - HASH_LENGTH); + mgf->mask(&tmp[HASH_LENGTH], tmp.size() - HASH_LENGTH, + &tmp[0], HASH_LENGTH); + mgf->mask(&tmp[0], HASH_LENGTH, + &tmp[HASH_LENGTH], tmp.size() - HASH_LENGTH); const bool phash_ok = same_mem(&tmp[HASH_LENGTH], &Phash[0], Phash.size()); @@ -86,7 +92,7 @@ SecureVector<byte> EME1::unpad(const byte in[], u32bit in_length, if(delim_idx && delim_ok && phash_ok) { - return SecureVector<byte>(tmp + delim_idx + 1, + return SecureVector<byte>(&tmp[delim_idx + 1], tmp.size() - delim_idx - 1); } diff --git a/src/pk_pad/emsa2/emsa2.cpp b/src/pk_pad/emsa2/emsa2.cpp index 74a045931..fe337a80b 100644 --- a/src/pk_pad/emsa2/emsa2.cpp +++ b/src/pk_pad/emsa2/emsa2.cpp @@ -38,8 +38,8 @@ SecureVector<byte> emsa2_encoding(const MemoryRegion<byte>& msg, output[0] = (empty ? 0x4B : 0x6B); output[output_length - 3 - HASH_SIZE] = 0xBA; - set_mem(output + 1, output_length - 4 - HASH_SIZE, 0xBB); - output.copy(output_length - (HASH_SIZE + 2), msg, msg.size()); + set_mem(&output[1], output_length - 4 - HASH_SIZE, 0xBB); + output.copy(output_length - (HASH_SIZE + 2), &msg[0], msg.size()); output[output_length-2] = hash_id; output[output_length-1] = 0xCC; diff --git a/src/pk_pad/emsa3/emsa3.cpp b/src/pk_pad/emsa3/emsa3.cpp index aa1b85f05..21ef072ef 100644 --- a/src/pk_pad/emsa3/emsa3.cpp +++ b/src/pk_pad/emsa3/emsa3.cpp @@ -28,10 +28,10 @@ SecureVector<byte> emsa3_encoding(const MemoryRegion<byte>& msg, const u32bit P_LENGTH = output_length - msg.size() - hash_id_length - 2; T[0] = 0x01; - set_mem(T+1, P_LENGTH, 0xFF); + set_mem(&T[1], P_LENGTH, 0xFF); T[P_LENGTH+1] = 0x00; T.copy(P_LENGTH+2, hash_id, hash_id_length); - T.copy(output_length-msg.size(), msg, msg.size()); + T.copy(output_length-msg.size(), &msg[0], msg.size()); return T; } @@ -64,7 +64,7 @@ SecureVector<byte> EMSA3::encoding_of(const MemoryRegion<byte>& msg, throw Encoding_Error("EMSA3::encoding_of: Bad input length"); return emsa3_encoding(msg, output_bits, - hash_id, hash_id.size()); + &hash_id[0], hash_id.size()); } /* @@ -80,7 +80,7 @@ bool EMSA3::verify(const MemoryRegion<byte>& coded, try { return (coded == emsa3_encoding(raw, key_bits, - hash_id, hash_id.size())); + &hash_id[0], hash_id.size())); } catch(...) { |