How set (or get after signing) random number for function openssl_sign?
$pkEcPem = "-----BEGIN EC PRIVATE KEY-----302e0201010420...a00706052b8104000a-----END EC PRIVATE KEY-----"
$pk = openssl_pkey_get_private($pkEcPem);
$signature = null;
openssl_sign($message, $signature, $pk, $algo);
openssl_free_key($pk);
Example of implementation in the PHP library https://github.com/phpecc/phpecc/blob/master/src/Crypto/Signature/Signer.php#L36
Variant names of this value
- random Key
- random Number
- random Point
k(the random number) must be generated explicitly is a peculiarity of the linked library. Depending on the value ofk, the library controls in this way whether the non-deterministic ECDSA variant (arbitraryk) or the deterministic ECDSA variant (determination ofkaccording to RFC6979) is used (see the ECDSA sample).ktakes placeinternally(and is not carried out by the user) and different methods or a flag are used to distinguish between the two variants (if the library offers both variants at all). AFAIK,openssl_sign()only supports non-deterministic ECDSA. For deterministic ECDSA you have to use a different library.