Hi,
I'm trying to implement the following code to substitute the following
openssl command
openssl dgst -sha1 -sign myKey.pem something.txt | openssl enc -base64
I'm using Delphi and the Opensll lib developed by Marco Ferrante
(http://www.disi.unige.it/person/FerranteM/delphiopenssl/)
The code is producing the hash '6676627A363352673862555A4D69464432376969'
instead of
Am1K5+CP4LDNVDZYvcLYGpnu8/1b+WWkzgoe8sbZhvk6QFzFvNN77Zsq+cHNm52jCVSEDgWLGHgPS1wcT8ZG7w6KgVq+2/VgOU+xKNt0lcC3gouyarZvcZpZclIReDgLh6m3nv8DYYHKAOQc+eCi/BQ4LqUnuJrca+7emgb/kpU=
Does anybody have any suggestions on what i am doing wrong ?
Thank you
Rui Francisco
var
mdLength, b64Length: integer;
Len: cardinal;
mdctx: EVP_MD_CTX;
inbuf, outbuf: array [0..1023] of char;
memout, b64: pBIO;
mdValue: array [0..EVP_MAX_MD_SIZE] of byte;
key: pEVP_PKEY;
msg : String;
begin
msg:='2010-05-18;2010-05-18T11:22:19;FAC 001/14;3.12; ';
StrPCopy(inbuf, msg);
InitOpenSSL;
key:=ReadPrivateKey('private_key.txt','');
EVP_DigestInit(@mdctx, EVP_sha1());
EVP_DigestUpdate(@mdctx, @inbuf, StrLen(inbuf));
EVP_DigestFinal(@mdctx, @outbuf, Len);
b64 := BIO_new(BIO_f_base64);
memout := BIO_new(BIO_s_mem);
b64 := BIO_push(b64, memout);
BIO_write(b64, @outbuf, Len);
BIO_flush(b64);
b64Length := BIO_read(memout, @outbuf, 1024);
outbuf[b64Length-1] := #0;
FreeOpenSSL;
BinToHex(outbuf, inbuf,Len);
inbuf[2*Len]:=#0;
result:= StrPas(inbuf);
end;
--
Rui Francisco - blackmo...@gmail.com
São João dos Montes - Portugal
Tel: +351 934162200
-----------------------------------------------------
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users@openssl.org
Automated List Manager majord...@openssl.org