Skip to content

Bindings for Apple's Common Crypto library, which supports symmetric encryption, hash-based message authentication codes, and digests.

License

Notifications You must be signed in to change notification settings

steven-joruk/common-crypto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

common-crypto

github action crates.io docs.rs

Bindings for Apple's Common Crypto APIs.

Examples

[dependencies]
common-crypto = "0.3"

Cryptor

let config = Config::AES256 {
    mode: Mode::CTR,
    iv: Some(b"use random iv :)"),
    key: b"0123456789abcdef0123456789abcdef",
};

let encrypted = Cryptor::encrypt(&config, b"Hello").unwrap();
let decrypted = Cryptor::decrypt(&config, encrypted).unwrap();
assert_eq!(decrypted, b"Hello");

Hash

let hash = Hash::sha256(b"data");
let mut hasher = hash::SHA256::new();
hasher.update(b"data");
hasher.update(b"more data");
let hash = hasher.finish();

HMAC

let auth_code = HMAC::sha512(b"Key", b"Input");
let mut hasher = hmac::SHA256::new(b"Key");
hasher.update(b"data");
hasher.update(b"more data");
let hash = hasher.finish();

What's missing?

  • Resetting cryptors - I don't see a use case for this, so I won't implement it unless someone requests it.
  • Padding and rounds for cryptors. I want to make sure they're only configurable where they're actually supported.

Contributing

Feel free to contribute in any way you like.

About

Bindings for Apple's Common Crypto library, which supports symmetric encryption, hash-based message authentication codes, and digests.

Resources

License

Stars

Watchers

Forks

Languages