使用 PKCS1 生成私钥 RSA [英] Generate private key RSA with PKCS1

查看:195
本文介绍了使用 PKCS1 生成私钥 RSA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在 PHP 中使用 openssl 通过 OpenSSL 生成私钥-pkey-new 在 RSA 和 PKCS1 中?

Is there a way to generate private key via OpenSSL in PHP using openssl-pkey-new in RSA and PKCS1?

推荐答案

如果您指的是带有 BEGIN RSA PRIVATE KEY 标头的私钥,那么 PHP 中有一个问题没有简单的解决方案.基本上用 OpenSSL 1.0+ 编译的 PHP 会生成 PKCS#8 PEM 格式的私钥,而且似乎无法再以 PKCS#1 格式生成它(至少我找不到解决方案).

if you mean private key with BEGIN RSA PRIVATE KEY header then there is one issue in PHP that does not have simple solution. Basically PHP compiled with OpenSSL 1.0+ produce PKCS#8 PEM formatted private keys and it seems like there is no way how to generate it in PKCS#1 format anymore (at least I was not able to find solution).

https://bugs.php.net/bug.php?id=53850

为什么在 Linux 或 Windows 下私钥字符串不同?

还有一个名为 phpseclib 的库应该能够做到.(但我没有亲身体验).

There is also library called phpseclib that shoul be able to do it. (but I don't have personal experience with it).

http://phpseclib.sourceforge.net/rsa/examples.html#create,pkcs1,pkcs1pub,sign1,enc1,

这篇关于使用 PKCS1 生成私钥 RSA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆