rabe is an Attribute Based Encryption library, written in Rust

Overview

Crates.io Docs.rs License

Rabe

rabe is a rust library implementing several Attribute Based Encryption (ABE) schemes using a modified version of the bn library of zcash (type-3 pairing / Baretto Naering curve). The modification of bn brings in serde instead of the deprecated rustc_serialize.

This is a rust crate and comes with C bindings. For integration in distributed applications contact us.

Implemented Ciphertext Policy Schemes (CP-ABE)

BDABE CP-ABE

Georg Bramm, Mark Gall, Julian Schütte , "Blockchain based Distributed Attribute-based Encryption". In Proceedings of the 15th International Joint Conference on e-Business and Telecommunications (ICETE 2018) - Volume 2: SECRYPT, pages 99-110. Available from https://doi.org/10.5220/0006852602650276

AC17 CP-ABE

Shashank Agrawal, Melissa Chase, "FAME: Fast Attribute-based Message Encryption", (Section 3). In Proceedings of the 2017 ACM SIGSAC Conference on Computer and Communications Security 2017. Available from https://eprint.iacr.org/2017/807.pdf

AW11 CP-ABE

Lewko, Allison, and Brent Waters, "Decentralizing Attribute-Based Encryption.", (Appendix D). In Eurocrypt 2011. Available from http://eprint.iacr.org/2010/351.pdf

BSW CP-ABE

John Bethencourt, Amit Sahai, Brent Waters, "Ciphertext-Policy Attribute-Based Encryption" In IEEE Symposion on Security and Privacy, 2007. Available from https://doi.org/10.1109/SP.2007.11

MKE08 CP-ABE

S Müller, S Katzenbeisser, C Eckert , "Distributed Attribute-based Encryption". Published in International Conference on Information Security and Cryptology, Heidelberg, 2008. Available from http://www2.seceng.informatik.tu-darmstadt.de/assets/mueller/icisc08.pdf

Implemented Key Policy Schemes (KP-ABE)

AC17 KP-ABE

Shashank Agrawal, Melissa Chase, "FAME: Fast Attribute-based Message Encryption". In Proceedings of the 2017 ACM SIGSAC Conference on Computer and Communications Security 2017. Available from https://eprint.iacr.org/2017/807.pdf

LSW KP-ABE

Allison Lewko, Amit Sahai and Brent Waters, "Revocation Systems with Very Small Private Keys". In IEEE Symposium on Security and Privacy, 2010. SP'10. Available from http://eprint.iacr.org/2008/309.pdf

YCT14 KP-ABE

Xuanxia Yao, Zhi Chen, Ye Tian, "A lightweight attribute-based encryption scheme for the Internet of things". In Future Generation Computer Systems. Available from http://www.sciencedirect.com/science/article/pii/S0167739X14002039

Building rabe

In order to compile and test:

  • install rust nightly
  • git clone library
  • install build-essential
  • and then run 'cargo build && RUST_BACKTRACE=1 cargo test -- --nocapture'

In order to run on the console use

  • target/debug/rabe

For example, in order to create msk and pk of an AC17 KP-ABE scheme run:

$ ./target/debug/rabe --scheme AC17KP setup
Comments
  • Library fails to process policies with more than 60 attributes.

    Library fails to process policies with more than 60 attributes.

    More or less. You need to create a policy with ~80 attributes to produces the bug and call encrypt/keygen, respectively. Unclear if this is a parser issue or scheme issue. Happens with AC17/BSW schemes (all).

    opened by schanzen 8
  • About the AES dependency

    About the AES dependency

    I've been using this library for part of my Ph.D. research. it has proven very useful so far, but I was wondering about the AES cipher used underneath.

    I've seen that rabe calls aes from aes-0.7.0. This crate only offers AES or AES-CTR. Seemed weird to me, and I have checked the newest version of aes crate and developers comment how:

    This crate implements only the low-level block cipher function, and is intended for use for implementing higher-level constructions only. It is NOT intended for direct use in applications.

    So now I'm wondering what mode of AES does Rabe use. Or whether at some point in the code you build AES-CBC or AES-GCM.

    In case Rabe is using pure AES, since this is not recommended, are you planning on implementing AEADs?

    BTW thanks for all the hard work 😄

    opened by PekeDevil 2
  • YCT14 KP-ABE scheme is broken

    YCT14 KP-ABE scheme is broken

    Hello,

    The YCT14 scheme was broken in [1] and a 'fixed' version was again broken in [2]. We have demonstrated how the attack can be implemented in practice in https://www.blackhat.com/eu-21/briefings/schedule/index.html#practical-attacks-against-attribute-based-encryption-25058.

    [1] https://ieeexplore.ieee.org/document/8651482 [2] https://ieeexplore.ieee.org/document/9291064

    opened by adelapie 1
  • CLI utilities do not work

    CLI utilities do not work

    The CLI tools do not work anymore for BSW and AC17 C/KP-ABE. Apparently, the added schemes cause this.

    The problem: https://github.com/Fraunhofer-AISEC/rabe/blob/master/src/main.rs#L1228 This line fails with:

      0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
                 at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
       1: std::sys_common::backtrace::_print
                 at src/libstd/sys_common/backtrace.rs:71
       2: std::panicking::default_hook::{{closure}}
                 at src/libstd/sys_common/backtrace.rs:59
                 at src/libstd/panicking.rs:197
       3: std::panicking::default_hook
                 at src/libstd/panicking.rs:211
       4: std::panicking::rust_panic_with_hook
                 at src/libstd/panicking.rs:474
       5: std::panicking::continue_panic_fmt
                 at src/libstd/panicking.rs:381
       6: std::panicking::begin_panic_fmt
                 at src/libstd/panicking.rs:336
       7: rabe::main::read_file
                 at src/main.rs:1574
       8: rabe::main::run_encrypt
                 at src/main.rs:1228
       9: rabe::main::run
                 at src/main.rs:406
      10: rabe::main
                 at src/main.rs:393
      11: std::rt::lang_start::{{closure}}
                 at /rustc/a53f9df32fbb0b5f4382caaad8f1a46f36ea887c/src/libstd/rt.rs:64
      12: std::panicking::try::do_call
                 at src/libstd/rt.rs:49
                 at src/libstd/panicking.rs:293
      13: __rust_maybe_catch_panic
                 at src/libpanic_unwind/lib.rs:85
      14: std::rt::lang_start_internal
                 at src/libstd/panicking.rs:272
                 at src/libstd/panic.rs:394
                 at src/libstd/rt.rs:48
      15: std::rt::lang_start
                 at /rustc/a53f9df32fbb0b5f4382caaad8f1a46f36ea887c/src/libstd/rt.rs:64
      16: main
      17: __libc_start_main
      18: _start
    

    Reason:

    https://github.com/Fraunhofer-AISEC/rabe/blob/master/src/main.rs#L329

    The wrong variable is assigned.

    opened by schanzen 1
  • Preparation of crate.io release

    Preparation of crate.io release

    This project depends on georgbramm/bn which is a fork of zcash-hackworks/bn. The former is not available as a crate, the latter seems to be not maintained anymore (the last PR is open for >2yrs).

    Publishing to crates.io requires all dependencies to be available on crate.io as well. So, there are only two options:

    1. Create a PR and convince the maintainers of zcash-hackworks to accept and publish it as a version bn:0.4.4

    2. Publish georgbramm/bn as a whole new crate, say under the name bn-serde.

    3. Include georgbramm/bn as a submodule into this project and bundle it into the published crate

    This PR does (3).

    (1) would obviously be favorable, but the chances of convincing the zcash authors to accept a major breaking PR in the near future are low.

    (2) is irreversible and may lead to further confusion

    (3) is not elegant, but it can easily be reverted in case an updated version of bn is published in the future

    opened by JulianSchuette 1
  • Error in encrypt files

    Error in encrypt files

    Hi. My name is Humberto. I am studying about ABE, and I get rabe-console to test it. But i don't take success in file encrypt e decryption. For example:

    Start with:

    $ rabe --s AC17CP setup $ rabe --s AC17CP keygen --a 'A B'

    In the encryption example 1:

    rabe --s AC17CP encrypt pk.key 'B' teste.doc

    It finish at error:

    error: The following required arguments were not provided:

    USAGE: rabe encrypt [ARGS]

    And other example, 2:

    rabe encrypt pk.key "B" ./teste.doc

    error: The following required arguments were not provided:

    USAGE: rabe --s encrypt [ARGS]

    How to encrypt the teste.doc, and after decrypt it?

    Would you add a full use scenario in the Rabe Console README file?

    Thank you for attention.

    opened by lindrix 0
  • Change some function signature

    Change some function signature

    Hi, I'm writing a C-FFI binding for this project, but i think some function signature is not reasonable enough.

    Example

    pub fn keygen(
        _pk: &KpAbePublicKey,
        _msk: &KpAbeMasterKey,
        _policy: &String,
        _language: PolicyLanguage,
    ) -> Result<KpAbeSecretKey, RabeError> 
    

    the parameter _policy in this function is &String, but this function only need a immutable reference, i recommend use &str. Similarly, in this function:

    pub fn encrypt(
        _gk: &Aw11GlobalKey,
        _pks: &Vec<Aw11PublicKey>,
        _policy: &String,
        _language: PolicyLanguage,
        _plaintext: &[u8],
    ) -> Result<Aw11Ciphertext, RabeError> 
    

    the type of _pks should be &[Aw11PublicKey] instead of &Vec<Aw11PublicKey>

    Reason

    • I can construct a String from a *const c_char by let s = String::from_raw_parts(policy as *mut u8,len, len) during FFI calling.But, because this String not really own its memory, so we need a std::mem::forget(s) to make sure not free the memory passed by FFI calling.
    • If use &str, i can construct a slice from pointer directly and no need to care about memory.
    • Also, When i pass a array of pointer for &Vec<Aw11PublicKey>, i need to use Vec::from_raw_partsand not free the memory.
    • Not only in FFI, if i want to pass a let policy = "xxxxx", i also need to construct a String and pass it to function. But if the parameter is &str, i can pass policy directly.
    • And because String had impl trait Deref<str>, pass a &String to a &str is ok.
    • Similarly, use &Vec<T> instead of &[T] has the same problem. Such as &Vec<String>, all of these are FFI unfriendly and may cause unnecessary overhead under certain circumstances.
    opened by Aya0wind 0
  •  in order to create example, how to calculate time based on number of Attributes?

    in order to create example, how to calculate time based on number of Attributes?

    Hi, in order to create msk and pk of an AC17 KP-ABE scheme, I used all as you say but it is not working. it says "--scheme: command not found". where should I use this command? in my rabe path "ubuntu:~/rabe" ? I think the problem is path, I did what you said in "compile and test" and it is work and I have no problem with it. also I have another issue, how can I calculate time of run based on number of attributes? where can I change the number? I hope you help me in this, I used so many ways but none works and I can't change number of attributes. thanks

    opened by karim14 1
  • cffi

    cffi

    Almost got cffi working, just missing 1 little thing, I guess...

    from cffi import FFI
    ffi = FFI()
    ffi.cdef("""
        struct CpAbeCiphertext;
        struct CpAbeContext;
        struct CpAbeSecretKey;
    
        struct CpAbeContext* rabe_bsw_context_create();
        void rabe_bsw_context_destroy(struct CpAbeContext* ctx);
        struct CpAbeSecretKey* rabe_bsw_keygen(const struct CpAbeContext* ctx, const char* attributes);
        void rabe_bsw_keygen_destroy(void* sk);
        int32_t rabe_bsw_encrypt(const void* pk, char* policy, char* pt, int32_t pt_len, char** ct, int32_t *ct_len);
        int32_t rabe_bsw_decrypt(const struct CpAbeSecretKey* sk, const char* ct, uint32_t ct_len, char** pt_buf, uint32_t *pt_len);
    """)
    
    C = ffi.dlopen("librabe.so")
    
    ctx = C.rabe_bsw_context_create()
    print(ctx)
    sk = C.rabe_bsw_keygen(ctx, b"[ \"test1\", \"test2\", \"test3\" ]")
    print(sk)
    pt = b"testing123"
    ct = ffi.new("char **")
    ct_len = ???
    
    output = C.rabe_bsw_encrypt(ctx, b"{\"OR\": [{\"ATT\": \"A\"}, {\"ATT\": \"B\"}]}", pt, len(pt), ct, ct_len)
    print(output)
    

    How should I define ct_len?

    opened by Sp0Q1 1
Releases(v0.3.1)
Owner
Fraunhofer AISEC
IT security research institute Fraunhofer AISEC (Applied and Integrated Security)
Fraunhofer AISEC
Authenticated Encryption with Associated Data Algorithms: high-level encryption ciphers

RustCrypto: Authenticated Encryption with Associated Data (AEAD) Algorithms Collection of Authenticated Encryption with Associated Data (AEAD) algorit

Rust Crypto 457 Jan 4, 2023
A Rust library for lattice-based additive homomorphic encryption.

Cupcake Cupcake is an efficient Rust library for the (additive version of) Fan-Vercauteren homomorphic encryption scheme, offering capabilities to enc

Facebook Research 365 Dec 11, 2022
Chargo is a tool for file encryption/decryption. It's based on Argon2 and ChaCha20Poly1305 algorithms.

| Documentation Chargo is a tool for file encryption/decryption with password. It's based on Argon2 and ChaCha20Poly1305 algorithms. From arg2u with ♥

Airat Galiullin 7 Jan 1, 2023
A secure file encryption utility, written in rust.

Dexios Dexios What is it? Building notes Checksums Performance Output file sizes Environment Variables Key Inputs Usage Examples To Do What is it? Dex

brxken 156 Dec 22, 2022
Simple to use CLI tool that makes encryption easy! Written in Rust.

?? eme: Encryption Made Easy an extremely simple AES-256 encryption tool written in Rust Usage: # To encrypt: eme --encrypt secret.png # To decrypt: e

null 5 Jan 3, 2023
A Rust Library of China's Standards of Encryption Algorithms (SM2/3/4)

Libsm Libsm is an open source pure rust library of China Cryptographic Algorithm Standards. It is completed by a collaborative effort between the Cryp

CITAHub 149 Dec 23, 2022
In addition to encryption library, pure RUST implementation of SSH-2.0 client protocol

In addition to encryption library, pure RUST implementation of SSH-2.0 client protocol

陈年旧事。 73 Jan 1, 2023
Rust library for practical time-lock encryption using `drand` threshold network

tlock-rs: Practical Timelock Encryption/Decryption in Rust This repo contains pure Rust implementation of drand/tlock scheme. It provides time-based e

Timofey 32 Jan 8, 2023
WebAssembly wrapper of the rage encryption library

rage-wasm: WebAssembly wrapper of rage rage is a simple, modern, and secure file encryption tool, using the age format. It features small explicit key

Kan-Ru Chen 35 Dec 16, 2022
Meta-repository for Miscreant: misuse-resistant symmetric encryption library with AES-SIV (RFC 5297) and AES-PMAC-SIV support

The best crypto you've never heard of, brought to you by Phil Rogaway A misuse resistant symmetric encryption library designed to support authenticate

miscreant. 480 Dec 8, 2022
A Rust binary for file encryption to multiple participants.

Kaspa-miner A Rust binary for file encryption to multiple participants. Installation From Sources With Rust's package manager cargo, you can install k

Elichai Turkel 31 Dec 30, 2022
A Rust Implementation of China's Standards of Encryption Algorithms(SM2/SM3/SM4)

gm-rs A Pure Rust High-Performance Implementation of China's Standards of Encryption Algorithms(SM2/SM3/SM4) Usage Add this to your Cargo.toml: [depen

null 2 Oct 27, 2022
End-to-end encryption and mutual authentication for distributed applications.

✨ Hands-on Introduction: Build end-to-end encrypted, mutually-authenticated, secure messaging in Rust ✨ Rust and Elixir libraries for end-to-end encry

Ockam | Trust for Data-in-Motion 2.8k Jan 2, 2023
DexiosGUI - Simple cross-platform drag-and-drop Dexios file encryption

DexiosGUI Simple cross-platform drag-and-drop Dexios file encryption. Latest Windows x64 release is here. DexiosGUI is a Qt/C++ app for encrypt and de

Fabrice Corraire 4 Jul 25, 2022
The Hybrid Public Key Encryption (HPKE) standard in Python

Hybrid PKE The Hybrid Public Key Encryption (HPKE) standard in Python. hybrid_pke = hpke-rs ➕ PyO3 This library provides Python bindings to the hpke-r

Cape Privacy 4 Nov 7, 2022
Project Masterpass is a deterministic databaseless key management algorithm, aimed to help those who cannot protect their encryption keys in storage

Project Masterpass (working title) Attention! This project is still under heavy development, and SHOULD NOT be used in practice, as the algorithms cou

Gyorgy Wang 2 Sep 11, 2022
A simple to use, cross-platform aes encryption

About Project End to End encryption (AES) for multiple languages (cross-platform) with CBC Icon Item ?? Upcoming ⚖️ License ?? ChangeLog Usage (rust)

Zot Cryptography 2 Dec 15, 2022
Arkworks circuits for verifiable time-lock encryption

zk-timelock This repo contains arithmetic circuits for verifiable time-lock encryption made using arkworks-rs toolkit. For more details on such an enc

Timofey 68 Apr 5, 2023
This is a Order-preserving encryption (OPE) lib inspired by cryptdb's ope implementation.

Ope in rust This is an Order-preserving encryption (OPE) lib inspired by cryptdb's ope implementation. It is a pure rust implementation, no c dependen

Sentclose 8 Jul 19, 2023