Skip to content

Commit

Permalink
add basic trait and files
Browse files Browse the repository at this point in the history
  • Loading branch information
sunhuachuang committed May 24, 2019
1 parent 8c0a474 commit b469f32
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/target
**/*.rs.bk
foo
6 changes: 6 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file added src/dh.rs
Empty file.
Empty file added src/encrypt.rs
Empty file.
Empty file added src/signature.rs
Empty file.
29 changes: 29 additions & 0 deletions src/traits.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
trait SignatureAlgorithm {
type SignKey;
type VerifyKey;

fn sign(plain: &Vec<u8>, sign_key: &SignKey) -> Vec<u8>;

fn verify(plain: &Vec<u8>, sign: &Vec<u8>, verify_key: &VerifyKey) -> bool;
}

trait PublicKeyAlgorithm {
type PublicKey;
type PrivateKey;

fn encrypt(plain: &Vec<u8>, public_key: &PublicKey) -> Vec<u8>;

fn decrypt(cipher: &Vec<u8>, secret_key: &PrivateKey) -> Vec<u8>;
}

trait SymmetricAlgorithm {
type Key;

fn encrypt(plain: &Vec<u8>, session_key: &Key) -> Vec<u8>;

fn decrypt(cipher: &Vec<u8>, session_key: &Key) -> Vec<u8>;
}

trait HashAlgorithm {
fn hash(data: Vec<u8>) -> Vec<u8>;
}

0 comments on commit b469f32

Please sign in to comment.