Giter Site home page Giter Site logo

gpki's Introduction

Goal: Simple Public Key Infrastructure

By storing Public Keys in a version controlled storage (like git), we can achieve a high level of automation in managing the network of trusted identities.

GPKI is being designed to automate and simplify the management of such a network. It is responsible for:
a) registering identities within the network
b) encrypting and decrypting messages from the network members

Design

GPKI leverages both git and gpg to provide its functionality. The system consists of two parts: private vault and public repository. Vault is a GPG keychain storing every private and public key while the public repository is where only the public keys end up for other members to see.

Identity

Every identity is a tuple of (name, email, description), where names should allow easy identification of its owner. It is possible for any user to own multiple identities, which might be beneficial when contacting external entities or if one needs to manually partition the network. Although in most cases a single identity should be enough.

Where is the Certificate Authority?

The key network is as secure as the git repository hosting the public key infrastructure. New identities can only be added by the users with correct permissions, hence there is no need for an explicit CA signing keys.

Use Case

Sometimes, people need to share with another person a message, which they would like to keep confidential. With the help of GPKI it becomes as easy as installing it and maintaining a git repository (e.g. on github).

Examples might be: household/family networks or confidential team-members communication (e.g. sharing confidential memos)

Documentation Website

Installation

GPKI is based on Python, Git and GnuPG, so make sure to have following installed:

python >= 3.6
GnuPG >= 2.1
Git >= 2.3

Install GPKI directly from repository with a few commands:

git clone [email protected]:VirtusLab/gpki.git
cd gpki
python3 -m pip install -r requirements.txt
sudo python3 -m pip install .

You are all set and ready to use GPKI

Getting started

The prerequisite is having a dedicated git repository with appropriate security settings set up (i.e. only trusted users should be allowed to push changes to master branch).

When run for the first time, the user will be asked for a link to the git repository. Every message is encrypted and signed by one of the locally created identities.

To create one, use:

gpki identity <name> [--email <email>] [--description <description>]

This creates a public/private key pair in the local gpg vault and pushes a new branch with the public key to the repository for review. It has to be approved (and merged) by one of the CAs to become visible to others.

To synchronize keyring with all available recipients from repository, use:

gpki update

Encrypt message or file with:

gpki encrypt [--all/-a] [--input/-i <input_path>] [--output/-o <output_path>]

When input is omitted, it will be read from standard input. When output is omitted, it will be printed to the standard output.

Decrypt message with:

gpki decrypt [--input/-i <input_path>] [--output/-o <output_path>] [--update/-u]

When input is omitted, it will be read from standard input. When output is omitted, it will be printed to the standard output.

gpki's People

Contributors

explicite avatar mzarnowski avatar rifel123 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

gpki's Issues

`Review_request`: handle `ImportKeyRequest`

Currently, there is support only for AddIdentityRequest.

But the changes in keys might be made by importing keys also. ImportKeyRequest will have different shape than AddIdentityRequest, it could look like: ImportKeyRequest(branch, message).

Allow to decrypt from and to files

Currently decryption works only from message injected by the user. There should be possibility to read file with encrypted message and decrypt it to a file if necessary, just like it is in encrypt option.

Add type annotations

Currently types are annotated only in several places.
Let's extend this approach for all python project files, so mypy could perform it's checks.

Use explicit origin name

Currently, we rely on the cloned repository to be referred to as 'origin'. It might not always be the case.
Let's specify the name explicitly using -o when cloning.

Become script-friendly

Currently, in some cases we provide alternatives for interactive user input (e.g. encrypting/decrypting files), but in other places we still rely on interactive input. It should be fairly easy to use most of the commands in a script.

The only one, which might be worth to keep as a semi-automatic is generating new identities, but it needs further discussion.

While exporting key, gpg exports all keys which has substring of given name in their name

for example, let's have public keys with name as follows:

  • tester
  • tester2
  • tester3
  • rifel123
    and user wants to export key tester with gpki export tester, then tester, tester2 and tester3 will be exported in one block.
    Described behaviour may lead to errors while review, where with multiple keys in request will raise exception due to filename and fingerprint mismatch.

TBD if we really need to have export/ import commands available to the user.

Add basic functional tests

For example as an entry point, create test:

  • create identity
  • encrypt and decrypt message (for same user, and two different ones as well)
  • encrypt and decrypt file

There is need to work around iterfzf interactive selection, but it should be possible to mock it or take signatory directly from self.__gpg.private_keys_list()

Find a way to revert changes when PR with new keys is rejected

Assumption: a PR is considered to be rejected, when it's head branch is deleted from remote by someone who is is charge of the repository

It may happen that PR will be rejected for some reason and some clean up needs to be done.
In such a case following approach is suggested:

  • call git fetch --prune to sync remote branches
  • search for branches that exist locally but not on the remote (method list_branches_unmerged_to_remote_counterpart_of may do this task)
  • remove keys from selected branches

WARNING:gnupg:gpg returned a non-zero error code: 2

We are asking gpg for a specific key to check for its existence. When it doesn't exist, we get this warning.

We need do the filtering by name/fingerprint in our wrapper, not delegating it to the python-gnupg.

Introduce `update` command

The update command shall fetch remote repository and source all keys from master branch.

This is to avoid executing running time consuming operation of git fetch at the beginning of git-pki runtime.

Format listed keys in suggested way

Right now we got print of raw NamedTuple of Key:
Screenshot 2021-12-03 at 13 44 27

Which is not a great input for additional programs/scripts which may use this tool in the future.
Here is suggestion how new formatting should look like:
<fingerprint> <created-on> <expires-on>\t<identity>\t<email>\t<description>

Ask user if private/public keys need to invalidated

While generating new identity the user may decide not replace existing one.
In such a case ask user what to do with existing public and private keys, invalidate them or keep untouched.
If previous keys gets invalidated, publish new keys to repository.

Reenable `git pull` keys from repository

In method update of Git class.
Since currently update method is called in each invocation of git-pki, hence, it would be wise to add check if there is need to perform git pull.
We should be able to check if have given person in the keychain and if not, pull the key from repository.

Rename project to gitPKI

Current name can be ambiguously interpreted as any of: git/github/gpg PKI.

Another thing is that it is much easier to type gpki than gitpki on the command line, but this could be handled by recommending a one-line alias, so probably not a big issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.