Skip to content

Commit

Permalink
Merge pull request #41 from Cosmian/fix/rename
Browse files Browse the repository at this point in the history
* Rename library `cover_crypt` to `cosmian_cover_crypt`
  • Loading branch information
Manuthor authored Oct 10, 2022
2 parents cd2ed9c + 324c2ff commit 03a2353
Show file tree
Hide file tree
Showing 12 changed files with 138 additions and 95 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/release_on_tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Release

on:
push:
tags:
- "*"

jobs:
release:
name: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Release
uses: softprops/action-gh-release@v1
90 changes: 55 additions & 35 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ variables:
KMS_PUBLIC_PATH: /tmp
KMS_PRIVATE_PATH: /tmp
KMS_SHARED_PATH: /tmp
# Postgres for `cosmian_js_lib` tests
# Postgres for `cloudproof_js` tests
POSTGRES_DB: app_db
POSTGRES_USER: app_user
POSTGRES_PASSWORD: password
PGPASSWORD: password
# Postgrest for `cosmian_js_lib` tests
# Postgrest for `cloudproof_js` tests
PGRST_SERVER_HOST: localhost
PGRST_SERVER_PORT: 3000
PGRST_DB_URI: postgres://app_user:password@localhost:5432/app_db
Expand All @@ -24,6 +24,7 @@ stages:
- prebuild
- build
- test
- package
- publish

rustfmt:
Expand Down Expand Up @@ -70,25 +71,19 @@ cargo_security_check:
before_script:
- sccache -s

benchmarks:
<<: *base_compile
script:
- cargo bench --all-features
when: manual

build_x86_64:
<<: *base_compile
script:
- cargo build --verbose --release --features ffi --target x86_64-unknown-linux-gnu
- cargo test --verbose --release --all-features --target x86_64-unknown-linux-gnu
- cargo build --release --features ffi --target x86_64-unknown-linux-gnu
- cargo test --release --all-features --target x86_64-unknown-linux-gnu
- cbindgen . -c cbindgen.toml | grep -v \#include | uniq >target/${CI_PROJECT_NAME}.h

build_x86_64_centos7:
<<: *base_compile
image: gitlab.cosmian.com:5000/core/ci-rust-glibc-2.17
script:
- cargo build --verbose --release --features ffi --target x86_64-unknown-linux-gnu
- cargo test --verbose --release --features ffi --target x86_64-unknown-linux-gnu
- cargo build --release --features ffi --target x86_64-unknown-linux-gnu
- cargo test --release --features ffi --target x86_64-unknown-linux-gnu
- cbindgen . -c cbindgen.toml | grep -v \#include | uniq >target/${CI_PROJECT_NAME}.h
artifacts:
paths:
Expand All @@ -100,9 +95,9 @@ build_wasm:
<<: *base_compile
image: gitlab.cosmian.com:5000/core/ci-npm:latest
script:
- wasm-pack build --release --features wasm_bindgen
- wasm-pack build -d pkg/bundler --release --features wasm_bindgen
- wasm-pack test --node --features wasm_bindgen --lib
- wasm-pack build --target nodejs --release --features wasm_bindgen
- wasm-pack build -d pkg/nodejs --target nodejs --release --features wasm_bindgen
artifacts:
paths:
- pkg
Expand All @@ -111,7 +106,7 @@ build_wasm:
build_windows:
<<: *base_compile
script:
- cargo build --verbose --release --features ffi --target x86_64-pc-windows-gnu
- cargo build --release --features ffi --target x86_64-pc-windows-gnu
- cbindgen . -c cbindgen.toml | grep -v \#include | uniq >target/${CI_PROJECT_NAME}.h
artifacts:
paths:
Expand All @@ -120,16 +115,19 @@ build_windows:
expire_in: 3 mos

build_osx:
<<: *base_compile
image: gitlab.cosmian.com:5000/core/ci-rust-osx:latest
stage: build
image: joseluisq/rust-linux-darwin-builder:1.64.0
before_script:
- cargo install cargo-lipo
- rustup target add aarch64-apple-ios x86_64-apple-ios x86_64-apple-darwin
- cp /root/.cargo/config "$CARGO_HOME/"
script:
- cargo build --verbose --release --features ffi
- cbindgen . -c cbindgen.toml | grep -v \#include | uniq >target/${CI_PROJECT_NAME}.h
- cargo build --release --features ffi --target x86_64-apple-darwin
- cargo lipo --release --features ffi --allow-run-on-non-macos
artifacts:
paths:
- target/release/*.a
- target/release/*.so
- target/*.h
- target/x86_64-apple-darwin/release/*.dylib
- target/universal/release/*.a
expire_in: 3 mos

build_android:
Expand All @@ -142,7 +140,7 @@ build_android:
- jniLibs
expire_in: 3 mos

test_cosmian_java_lib:
test_cloudproof_java:
image: openjdk:8
stage: test
services:
Expand All @@ -152,9 +150,9 @@ test_cosmian_java_lib:
before_script:
- apt update && apt install -y maven
script:
- git clone https://github.com/Cosmian/cosmian_java_lib.git
- cp target/x86_64-unknown-linux-gnu/release/libcover_crypt.so cosmian_java_lib/src/test/resources/linux-x86-64/
- cd cosmian_java_lib
- git clone https://github.com/Cosmian/cloudproof_java.git
- cp target/x86_64-unknown-linux-gnu/release/libcosmian_${CI_PROJECT_NAME}.so cloudproof_java/src/test/resources/linux-x86-64/
- cd cloudproof_java
- mvn package
allow_failure: true

Expand All @@ -168,7 +166,7 @@ test_python:
- target/wheels/*.whl
expire_in: 3 mos

test_cosmian_js_lib:
test_cloudproof_js:
image: node:16
stage: test
services:
Expand All @@ -180,14 +178,26 @@ test_cosmian_js_lib:
before_script:
- apt update && apt install -y postgresql libpq-dev
script:
- git clone https://github.com/Cosmian/cosmian_js_lib.git
- cp -r pkg/* cosmian_js_lib/tests/wasm_lib/abe/cover_crypt/
- cd cosmian_js_lib
- git clone https://github.com/Cosmian/cloudproof_js.git
- mkdir -p cloudproof_js/tests/wasm_lib/${CI_PROJECT_NAME}
- cp -r pkg/nodejs/* cloudproof_js/tests/wasm_lib/${CI_PROJECT_NAME}/
- cd cloudproof_js
- psql -h localhost -U "$POSTGRES_USER" -d "$POSTGRES_DB" -f ./dump_db_demo.sql
- npm install jest
- npm test
allow_failure: true

pack_all_artifacts:
stage: package
before_script:
- apt update && apt install -y zip
script:
- zip -r ${CI_PROJECT_NAME}-${CI_COMMIT_TAG}-bin.zip pkg target jniLibs
artifacts:
paths:
- ${CI_PROJECT_NAME}-${CI_COMMIT_TAG}-bin.zip
expire_in: 3 mos

npm_publish:
image: gitlab.cosmian.com:5000/core/ci-npm:latest
stage: publish
Expand All @@ -208,9 +218,19 @@ cargo_publish:
script:
- echo "[registry]" > ~/.cargo/credentials
- echo "token = \"$CRATES_IO\"" >> ~/.cargo/credentials
- rm -rf /tmp/cover_crypt
- cp -rf . /tmp/cover_crypt
- cd /tmp/cover_crypt
- rm -rf jniLibs target
- rm -rf /tmp/${CI_PROJECT_NAME}
- cp -rf . /tmp/${CI_PROJECT_NAME}
- cd /tmp/${CI_PROJECT_NAME}
- rm -rf ${CI_PROJECT_NAME}-${CI_COMMIT_TAG}-bin.zip jniLibs target
- cargo publish --token $CRATES_IO
- rm -rf /tmp/cover_crypt
- rm -rf /tmp/${CI_PROJECT_NAME}

# Finally, run benchmarks at once
benchmarks:
stage: publish
rules:
- if: '$CI_COMMIT_TAG =~ /^v\d+.\d+.\d+$/'
before_script:
- apt update && apt install -y gnuplot
script:
- cargo bench --all-features
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
All notable changes to this project will be documented in this file.


---
## [6.0.5] - 2022-10-07
### Added
### Changed
- Rename library `cover_crypt` to `cosmian_cover_crypt`
### Fixed
### Removed
---

---
## [6.0.4] - 2022-09-28
### Added
Expand Down
42 changes: 21 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
[package]
name = "cover_crypt"
version = "6.0.4"
name = "cosmian_cover_crypt"
version = "6.0.5"
edition = "2021"
authors = [
"Théophile Brezot <[email protected]>",
"Bruno Grieder <[email protected]>",
]
description = "Key Policy attribute encryption based on subset cover"
documentation = "https://docs.rs/cover_crypt/"
documentation = "https://docs.rs/cosmian_cover_crypt/"
license = "MIT/Apache-2.0"
repository = "https://github.com/Cosmian/cover_crypt"


[lib]
name = "cover_crypt"
crate-type = ["lib", "cdylib", "staticlib"]
name = "cosmian_cover_crypt"
crate-type = ["rlib", "cdylib", "staticlib"]
# The cdylib is only interesting if the `--features ffi` flag is set on build
# This does not seem to be actionable conditionally https://github.com/rust-lang/cargo/issues/4881

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ CoverCrypt has been designed as a fast alternative to Key Policy Attribute Based
It is typically used in a hybrid encryption scheme as a KEM to encapsulate the symmetric key of a DEM (AES 256 GCM in the provided hybrid implementation)

```
CoverCrypt encryption over 1 partition:
CoverCrypt encryption over 1 partition:
time: [156.28 µs 156.73 µs 157.21 µs]
Found 538 outliers among 5000 measurements (10.76%)
207 (4.14%) high mild
331 (6.62%) high severe
CoverCrypt encryption over 3 partitions
CoverCrypt encryption over 3 partitions
time: [255.07 µs 255.70 µs 256.36 µs]
Found 364 outliers among 5000 measurements (7.28%)
135 (2.70%) high mild
Expand Down Expand Up @@ -58,7 +58,7 @@ Run `cargo bench` to get the details (see below)

The crate is separated in 3 main modules:

- `cover_crypt_core`: contains the cryptographic code for CoverCrypt.
- `cover_crypt_core`: contains the cryptographic code for CoverCrypt.
- `api.rs`: exposes the public API with policy management
- `interfaces`: contains interfaces useful for Cosmian matching those in [crypto_base](https://github.com/Cosmian/crypto_base) as well as a Foreign Function Interface (FFI) useful to integrate with other languages. In particular, the code in this module demonstrates the use of hybrid cryptography involving ABE and AES and exposes it as a FFI.

Expand All @@ -80,7 +80,7 @@ cargo build --release --all-features

The latter will build a shared library and one can verify that the FFI symbols are present using (linux)
```bash
objdump -T target/release/libcover_crypt.so
objdump -T target/release/libcosmian_cover_crypt.so
```

The code contains numerous tests that you can run using
Expand Down
10 changes: 5 additions & 5 deletions benches/benches.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
use abe_policy::{AccessPolicy, Attribute, Policy, PolicyAxis};
#[cfg(feature = "ffi")]
use cosmian_crypto_core::symmetric_crypto::aes_256_gcm_pure;
use cosmian_crypto_core::symmetric_crypto::{aes_256_gcm_pure::Aes256GcmCrypto, Metadata};
use cover_crypt::{
use cosmian_cover_crypt::{
api::CoverCrypt,
error::Error,
interfaces::statics::{decrypt_hybrid_header, encrypt_hybrid_header, EncryptedHeader},
PublicKey,
};
#[cfg(feature = "ffi")]
use cosmian_crypto_core::symmetric_crypto::aes_256_gcm_pure;
use cosmian_crypto_core::symmetric_crypto::{aes_256_gcm_pure::Aes256GcmCrypto, Metadata};
use criterion::{criterion_group, criterion_main, Criterion};
#[cfg(feature = "ffi")]
use {
cover_crypt::interfaces::ffi::{
cosmian_cover_crypt::interfaces::ffi::{
error::get_last_error,
hybrid_cc_aes::{
h_aes_create_decryption_cache, h_aes_create_encryption_cache, h_aes_decrypt_header,
Expand Down
2 changes: 1 addition & 1 deletion src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ fn to_partitions(attributes: &[Attribute], policy: &Policy) -> Result<HashSet<Pa
let mut map = HashMap::new();
for attribute in attributes.iter() {
let value = policy.attribute_current_value(attribute)?;
let entry = map.entry(attribute.axis.to_owned()).or_insert(Vec::new());
let entry: &mut Vec<u32> = map.entry(attribute.axis.to_owned()).or_default();
entry.push(value);
}

Expand Down
3 changes: 1 addition & 2 deletions src/interfaces/ffi/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,8 +616,7 @@ unsafe fn refresh_user_private_key(
.map_err(|e| Error::Other(e.to_string()))?;
let access_policy_ptr = access_policy_cs.as_ptr();

let preserve_old_partitions_access_c: c_int =
if preserve_old_partitions_access { 1 } else { 0 };
let preserve_old_partitions_access_c: c_int = i32::from(preserve_old_partitions_access);

// prepare updated user private key pointer
let mut updated_user_private_key_bytes = vec![0u8; 64 * 1024];
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/pyo3/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl From<Error> for pyo3::PyErr {

/// A Python module implemented in Rust.
#[pymodule]
fn cover_crypt(_py: Python, m: &PyModule) -> PyResult<()> {
fn cosmian_cover_crypt(_py: Python, m: &PyModule) -> PyResult<()> {
m.add_function(wrap_pyfunction!(generate_master_keys, m)?)?;
m.add_function(wrap_pyfunction!(generate_user_private_key, m)?)?;
m.add_function(wrap_pyfunction!(generate_policy, m)?)?;
Expand Down
Loading

0 comments on commit 03a2353

Please sign in to comment.