Coder Social home page Coder Social logo

sodium-alloc's Introduction

sodium-alloc

crates.io docs.rs

Rust Allocator type that allocates memory using Sodium's secure memory utilities.

Requires nightly Rust, as the Allocator API is not yet stable.

This library implements SodiumAllocator, an Allocator which uses the sodium_malloc and corresponding sodium_free functions to manage memory. When managing sensitive data in memory, there are a number of steps we can take to help harden our software against revealing these secrets.

Sodium's sodium_malloc implementation introduces many of these hardening steps to the memory management process: Allocated memory is placed at the end of a page boundary, immediately followed by a guard page (a region of memory which is marked as inaccessible, any attempt to access it will result in termination of the program). A canary is placed before the allocated memory, any modifications to which are detected on free, again resulting in program termination, and a guard page is placed before this. sodium_mlock is used to instruct the operating system not to swap the memory to disk, or to include it in core dumps.

When memory is freed with SodiumAllocator, the sodium_free function is called, which will securely zero the memory before marking it as free. This means that for types allocated with SodiumAllocator, there is no need to implement Zeroize or a similar Drop implementation to zero the memory when no longer in use: It will automatically be zeroed when freed.

This library is not suitable for use as a general-purpose allocator or global allocator: The overhead of this API is much greater than Rust's standard allocator, and the implementation is more likely to encounter errors. It is intended for use when allocating sensitive data types only, for example, a key or password which needs to be stored in memory.

Security/Vulnerability Disclosures

If you find a vulnerability in sodium-alloc, please immediately contact [email protected] with details.

My age public key (preferred) is:

age1gglesedq4m2z9kc7urjhq3zlpc6qewcwpcna7s0lwh8k2c4e6fxqf3kdvq

My PGP public key has fingerprint 0x4712EC7C9F404B14, and is available from keyserver.ubuntu.com, pgp.mit.edu, or Github.

License

Licensed under either of:

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.

sodium-alloc's People

Contributors

tom25519 avatar

Stargazers

Harry avatar Wittawat Manha avatar Conrad Meyer avatar

Watchers

 avatar

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.