Skip to content

Commit

Permalink
root: lay foundation for portions
Browse files Browse the repository at this point in the history
This patch provides the foundations for the various components of libacc to be formed.

Signed-off-by: Amy Parker <amy@amyip.net>
  • Loading branch information
amyipdev committed Feb 1, 2024
1 parent 7a43132 commit b5d16e4
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ Cargo.lock

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

# Added by cargo

/target
8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "libacc"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
13 changes: 13 additions & 0 deletions src/aes.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/// Generates AES-encrypted packet from key.
/// Returns the encrypted packet with appended nonce,
/// which is really only the first 96 bits of the last 16 bytes.
fn encapsulate(pkt: &[u8], key: &[u8]) -> Vec<u8> {
unimplemented!()
}

/// Attempts to decrypt AES with a given key.
/// If this fails, returns Err.
/// On success, returns Ok(Vec<u8>) containing the packet.
fn reveal(pkt: &[u8]) -> Result<Vec<u8>, std::io::Error> {
unimplemented!()
}
5 changes: 5 additions & 0 deletions src/bson.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// No definitions yet.
// Need to define the encapsulate and reveal functions.
// Because BSON depends on the protocol version,
// need to develop an Enum<Struct, Struct, ...> to
// work based on the protocol version.
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mod aes;
mod bson;
mod padding;
12 changes: 12 additions & 0 deletions src/padding.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Applies new padding to a BSON packet.
// Returns the padded packet.
fn encapsulate(pkt: &[u8]) -> Vec<u8> {
unimplemented!()
}

/// Strips the padding from an unencrypted packet.
/// Returns Ok(Vec<u8>) containing the BSON if successful.
/// Returns Err if the packet is invalid.
fn reveal(pkt: &[u8]) -> Result<Vec<u8>, std::io::Error> {
unimplemented!()
}

0 comments on commit b5d16e4

Please sign in to comment.