GithubHelp home page GithubHelp logo

sodalite's Introduction

sodalite

An implementation of tweetnacl in pure rust. Originally generated by manually translating tweetnacl.c into rust. Tested by verifying outputs match those of tweetnacl.

Todo

  • provide additional APIs:
  • rather than take bare mutable references, use wrapper types around the refs to capture the underlying type (ie: prevent mixing keys between primitives)
  • add a buffer and/or "set-only" abstraction to prevent unsafety wrt uninitialized values (also should allow some internal optimization).
  • sodiumoxide style API that returns values rather than taking mutable refs
  • Use namespacing to separate different APIs and backend impls
  • start testing against sodiumoxide as well
  • Provide some of the API improvements from libsodium that are missing nacl (disjoint signatures, not requiring special extra space in buffers)

License

Licensed under either of

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.

sodalite's People

Contributors

bors[bot] avatar codyps avatar davidlattimore avatar dependabot-preview[bot] avatar pidelport avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sodalite's Issues

Question about secretbox

Dear sodalite developer,

I have been using your library and I have a question about the secretbox function. In the documentation, it states that the first 32 bytes of the message must be zero. Can you explain why this is necessary?

Thank you for your time and for creating this library.

Best regards,
Aitor Ruiz

Get 'signal: 11, SIGSEGV: invalid memory reference'

When I use secretbox_open API I got 'signal: 11, SIGSEGV: invalid memory reference', below is some demo code:

const NONCE_LENGTH: usize = 24;

fn decrypt_content(password: &str, encrypted: &str) -> Result<String> {

    let encrypted_bytes = hex::decode(encrypted)?;
    let nonce: &[u8; 24] = &encrypted_bytes[0..NONCE_LENGTH].try_into().unwrap();
    println!("nonce: {}", hex::encode(nonce.clone()));
    let cipher_text = &encrypted_bytes[NONCE_LENGTH..];
    println!("cipher_text: {}", hex::encode(cipher_text.clone()));
    let mut encoded = Vec::<u8>::new();
    encoded.resize(cipher_text.len(), 0u8);

    let key = password_to_key(password);  // return a [u8; 32]

    println!("key: {}", hex::encode(key.clone()));
    let ret = secretbox_open(&mut encoded, cipher_text, nonce, &key);
    assert!(ret.is_ok(), "open secretbox failed");

    println!("encoded: {}", hex::encode(encoded.clone()));
   
    Ok(hex::encode(encoded))
}

Pls give me some suggestions

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.