EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Sign "ArrayofBytes" with RSA-SHA1

#21142
Posted: 08/22/2012 13:27:31
by Bremen Sistemas (Basic support level)
Joined: 08/20/2012
Posts: 17

Here is my code:

Code
S := StrToByte(aString);
            Crypto := TElRSAPublicKeyCrypto.Create();
            try
              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;
            finally
              FreeAndNil(InputBuffer);
              FreeAndNil(SignBuffer);
              FreeAndNil(Crypto);
            end;


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"?
#21145
Posted: 08/22/2012 16:40:23
by Ken Ivanov (Team)

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

Reply

Statistics

Topic viewed 737 times

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




|

Back to top

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

Got it!