Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Remove Into impls for Memzero.
Browse files Browse the repository at this point in the history
  • Loading branch information
twittner committed Apr 10, 2018
1 parent a56b226 commit 74fed42
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 23 deletions.
18 changes: 0 additions & 18 deletions util/mem/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,3 @@ impl<T: AsMut<[u8]>> DerefMut for Memzero<T> {
}
}

impl Into<[u8; 8]> for Memzero<[u8; 8]> {
fn into(self) -> [u8; 8] {
self.mem
}
}

impl Into<[u8; 16]> for Memzero<[u8; 16]> {
fn into(self) -> [u8; 16] {
self.mem
}
}

impl Into<[u8; 32]> for Memzero<[u8; 32]> {
fn into(self) -> [u8; 32] {
self.mem
}
}

15 changes: 10 additions & 5 deletions whisper/src/rpc/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,10 @@ impl EncryptionInstance {
}
AesEncode::OnTopics(topics) => {
let mut buf = Vec::new();
let key = H256(key.into());

for topic in topics {
buf.extend(&*(topic ^ key));
for mut t in topics {
xor(&mut t.0, &key);
buf.extend(&t.0);
}

encrypt_plain(&mut buf);
buf
}
Expand All @@ -126,6 +124,13 @@ impl EncryptionInstance {
}
}

#[inline]
fn xor(a: &mut [u8; 32], b: &[u8; 32]) {
for i in 0 .. 32 {
a[i] ^= b[i]
}
}

enum AesExtract {
AppendedNonce(Memzero<[u8; AES_KEY_LEN]>), // extract appended nonce.
OnTopics(usize, usize, H256), // number of topics, index we know, topic we know.
Expand Down

0 comments on commit 74fed42

Please sign in to comment.