I
I
I_Vetrov2016-12-21 21:53:44
PHP
I_Vetrov, 2016-12-21 21:53:44

How to form PHP string signature using private key and passphrase?

Hello everyone, I need advice.
In the process of integrating the site with the service, it became necessary to sign api requests (in fact, just some MD5 sequence) with a private key. On the server we use php.
What has been done before:
1. Using the service software, a public/private key pair was generated by specifying a passphrase.
2. The public key was sent to the service.
3. The private key was uploaded to your server.
And then there was a hitch.
The service requires that the process of signing the request (that is, the function that performs this) use as an argument not only the private key, but also the passphrase.
That is, it turns out that the method openssl_sign($str, $signature, $privkey); from openssl is not suitable.
I have no idea what function/method/library can be used to meet the conditions.
The service we are integrating with sent us an example implementation in .net c#, but I don't understand how to use it in PHP. See their example at the link: pastebin.com/SXT0fniy
Actually the question is: what function/library should I use? I looked at gnupg, but there is also no passphrase as an argument. string gnupg_sign ( resource $identifier , string $plaintext )
How to be?
Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
riot26, 2016-12-21
@riot26

php.net/manual/en/function.gnupg-sign.php :
php.net/manual/en/function.gnupg-addsignkey.php :

bool gnupg_addsignkey ( resource $identifier , string $fingerprint [, string $passphrase ] )

Y
Yuri Bogoslavets, 2019-08-12
@uranik

$sign = hash_hmac("sha512", $post_data, $secret.$passphrase);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question