Nit: "due to" Start with capital letter "Fix"
On Tue, Mar 02, 2021 at 01:06:52PM +0800, Tianjia Zhang wrote: > > > On 3/1/21 5:54 PM, Jarkko Sakkinen wrote: > > On Mon, Mar 01, 2021 at 01:18:36PM +0800, Tianjia Zhang wrote: > > > q2 is not always 384-byte length. Sometimes it only has 383-byte. > > > > What does determine this? > > > > > In this case, the valid portion of q2 is reordered reversely for > > > little endian order, and the remaining portion is filled with zero. > > > > I'm presuming that you want to say "In this case, q2 needs to be reversed > > because...". > > > > I'm lacking these details: > > > > 1. Why the length of Q2 can vary? > > 2. Why reversing the bytes is the correct measure to counter-measure > > this variation? > > > > /Jarkko > > > > When use openssl to generate a key instead of using the built-in > sign_key.pem, there is a probability that will encounter this problem. > > Here is a problematic key I encountered. The calculated q1 and q2 of this > key are both 383 bytes, If the length is not processed, the hardware > signature will fail. Why is reversing bytes the correct way to fix the issue? > -----BEGIN RSA PRIVATE KEY----- > MIIG4gIBAAKCAYEAnWxc9HyjCuLWtFVKm0xrkHimyeTEdx7LJpRzm07M/gLFxqwV > bFEFL1SdK912H8S0yRKGzCTqrEa0AKaBhIzw19OgW1jIQx9+ybENnIYh4O+YGwKH > ngTAw5Xfuw8iaPeLe3Pujg4h7ePI4cx6C98KM2tDHb0GeN35wM/2AxaWmuwMGosv > kbNN2EN9zQVLIkaUtCJHH8UlfZ+QQVO32Mij46wO4O4783Hgr7PUmI7LCkk31vBT > fzPch6LSgBy6UvtvBfJWo+t/Rk5aGm90JchY4+H1/23vwpkmKhRazBDbUeHVcX7f > ytwJkmODIjbiapB6gf0AxQooIwJaqdRKddn/BB/IAkanG0m6COuvgP2Z9256U262 > GvEWf+IHY2/DmoivAcc/koYHrRjNgcak8nPq9iTE4R9jPFj41+2r5k3AycCGlt75 > HdYP1oZ/F0nTKp8yGOsf61DXaQLXPnPyjQunKGjBQONJb7Kj/8TOJjSuh7cdRqRP > OXGZPwOEkhKU4QwtAgEDAoIBgGjy6KL9wgdB5Hg43GeIR7WlxIa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