#encryption-decryption #encryption #genome #genetic #generate-keys #stdin #c4gh

bin+lib crypt4gh

Encryption and decryption implementation of the Crypt4GH encryption format

12 releases

0.4.1 May 2, 2022
0.4.0 Mar 14, 2022
0.3.1 Jul 5, 2021
0.2.1 Jun 9, 2021
0.1.2 Nov 19, 2020

#488 in Cryptography

Download history 3/week @ 2024-07-27 29/week @ 2024-09-28 1/week @ 2024-10-05 31/week @ 2024-10-12 7/week @ 2024-10-19 3/week @ 2024-10-26 21/week @ 2024-11-02

62 downloads per month
Used in 9 crates (4 directly)

Apache-2.0

1.5MB
2K SLoC

Contains (WOFF font, 99KB) fontawesome-webfont.woff, (WOFF font, 78KB) fontawesome-webfont.woff2, (WOFF font, 45KB) open-sans-v17-all-charsets-300.woff2, (WOFF font, 41KB) open-sans-v17-all-charsets-300italic.woff2, (WOFF font, 45KB) open-sans-v17-all-charsets-600.woff2, (WOFF font, 43KB) open-sans-v17-all-charsets-600italic.woff2 and 7 more.

crypt4gh-rust

Crates.io Docs.rs codecov GitHub

Rust implementation for the Crypt4GH encryption format.

CLI

Installation

From source

Requirements: Rust

cargo install crypt4gh

Binaries

In the releases page, You can find compiled binaries for:

Usage

Utility for the cryptographic GA4GH standard, reading from stdin and outputting to stdout.

USAGE:
    crypt4gh [FLAGS] [SUBCOMMAND]

FLAGS:
    -h, --help       Prints help information
    -v, --verbose    Sets the level of verbosity
    -V, --version    Prints version information

SUBCOMMANDS:
    decrypt      Decrypts the input using your secret key and the (optional) public key of the sender.
    encrypt      Encrypts the input using your (optional) secret key and the public key of the recipient.
    help         Prints this message or the help of the given subcommand(s)
    keygen       Utility to create Crypt4GH-formatted keys.
    rearrange    Rearranges the input according to the edit list packet.
    reencrypt    Decrypts the input using your (optional) secret key and then it reencrypts it using the
                 public key of the recipient.

Example

Alice and Bob generate both a pair of public/private keys.

crypt4gh keygen --sk alice.sec --pk alice.pub
crypt4gh keygen --sk bob.sec --pk bob.pub

Bob encrypts a file for Alice:

crypt4gh encrypt --sk bob.sec --recipient_pk alice.pub < file > file.c4gh

Alice decrypts the encrypted file:

crypt4gh decrypt --sk alice.sec < file.c4gh

Library

Library installation

Add this to your Cargo.toml:

[dependencies]
crypt4gh = "0.4.0"

Usage (in Rust)

Use the exposed functions:

pub fn encrypt<R: Read, W: Write>(
    recipient_keys: &HashSet<Keys>,
    read_buffer: &mut R,
    write_buffer: &mut W,
    range_start: usize,
    range_span: Option<usize>
) -> Result<()>

pub fn decrypt<R: Read, W: Write>(
    keys: Vec<Keys>,
    read_buffer: &mut R,
    write_buffer: &mut W,
    range_start: usize,
    range_span: Option<usize>,
    sender_pubkey: Option<Vec<u8>>,
) -> Result<()>

pub fn reencrypt<R: Read, W: Write>(
    keys: Vec<Keys>,
    recipient_keys: HashSet<Keys>,
    read_buffer: &mut R,
    write_buffer: &mut W,
    trim: bool,
) -> Result<()>

pub fn rearrange<R: Read, W: Write>(
    keys: Vec<Keys>,
    read_buffer: &mut R,
    write_buffer: &mut W,
    range_start: usize,
    range_span: Option<usize>,
) -> Result<()>

Documentation

To learn more about Crypt4GH, see the official documentation.

Troubleshooting

To build from source on Windows, you should first have installed the MSVC Build Tools.

Dependencies

~35MB
~315K SLoC