Skip to content

Commit

Permalink
Mla/Fuzz: switch to mlakey-parser
Browse files Browse the repository at this point in the history
  • Loading branch information
commial committed Aug 1, 2024
1 parent f9601ef commit 5f19c79
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion mla-fuzz-afl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ edition = "2018"
afl = "0"
bincode = "~1.3"
serde = { version = "1", features = ["derive"] }
curve25519-parser = { version = "0.4", default-features = false }
mlakey-parser = { path = "../mlakey-parser", version = "0", default-features = false }
mla = { path = "../mla" }

[lints.rust]
Expand Down
16 changes: 8 additions & 8 deletions mla-fuzz-afl/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use afl::fuzz;
extern crate afl;
use bincode::Options;
use curve25519_parser::{parse_openssl_25519_privkey, parse_openssl_25519_pubkey};
use mlakey_parser::{parse_mlakey_privkey, parse_mlakey_pubkey};
use serde::{Deserialize, Serialize};
use std::fs::File;
use std::io::{self, Cursor, Read, Write};
Expand All @@ -13,8 +13,8 @@ use mla::{ArchiveFailSafeReader, ArchiveFileID, ArchiveReader, ArchiveWriter, La

use std::collections::HashMap;

static PUB_KEY: &[u8] = include_bytes!("../../samples/test_x25519_pub.pem");
static PRIV_KEY: &[u8] = include_bytes!("../../samples/test_x25519.pem");
static PUB_KEY: &[u8] = include_bytes!("../../samples/test_mlakey_pub.pem");
static PRIV_KEY: &[u8] = include_bytes!("../../samples/test_mlakey.pem");

#[derive(Serialize, Deserialize, Debug)]
struct TestInput {
Expand Down Expand Up @@ -45,7 +45,7 @@ fn run(data: &[u8]) {
}

// Load the needed public key
let public_key = parse_openssl_25519_pubkey(PUB_KEY).unwrap();
let public_key = parse_mlakey_pubkey(PUB_KEY).unwrap();

// Create a MLA Archive
let mut buf = Vec::new();
Expand Down Expand Up @@ -120,7 +120,7 @@ fn run(data: &[u8]) {
// Parse the created MLA Archive
let dest = mla.into_raw();
let buf = Cursor::new(dest.as_slice());
let private_key = parse_openssl_25519_privkey(PRIV_KEY).unwrap();
let private_key = parse_mlakey_privkey(PRIV_KEY).unwrap();
let mut config = ArchiveReaderConfig::new();
config.add_private_keys(&[private_key]);
let mut mla_read = ArchiveReader::from_config(buf, config).unwrap();
Expand Down Expand Up @@ -148,7 +148,7 @@ fn run(data: &[u8]) {
// Build FailSafeReader
let buf = Cursor::new(dest.as_slice());
let mut config = ArchiveReaderConfig::new();
let private_key = parse_openssl_25519_privkey(PRIV_KEY).unwrap();
let private_key = parse_mlakey_privkey(PRIV_KEY).unwrap();
config.add_private_keys(&[private_key]);
let mut mla_fsread = ArchiveFailSafeReader::from_config(buf, config).unwrap();

Expand Down Expand Up @@ -195,7 +195,7 @@ fn run(data: &[u8]) {
// Check the resulting files
let buf = Cursor::new(dest_mut.as_slice());
let mut config = ArchiveReaderConfig::new();
let private_key = parse_openssl_25519_privkey(PRIV_KEY).unwrap();
let private_key = parse_mlakey_privkey(PRIV_KEY).unwrap();
config.add_private_keys(&[private_key]);
let _do_steps = || -> Result<(), Error> {
let mut mla_read = ArchiveReader::from_config(buf, ArchiveReaderConfig::new())?;
Expand All @@ -213,7 +213,7 @@ fn run(data: &[u8]) {
// Build FailSafeReader
let buf = Cursor::new(dest_mut.as_slice());
let mut config = ArchiveReaderConfig::new();
let private_key = parse_openssl_25519_privkey(PRIV_KEY).unwrap();
let private_key = parse_mlakey_privkey(PRIV_KEY).unwrap();
config.add_private_keys(&[private_key]);
let mut mla_fsread = {
if let Ok(mla) = ArchiveFailSafeReader::from_config(buf, config) {
Expand Down

0 comments on commit 5f19c79

Please sign in to comment.