always produce a signature that is the size of the modulus

This commit is contained in:
Love Hornquist Astrand
2012-09-11 20:45:43 -07:00
parent 12f7c3248b
commit 846f6e0e7b

View File

@@ -740,11 +740,13 @@ rsa_create_signature(hx509_context context,
"RSA private encrypt failed: %d", ret);
return ret;
}
if ((size_t)ret > sig->length)
if (sig->length > (size_t)ret) {
size = sig->length - ret;
memmove((uint8_t *)sig->data + size, sig->data, ret);
memset(sig->data, 0, size);
} else if (sig->length < (size_t)ret)
_hx509_abort("RSA signature prelen longer the output len");
sig->length = ret;
return 0;
}