This repository has been archived by the owner on Nov 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fix/decoding-headers-can-fail-#8553
* master: Rlp decode returns Result (#8527) Node table sorting according to last contact data (#8541) Keep all enacted blocks notify in order (#8524) ethcore, rpc, machine: refactor block reward application and tracing (#8490) Consolidate crypto functionality in `ethcore-crypto`. (#8432) EIP 145: Bitwise shifting instructions in EVM (#8451) Remove expect (#8536) Don't panic in import_block if invalid rlp (#8522) Pass on storage keys tracing to handle the case when it is not modified (#8491) Fetching logs by hash in blockchain database (#8463) Transaction Pool improvements (#8470) More changes for Android (#8421) Enable WebAssembly and Byzantium for Ellaism (#8520) SecretStore: merge two types of errors into single one + Error::is_non_fatal (#8357) Hardware Wallet trait (#8071) Directly return None if tracing is disabled (#8504) Show imported messages for light client (#8517)
- Loading branch information
Showing
144 changed files
with
3,429 additions
and
1,853 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -4,13 +4,9 @@ version = "0.1.0" | |
authors = ["Parity Technologies <[email protected]>"] | ||
|
||
[dependencies] | ||
ethereum-types = "0.3" | ||
quick-error = "1.2" | ||
ring = "0.12" | ||
rust-crypto = "0.2.36" | ||
tiny-keccak = "1.3" | ||
eth-secp256k1 = { git = "https://github.com/paritytech/rust-secp256k1", optional = true } | ||
ethkey = { path = "../../ethkey", optional = true } | ||
ethereum-types = "0.3" | ||
subtle = "0.5" | ||
|
||
[features] | ||
default = ["secp256k1"] | ||
secp256k1 = ["eth-secp256k1", "ethkey"] |
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright 2015-2017 Parity Technologies (UK) Ltd. | ||
// This file is part of Parity. | ||
|
||
// Parity is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Parity is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Parity. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
use error::SymmError; | ||
use rcrypto::blockmodes::{CtrMode, CbcDecryptor, PkcsPadding}; | ||
use rcrypto::aessafe::{AesSafe128Encryptor, AesSafe128Decryptor}; | ||
use rcrypto::symmetriccipher::{Encryptor, Decryptor}; | ||
use rcrypto::buffer::{RefReadBuffer, RefWriteBuffer, WriteBuffer}; | ||
|
||
/// Encrypt a message (CTR mode). | ||
/// | ||
/// Key (`k`) length and initialisation vector (`iv`) length have to be 16 bytes each. | ||
/// An error is returned if the input lengths are invalid. | ||
pub fn encrypt_128_ctr(k: &[u8], iv: &[u8], plain: &[u8], dest: &mut [u8]) -> Result<(), SymmError> { | ||
let mut encryptor = CtrMode::new(AesSafe128Encryptor::new(k), iv.to_vec()); | ||
encryptor.encrypt(&mut RefReadBuffer::new(plain), &mut RefWriteBuffer::new(dest), true)?; | ||
Ok(()) | ||
} | ||
|
||
/// Decrypt a message (CTR mode). | ||
/// | ||
/// Key (`k`) length and initialisation vector (`iv`) length have to be 16 bytes each. | ||
/// An error is returned if the input lengths are invalid. | ||
pub fn decrypt_128_ctr(k: &[u8], iv: &[u8], encrypted: &[u8], dest: &mut [u8]) -> Result<(), SymmError> { | ||
let mut encryptor = CtrMode::new(AesSafe128Encryptor::new(k), iv.to_vec()); | ||
encryptor.decrypt(&mut RefReadBuffer::new(encrypted), &mut RefWriteBuffer::new(dest), true)?; | ||
Ok(()) | ||
} | ||
|
||
/// Decrypt a message (CBC mode). | ||
/// | ||
/// Key (`k`) length and initialisation vector (`iv`) length have to be 16 bytes each. | ||
/// An error is returned if the input lengths are invalid. | ||
pub fn decrypt_128_cbc(k: &[u8], iv: &[u8], encrypted: &[u8], dest: &mut [u8]) -> Result<usize, SymmError> { | ||
let mut encryptor = CbcDecryptor::new(AesSafe128Decryptor::new(k), PkcsPadding, iv.to_vec()); | ||
let len = dest.len(); | ||
let mut buffer = RefWriteBuffer::new(dest); | ||
encryptor.decrypt(&mut RefReadBuffer::new(encrypted), &mut buffer, true)?; | ||
Ok(len - buffer.remaining()) | ||
} | ||
|
Oops, something went wrong.