生成与OpenSSL的RSA公钥/私钥? [英] Generate RSA public/private key with OpenSSL?

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

问题描述

主要的问题是,我很新的C,和OpenSSL文档是不是对我不够清晰,我已经尝试过使用<一个href=\"http://stackoverflow.com/questions/12647220/reading-and-writing-rsa-keys-to-a-pem-file-in-c\">Reading和写作RSA密钥在C 一个PEM文件,但我不太明白。例如,如何在 create_rsa_key()函数创建私人和公众?和在哪里呢 pCipher 从何而来?什么是点的 pcszPassphrase

The main problem is that I'm quite new to C, and the OpenSSL documentation is not clear enough for me, I've tried using Reading and writing rsa keys to a pem file in C, but I don't quite understand it. For example, how does the create_rsa_key() function creates both the private and the public? And where does pCipher come from? And what's the point of the pcszPassphrase?

我会解释,如果它是某种伪code,这就是我想做的事,并以粗体显示的部分是那些我不知道如何做到这一点:

I'll explain as if it was some sort of pseudocode, this is what I want to do, and the parts in bold are those I don't know how to do it:


  • 生成私钥和公钥作为缓冲十六进制(客户端)

  • 发送公钥到另一个端点安全(客户端)

  • 使用AES256 CBC(服务器)
  • 一个随机的256位密码加密一些数据
  • 使用公共密钥(服务器)加密密码

  • 加密的数据发送到客户端(服务器)

  • 使用私钥(客户端)解密该加密的256位密码

  • 解密文件

  • generate private key and public key as buffers in hex (client)
  • send the public key to the other endpoint safely (client)
  • encrypt some data with a random 256 bit password using AES256 CBC (server)
  • encrypt the password using the public key (server)
  • send the encrypted data to the client (server)
  • decrypt the encrypted 256 bit password using the private key (client)
  • decrypt the file

基本上我知道如何处理AES加密/解密和通信协议,他们已经实施无论如何,我的问题是RSA,我需要的十六进制格式的base64没有或PEM因为我与插座的工作和发送和存储为二进制数据。

Basically I know how to handle AES encryption/decryption and the communication protocol, they're already implemented anyway, my issue is RSA, and I need hex format not base64 or pem as I'm working with sockets and sending and storing as binary data.

推荐答案

随着IRC上讨论的,答案create_rsa_key问题是通过的 http://stackoverflow.com/a/29589818/37923 - 这并不意味着以这种方式工作。

As discussed on IRC, the answer to the create_rsa_key question is addressed by http://stackoverflow.com/a/29589818/37923 - it's not meant to work that way.

pcszPassphrase意指是密码/短语以保护专用密钥。它将由用户提供的,但并不是必需的。

pcszPassphrase is meant to be the password/phrase to protect the private key. It would be provided by the user, but isn't a requirement.

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

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