diff options
author | Niels Möller <nisse@lysator.liu.se> | 2012-06-03 22:02:59 +0200 |
---|---|---|
committer | Niels Möller <nisse@lysator.liu.se> | 2012-06-03 22:02:59 +0200 |
commit | adad6eaac2d03fba830eb1630b5458c1ac7f1907 (patch) | |
tree | ea02b675e2cf8f3c6584f35f9f73fd0d072b3428 /pkcs1.c | |
parent | 0589865876f8c89047eaee1698071e31956b0480 (diff) | |
download | nettle-adad6eaac2d03fba830eb1630b5458c1ac7f1907.tar.gz |
Changes to pkcs1_signature_prefix interface.
Diffstat (limited to 'pkcs1.c')
-rw-r--r-- | pkcs1.c | 25 |
1 files changed, 13 insertions, 12 deletions
@@ -34,13 +34,13 @@ /* Formats the PKCS#1 padding, of the form * - * 0x01 0xff ... 0xff 0x00 id ...digest... + * 0x00 0x01 0xff ... 0xff 0x00 id ...digest... * * where the 0xff ... 0xff part consists of at least 8 octets. The - * total size should be one less than the octet size of n. + * total size equals the octet size of n. */ -int -pkcs1_signature_prefix(unsigned size, +uint8_t * +pkcs1_signature_prefix(unsigned key_size, uint8_t *buffer, unsigned id_size, const uint8_t *id, @@ -48,17 +48,18 @@ pkcs1_signature_prefix(unsigned size, { unsigned j; - if (size < 10 + id_size + digest_size) - return 0; + if (key_size < 11 + id_size + digest_size) + return NULL; - j = size - digest_size - id_size; + j = key_size - digest_size - id_size; memcpy (buffer + j, id, id_size); - buffer[0] = 1; - buffer[--j] = 0; + buffer[0] = 0; + buffer[1] = 1; + buffer[j-1] = 0; - assert(j >= 9); - memset(buffer + 1, 0xff, j - 1); + assert(j >= 11); + memset(buffer + 2, 0xff, j - 3); - return 1; + return buffer + j + id_size; } |