2

使用 DNSSEC 和 PowerDNS 我正在尝试使用 Python 解析私钥格式 1.2,以便获得相应的公钥。

使用 pydnssec ( https://github.com/tomas-mazak/pydnssec ) 我能够生成私钥。

它们的键如下所示:

Private-key-format: v1.2 Algorithm: 8 (RSASHA256) Modulus: s3cHXKgqP4JY6yQSGRVftnz+omoBfwDbc7BoDGzQsMVa0eQpASVb0QryPfejfG3K/F9tEPzYgeMMjzwlDuHnK46DGS7WynKDMUPYDYSb8dvRGyD2Ef027ReAB5OYstSnIXRbyj+NzpaF1V0R3Xlg2mXnHO2UZ+PjmDKx+4353D/pUyqoVoNvZi4AESnWBC11ZlNsaxX5ILy/RlYLxQ7Kobh3pfWtHiXPqnyAy1sJFaCyVCGng4a9lUzfMRIbEYATSoDIfNN8rUMMU2c9eUax1Lwp370AbuTycVVXQYafwoRmMN/R9YmYAFHdmwsnWe+yv/ErDGYyoYGn/W0P44UpUQ== PublicExponent: AQAB PrivateExponent: Xiw5qr972/O0YT9+V7dFkGcq32MtAc4bWivZjZuULw6Ax98oPTezZJCP6UCHg4XBnIkenGlx20afkpIHCDY2rj6MQKy5fWZ1vWZSe1V414N3yPqU5X+wUN2iC1fCKyU3xnBeslSDP0LxW7MI6uUEk9YhXqa014dYKMeBafVohdAKiPWnxrhTFafDqrYj0ltt76y+ffUK7tuTvzkaCB+MQawGG96nf4Y9VaFHl2yt1jYcL7Bd7QpWmw0snCpYroeIOStce2l9mcgZeedPzp2hL0xWdYMoiqZgcc+lkt8g8jBkHd9lUKykvtaiQ3s9egGtMlOl+ULt/MGlSE6VbHTsoQ== Prime1: y4xJLcfVptBD/Mr8rMi70zlbS01VomMYi2GBsROPmwWN8gVTY3yjo7VcBFTMegW0nfVNIjwmCKWQ6GL8s54Zf8qSG2cpUGQZrNoym7efzeGPYyg4THzg7XU3+vEFlt7FVjLZ30UeKEMGVNAf6A9BADvh1XNR7/3VvzAOSr8JQ20= Prime2: 4bYGrbHrCNATTWm+0l8i2ACsGEhKOa4YMOU5pKm2p/DoI0cfDd5yfPqwwdYPyufQbfQMiEaWM8HlRBvSZs3YD+n31bkmjhsOOQCyI+iHX7jkScM5JUodyFRbAG+743dWJOSkiqLTwuhuK66TZo6fdTjDxnjt2s/7KH5gDW5e6vU= Exponent1: KM38tZLD/+bsWjcPJEwxawyqgpQEQMOA3iAz8Z2sQjWA2S28I8uOunjW839UZnnSVYAhcGWCcmVOgWempRNipT2kwJ2TqKwIgaBUWOccwBchuY0MjDjUloXTLRk4N6B9CuSyzJF8lDGriUEXxFuaekOG6FVv7Z6DRQqLMuzNHJk= Exponent2: KM38tZLD/+bsWjcPJEwxawyqgpQEQMOA3iAz8Z2sQjWA2S28I8uOunjW839UZnnSVYAhcGWCcmVOgWempRNipT2kwJ2TqKwIgaBUWOccwBchuY0MjDjUloXTLRk4N6B9CuSyzJF8lDGriUEXxFuaekOG6FVv7Z6DRQqLMuzNHJk= Coefficient: Pohsb1j3g9Em+luwFMyddO7jKtdP76kdQx+xqDz6ctOgGmyjKx/Fu6m2CMGc3uIBOfKNEb6zLpKHvetzhKlDGNb24ca8S0WWNCW3wutZ32GvR8gpTHVQraAbOhPEDVSk1QuDAOWI/jEkf7OGuPUj8/GmLGU1rflYvNr1nLrD3yI=

我正在尝试从字符串/文件加载新生成的密钥并提取公钥。

结果将是这样的:

257 3 8 AwEAAepo5mc4fDlpcaGx9+hTNSZwC1LIGyPtK8VjdS0wfAaQa8FAwtrVXO9aQRYjKrUnHEtE52olCbJMlVygDllb3d8UcKyWRo+gm7YO02f/ckhqKghM9LVUWxfsxFWI4jA7zJ9I8+ACc3WN9PRAb7dHTLctjTejJ1/DQi6KoWidLHqTKoaOo8FMfCZrCc9XJ3DqCwEPIQQwe2SdpWwAByouQH4OBdaVx6nu9uHvroKsU/kRxW18vySWk+LnFjg0hI1UId/6Ud/3fS7RW/V6B+wJFd9XdfZtfAJDIsVQiBfvm0HguBIB6nMfSEBnuuEb/dyUVadtWTHtp8fY/+Y/2XY/0bM=

python Crypto 库似乎不支持这一点。关于如何做到这一点的任何想法?

key = Crypto.PublicKey.RSA.importKey(externKey=keystring)

给我:

Traceback (most recent call last): File "pubkey.py", line 14, in <module> key = Crypto.PublicKey.RSA.importKey(externKey=keystring) File "/usr/lib/python3/dist-packages/Crypto/PublicKey/RSA.py", line 682, in importKey raise ValueError("RSA key format is not supported") ValueError: RSA key format is not supported

4

0 回答 0