Consolidate crypto functionality in ethcore-crypto. (#8432)
* Consolidate crypto functionality in `ethcore-crypto`.
- Move `ecdh`/`ecies` modules to `ethkey`.
- Refactor `ethcore-crypto` to use file per module.
- Replace `subtle` with `ethcore_crypto::is_equal`.
- Add `aes_gcm` module to `ethcore-crypto`.
* Rename `aes::{encrypt,decrypt,decrypt_cbc}` ...
... to `aes::{encrypt_128_ctr,decrypt_128_ctr,decrypt_128_cbc}`.
This commit is contained in:
committed by
Marek Kotewicz
parent
a4c7843a07
commit
e30839e85f
@@ -18,9 +18,7 @@ use std::cmp::{max, min};
|
||||
use std::io::{self, Read};
|
||||
|
||||
use byteorder::{ByteOrder, BigEndian};
|
||||
use crypto::sha2::Sha256 as Sha256Digest;
|
||||
use crypto::ripemd160::Ripemd160 as Ripemd160Digest;
|
||||
use crypto::digest::Digest;
|
||||
use ethcore_crypto::digest;
|
||||
use num::{BigUint, Zero, One};
|
||||
|
||||
use hash::keccak;
|
||||
@@ -295,28 +293,17 @@ impl Impl for EcRecover {
|
||||
|
||||
impl Impl for Sha256 {
|
||||
fn execute(&self, input: &[u8], output: &mut BytesRef) -> Result<(), Error> {
|
||||
let mut sha = Sha256Digest::new();
|
||||
sha.input(input);
|
||||
|
||||
let mut out = [0; 32];
|
||||
sha.result(&mut out);
|
||||
|
||||
output.write(0, &out);
|
||||
|
||||
let d = digest::sha256(input);
|
||||
output.write(0, &*d);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Impl for Ripemd160 {
|
||||
fn execute(&self, input: &[u8], output: &mut BytesRef) -> Result<(), Error> {
|
||||
let mut sha = Ripemd160Digest::new();
|
||||
sha.input(input);
|
||||
|
||||
let mut out = [0; 32];
|
||||
sha.result(&mut out[12..32]);
|
||||
|
||||
output.write(0, &out);
|
||||
|
||||
let hash = digest::ripemd160(input);
|
||||
output.write(0, &[0; 12][..]);
|
||||
output.write(12, &hash);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,9 +63,9 @@ extern crate bn;
|
||||
extern crate byteorder;
|
||||
extern crate crossbeam;
|
||||
extern crate common_types as types;
|
||||
extern crate crypto;
|
||||
extern crate ethash;
|
||||
extern crate ethcore_bloom_journal as bloom_journal;
|
||||
extern crate ethcore_crypto;
|
||||
extern crate ethcore_io as io;
|
||||
extern crate ethcore_bytes as bytes;
|
||||
extern crate ethcore_logger;
|
||||
|
||||
Reference in New Issue
Block a user