Secure storage for cryptographic secrets in Rust

Overview

secrets

Build Status

Cargo Crate Docs License

secrets is a library to help Rust programmers safely held cryptographic secrets in memory.

It is mostly an ergonomic wrapper around the memory-protection utilities provided by libsodium.

Fixed-size buffers allocated on the stack gain the following protections:

  • mlock(2) is called on the underlying memory
  • the underlying memory is zeroed out when no longer in use
  • they are borrowed for their entire lifespan, so cannot be moved
  • they are compared in constant time
  • they are prevented from being printed by Debug
  • they are prevented from being Cloned

Fixed and variable-sized buffers can be allocated on the heap and gain the following protections:

  • the underlying memory is protected from being read from or written to with mprotect(2) unless an active borrow is in scope
  • mlock(2) is called on the allocated memory
  • the underlying memory is zeroed out when no longer in use
  • overflows and underflows are detected using inaccessible guard pages, causing an immediate segmentation fault and program termination
  • short underflows that write to memory are detected when memory is freed using canaries, and will result in a segmentation fault and program termination

Panic Safety

This library is explicitly not panic-safe. To ensure the safety of protected memory space, this library can and will panic if it is unable to enforce its advertised guarantees.

Similarly, this library will cause segmentation faults if (and only if) it detects certain safety violations. For example, this can happen if a process attempts to directly read or write to the contents of memory that hasn't been properly unlocked, or if canaries have been overwritten. This library has been written to ensure that such violations should be impossible to cause through well-formed Rust, and so should only occur as a result of a security vulnerability.

Examples

Example: generating cryptographic keys

Secret::<[u8; 16]>::random(|s| {
    // use `s` as if it were a `&mut [u8; 16]`
    //
    // the memory is `mlock(2)`ed and will be zeroed when this closure
    // exits
});

Example: load a master key from disk and generate subkeys from it

use std::fs::File;
use std::io::Read;

use libsodium_sys as sodium;
use secrets::SecretBox;

const KEY_LEN : usize = sodium::crypto_kdf_KEYBYTES     as _;
const CTX_LEN : usize = sodium::crypto_kdf_CONTEXTBYTES as _;

const CONTEXT : &[u8; CTX_LEN] = b"example\0";

fn derive_subkey(
    key:       &[u8; KEY_LEN],
    context:   &[u8; CTX_LEN],
    subkey_id: u64,
    subkey:    &mut [u8],
) {
    unsafe {
        libsodium_sys::crypto_kdf_derive_from_key(
            subkey.as_mut_ptr(),
            subkey.len(),
            subkey_id,
            context.as_ptr().cast(),
            key.as_ptr()
        );
    }
}

let master_key = SecretBox::<[u8; KEY_LEN]>::try_new(|mut s| {
    File::open("example/master_key/key")?.read_exact(s)
})?;

let subkey_0 = SecretBox::<[u8; 16]>::new(|mut s| {
    derive_subkey(&master_key.borrow(), CONTEXT, 0, s);
});

let subkey_1 = SecretBox::<[u8; 16]>::new(|mut s| {
    derive_subkey(&master_key.borrow(), CONTEXT, 1, s);
});

assert_ne!(
    subkey_0.borrow(),
    subkey_1.borrow(),
);

Example: securely storing a decrypted ciphertext in memory

use std::fs::File;
use std::io::Read;

use libsodium_sys as sodium;
use secrets::{SecretBox, SecretVec};

const KEY_LEN   : usize = sodium::crypto_secretbox_KEYBYTES   as _;
const NONCE_LEN : usize = sodium::crypto_secretbox_NONCEBYTES as _;
const MAC_LEN   : usize = sodium::crypto_secretbox_MACBYTES   as _;

let mut key        = SecretBox::<[u8; KEY_LEN]>::zero();
let mut nonce      = [0; NONCE_LEN];
let mut ciphertext = Vec::new();

File::open("example/decrypted_ciphertext/key")?
    .read_exact(key.borrow_mut().as_mut())?;

File::open("example/decrypted_ciphertext/nonce")?
    .read_exact(&mut nonce)?;

File::open("example/decrypted_ciphertext/ciphertext")?
    .read_to_end(&mut ciphertext)?;

let plaintext = SecretVec::<u8>::new(ciphertext.len() - MAC_LEN, |mut s| {
    if -1 == unsafe {
        sodium::crypto_secretbox_open_easy(
            s.as_mut_ptr(),
            ciphertext.as_ptr(),
            ciphertext.len() as _,
            nonce.as_ptr(),
            key.borrow().as_ptr(),
        )
    } {
        panic!("failed to authenticate ciphertext during decryption");
    }
});

assert_eq!(
    *b"attack at dawn",
    *plaintext.borrow(),
);

License

Licensed under either of

at your option.

Comments
  • Macro for markers & minor cleanups

    Macro for markers & minor cleanups

    One quick question before merging. Is there any reason that the array implementations went up to 64? It is far more common to cover 0..32 (inclusive). The [T; 0] was also not included. I've also added the floating point numbers f32, f64.

    Tuples are simple, this implementation covers () (zero size) .. (A, B, C, D, E, F, G, H, I, J, K, L) where all implement the relevant marker.

    Macro expands to: https://gist.github.com/james-darkfox/c327aab0a5541dfdb5a5

    When implementing PartialEq on Sec, Eq is not needed and should only be used when comparing complete equality, which is not asserted on T. This isn't really a problem as all secrets are just primitive numbers, which are Eq. But again, sodium::cmp does a bitwise comparison so maybe Eq is suitable... This is worth a discussion: "Rust type-level equality" vs "bitwise equality".

    opened by WildCryptoFox 8
  • is there protection agains gcode

    is there protection agains gcode

    Hello,

    i tried the code and it looks like it does not protect against reading the process memory with gcore from gdb.

    code:

    use std::fs::File;
    use std::io::Read;
    
    use std::io::Error;
    
    use std::time::Duration;
    use std::thread::sleep;
    
    
    use secrets::SecretBox;
    
    const KEY_LEN : usize = 10;
    
    fn main() -> Result<(), Error> {
    
        let mut key = SecretBox::<[u8; KEY_LEN]>::zero();
        File::open("key.txt")?
            .read_exact(key.borrow_mut().as_mut())?;
    
        let mut cnt = 0u32;
    
        loop {
            cnt += 1;
    
            sleep(Duration::from_secs(60));
            if cnt == 10 {
                break;
            }
        }
        Ok(())
    }
    

    I f you use

    # gcore -a -o rust_secret_process_dump  $PID
    

    you will find the content of key.txt with the strings tool in the generated process memory dump.

    # strings rust_secret_process_dump.$PID | grep (cat key.txt)
    

    Maybe i missed that this class of attack is not what the library intends to protect from, but could someone elaborate on that.

    opened by jorgeelmundoso 7
  • Allow linking with libsodium-sys via sodiumoxide

    Allow linking with libsodium-sys via sodiumoxide

    @oblique This isn't quite working yet, secrets isn't seeing the symbols for the libsodium packaged by libsodium-sys:

    $ cargo test --no-default-features --features use-libsodium-sys
       Compiling libsodium-sys v0.2.5
       Compiling secrets v1.0.0 (/Users/stephen/Development/github.com/stouset/secrets)
    error: linking with `cc` failed: exit code: 1
      |
      = note: "cc" "-m64" "-L" "/Users/stephen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.10d4y3wwrv6otvh3.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.13xxlqh0xw8kpwbm.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.14v2lsbebybs94pa.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.164cs9vpisbx81rh.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.182gbd6qzvjc6pr8.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.1dok6wsous8ay0uy.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.1dyw8ubt8dz0hhy4.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.1exw2nz62qf7lllm.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.1f1qyjq78rohmncl.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.1g3u00qxmsi2s155.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.1gm3hs578laox7id.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.1l882uuzhuz9x8dq.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.1mnfc3208dwqy3yn.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.1o1d84ss8x083yej.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.1qbikhsggruhkmi8.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.1xtvxtfn5909b3lv.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.1ygbgdb5gg41n8gk.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.1yq8380h7zcgnzz3.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.1z3gf4802o94p2rk.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.1zxv2622z1wn7pkh.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.21ip2z6w6e050s0j.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.2390f6118uy6jx8.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.24skkb8udfgtnege.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.25d61rhoakyl9733.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.26rsk1zknmskbb8q.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.27cpdrj2oaiw8btt.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.291m5c96ln89m35f.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.2a5cwcwlvz2c1uux.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.2b1sn5d56qd8zzz3.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.2bfzwvadwzeltigf.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.2dpzb28tc5w9q5ay.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.2dwhinbrfiggjty2.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.2eppjsn5o3lx8ha.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.2fb0h8dm72aphpjo.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.2jrusdwz0il9hu4f.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.2kmgy31vmag2m6ci.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.2otzxm3vzzakm6zp.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.2piyqnmnthsj2mhp.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.2ppvbe8o5s72muxq.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.2pt7r3qq8mbnlfj1.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.2sh4u5a858o4nvc0.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.2x3pcq42h891rohz.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.2x5pqnii2vkvyopb.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.2xuvsbb6j50mokev.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.34q668pbiv90lqo6.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.36au0xxnwn71kh22.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.37fldbwipnw7n7z2.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.37zbhl1ikeja29a6.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.38wq95zrtys9es2p.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.3allgwy3wkfz7djb.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.3d3x4grca6j56tij.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.3dkib7sw4gox7o7u.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.3e0d2e43lyj7m3rv.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.3f0i5vcpid3e72p9.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.3fpm8oi1sr46uu90.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.3fzkt9yrgyx4ygiz.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.3henpy0wne7ltld2.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.3hnnq4zbjl5g9cul.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.3ia7060xqoo5n3wp.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.3jjy3e37r8s7kdzq.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.3kzrclaiou7pv3bc.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.3r89n2ek9jvy5o6i.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.3r8mccsq6u73nhx5.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.3s993nh6va2gbi7o.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.3t0qexucyavoa0x8.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.3uax2rm8tsfwtsk2.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.3wngs211rdsffnhe.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.3wu0qaw10fvjoiox.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.3y0rf62kaxkrwma0.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.3y71fvv3r8iwqmvc.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.40a81xheazmjyt7r.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.43t29chdrhym0xpe.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.45j3u5s08a3p7hyw.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.463yroirfkm1i99g.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.46w458afqat2jj0p.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.48p24lnxo7mqqksy.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.49qj4ezq8qlll488.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.4b0cpeckgs27wcea.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.4d9s35q0t959q8km.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.4gdkh61hc84hckor.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.4hwnkeqper7fd995.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.4jpr2u8w3auan0le.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.4k2fz4t9nlpbaybw.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.4k8gz9p23v67dozz.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.4kyvwqy5wlb3jxvh.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.4lc3cbrkay1v9xee.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.4qrtzsf4tp18u84d.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.4va6fmo151nlctdj.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.4xykeafjq7tj2tmu.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.509nuxwcicwaisoq.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.52ap3a7gkzasrfch.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.52yghvnkdig227xw.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.54ba2czdxrajfw5i.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.55vkvuk7d6mw70yy.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.5a4skjdtnff98t8f.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.5a6tmsttr8wiuitv.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.5bmfzmhekjhlc5kd.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.5bxgrim2exsl3pe3.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.5ztote16oveb17e.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.717pwozb70rsxpe.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.77brmt2mivsi39c.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.77lr2ewabs17fhf.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.8a82f9oohj04bxy.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.97uwrhad3xdfu68.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.9g3bj77dal2moo8.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.9jl8lj56to2dvfp.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.dx4d1c5nax5co1q.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.i67ejiunulh6wqh.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.l2qe60c2qfto6qz.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.mlzx5p5a597ay0l.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.ndd9e4u7d7twmre.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.ni8f2o9j90dkqjl.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.s8ioydu3ot2mqu.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.szlq6eodscfh92c.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.t5xld3xjuj65f33.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.v5ov6590toyedhb.rcgu.o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.xxkxg2jir19dfij.rcgu.o" "-o" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/secrets-661a7d2728c81019.1aun1vmccq3hkxvx.rcgu.o" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps" "-L" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/build/libsodium-sys-03167c89e96d0ed0/out/installed/lib" "-L" "/Users/stephen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/stephen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libtest-f3aae3c07b46a1b9.rlib" "/Users/stephen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libterm-6339f3af600fdd34.rlib" "/Users/stephen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libgetopts-a4a55ee648c6f6eb.rlib" "/Users/stephen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libunicode_width-f85a23f819c9e138.rlib" "/Users/stephen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_std-f83c45693b829c57.rlib" "/Users/stephen/Development/github.com/stouset/secrets/target/debug/deps/liblibc-195db325339b57d1.rlib" "/Users/stephen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd-473bfa6649025a67.rlib" "/Users/stephen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-8e1c1c2f3b88fa26.rlib" "/Users/stephen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libhashbrown-73b777ace327e6f8.rlib" "/Users/stephen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_alloc-b666c9c30cd05ed8.rlib" "/Users/stephen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libbacktrace-13799bdb379be2ce.rlib" "/Users/stephen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libbacktrace_sys-63abd5899e0d7e6b.rlib" "/Users/stephen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_demangle-1b07ed0286619776.rlib" "/Users/stephen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libunwind-89188c3232051162.rlib" "/Users/stephen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcfg_if-caece456e5f78fce.rlib" "/Users/stephen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liblibc-628a35dcde52dad2.rlib" "/Users/stephen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc-a0fac8d46f97ec7a.rlib" "/Users/stephen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_core-ef5998790eeac756.rlib" "/Users/stephen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcore-3fe78a4d2924ae43.rlib" "/Users/stephen/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-e166c2d904273814.rlib" "-lSystem" "-lresolv" "-lc" "-lm"
      = note: Undefined symbols for architecture x86_64:
                "_sodium_mprotect_readwrite", referenced from:
                    secrets::ffi::sodium::mprotect_readwrite::h474d775c5b6cfa4d in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::mprotect_readwrite::h60df18b40a4ec1d9 in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::mprotect_readwrite::h62e5f6f12be8c6bb in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::mprotect_readwrite::h65a4c6136b70de7e in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::mprotect_readwrite::h70f2d1a6e9892447 in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::mprotect_readwrite::h7a1dffd6503597f3 in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::mprotect_readwrite::h885d99ccc9d0b1e2 in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    ...
                "_sodium_mprotect_noaccess", referenced from:
                    secrets::ffi::sodium::mprotect_noaccess::h5ceccb8aa96a34d1 in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::mprotect_noaccess::h6c539286e53ff67d in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::mprotect_noaccess::h9fbbcee91e2fc4a8 in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::mprotect_noaccess::hae9dc5d1f1ec7fe1 in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::mprotect_noaccess::hb4fa9040b476a9cc in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::mprotect_noaccess::hc82a680417534464 in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::mprotect_noaccess::hc9ca4068f125c986 in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    ...
                "_sodium_mprotect_readonly", referenced from:
                    secrets::ffi::sodium::mprotect_readonly::h019eda1a14d4bcd6 in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::mprotect_readonly::h2a632d4793a9867f in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::mprotect_readonly::h585a0f19d5ae60f5 in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::mprotect_readonly::h5d3cc987dc11fc2d in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::mprotect_readonly::h723c2de217780e14 in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::mprotect_readonly::h8488328422b3b4cc in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::mprotect_readonly::ha2dbd30ed065fcd3 in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    ...
                "_sodium_munlock", referenced from:
                    secrets::ffi::sodium::munlock::h21ae55e554282bee in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::munlock::h65e0afe7572bd2fd in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::munlock::h7435df98392d177b in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::munlock::ha28e0647654fefa0 in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::munlock::ha349bd92024045ac in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::munlock::haef8804395ab69ae in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                   (maybe you meant: secrets::secret::tests::it_detects_sodium_munlock_failure::_$u7b$$u7b$closure$u7d$$u7d$::he4da3d9052a2baaa, secrets::secret::tests::it_detects_sodium_munlock_failure::hd52534a8494cc257 , secrets::secret::tests::it_detects_sodium_munlock_failure::_$u7b$$u7b$closure$u7d$$u7d$::h465d00648340114d )
                "_sodium_free", referenced from:
                    secrets::ffi::sodium::free::h20fddbf6058d5e15 in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::free::h38a57b04e81a98e5 in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::free::h4b84bb48832f5ac3 in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::free::h542b57b878ca15b8 in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::free::h777fb3d768ffb302 in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::free::h7811ea5513c575c0 in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::free::h9ed4e92d4dcf0b08 in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    ...
                "_sodium_allocarray", referenced from:
                    secrets::ffi::sodium::allocarray::h034cf02e60faf437 in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::allocarray::h41815914a65e343f in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::allocarray::h4baaaad44f8add33 in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::allocarray::h5d2ea03db841921d in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::allocarray::ha15122cd69ba70b5 in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::allocarray::ha342d241a12ab225 in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::allocarray::hd31b1bdb9c3d2b04 in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    ...
                "_sodium_memcmp", referenced from:
                    secrets::ffi::sodium::memcmp::h52115ab97d9ba14f in secrets-661a7d2728c81019.1ygbgdb5gg41n8gk.rcgu.o
                "_sodium_init", referenced from:
                    secrets::ffi::sodium::init::_$u7b$$u7b$closure$u7d$$u7d$::h4fedc6fd8de3dcaf in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                   (maybe you meant: secrets::boxed::tests::it_detects_sodium_init_failure::h90ee19433c12555e, secrets::boxed::tests::it_detects_sodium_init_failure::_$u7b$$u7b$closure$u7d$$u7d$::h97a4fdd66299c649 )
                "_sodium_mlock", referenced from:
                    secrets::ffi::sodium::mlock::h0eacf33a866befc0 in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::mlock::h2565b20e3fe9eb0c in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::mlock::h3d165a6307fc8c2a in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::mlock::h8e501c2b5b837b34 in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::mlock::hbd45026c7197c3dc in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                    secrets::ffi::sodium::mlock::hc20556c3ea406871 in secrets-661a7d2728c81019.3pf1yjxb9kdai3b3.rcgu.o
                   (maybe you meant: secrets::secret::tests::it_detects_sodium_mlock_failure::_$u7b$$u7b$closure$u7d$$u7d$::h45bcd0e9be9679b7, secrets::secret::tests::it_detects_sodium_mlock_failure::h0863e1b9a55630dd , secrets::secret::tests::it_detects_sodium_mlock_failure::_$u7b$$u7b$closure$u7d$$u7d$::h26b8d9228c265b8c )
                "_sodium_memzero", referenced from:
                    secrets::ffi::sodium::memzero::hd00977e11cbeaafd in secrets-661a7d2728c81019.1ygbgdb5gg41n8gk.rcgu.o
                "_randombytes_buf", referenced from:
                    secrets::ffi::sodium::memrandom::h3a74c0e1e8cbfa20 in secrets-661a7d2728c81019.1ygbgdb5gg41n8gk.rcgu.o
              ld: symbol(s) not found for architecture x86_64
              clang: error: linker command failed with exit code 1 (use -v to see invocation)
              
    
    error: aborting due to previous error
    
    error: could not compile `secrets`.
    
    To learn more, run the command again with --verbose.
    
    opened by stouset 5
  • Trouble compiling on OpenBSD

    Trouble compiling on OpenBSD

    I'm having trouble compiling on OpenBSD 6.6 with libsodioum (version 1.0.18) and rustc version 1.38.0.

    I have tried the latest version both on crates.io and github.

    I get the following output (tried both debug and release):

    RUST_BACKTRACE=1 cargo build --release
       Compiling secrets v0.12.1 (https://github.com/stouset/secrets#7c1d5ab8)
    error: failed to run custom build command for `secrets v0.12.1 (https://github.com/stouset/secrets#7c1d5ab8)`
    
    Caused by:
      process didn't exit successfully: `/root/memsecstore/target/release/build/secrets-f5777c6962e6309d/build-script-build` (exit code: 101)
    --- stdout
    cargo:rerun-if-env-changed=COVERAGE
    cargo:rerun-if-env-changed=PROFILE
    cargo:rustc-cfg=profile="release"
    cargo:rerun-if-env-changed=LIBSODIUM_NO_PKG_CONFIG
    cargo:rerun-if-env-changed=PKG_CONFIG
    cargo:rerun-if-env-changed=LIBSODIUM_STATIC
    cargo:rerun-if-env-changed=LIBSODIUM_DYNAMIC
    cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
    cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
    cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-openbsd
    cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_openbsd
    cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
    cargo:rerun-if-env-changed=PKG_CONFIG_PATH
    cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-openbsd
    cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_openbsd
    cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
    cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
    cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-openbsd
    cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_openbsd
    cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
    cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
    cargo:rerun-if-env-changed=LIBSODIUM_STATIC
    cargo:rerun-if-env-changed=LIBSODIUM_DYNAMIC
    cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
    cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
    cargo:rerun-if-env-changed=PKG_CONFIG
    cargo:rerun-if-env-changed=LIBSODIUM_STATIC
    cargo:rerun-if-env-changed=LIBSODIUM_DYNAMIC
    cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
    cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
    cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-openbsd
    cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_openbsd
    cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
    cargo:rerun-if-env-changed=PKG_CONFIG_PATH
    cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-openbsd
    cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_openbsd
    cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
    cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
    cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-openbsd
    cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_openbsd
    cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
    cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
    
    --- stderr
    thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:378:21
    stack backtrace:
       0: __register_frame_info
       1: __register_frame_info
       2: __register_frame_info
       3: __register_frame_info
       4: __register_frame_info
       5: __register_frame_info
       6: __register_frame_info
       7: __register_frame_info
       8: __register_frame_info
       9: __register_frame_info
      10: __register_frame_info
      11: __register_frame_info
      12: __register_frame_info
      13: __register_frame_info
      14: __register_frame_info
      15: <unknown>
    
    
    opened by alex-caelus 5
  • SIGSEGV on SecretVec::zero()

    SIGSEGV on SecretVec::zero()

    I am running secrets v0.11.1 and libsodium

    $ apt-cache policy libsodium13
    libsodium13:
      Installed: 1.0.1-1
    

    and even a small program like

    extern crate secrets;
    use secrets::SecretVec;
    fn main() {
        let secret = SecretVec::<u8>::zero(48);
    }
    

    segfaults with this backtrace:

    Program received signal SIGSEGV, Segmentation fault.
    0x00007ffff7ba5844 in sodium_memcmp () from /usr/lib/x86_64-linux-gnu/libsodium.so.13
    (gdb) where
    #0  0x00007ffff7ba5844 in sodium_memcmp ()
       from /usr/lib/x86_64-linux-gnu/libsodium.so.13
    #1  0x00007ffff7ba5d0b in sodium_free ()
       from /usr/lib/x86_64-linux-gnu/libsodium.so.13
    #2  0x000055555555b2fd in secrets::sodium::free<u8> (ptr=0x7ffff7ff2fd0 "")
        at /home/manuel/.cargo/registry/src/github.com-1ecc6299db9ec823/secrets-0.11.1/src/sodium.rs:51
    #3  0x000055555555b0c5 in secrets::sec::{{impl}}::drop<u8> (self=0x7fffffffdf98)
        at /home/manuel/.cargo/registry/src/github.com-1ecc6299db9ec823/secrets-0.11.1/src/sec.rs:40
    #4  0x000055555555aae1 in drop::h68a5af34c64127be ()
    #5  0x000055555555ab29 in drop::h8ecd862ad2c8e15b ()
    #6  0x000055555555b491 in xx::main () at /tmp/xx/src/main.rs:7
    #7  0x000055555556c747 in __rust_maybe_catch_panic ()
    #8  0x0000555555563a02 in std::rt::lang_start::haaae1186de9de8cb ()
    #9  0x000055555555b514 in main ()
    

    PS: Oh, and I am running rustc 1.13.0-nightly (55bf6a4f8 2016-09-18)

    opened by manuels 4
  • Relicense under dual MIT/Apache-2.0

    Relicense under dual MIT/Apache-2.0

    This issue was automatically generated. Feel free to close without ceremony if you do not agree with re-licensing or if it is not possible for other reasons. Respond to @cmr with any questions or concerns, or pop over to #rust-offtopic on IRC to discuss.

    You're receiving this because someone (perhaps the project maintainer) published a crates.io package with the license as "MIT" xor "Apache-2.0" and the repository field pointing here.

    TL;DR the Rust ecosystem is largely Apache-2.0. Being available under that license is good for interoperation. The MIT license as an add-on can be nice for GPLv2 projects to use your code.

    Why?

    The MIT license requires reproducing countless copies of the same copyright header with different names in the copyright field, for every MIT library in use. The Apache license does not have this drawback. However, this is not the primary motivation for me creating these issues. The Apache license also has protections from patent trolls and an explicit contribution licensing clause. However, the Apache license is incompatible with GPLv2. This is why Rust is dual-licensed as MIT/Apache (the "primary" license being Apache, MIT only for GPLv2 compat), and doing so would be wise for this project. This also makes this crate suitable for inclusion and unrestricted sharing in the Rust standard distribution and other projects using dual MIT/Apache, such as my personal ulterior motive, the Robigalia project.

    Some ask, "Does this really apply to binary redistributions? Does MIT really require reproducing the whole thing?" I'm not a lawyer, and I can't give legal advice, but some Google Android apps include open source attributions using this interpretation. Others also agree with it. But, again, the copyright notice redistribution is not the primary motivation for the dual-licensing. It's stronger protections to licensees and better interoperation with the wider Rust ecosystem.

    How?

    To do this, get explicit approval from each contributor of copyrightable work (as not all contributions qualify for copyright, due to not being a "creative work", e.g. a typo fix) and then add the following to your README:

    ## License
    
    Licensed under either of
    
     * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
     * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
    
    at your option.
    
    ### Contribution
    
    Unless you explicitly state otherwise, any contribution intentionally submitted
    for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any
    additional terms or conditions.
    

    and in your license headers, if you have them, use the following boilerplate (based on that used in Rust):

    // Copyright 2016 secrets Developers
    //
    // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
    // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
    // http://opensource.org/licenses/MIT>, at your option. This file may not be
    // copied, modified, or distributed except according to those terms.
    

    It's commonly asked whether license headers are required. I'm not comfortable making an official recommendation either way, but the Apache license recommends it in their appendix on how to use the license.

    Be sure to add the relevant LICENSE-{MIT,APACHE} files. You can copy these from the Rust repo for a plain-text version.

    And don't forget to update the license metadata in your Cargo.toml to:

    license = "MIT OR Apache-2.0"
    

    I'll be going through projects which agree to be relicensed and have approval by the necessary contributors and doing this changes, so feel free to leave the heavy lifting to me!

    Contributor checkoff

    To agree to relicensing, comment with :

    I license past and future contributions under the dual MIT/Apache-2.0 license, allowing licensees to chose either at their option.
    

    Or, if you're a contributor, you can check the box in this repo next to your name. My scripts will pick this exact phrase up and check your checkbox, but I'll come through and manually review this issue later as well.

    • [x] @james-darkfox
    • [x] @stouset
    opened by emberian 4
  • any updates on using libsodium mshild

    any updates on using libsodium mshild

    FWIW, libsodium recently added an mshield function that performs in-memory encryption. When that is stabilized and released, I'll be able to use it.

    Of course, anyone with similar privileges can still find the key and IV in memory and decrypt the secret, but it does increase the level of effort for such an attach.

    Originally posted by @stouset in https://github.com/stouset/secrets/issues/72#issuecomment-520934478

    That was the result of an other issue from last year, is that still on the roaster?

    opened by jorgeelmundoso 3
  • This crate now fully builds on Windows.

    This crate now fully builds on Windows.

    Made it possible for this create to build on windows. I unfortunately had to add a #[cfg(...)] block enclosing the libc::setrlibit call because windows has no such functionality that I can find. If there is such functionality, I have absolutely no idea how to do it (one answer to this question suggested that I use "job objects", but I don't know how I'd use those in Rust). I don't know if this lowers the security barrier or not, however.

    opened by ethindp 2
  • Question about linkage

    Question about linkage

    Is there any reason that you explicitly search with pkg-config for libsodium? This is done by libsodium-sys with use-pkg-config feature flag.

    I believe this should be left to the user of the crate. Is it ok with you if I remove the link in build.rs and add use-pkg-config feature flag that enables libsodium-sys/use-pkg-config?

    opened by oblique 1
  • Update Cargo.toml

    Update Cargo.toml

    Mentioning "0" would mean cargo would pick the latest dependency which is versioned "0.*" which would include versions incompatible with the one that this crate was written with and may break your create.

    opened by Dylan-DPC 0
  • Update libc dependency

    Update libc dependency

    You don't support [email protected]. So don't say you do.

    Yes, cargo by default will give you [email protected], and everything will work. But also, libc could release a version 0.3 with API changes (however unlikely that may be), and you would break because of that. And you don't even have the benefit of allowing a 1.0 libc, either.

    You don't necessarily need to be fully minimal-versions correct (though it would be better if you were), but saying you work with [email protected] and [email protected] is just completely incorrect.

    opened by CAD97 0
  • `bool` and `char`'s `Bytes` implementations cause undefined behavior.

    `bool` and `char`'s `Bytes` implementations cause undefined behavior.

    The documentation for secrets::traits::Bytes states:

    Any type that implements Bytes must not exhibit undefined behavior when its underlying bits are set to any arbitrary bit pattern.

    Currently, bool and char (the primitive types) have implementations for Bytes (https://github.com/stouset/secrets/blob/master/src/traits.rs#L69 ), but these types can not be set to arbitrary bit patterns (specifically, bool must have the bit pattern 0x00 or 0x01, and char must have a bit pattern in the range 0x0000_0000..=0x0000_D7FF or the range 0x0000_E000..=0x0010_FFFF)

    The following example program exhibits undefined behavior due to this (run it in debug mode and in release mode and you'll most likely see different results):

    fn main() {
        let b: char = secrets::traits::Bytes::uninitialized();
        match b {
            // Note that these two patterns together include all valid char values
            '\x00'..='\u{10fffe}' => dbg!("char1"),
            '\x01'..='\u{10ffff}' => dbg!("char2"), // This prints in release mode on my machine (secrets 1.2.0, rustc 1.61.0)
            _ => dbg!("huh?"), // This prints in debug mode on my machine
        };
    }
    
    opened by zachs18 0
  • How do I handle Strings combined with Secret(Box)?

    How do I handle Strings combined with Secret(Box)?

    Hey!

    Your examples mostly showcase usage with raw bytes. Could you help me out on working with a String that I want to securely store inside one of the Secret variants? The String is read from the tty (it's a user-entered password).

    The SecretBox documentation showcases an example where some bytes are moved into SecretVec by using the from method. Is that currently the only way to accomplish this?

    Thanks for helping me out!

    opened by mainrs 1
  • Pure Rust implementation of libsodium/utils

    Pure Rust implementation of libsodium/utils

    There is crate called memsec which is a pure Rust implementation of libsodium/utils.

    Maybe we can replace libsodium entirely? I'm willing to open a PR.

    opened by oblique 6
Owner
Stephen Touset
Stephen Touset
Secure multithreaded packet sniffer

sniffglue sniffglue is a network sniffer written in rust. Network packets are parsed concurrently using a thread pool to utilize all cpu cores. Projec

null 914 Dec 30, 2022
Secure transport for running MPC protocols backed by Signal

MPC over Signal Overview This library provides a high-level interface for connecting to Signal Server and using it to exchange messages with other con

[ZenGo X] 42 Jan 4, 2023
Secure sandboxing system for untrusted code execution

Godbox Secure sandboxing system for untrusted code execution. It uses isolate which uses specific functionnalities of the Linux kernel, thus godbox no

Nathanael Demacon 19 Dec 14, 2022
Cross-platform Secure TUI Secret Locker

SafeCloset keeps your secrets in password protected files. SafeCloset is designed to be convenient and avoid common weaknesses like external editing or temporary files written on disk.

Canop 63 Dec 26, 2022
Secure and fast microVMs for serverless computing.

Our mission is to enable secure, multi-tenant, minimal-overhead execution of container and function workloads. Read more about the Firecracker Charter

firecracker-microvm 20.3k Jan 1, 2023
Use Touch ID / Secure Enclave for SSH Authentication!

SeKey About SeKey is a SSH Agent that allow users to authenticate to UNIX/Linux SSH servers using the Secure Enclave How it Works? The Secure Enclave

SeKey 2.3k Dec 26, 2022
Cyg will help you to secure files in your repository directly using PGP encryption

cyg: Secure files in your repository Cyg will help you to secure files in your repository directly using PGP encryption. The name "cyg" was inspired b

Hisam Fahri 2 Aug 31, 2022
Detects usage of unsafe Rust in a Rust crate and its dependencies.

cargo-geiger ☢️ Looking for maintainer: https://github.com/rust-secure-code/cargo-geiger/issues/210 A program that lists statistics related to the usa

Rust Secure Code Working Group 1.1k Jan 4, 2023
An esoteric language/compiler written with Rust and Rust LLVM bindings

MeidoLang (メイドラング) A not so useful and esoteric language. The goal of this project was to contain some quirky or novel syntax in a stack-style program

null 0 Dec 24, 2021
Rust-verification-tools - RVT is a collection of tools/libraries to support both static and dynamic verification of Rust programs.

Rust verification tools This is a collection of tools/libraries to support both static and dynamic verification of Rust programs. We see static verifi

null 253 Dec 31, 2022
Rust bindings for libinjection

libinjection-rs Rust bindings for libinjection. How to use Add libinjection to dependencies of Cargo.toml: libinjection = "0.2" Import crate: extern c

ArvanCloud 35 Sep 24, 2022
A simple password manager written in Rust

ripasso A simple password manager written in Rust. The root crate ripasso is a library for accessing and decrypting passwords stored in pass format (G

Joakim Lundborg 548 Dec 26, 2022
tcp connection hijacker, rust rewrite of shijack

rshijack tcp connection hijacker, rust rewrite of shijack from 2001. This was written for TAMUctf 2018, brick house 100. The target was a telnet serve

null 377 Jan 1, 2023
A fast, simple, recursive content discovery tool written in Rust.

A simple, fast, recursive content discovery tool written in Rust ?? Releases ✨ Example Usage ✨ Contributing ✨ Documentation ?? ?? What the heck is a f

epi 3.6k Dec 30, 2022
link is a command and control framework written in rust

link link is a command and control framework written in rust. Currently in alpha. Table of Contents Introduction Features Feedback Build Process Ackno

null 427 Dec 24, 2022
CVEs for the Rust standard library

Rust CVE Preface This is a list of CVEs for unsound APIs in the Rust standard library. These bugs break Rust's memory safety guarantee and lead to sec

Yechan Bae 26 Dec 4, 2022
Rust bindings for VirusTotal/Yara

yara-rust Bindings for the Yara library from VirusTotal. More documentation can be found on the Yara's documentation. Example The implementation is in

null 43 Dec 17, 2022
Rust library for building and running BPF/eBPF modules

RedBPF A Rust eBPF toolchain. Overview The redbpf project is a collection of tools and libraries to build eBPF programs using Rust. It includes: redbp

foniod 1.5k Jan 1, 2023
Rust library for developing safe canisters.

IC Kit This library provides an alternative to ic-cdk that can help developers write canisters and unit test them in their Rust code. Install Add this

Psychedelic 26 Nov 28, 2022