-
-
Notifications
You must be signed in to change notification settings - Fork 890
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Load ASN.1 private key to generate an RSA signature #1994
Comments
You can make phpseclib 3.0 work "without" Composer using the instructions at https://phpseclib.com/docs/install#without-composer . That said, for 1.0... why can't you just do this?:
If you're gonna go the |
Hi @terrafrost I tried this at first attempt:
But Will try with phpseclib 3.0 ... |
Do not work better with phpseclib 3... Tried to load my key as exponent and modulus, but I have a 30 seconds timeout while trying to $rsa = PublicKeyLoader::load([
// Modulus
'n' => new BigInteger('5BDD6AFB1E1AFB50D1B2989F70B549B8D44AE3712B444F2C5D862C46C99526E998B79BF0B4F1461524E39D263F3130B9E08F3B17C2070785EFB0EDEC1E75C6C2B8185FA9596886D5DAF8B68E92FCF5F1B33E7CD772845555B086D2A2466B6398A04DFE1C727BB020ED2BF3F03D2826F89616D0846C18B1D87064616FAD394462', 16),
// Exponent
'e' => new BigInteger('6FE4F5D0AFCC16E8A5CC68955D4EF28255A546D06F34DD103540B9A7D202AEC96353072DB65D9C360E9030F413971142EE6A28974767CCF3ABFA4E7ADDAEAD81D3F8AE5FF1B8241CA9EF51C10941FFFA74482A636CBD909D29CF7A0346653D3C286EA1F392F4968AEF1489EC4B4BCEA4F248F3931B1C9BE2808DBD33B049731A', 16)
]
)
->withPadding(RSA::SIGNATURE_PKCS1)
->withHash('md5')
->withMGFHash('md5')
->asPrivateKey()
;
echo $rsa->sign("toto"); // <-- Fatal error: Maximum execution time of 30 seconds exceeded Note that my private key was generated with an external app with these parameters:
Do I need to pass these parameters to the |
$rsa = new Crypt_RSA();
$priv_key = file_get_contents('./my.rsa.private.key.txt');
$rsa->loadKey($priv_key); // <-- return false Would be helpful to see the key - or at least a key that reproduces the problem. As is I can only speculate as to why that doesn't work. $rsa = $key->asPrivateKey();
echo $key->sign("toto"); // <-- Fatal error: Maximum execution time of 30 seconds exceeded You'd need to do That said, when I did it with So if
If |
@terrafrost I fixed the code from my previous comment and changes Modulus and Exponent to a key that timout on my computer. The previous one was working for unknown reason... |
Apologies for the delay - I've been traveling / vacationing. Anyway, I was able to reproduce the issue and 2689c72 fixed it for me. Does it fix it for you? |
@terrafrost Yes it fixes the timeout, thanks ! |
the changes for phpseclib#1994 (commit 2689c72) slowed things down unnecessarily.
Hi,
I'm using phpseclib 1.0.23 because I can't achieve to make version 3 work without using composer to install it, I want a zip file
I'd like to load a private key saved in a ASN.1 binary file but it doesn't work. Here is my code so far...
Any help ?
The text was updated successfully, but these errors were encountered: