This repository has been archived by the owner on Jun 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding documentation and explanations to some parts of core (#122)
Adding documentation and explanations to some parts of core
- Loading branch information
Showing
25 changed files
with
401 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,24 @@ | ||
use crate::CryptoError; | ||
//! # Rand module | ||
//! This module is an abstraction layer over the random functions. <br> | ||
//! The purpose of it is so it can be used the same within and outside of SGX | ||
//! (through `/dev/urandom` and through the `RDRAND` instruction.) | ||
|
||
#[cfg(all(feature = "std", not(feature = "sgx")))] | ||
pub fn random(rand: &mut [u8]) -> Result<(), CryptoError> { | ||
/// This function gets a mutable slice and will fill it | ||
/// with random data using the available randomness source | ||
pub fn random(rand: &mut [u8]) -> Result<(), crate::CryptoError> { | ||
use rand_std::{Rng, rngs::EntropyRng}; | ||
let mut rng = EntropyRng::new(); | ||
rng.try_fill(rand) | ||
.map_err(|e| CryptoError::RandomError { err: e } ) | ||
.map_err(|e| crate::CryptoError::RandomError { err: e } ) | ||
} | ||
|
||
|
||
#[cfg(all(feature = "sgx", not(feature = "std")))] | ||
pub fn random(rand: &mut [u8]) -> Result<(), CryptoError> { | ||
/// This function gets a mutable slice and will fill it | ||
/// with random data using the available randomness source | ||
pub fn random(rand: &mut [u8]) -> Result<(), crate::CryptoError> { | ||
use sgx_trts::trts::rsgx_read_rand; | ||
rsgx_read_rand(rand) | ||
.map_err(|e| CryptoError::RandomError { err: e } ) | ||
.map_err(|e| crate::CryptoError::RandomError { err: e } ) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,20 @@ | ||
//! # Errors | ||
//! This is a module for the errors of this crate. | ||
//! we use Failure to handle the Error and Display traits and other conversions. | ||
//! | ||
use failure::Fail; | ||
|
||
/// This Error enum is used to represent errors from this library. | ||
/// Pro tip: If you want to add a string message to the error and you always hard code it, | ||
/// then you can use `&'static str` instead of String, this will make your code much nicer. | ||
#[derive(Debug, Fail, Clone)] | ||
pub enum ToolsError { | ||
/// The `MessagingError` error. | ||
/// | ||
/// This error means that there was a Messaging problem (e.g. couldn't deserialize a message) | ||
#[fail(display = "There's an error with the messaging: {}", err)] | ||
MessagingError { err: &'static str }, | ||
MessagingError { | ||
/// `Err` is the custom message that should explain what and where was the problem. | ||
err: &'static str | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.