Skip to content

A Rust implementation of Keybase's TripleSec and other layered encryption schemes based on it. Mirror of https://git.hazardcell.com/rust-layeredsec/about/.

License

Notifications You must be signed in to change notification settings

joejacobs/rust-layeredsec

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

layeredsec

License Build Status Dependency Status

Rust implementation of Keybase's TripleSec (.onion) encryption scheme (versions 3 and 4) and other layered encryption schemes based on it.

UNAUDITED, USE AT YOUR OWN RISK

TripleSec

TripleSec itself is available via the layeredsec::triplesec module. triplesec::encrypt encrypts a plaintext with the latest version of TripleSec (currently v4) while triplesec::decrypt can decrypt ciphertext versions 3/4. Alternatively you could use the encrypt and decrypt functions in triplesec::v3 and triplesec::v4 if you want specific versions of TripleSec.

Custom Layered Encryption Schemes

You should probably stick to the tried and tested TripleSec encryption scheme. But if you know what you're doing and you really want/need to, then you could use the define_2_layer_encryption_scheme and define_3_layer_encryption_scheme macros in layeredsec to define custom layered encryption scheme modules. The macros use 2 or 3 stream ciphers, 2 HMACs and can optionally have a header (e.g. for magic bytes or version numbers). Right now layeredsec has the following stream ciphers and HMACs:

Stream Ciphers

HMAC (uses RustCrypto)

  • BLAKE2b
  • Keccak-512
  • SHA-512
  • SHA3-512

For instance, the following defines the "Python version" of TripleSec v3:

define_3_layer_encryption_module!(
    triplesec_v3_python,                            // module name
    &[0x1c, 0x94, 0xd7, 0xde, 0x0, 0x0, 0x0, 0x3],  // header
    XSalsa20,                                       // inner-most cipher
    Twofish256Ctr,                                  // middle cipher
    Aes256Ctr,                                      // outer-most cipher
    hmac_sha2,                                      // HMAC 1
    hmac_sha3                                       // HMAC 2
);

License

Copyright (C) 2019 Joe Jacobs

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.

About

A Rust implementation of Keybase's TripleSec and other layered encryption schemes based on it. Mirror of https://git.hazardcell.com/rust-layeredsec/about/.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages