I am looking into php openSSL library and need to sign a string using pub and priv key. The function openssl_pkcs7_sign()
from documentation it seem to take the file path as a file parameter but I have string in a variable that I need to encrypt. I see all of its examples points to writing files.
Is there any way I can pass the string into the function? Or perhaps some other functions available? Writing file to disk doesn't seem very practical for my use cases.
As far as I know, it's not possible.
According to the source code of OpenSSL PHP extension, they use openssl library function PKCS7_sign.
This function takes a BIO stream as input, which can be a buffer.
However, in OpenSSL PHP extension, the BIO stream is created as a file, taking the filename as a parameter.
You can ask for the implementation of this new feature through an RFC, but you probably want to discuss the matter in the internals mailing list first.