aboutsummaryrefslogtreecommitdiffstats
path: root/src/pk_pad
diff options
context:
space:
mode:
authorlloyd <[email protected]>2012-05-18 13:58:23 +0000
committerlloyd <[email protected]>2012-05-18 13:58:23 +0000
commit2c3dc93d6466a9215d585613fb55f5222ce70d10 (patch)
tree9d44c738fdbb79103bed2d34c8fb171f8eaa00a2 /src/pk_pad
parentc2d0d2982e96ab7ce15e90b8d73c9774e2650d86 (diff)
First step towards replacing the existing containers with std::vector
with a custom allocator; remove the 3 argument version of MemoryRegion::copy, replacing with freestanding buffer_insert function.
Diffstat (limited to 'src/pk_pad')
-rw-r--r--src/pk_pad/eme1/eme1.cpp6
-rw-r--r--src/pk_pad/eme_pkcs/eme_pkcs.cpp2
-rw-r--r--src/pk_pad/emsa2/emsa2.cpp2
-rw-r--r--src/pk_pad/emsa3/emsa3.cpp4
-rw-r--r--src/pk_pad/emsa4/emsa4.cpp6
5 files changed, 10 insertions, 10 deletions
diff --git a/src/pk_pad/eme1/eme1.cpp b/src/pk_pad/eme1/eme1.cpp
index 1cc0c332d..69251605f 100644
--- a/src/pk_pad/eme1/eme1.cpp
+++ b/src/pk_pad/eme1/eme1.cpp
@@ -28,9 +28,9 @@ SecureVector<byte> EME1::pad(const byte in[], size_t in_length,
rng.randomize(&out[0], Phash.size());
- out.copy(Phash.size(), &Phash[0], Phash.size());
+ buffer_insert(out, Phash.size(), &Phash[0], Phash.size());
out[out.size() - in_length - 1] = 0x01;
- out.copy(out.size() - in_length, in, in_length);
+ buffer_insert(out, out.size() - in_length, in, in_length);
mgf->mask(&out[0], Phash.size(),
&out[Phash.size()], out.size() - Phash.size());
@@ -66,7 +66,7 @@ SecureVector<byte> EME1::unpad(const byte in[], size_t in_length,
in_length = 0;
SecureVector<byte> input(key_length);
- input.copy(key_length - in_length, in, in_length);
+ buffer_insert(input, key_length - in_length, in, in_length);
mgf->mask(&input[Phash.size()], input.size() - Phash.size(),
&input[0], Phash.size());
diff --git a/src/pk_pad/eme_pkcs/eme_pkcs.cpp b/src/pk_pad/eme_pkcs/eme_pkcs.cpp
index c4d6838b1..a217d6d03 100644
--- a/src/pk_pad/eme_pkcs/eme_pkcs.cpp
+++ b/src/pk_pad/eme_pkcs/eme_pkcs.cpp
@@ -29,7 +29,7 @@ SecureVector<byte> EME_PKCS1v15::pad(const byte in[], size_t inlen,
for(size_t j = 1; j != olen - inlen - 1; ++j)
while(out[j] == 0)
out[j] = rng.next_byte();
- out.copy(olen - inlen, in, inlen);
+ buffer_insert(out, olen - inlen, in, inlen);
return out;
}
diff --git a/src/pk_pad/emsa2/emsa2.cpp b/src/pk_pad/emsa2/emsa2.cpp
index 96ac8e908..50ea7dbe3 100644
--- a/src/pk_pad/emsa2/emsa2.cpp
+++ b/src/pk_pad/emsa2/emsa2.cpp
@@ -39,7 +39,7 @@ 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[0], msg.size());
+ buffer_insert(output, 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 a381a82f6..6532bafd4 100644
--- a/src/pk_pad/emsa3/emsa3.cpp
+++ b/src/pk_pad/emsa3/emsa3.cpp
@@ -30,8 +30,8 @@ SecureVector<byte> emsa3_encoding(const MemoryRegion<byte>& msg,
T[0] = 0x01;
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[0], msg.size());
+ buffer_insert(T, P_LENGTH+2, hash_id, hash_id_length);
+ buffer_insert(T, output_length-msg.size(), &msg[0], msg.size());
return T;
}
diff --git a/src/pk_pad/emsa4/emsa4.cpp b/src/pk_pad/emsa4/emsa4.cpp
index ef88e1953..65078de5e 100644
--- a/src/pk_pad/emsa4/emsa4.cpp
+++ b/src/pk_pad/emsa4/emsa4.cpp
@@ -54,10 +54,10 @@ SecureVector<byte> EMSA4::encoding_of(const MemoryRegion<byte>& msg,
SecureVector<byte> EM(output_length);
EM[output_length - HASH_SIZE - SALT_SIZE - 2] = 0x01;
- EM.copy(output_length - 1 - HASH_SIZE - SALT_SIZE, salt, SALT_SIZE);
+ buffer_insert(EM, output_length - 1 - HASH_SIZE - SALT_SIZE, salt);
mgf->mask(H, HASH_SIZE, EM, output_length - HASH_SIZE - 1);
EM[0] &= 0xFF >> (8 * ((output_bits + 7) / 8) - output_bits);
- EM.copy(output_length - 1 - HASH_SIZE, H, HASH_SIZE);
+ buffer_insert(EM, output_length - 1 - HASH_SIZE, H);
EM[output_length-1] = 0xBC;
return EM;
@@ -85,7 +85,7 @@ bool EMSA4::verify(const MemoryRegion<byte>& const_coded,
if(coded.size() < KEY_BYTES)
{
SecureVector<byte> temp(KEY_BYTES);
- temp.copy(KEY_BYTES - coded.size(), coded, coded.size());
+ buffer_insert(temp, KEY_BYTES - coded.size(), coded);
coded = temp;
}