Add some helpful documentation for the SSH library.
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -22,4 +22,5 @@ Cargo.lock
|
|||||||
FlameGraph
|
FlameGraph
|
||||||
*.user_stacks
|
*.user_stacks
|
||||||
**/.ghc.environment.*
|
**/.ghc.environment.*
|
||||||
tests/rsa/dist*
|
|
||||||
|
test.ed25519
|
||||||
@@ -5,8 +5,6 @@
|
|||||||
//! you're not sure, this is a pretty good choice.
|
//! you're not sure, this is a pretty good choice.
|
||||||
//!
|
//!
|
||||||
//! ```rust
|
//! ```rust
|
||||||
//! extern crate sha2;
|
|
||||||
//!
|
|
||||||
//! use simple_crypto::ed25519::ED25519KeyPair;
|
//! use simple_crypto::ed25519::ED25519KeyPair;
|
||||||
//!
|
//!
|
||||||
//! // Generate a new ED25519 key
|
//! // Generate a new ED25519 key
|
||||||
@@ -39,6 +37,7 @@ use std::collections::HashMap;
|
|||||||
use super::KeyPair;
|
use super::KeyPair;
|
||||||
|
|
||||||
/// An ED25519 key pair
|
/// An ED25519 key pair
|
||||||
|
#[derive(Debug,PartialEq)]
|
||||||
pub struct ED25519KeyPair
|
pub struct ED25519KeyPair
|
||||||
{
|
{
|
||||||
pub public: ED25519Public,
|
pub public: ED25519Public,
|
||||||
|
|||||||
@@ -1,3 +1,35 @@
|
|||||||
|
//! Most of the routines you want are exported from this module as functions,
|
||||||
|
//! not as structs, macros, enums, or what have you. In particular, you
|
||||||
|
//! probably want the `decode` or `encode` functions, or one of the functions
|
||||||
|
//! that `load`s data from disk or `write`s it. Here's some example code
|
||||||
|
//! to get you started, using a generated ED25519 key for fun:
|
||||||
|
//!
|
||||||
|
//! ```rust
|
||||||
|
//! use simple_crypto::ed25519::ED25519KeyPair;
|
||||||
|
//! use simple_crypto::ssh::*;
|
||||||
|
//!
|
||||||
|
//! // Generate a new ED25519 key
|
||||||
|
//! let mut rng = rand::rngs::OsRng::new().unwrap();
|
||||||
|
//! let kp = ED25519KeyPair::generate(&mut rng);
|
||||||
|
//!
|
||||||
|
//! // Now that we have it, we can encode it as a handy ASCII string in memory,
|
||||||
|
//! // using a totally fake email address for fun:
|
||||||
|
//! let ascii_rep = encode_ssh(&kp, "fake@email.addr").expect("Encode failure!");
|
||||||
|
//!
|
||||||
|
//! // As usual, we should be able to decode anything we encode, and the
|
||||||
|
//! // keys should match:
|
||||||
|
//! let (kp2, addr2) = decode_ssh(&ascii_rep).expect("Decode failure!");
|
||||||
|
//! assert_eq!(kp, kp2);
|
||||||
|
//! assert_eq!(&addr2, "fake@email.addr");
|
||||||
|
//!
|
||||||
|
//! // If you want to write this to a file, you can just do so directly:
|
||||||
|
//! write_ssh_keyfile("test.ed25519", &kp, "fake@email.addr").expect("write error");
|
||||||
|
//! // And then load it back:
|
||||||
|
//! let (kp3, addr3) = load_ssh_keyfile("test.ed25519").expect("load error");
|
||||||
|
//! // And, of course, it should be the same.
|
||||||
|
//! assert_eq!(kp, kp3);
|
||||||
|
//! assert_eq!(addr2, addr3);
|
||||||
|
//! ```
|
||||||
mod dsa;
|
mod dsa;
|
||||||
mod ecdsa;
|
mod ecdsa;
|
||||||
mod ed25519;
|
mod ed25519;
|
||||||
|
|||||||
Reference in New Issue
Block a user