Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sign with RSA-1024 an SHA-256 digest: what is the size?

I was wondering: 1) if I compute the digest of some datas with SHA-512 => resulting in a hash of 64 bytes 2) and then I sign this hash with RSA-1024 => so a block of 128 bytes, which is bigger than the 64 bytes of the digest

=> does it mean in the end my signed hash will be exactly 128 bytes?

Thanks a lot for any info.

like image 530
puccio Avatar asked Dec 04 '09 10:12

puccio


People also ask

What is the size of RSA signature?

The maximum size for RSA is 512 bytes. The maximum size of ECC is 132. For RSA, this must be at least the byte length of the modulus rounded up to a multiple of 32 bytes for the X9. 31 signature format or one byte for all other signature formats.

What does RSA 1024 mean?

When we say a "1024-bit RSA key", we mean that the modulus has length 1024 bits, i.e. is an integer greater than 2^1023 but lower than 2^1024. Such an integer could be encoded as a sequence of 1024 bits, i.e. 128 bytes.

What is RSA SHA256 signature?

SHA256 with RSA signature is an efficient asymmetric encryption method used in many secure APIs. This algorithm first calculates a unique hash of the input data using SHA256 algorithm. The hash is then encrypted with a private key using the RSA algorithm.

Is 1024 bit RSA secure?

Encryption algorithms using 1024-bit keys are no longer secure, due to the emergence of 'trapdoored' primes. Expert Michael Cobb explains how the encryption backdoor works. The National Institute of Standards and Technology (NIST) has recommended minimum key sizes of 2048-bits for the...


1 Answers

With RSA, as specified by PKCS#1, the data to be signed is first hashed with a hash function, then the result is padded (a more or less complex operation which transforms the hash result into a modular integer), and then the mathematical operation of RSA is applied on that number. The result is a n-bit integer, where n is the length in bits of the "modulus", usually called "the RSA key size". Basically, for RSA-1024, n is 1024. A 1024-bit integer is encoded as 128 bytes, exactly, as per the encoding method described in PKCS#1 (PKCS#1 is very readable and not too long).

Whether a n-bit RSA key can be used to sign data with a hash function which produces outputs of length m depends on the details of the padding. As the name suggests, padding involves adding some extra data around the hash output, hence n must be greater than m, leaving some room for the extra data. A 1024-bit key can be used with SHA-512 (which produces 512-bit strings). You could not use a 640-bit key with SHA-512 (and you would not, anyway, since 640-bit RSA keys can be broken -- albeit not trivially).

like image 100
Thomas Pornin Avatar answered Oct 01 '22 03:10

Thomas Pornin