diff options
author | Jack Lloyd <[email protected]> | 2018-09-20 12:21:41 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-09-20 12:21:41 -0400 |
commit | 7f0d0fe571e60340cd7995c518c343c8d25e853d (patch) | |
tree | 05b6221e114ec6b7091eb096e77a5cd6065f9c41 /src/lib/pk_pad/mgf1 | |
parent | 0b5ca4d367b634c8002e66b1c942b697bb849232 (diff) |
Slight optimization for MGF1
Avoid needless allocations during PSS and OAEP operations.
Diffstat (limited to 'src/lib/pk_pad/mgf1')
-rw-r--r-- | src/lib/pk_pad/mgf1/mgf1.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lib/pk_pad/mgf1/mgf1.cpp b/src/lib/pk_pad/mgf1/mgf1.cpp index dbfac5110..2e7ef9973 100644 --- a/src/lib/pk_pad/mgf1/mgf1.cpp +++ b/src/lib/pk_pad/mgf1/mgf1.cpp @@ -17,13 +17,14 @@ void mgf1_mask(HashFunction& hash, { uint32_t counter = 0; + secure_vector<uint8_t> buffer(hash.output_length()); while(out_len) { hash.update(in, in_len); hash.update_be(counter); - secure_vector<uint8_t> buffer = hash.final(); + hash.final(buffer.data()); - size_t xored = std::min<size_t>(buffer.size(), out_len); + const size_t xored = std::min<size_t>(buffer.size(), out_len); xor_buf(out, buffer.data(), xored); out += xored; out_len -= xored; |