Re: Question about SHA1 result length



DERASN.1@xxxxxxxxx writes:
I am working with the SHA1 algorithm to produce digital signatures for
RSA encryption/decryption. My question is: does a lower bound exist
for the result of an SHA1 hash? Is it possible that there is some data
that would hash to 0 (20 bytes of 0's) or to something very small like
1 or 2?

Yes, this could happen, but the probability is very low. For example,
the probability of even the first 60 bits being zero is 2**-60.

I ask this because I am wondering if a SHA1 hash encrypted
with a reasonably large (1024 bit) RSA key could yield a result that is
too small to be cryptographically secure (by this I mean when raised to
the exponent the result would be less than the modulus). Has anyone
ever run into this or have any knowledge of this? Thanks.

You would not encrypt the hash directly with RSA. You'd use a padding
scheme like OAEP or PSS. Basically that means you insert a bunch of
random bits along with the hash when encrypting, and remove them when
decrypting. Of course there is a tiny probability that all these bits
will be zero. There is similarly a tiny probability that the attacker
can simply guess your private key and get it right on the first try.
In cryptography we're mostly concerned with making these events
extremely unlikely, not with making them impossible.
.



Relevant Pages

  • Re: Public key encryption
    ... > messages as to break the hash algorithm. ... it amounts to equivalence to the RSA problem. ... anything that can forge PSS signatures can do arbitrary RSA ... > message is small compared to the encryption exponent but still a hash ...
    (sci.crypt)
  • Re: ADVERT: Secure communications
    ... Hash: SHA1 ... security analysis on it in existence were by its author. ... I'm assuming this means RSA without hybridizing with a symmetric cipher. ... than encrypting a whole message block-by-block with a 2048-bit ...
    (sci.crypt)
  • Re: question about certificate verifiy using TLS
    ... you use the SHA-1 hash of the handshake ... With RSA, it is a bit more complex. ... using the MD5 hash function. ... The handshake messages are hashed ...
    (sci.crypt)
  • Re: Public key encryption
    ... >>messages as to break the hash algorithm. ... > it amounts to equivalence to the RSA problem. ... > anything that can forge PSS signatures can do arbitrary RSA ... > attack on weak padding is Bleichenbacher's "Million Message Attack", ...
    (sci.crypt)
  • Re: Is MD5 outdated ?
    ... ]> will produce a second document that has the same hash as the first. ... ]that Greg Rose described would yield a collision with high probability ... ]In security, a threat cannot be ignored simply because it is not certain ... ]a large amount of computation, but it's not so large as to be ...
    (sci.crypt)