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
@@ -34,7 +34,7 @@ use rcrypto::symmetriccipher::*;
|
||||
use rcrypto::buffer::*;
|
||||
use tiny_keccak::Keccak;
|
||||
use bytes::{Buf, BufMut};
|
||||
use crypto;
|
||||
use ethkey::crypto;
|
||||
use network::{Error, ErrorKind};
|
||||
|
||||
const ENCRYPTED_HEADER_LEN: usize = 32;
|
||||
|
||||
@@ -25,7 +25,7 @@ use connection::{Connection};
|
||||
use node_table::NodeId;
|
||||
use io::{IoContext, StreamToken};
|
||||
use ethkey::{KeyPair, Public, Secret, recover, sign, Generator, Random};
|
||||
use crypto::{ecdh, ecies};
|
||||
use ethkey::crypto::{ecdh, ecies};
|
||||
use network::{Error, ErrorKind, HostInfo};
|
||||
|
||||
#[derive(PartialEq, Eq, Debug)]
|
||||
|
||||
@@ -151,8 +151,14 @@ impl From<ethkey::Error> for Error {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<crypto::Error> for Error {
|
||||
fn from(_err: crypto::Error) -> Self {
|
||||
impl From<ethkey::crypto::Error> for Error {
|
||||
fn from(_err: ethkey::crypto::Error) -> Self {
|
||||
ErrorKind::Auth.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<crypto::error::SymmError> for Error {
|
||||
fn from(_err: crypto::error::SymmError) -> Self {
|
||||
ErrorKind::Auth.into()
|
||||
}
|
||||
}
|
||||
@@ -168,11 +174,11 @@ fn test_errors() {
|
||||
|
||||
match *<Error as From<rlp::DecoderError>>::from(rlp::DecoderError::RlpIsTooBig).kind() {
|
||||
ErrorKind::Auth => {},
|
||||
_ => panic!("Unexpeceted error"),
|
||||
_ => panic!("Unexpected error"),
|
||||
}
|
||||
|
||||
match *<Error as From<crypto::Error>>::from(crypto::Error::InvalidMessage).kind() {
|
||||
match *<Error as From<ethkey::crypto::Error>>::from(ethkey::crypto::Error::InvalidMessage).kind() {
|
||||
ErrorKind::Auth => {},
|
||||
_ => panic!("Unexpeceted error"),
|
||||
_ => panic!("Unexpected error"),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user