Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ecies): expose ECIESCodec for fuzzing #9182

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions crates/net/ecies/src/codec.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! This contains the main codec for `RLPx` ECIES messages

use crate::{algorithm::ECIES, ECIESError, EgressECIESValue, IngressECIESValue};
use alloy_primitives::{bytes::BytesMut, B512 as PeerId};
use secp256k1::SecretKey;
Expand All @@ -7,14 +9,14 @@ use tracing::{instrument, trace};

/// Tokio codec for ECIES
#[derive(Debug)]
pub(crate) struct ECIESCodec {
pub struct ECIESCodec {
ecies: ECIES,
state: ECIESState,
}

/// Current ECIES state of a connection
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
enum ECIESState {
pub enum ECIESState {
/// The first stage of the ECIES handshake, where each side of the connection sends an auth
/// message containing the ephemeral public key, signature of the public key, nonce, and other
/// metadata.
Expand All @@ -23,7 +25,12 @@ enum ECIESState {
/// The second stage of the ECIES handshake, where each side of the connection sends an ack
/// message containing the nonce and other metadata.
Ack,

/// The third stage of the ECIES handshake, where header is parsed, message integrity checks
/// performed, and message is decrypted.
Header,

/// The final stage, where the ECIES message is actually read and returned by the ECIES codec.
Body,
}

Expand Down
2 changes: 1 addition & 1 deletion crates/net/ecies/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub mod util;
mod error;
pub use error::ECIESError;

mod codec;
pub mod codec;

use alloy_primitives::{
bytes::{Bytes, BytesMut},
Expand Down
Loading