EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Sign "ArrayofBytes" with RSA-SHA1

Also by EldoS: CallbackDisk
Create virtual disks backed by memory or custom location, expose disk images as disks and more.
Posted: 08/22/2012 13:27:31
by Bremen Sistemas (Basic support level)
Joined: 08/20/2012
Posts: 17

Here is my code:

S := StrToByte(aString);
            Crypto := TElRSAPublicKeyCrypto.Create();
              Crypto.InputEncoding      := pkeBinary;
              Crypto.OutputEncoding     := pkeBase64;
              Crypto.KeyMaterial        := Cert.KeyMaterial;
              Crypto.InputIsHash        := False; //True;
              Crypto.UseAlgorithmPrefix := True;
              Crypto.HashAlgorithm      := SB_ALGORITHM_DGST_SHA1;

              InputBuffer := TMemoryStream.Create;
              InputBuffer.Write(S[1], Length(S));
              InputBuffer.Position := 0;

              SignBuffer := TMemoryStream.Create;

              // Sign
              Crypto.SignDetached(InputBuffer, SignBuffer);

              SetLength(S, SignBuffer.Size);
              SignBuffer.Position := 0;
              SignBuffer.Read(S[1], SignBuffer.Size);

              Result := S;

Steps of my Sign:
2 - Convert the string ASCII to bytes.
3 - Generate HASH (byte array) using SHA1.
4 - Get the HASH (byte array) using RSA-SHA1.

My question is:

In my code, the signature is already doing step 3 would be the hash of "S"?
Posted: 08/22/2012 16:40:23
by Ken Ivanov (EldoS Corp.)

Yes, under the above configuration the SignDetached() method calculates the hash over the data (S) and digitally signs it with the attached private key.



Topic viewed 698 times

Number of guests: 1, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!