chore(ecies): expose ECIESCodec for fuzzing (#9182)

This commit is contained in:
Dan Cline
2024-06-28 16:01:02 -04:00
committed by GitHub
parent 6e564cd064
commit d1efe2b19b
2 changed files with 10 additions and 3 deletions

View File

@ -1,3 +1,5 @@
//! This contains the main codec for `RLPx` ECIES messages
use crate::{algorithm::ECIES, ECIESError, EgressECIESValue, IngressECIESValue}; use crate::{algorithm::ECIES, ECIESError, EgressECIESValue, IngressECIESValue};
use alloy_primitives::{bytes::BytesMut, B512 as PeerId}; use alloy_primitives::{bytes::BytesMut, B512 as PeerId};
use secp256k1::SecretKey; use secp256k1::SecretKey;
@ -7,14 +9,14 @@ use tracing::{instrument, trace};
/// Tokio codec for ECIES /// Tokio codec for ECIES
#[derive(Debug)] #[derive(Debug)]
pub(crate) struct ECIESCodec { pub struct ECIESCodec {
ecies: ECIES, ecies: ECIES,
state: ECIESState, state: ECIESState,
} }
/// Current ECIES state of a connection /// Current ECIES state of a connection
#[derive(Clone, Copy, Debug, PartialEq, Eq)] #[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 /// 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 /// message containing the ephemeral public key, signature of the public key, nonce, and other
/// metadata. /// metadata.
@ -23,7 +25,12 @@ enum ECIESState {
/// The second stage of the ECIES handshake, where each side of the connection sends an ack /// The second stage of the ECIES handshake, where each side of the connection sends an ack
/// message containing the nonce and other metadata. /// message containing the nonce and other metadata.
Ack, Ack,
/// The third stage of the ECIES handshake, where header is parsed, message integrity checks
/// performed, and message is decrypted.
Header, Header,
/// The final stage, where the ECIES message is actually read and returned by the ECIES codec.
Body, Body,
} }

View File

@ -16,7 +16,7 @@ pub mod util;
mod error; mod error;
pub use error::ECIESError; pub use error::ECIESError;
mod codec; pub mod codec;
use alloy_primitives::{ use alloy_primitives::{
bytes::{Bytes, BytesMut}, bytes::{Bytes, BytesMut},