Python M2Crypto - 生成 DSA 密钥对并分离公共/私有组件
任何人都可以解释以下原因是什么:
>>> from M2Crypto import DSA, BIO
>>> dsa = DSA.gen_params(1024)
..+........+++++++++++++++++++++++++++++++++++++++++++++++++++*
............+.+.+..+.........+.............+.....................+.
...+.............+...........+.........................................
+.........+................+..........+......+..+.+...+..........+..+..
..+...+......+....+.............+.................+.......+.........+..
....+......+.+..+..........+........+.+...+..+...............+.........
..+.....+........+..........+++++++++++++++++++++++++++++++++++++++++++
++++++++*
>>> mem = BIO.MemoryBuffer()
>>> dsa.save_key_bio(mem, cipher=None)
1
>>> dsa.save_pub_key_bio(mem)
0
>>> print mem.getvalue()
-----BEGIN DSA PRIVATE KEY-----
MIIBIgIBAAKBgQDPGRFSTqqx8vet5kaW5m99A83REotTcX9HOv+zrqMxQpaTlinS
MDz49I4psDPJ+bWH7vySEdOYO2JGUj6kYZdz/ZwyNjphWNjQkaUrmfaVLzS3PHpW
aMrPEweLesf/PT4KXm2HaDbaW/g2Ds5h+Zlq9LDKcN2vfvyeiTCmf1esyQIVAO9I
ippU4PIdvJVO9HQRkqrD2bxPAoGBAIwVgM7dgNVwihJva6qeeh7ypy3ESNB9k8nY
fOnES+SqZGQbkPrJIusRCJNKERiMATJXNRMfBeWD8htNRezbgtr0OpuYSBurAQjp
hKKVI3DHSv7XT49BQ3tdJww8lQfkOhHOfFTG6U1dJhWdggp0WN3EjYlt77agRsjR
4t5sD1f3
-----END DSA PRIVATE KEY-----
-----BEGIN PUBLIC KEY-----
-----END PUBLIC KEY-----
>>>
显然我错过了一些东西。 M2Crypto 不存在的文档没有帮助。
Could anybody explain what is the cause of the following:
>>> from M2Crypto import DSA, BIO
>>> dsa = DSA.gen_params(1024)
..+........+++++++++++++++++++++++++++++++++++++++++++++++++++*
............+.+.+..+.........+.............+.....................+.
...+.............+...........+.........................................
+.........+................+..........+......+..+.+...+..........+..+..
..+...+......+....+.............+.................+.......+.........+..
....+......+.+..+..........+........+.+...+..+...............+.........
..+.....+........+..........+++++++++++++++++++++++++++++++++++++++++++
++++++++*
>>> mem = BIO.MemoryBuffer()
>>> dsa.save_key_bio(mem, cipher=None)
1
>>> dsa.save_pub_key_bio(mem)
0
>>> print mem.getvalue()
-----BEGIN DSA PRIVATE KEY-----
MIIBIgIBAAKBgQDPGRFSTqqx8vet5kaW5m99A83REotTcX9HOv+zrqMxQpaTlinS
MDz49I4psDPJ+bWH7vySEdOYO2JGUj6kYZdz/ZwyNjphWNjQkaUrmfaVLzS3PHpW
aMrPEweLesf/PT4KXm2HaDbaW/g2Ds5h+Zlq9LDKcN2vfvyeiTCmf1esyQIVAO9I
ippU4PIdvJVO9HQRkqrD2bxPAoGBAIwVgM7dgNVwihJva6qeeh7ypy3ESNB9k8nY
fOnES+SqZGQbkPrJIusRCJNKERiMATJXNRMfBeWD8htNRezbgtr0OpuYSBurAQjp
hKKVI3DHSv7XT49BQ3tdJww8lQfkOhHOfFTG6U1dJhWdggp0WN3EjYlt77agRsjR
4t5sD1f3
-----END DSA PRIVATE KEY-----
-----BEGIN PUBLIC KEY-----
-----END PUBLIC KEY-----
>>>
clearly I'm missing something. M2Crypto nonexistant docs don't help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
调用 dsa.gen_key(),然后保存。 您实际上并没有生成公钥。
Call dsa.gen_key(), then save. You aren't actually generating the public key.