diff options
author | Jack Lloyd <[email protected]> | 2017-03-03 22:13:20 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-03-03 22:14:24 -0500 |
commit | 4519b036977264cc88ab82669c1d67e21667989a (patch) | |
tree | e6531d0df4415049deb8c7e8a5b4dc5b16304957 /src/lib/pk_pad/emsa_pkcs1 | |
parent | ca787707ba1b386e5969927dead31781351cc32b (diff) |
Avoid calling memmove with a null source in PKCSv1 signature encoding
Only occured with EMSA_Raw. Caught by GCC 7 warning
Diffstat (limited to 'src/lib/pk_pad/emsa_pkcs1')
-rw-r--r-- | src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.cpp b/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.cpp index c4cdc6f35..ebe6f5fa7 100644 --- a/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.cpp +++ b/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.cpp @@ -27,7 +27,13 @@ secure_vector<uint8_t> emsa3_encoding(const secure_vector<uint8_t>& msg, T[0] = 0x01; set_mem(&T[1], P_LENGTH, 0xFF); T[P_LENGTH+1] = 0x00; - buffer_insert(T, P_LENGTH+2, hash_id, hash_id_length); + + if(hash_id_length > 0) + { + BOTAN_ASSERT_NONNULL(hash_id); + buffer_insert(T, P_LENGTH+2, hash_id, hash_id_length); + } + buffer_insert(T, output_length-msg.size(), msg.data(), msg.size()); return T; } |