Skip to content

Commit

Permalink
fix: cleanup deny.toml and delete docker-compose.yml (#97)
Browse files Browse the repository at this point in the history
* fix: cleanup deny.toml and delete docker-compose.yml

* fix: remove .rustfmt.toml
  • Loading branch information
Manuthor authored Dec 3, 2024
1 parent 2cded1e commit 2ee118d
Show file tree
Hide file tree
Showing 12 changed files with 107 additions and 190 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ repos:
args: [--skip-string-normalization]

- repo: https://github.com/Cosmian/git-hooks.git
rev: v1.0.32
rev: v1.0.35
hooks:
- id: cargo-format
# - id: cargo-upgrade
# - id: cargo-update
- id: cargo-machete
- id: docker-compose-up
- id: redis-container-up
- id: cargo-tests-all
- id: cargo-test-doc
- id: clippy-autofix-unreachable-pub
Expand All @@ -135,7 +135,7 @@ repos:
- id: cargo-format
- id: cargo-dry-publish
args: [--allow-dirty]
- id: docker-compose-down
- id: redis-container-down

- repo: https://github.com/EmbarkStudios/cargo-deny
rev: 0.16.1 # choose your preferred tag
Expand Down
43 changes: 0 additions & 43 deletions .rustfmt.toml

This file was deleted.

4 changes: 2 additions & 2 deletions benches/benches.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::{collections::HashSet, time::Duration};

use cosmian_findex::{
Findex, InMemory, IndexADT, MemoryADT, Op, Secret, WORD_LENGTH, dummy_decode, dummy_encode,
dummy_decode, dummy_encode, Findex, InMemory, IndexADT, MemoryADT, Op, Secret, WORD_LENGTH,
};
use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
use futures::{executor::block_on, future::join_all};
use lazy_static::lazy_static;
use rand_chacha::ChaChaRng;
Expand Down
57 changes: 0 additions & 57 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
# dependencies not shared by any other crates, would be ignored, as the target
# list here is effectively saying which targets you are building for.
targets = [


# The triple can be any string, but only the target triples built in to
# rustc (as of 1.40) can be checked against actual config expressions
# "x86_64-unknown-linux-musl",
Expand Down Expand Up @@ -72,7 +70,6 @@ feature-depth = 1
# A list of advisory IDs to ignore. Note that ignored advisories will still
# output a note when they are encountered.
ignore = [
# { id = "RUSTSEC-2023-0071", reason = "rsa" },
# { id = "RUSTSEC-0000-0000", reason = "you can specify a reason the advisory is ignored" },
# "[email protected]", # you can also ignore yanked crate versions if you wish
# { crate = "[email protected]", reason = "you can specify why you are ignoring the yanked crate" },
Expand All @@ -95,7 +92,6 @@ allow = [
"Apache-2.0",
"Apache-2.0 WITH LLVM-exception",
"Zlib",
"BSD-2-Clause",
"BSD-3-Clause",
"Unicode-DFS-2016",
"BUSL-1.1",
Expand All @@ -110,31 +106,11 @@ confidence-threshold = 0.8
# Allow 1 or more licenses on a per-crate basis, so that particular licenses
# aren't accepted for every possible crate as with the normal allow list
exceptions = [


# Each entry is the crate and version constraint, and its specific allow
# list
# { allow = ["Zlib"], crate = "adler32" },
]

# Some crates don't have (easily) machine readable licensing information,
# adding a clarification entry for it allows you to manually specify the
# licensing information
[[licenses.clarify]]
# The package spec the clarification applies to
crate = "ring"
# The SPDX expression for the license requirements of the crate
expression = "MIT AND ISC AND OpenSSL"
# One or more files in the crate's source used as the "source of truth" for
# the license expression. If the contents match, the clarification will be used
# when running the license check, otherwise the clarification will be ignored
# and the crate will be checked normally, which may produce warnings or errors
# depending on the rest of your configuration
license-files = [
# Each entry is a crate relative path, and the (opaque) hash of its contents
{ path = "LICENSE", hash = 0xbd0eed23 },
]

[licenses.private]
# If true, ignores workspace crates that aren't published, or are only
# published to private registries.
Expand All @@ -145,8 +121,6 @@ ignore = false
# is only published to private registries, and ignore is true, the crate will
# not have its license(s) checked
registries = [


# "https://sekretz.com/registry
]

Expand Down Expand Up @@ -174,49 +148,20 @@ workspace-default-features = "allow"
external-default-features = "allow"
# List of crates that are allowed. Use with care!
allow = [


# "[email protected]",
# { crate = "[email protected]", reason = "you can specify a reason it is allowed" },
]
# List of crates to deny
deny = [


# "[email protected]",
# { crate = "[email protected]", reason = "you can specify a reason it is banned" },
# Wrapper crates can optionally be specified to allow the crate when it
# is a direct dependency of the otherwise banned crate
# { crate = "[email protected]", wrappers = ["this-crate-directly-depends-on-ansi_term"] },
]

# List of features to allow/deny
# Each entry the name of a crate and a version range. If version is
# not specified, all versions will be matched.
# [[bans.features]]
# crate = "reqwest"
# Features to not allow
# deny = ["json"]
# Features to allow
# allow = [
# "rustls",
# "__rustls",
# "__tls",
# "hyper-rustls",
# "rustls",
# "rustls-pemfile",
# "rustls-tls-webpki-roots",
# "tokio-rustls",
# "webpki-roots",
# ]
# If true, the allowed features must exactly match the enabled feature set. If
# this is set there is no point setting `deny`
# exact = true

# Certain crates/versions that will be skipped when doing duplicate detection.
skip = [


# "[email protected]",
# { crate = "[email protected]", reason = "you can specify a reason why it can't be updated/removed" },
]
Expand All @@ -225,8 +170,6 @@ skip = [
# dependencies starting at the specified crate, up to a certain depth, which is
# by default infinite.
skip-tree = [


# "[email protected]", # will be skipped along with _all_ of its direct and transitive dependencies
# { crate = "[email protected]", depth = 20 },
]
Expand Down
6 changes: 0 additions & 6 deletions docker-compose.yml

This file was deleted.

2 changes: 1 addition & 1 deletion examples/insert.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::HashSet;

use cosmian_findex::{Findex, InMemory, IndexADT, Secret, Value, dummy_decode, dummy_encode};
use cosmian_findex::{dummy_decode, dummy_encode, Findex, InMemory, IndexADT, Secret, Value};
use futures::executor::block_on;
use rand_chacha::ChaChaRng;
use rand_core::{CryptoRngCore, SeedableRng};
Expand Down
59 changes: 33 additions & 26 deletions src/encryption_layer.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use std::{fmt::Debug, ops::Deref, sync::Arc};

use aes::{
cipher::{generic_array::GenericArray, BlockEncrypt, KeyInit},
Aes256,
cipher::{BlockEncrypt, KeyInit, generic_array::GenericArray},
};
use xts_mode::Xts128;

use crate::{
ADDRESS_LENGTH, KEY_LENGTH, MemoryADT, address::Address, error::Error, secret::Secret,
symmetric_key::SymmetricKey,
address::Address, error::Error, secret::Secret, symmetric_key::SymmetricKey, MemoryADT,
ADDRESS_LENGTH, KEY_LENGTH,
};

#[derive(Clone)]
Expand Down Expand Up @@ -44,9 +44,9 @@ pub struct MemoryEncryptionLayer<
}

impl<
const WORD_LENGTH: usize,
Memory: Send + Sync + MemoryADT<Address = Address<ADDRESS_LENGTH>, Word = [u8; WORD_LENGTH]>,
> MemoryEncryptionLayer<WORD_LENGTH, Memory>
const WORD_LENGTH: usize,
Memory: Send + Sync + MemoryADT<Address = Address<ADDRESS_LENGTH>, Word = [u8; WORD_LENGTH]>,
> MemoryEncryptionLayer<WORD_LENGTH, Memory>
{
/// Instantiates a new memory encryption layer.
pub fn new(seed: Secret<KEY_LENGTH>, stm: Memory) -> Self {
Expand Down Expand Up @@ -80,9 +80,9 @@ impl<
}

impl<
const WORD_LENGTH: usize,
Memory: Send + Sync + MemoryADT<Address = Address<ADDRESS_LENGTH>, Word = [u8; WORD_LENGTH]>,
> MemoryADT for MemoryEncryptionLayer<WORD_LENGTH, Memory>
const WORD_LENGTH: usize,
Memory: Send + Sync + MemoryADT<Address = Address<ADDRESS_LENGTH>, Word = [u8; WORD_LENGTH]>,
> MemoryADT for MemoryEncryptionLayer<WORD_LENGTH, Memory>
{
type Address = Address<ADDRESS_LENGTH>;
type Error = Error<Self::Address, Memory::Error>;
Expand Down Expand Up @@ -126,20 +126,20 @@ impl<
#[cfg(test)]
mod tests {
use aes::{
cipher::{generic_array::GenericArray, BlockDecrypt, KeyInit},
Aes256,
cipher::{BlockDecrypt, KeyInit, generic_array::GenericArray},
};
use futures::executor::block_on;
use rand_chacha::ChaChaRng;
use rand_core::SeedableRng;

use crate::{
MemoryADT,
address::Address,
encryption_layer::{ADDRESS_LENGTH, MemoryEncryptionLayer},
encryption_layer::{MemoryEncryptionLayer, ADDRESS_LENGTH},
memory::in_memory::InMemory,
secret::Secret,
symmetric_key::SymmetricKey,
MemoryADT,
};

const WORD_LENGTH: usize = 128;
Expand Down Expand Up @@ -192,33 +192,40 @@ mod tests {
let val_addr_4 = Address::<ADDRESS_LENGTH>::random(&mut rng);

assert_eq!(
block_on(obf.guarded_write((header_addr.clone(), None), vec![
(header_addr.clone(), [2; WORD_LENGTH]),
(val_addr_1.clone(), [1; WORD_LENGTH]),
(val_addr_2.clone(), [1; WORD_LENGTH])
]))
block_on(obf.guarded_write(
(header_addr.clone(), None),
vec![
(header_addr.clone(), [2; WORD_LENGTH]),
(val_addr_1.clone(), [1; WORD_LENGTH]),
(val_addr_2.clone(), [1; WORD_LENGTH])
]
))
.unwrap(),
None
);

assert_eq!(
block_on(obf.guarded_write((header_addr.clone(), None), vec![
(header_addr.clone(), [2; WORD_LENGTH]),
(val_addr_1.clone(), [3; WORD_LENGTH]),
(val_addr_2.clone(), [3; WORD_LENGTH])
]))
block_on(obf.guarded_write(
(header_addr.clone(), None),
vec![
(header_addr.clone(), [2; WORD_LENGTH]),
(val_addr_1.clone(), [3; WORD_LENGTH]),
(val_addr_2.clone(), [3; WORD_LENGTH])
]
))
.unwrap(),
Some([2; WORD_LENGTH])
);

assert_eq!(
block_on(
obf.guarded_write((header_addr.clone(), Some([2; WORD_LENGTH])), vec![
block_on(obf.guarded_write(
(header_addr.clone(), Some([2; WORD_LENGTH])),
vec![
(header_addr.clone(), [4; WORD_LENGTH]),
(val_addr_3.clone(), [2; WORD_LENGTH]),
(val_addr_4.clone(), [2; WORD_LENGTH])
])
)
]
))
.unwrap(),
Some([2; WORD_LENGTH])
);
Expand Down
Loading

0 comments on commit 2ee118d

Please sign in to comment.