Hi,

I am trying to verify signature created in unix and verifying in PHP.

Followed below steps in unix.

openssl genrsa -des3 1024 > private.key
openssl req -new -x509 -nodes -md5 -key private.key > public.key

*message* = Hi,This is just gonna be a sample message with digital signature
openssl dgst -sha1 -sign private.key message.txt | openssl enc -base64 >
signed.txt
openssl enc -base64 signed.txt > encodedmsg.txt

*encodedmsg* = fBK/s9RTr eLFXzJswKAUwDyqPNXhIceXUEogJYFONroF9DX904L5t2wa3
BzB
GubcymJkR9AoPkSjI1hJi/rs9LkvB hnqc818JXXAswb5BfSjnC/uccAnPznAJf7
BJaPYc46rEEpq9ArcNKR1yFNk6mMUL6yP38ped39Y0o=

Copied and sent signature to php through html form.

Trying to verify in PHP with below code.

$text = "Hi,This is just gonna be a sample message with digital signature";
$enc_signature = _POST["*encodedmsg*"];
$dec_signature = base64_decode($enc_signature);

$file = "C:\public.key";
$fp = fopen($file, "r");
$pem_data = fread($fp, filesize($file));
fclose($fp);
 $public_key = openssl_get_publickey($pem_data);
 $status = *openssl_verify($text, $dec_signnature, $public_key); *
 echo 'Status : '.$status.'</br>';

 $file = "C:\private.key";
 $fp = fopen($file, "r");
 $pem_data = fread($fp, filesize($file));
 fclose($fp);

//creating signature in php
 $password = "123";
 $priate_keyid = openssl_get_privatekey($pem_data, $password);
 *openssl_sign($text, $signature, $private_keyid);
* echo 'New formed signed1 : '.$signature.'</br>';

  echo 'dec_signature .. : '.$dec_signature.'</br>';
 openssl_free_key($private_keyid);
Asper my understanding "dec_signature" and "signature" should get match.
"dec_signature" passed to openssl_verify should verify the same.
Unable to understand wht exactly the problem is. can you people help me to
resolve this issue.
Can i also have EVP sample in php.

Thanks a lot.
Mazheruddin.

Reply via email to