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
How encode public key? #6
Comments
Does https://security.stackexchange.com/questions/115862/what-is-the-format-of-an-rsa-public-key help explain it any?
You should be able to just take the public key in DER format and wrap it with RSA PUBLIC KEY, no?
… On Nov 18, 2017, at 10:24 AM, Quanyi Ma ***@***.***> wrote:
I write a generate private key program with pem:
extern crate openssl;
extern crate pem;
use openssl::rsa::Rsa;
use pem::{Pem, encode};
fn main() {
// Generate a new 4096-bit key.
let rsa = Rsa::generate(4096).unwrap();
let public_key = rsa.public_key_to_der().unwrap();
let private_key = rsa.private_key_to_der().unwrap();
let private_pem = Pem {
tag: String::from("RSA PRIVATE KEY"),
contents: private_key,
};
let private = encode(&private_pem);
println!("{}", private);
}
But I couldn't found a way encode public data to PKIX format, do you have an idea?
Thanks much!
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
To expand a little bit:
Should do the trick. |
Yeah, I want to use the public key in OpenSSH. The format looks like
|
That’s not PEM format. That’s OpenSSH’s key format. You’ll need a different library.
… On Nov 18, 2017, at 11:34 PM, Quanyi Ma ***@***.***> wrote:
Yeah, I want to use the public key in OpenSSH. The format looks like
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDsczjw5Sns1AQGhO6I7Ldxc2bSxaVH3pl0iSEs7MG35RgxUEZz98EruAnGkhPJZiAx72EyJDlYWgOk5MoGoqlyh9zsk9sIZbPRh1J3YJPYmWoVyiTiV2a2UO7FLYhZbz70trX2Ey8yon5JYaspJemltNQzmhxAOA6ObRqLGSKQNIYV+LV2RFfIoPozD7D6DON3claaExogOy7N5Q8SqvNNzSo+sN/vRai0eEzEC88ERc4uJQbftm9lveoPNKN9lkKpeUmzoN6HQtO7CFK2Z7qELFfvGJDe30VpLWAqMs88ipjajAGSMT2dDPOtO9xEKkNIGHbeo8hjopj7sUuAnydUmDq4JYwqmX55NkAWWN785RGLWjxLY7ID7zrx4d8hyWv5h99J6CJdy87svwwF1pNJIxsQulNSwwtJhe/Y5nZpUjQhEYo7LyWuVAGE79tvk2lMLskdR05ubmxgSl/xI3NXbBZfmg8nEnwbLA426tiK1W5tk/RoFYKktmhwXci6dbuqRfHh7keRolY+4mcRO3jfAYlohjIwCzzrlD0AttVEWKo0tQukKF+vVn8R6H18V1XQpY0wJ9Zjlg94ETmYBziNAVhdTNimk2ElXwYFbU1bNxEcEaPI7xCz+EWQcyEalySqN/0AYqZ+cLyCqIR8TQxWMBJxjpDP08IyUXWhIP2xew== ***@***.***
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@cardoe I resolved the problem with |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I write a generate private key program with pem:
But I couldn't found a way encode public data to PKIX format, do you have an idea?
Thanks much!
The text was updated successfully, but these errors were encountered: