Does the SHA512 hashvalue 128 bits long?

I have a strange problem. In my code, I create a sha512 hash algorithm and sign some data with it. Now I would expect the hash to be 512 bits in length, but its 128. What error did I make?

My code is:

var hashAlgorithm = HashAlgorithm.Create( โ€žSHA512" ); var signedhHash = rsaCryptoServiceProvider.SignData( plainData, hashAlgorithm ); 

PS. Ive downloaded the RSA keys from the file that Ive created with the following script:

 makecert -r -n "CN=myCert" -sky exchange -sy 24 -sv myCert.pvk myCert.cer cert2spc myCert.cer myCert.spc pvk2pfx -pvk myCert.pvk -spc myCert.spc -pfx myCert.pfx โ€“f 

Edit:

I got the length from signedhHash.Length , which is 128.

+4
source share
2 answers

The hash value is 512, but the hash value (from SignData ) is 1024.

 var alg = HashAlgorithm.Create("SHA512"); var hashArr = alg.ComputeHash(ASCIIEncoding.UTF8.GetBytes("test")); var size = hashArr.Length * 8; //512 var rsaCryptoServiceProvider = new RSACryptoServiceProvider(); var signedValue = rsaCryptoServiceProvider.SignData(ASCIIEncoding.UTF8.GetBytes("test"), alg); size = signedValue.Length * 8; //1024 

(1 byte = 8 bits)

+3
source

SignData does not return a hash made using the SHA512 algorithm, it returns a signature for this hash created using the SignatureAlgorithm property of the provider ( http://www.w3.org/2000/09/xmldsig#rsa-sha1 )

0
source

All Articles