crypt4gh

command module
v1.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2024 License: MIT Imports: 6 Imported by: 0

README

crypt4gh

Build Status GoDoc Go Report Card codecov

Overview

Specification

Current version of specs can be found here.

Installation

Linux / MacOS
curl -fsSL https://raw.githubusercontent.com/neicnordic/crypt4gh/master/install.sh | sudo sh
Windows

Go to the releases page and download the binary manually.

Usage

$ crypt4gh
crypt4gh [generate | encrypt | decrypt | reencrypt] <args>

 generate:
  -n, --name=                     Key pair name
  -f, --format=[openssl|crypt4gh] Key pair format
  -p, --password=                 Password to lock Crypt4GH private key (will be prompted afterwords if skipped)

 encrypt:
  -f, --file=FILE      File to encrypt
  -p, --pubkey=FILE    Public key to use, this parameter can be used multiple times, one key per parameter
  -s, --seckey=FILE    Secret key to use

 decrypt:
  -f, --file=FILE      File to decrypt
  -s, --seckey=FILE    Secret key to use

 reencrypt:
  -f, --file=FILE      Input File to re-encrypt
  -o, --out=FILE       Output File to after re-encrypt
  -p, --pubkey=FILE    Public key to use, this parameter can be used multiple times, one key per parameter
  -s, --seckey=FILE    Secret key to use

 Environment variables:

 C4GH_SECRET_KEY	If defined, it will be used as the secret key file if parameter not set parameter not set
 C4GH_PASSPHRASE	If defined it will be used as the default password for decoding the secret key
Examples

Examples on how to make use of the crypt4gh library are in the examples folder

Generate Keys
crypt4gh generate -n=recipient-A
crypt4gh generate -n=recipient-B
crypt4gh generate -n=sender-C
Encrypt Files
crypt4gh encrypt -f sample.txt -s sender-C.sec.pem -p recipient-A.pub.pem

Multiple recipients can be added with by using the -p parameter multiple times

crypt4gh encrypt -f sample.txt -s sender-C.sec.pem -p recipient-A.pub.pem -p recipient-B.pub.pem
Decrypt Files
crypt4gh decrypt -f sample.txt.c4gh -s recipient-A.sec.pem
Re-Encrypt Files

Re-encrypting a file will completely replace the old header with a new one. If the file is intended to be decrypted by multiple recipients, all relevant public keys must be given again on re-encryption.

crypt4gh encrypt -f sample.txt -s sender-C.sec.pem -p recipient-A.pub.pem
crypt4gh reencrypt -f sample.txt.c4gh -s recipient-A.sec.pem -p recipient-B.pub.pem  -p recipient-A.pub.pem -o cool.c4gh
crypt4gh decrypt -f cool.c4gh -s recipient-A.sec.pem
crypt4gh decrypt -f cool.c4gh -s recipient-B.sec.pem

Documentation

Overview

Package main is the main package of Crypt4GH command-line tool, containing "generate", "encrypt" and "decrypt" commands implementations along with additional helper methods.

Directories

Path Synopsis
examples
keycreator
package main for keycreator, an example of what a key creator can look like
package main for keycreator, an example of what a key creator can look like
reader
package main for reader, an example of what a crypt4gh file reader can look like
package main for reader, an example of what a crypt4gh file reader can look like
writer
package main for writer, an example of what a crypt4gh file writer can look like
package main for writer, an example of what a crypt4gh file writer can look like
internal
cli
Package kdf incorporates three KDFs (https://en.wikipedia.org/wiki/Key_derivation_function) used by Crypt4GH
Package kdf incorporates three KDFs (https://en.wikipedia.org/wiki/Key_derivation_function) used by Crypt4GH
Package keys holds helper methods to generate/read/convert/write keys for Crypt4GH.
Package keys holds helper methods to generate/read/convert/write keys for Crypt4GH.
model
body
Package body contains structure and related methods for representing Crypt4GH data segments.
Package body contains structure and related methods for representing Crypt4GH data segments.
headers
Package headers contains structure and related methods for representing Crypt4GH header packets.
Package headers contains structure and related methods for representing Crypt4GH header packets.
Package streaming contains Writer and Reader implementing Crypt4GH encryption and decryption correspondingly.
Package streaming contains Writer and Reader implementing Crypt4GH encryption and decryption correspondingly.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL