Skip to main content

Python Keystore

This package provides a simple keystore,

The keystore is available is three types

  • Simple need too supply the passphres for every secure opration
  • Exteneded need only onetime supply the passphrase
  • Keyring need to supply the keyring information one time, for every secure operation the passphrase is retrieved from the keyring.

All three classes have functions for account information, asymmetric keys and symmetric keys.

The keys are stored by there alias and algorithm.

There are two layers of encryption;

  1. The keystore it self.
  2. the passwords, secrets and keys.

Therefore when the keystore is loaded into memory the actual secure information is not in clear text, only the data structure it readable.

Keystore class functions

Simple

This atre the functions in the Keystore class

  • classmethod create( filename: str, passphrase: Union[str,bytes] ) -> 'KeyStore'
  • classmethod load( cls, filename: str, passphrase: Union[str,bytes] ) -> 'KeyStore'
  • function save( self, filename:str, passphrase: Union[str,bytes,None] ) -> None
  • function hasAccount( self, account: str ) -> bool:
  • function setPassword( self, account: str, password: str, passphrase: Union[str,bytes], two_fa = None ) -> None
  • function getPassword( self, account:str, passphrase: Union[str,bytes] ) -> bytes
  • function get2fa( self, account:str, passphrase: Union[str,bytes] ) -> bytes
  • function getAccount( self, account:str, passphrase: Union[str,bytes] ) -> tuple( account, password [, twofa ] )
  • function hasPrivateKey( self, alias:str, algo:str = 'RSA' ) -> bool
  • function setPrivateKey( self, alias:str, key, algo:str, passphrase: Union[str,bytes] ) -> bool
  • function getPrivateKey( self, alias:str, algo:str, passphrase: Union[str,bytes] ) -> bytes
  • function hasPublicKey( self, alias:str, algo:str = 'RSA' ) -> bool
  • function setPublicKey( self, alias:str, key = None, algo:str = 'RSA' ) -> bool
  • function getPublicKey( self, alias:str, algo:str = 'RSA' ) -> bytes
  • function hasCertificate( self, alias:str, algo:str = 'RSA' ) -> bool
  • function setCertificate( self, alias:str, cert, algo:str = 'RSA' ) -> bool
  • function getCertificate( self, alias:str, algo:str = 'RSA' ) -> Union[bytes,None]
  • function hasEncriptioneKey( self, alias:str, algo:str ) -> bool
  • function setEncriptioneKey( self, alias:str, algo:str, key, passphrase: Union[str,bytes] ) -> None
  • function getEncriptioneKey( self, algo:str, alias:str, passphrase: Union[str,bytes] ) -> bytes

Extended

Most functions are the same as for the simple Keystore, the following functions differ;

  • setPassword( self, account: str, password: str, two_fa = None ) -> None
  • getPassword( self, account:str ) -> bytes
  • get2fa( self, account:str ) -> bytes
  • getAccount( self, account:str ) -> tuple
  • setPrivateKey( self, alias:str, key, algo:str ) -> bool
  • getPrivateKey( self, alias:str, algo:str ) -> bytes
  • setEncriptioneKey( self, alias:str, algo:str, key ) - None
  • getEncriptioneKey( self, algo:str, alias: str ) -> bytes

Keyring

Most functions are the same as for the extended/simple Keystore, the following functions differ;

  • classmethod loadWithKeyring( filename, system_name, keyring_name ) -> 'KeyringKeystore'
  • classmethod createWithKeyring( filename, system_name, keyring_name ) -> 'KeyringKeystore'
  • saveWithKeyring( filename, system_name, keyring_name ) -> None

Examples

Simple

For the simple Keystore the passphrase needs to be supplied for every operation,

import pykeystore
passphrase = pykeystore.create_password( '~/python-keystore-passphrase' )
store = pykeystore.KeyStore.create( 'keystore.pykst', passphrase )
store.setPassord( 'account@example.com', 'somepassword', passphrase, '2FA-secret' )

password = store.getPassword( 'account@example.com', passphrase )
twofa = store.get2fa( 'account@example.com', passphrase )

info = store.getAccount( 'account@example.com', passphrase  )

keystore.save( 'keystore.pykst', passphrase )

pykeystore.KeyStore.load( 'keystore.pykst', passphrase )
info = store.getAccount( 'account@example.com', passphrase  )

Extended

For the exetended Keystore the passphrase needs to be supplied once, this is less secure as every thing is stored in memory at the same time.

import pykeystore
passphrase = pykeystore.create_password( '~/python-keystore-passphrase' )
store = pykeystore.KeyStoreEx.create( 'keystore.pykst', passphrase )
store.setPassord( 'account@example.com', 'somepassword', '2FA-secret' )

keystore.save( 'keystore.pykst', passphrase )

Keyring

For the keyring Keystore the system-name and username are supplied once, but the actual passphrase the retrieved seperatly for every operation.

import pykeystore

store = pykeystore.KeyRingStore.create( 'keystore.pykst', 'systemname', 'account' )
store.setPassord( 'account@example.com', 'somepassword', '2FA-secret' )

keystore.save( 'keystore.pykst' )

Metadata

Release files for pykeystore 1.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pykeystore 1.1.5
File Size Uploaded
pykeystore-1.1.5.tar.gz 11.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pykeystore 1.1.5
File Interpreter ABI Platform
pykeystore-1.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 23.1 kB

Release files / pykeystore-1.1.5.tar.gz

Download URL pykeystore-1.1.5.tar.gz
Size 11.2 kB
Tags Source
SHA-256 checksum
How to use checksums
7853fd71b6827c809409b642b9073a31578d841e1b64c06525ef29862891cd3d
BLAKE2b-256 checksum
How to use checksums
73d52e4a4a735bf99af48eef71589d54102f2ea617269c1edcc56c1fcfe94f14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / pykeystore-1.1.5-py3-none-any.whl

Download URL pykeystore-1.1.5-py3-none-any.whl
Size 11.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b0ecfdfdd8e68b7c2f4efc1ef89cdb6f7a1912a05a60ffdec6580de4e4d695a7
BLAKE2b-256 checksum
How to use checksums
0b19c4620141f7a9a67d8f3698d6e98d7a9760df6e6de7c54ddb17c9fbad9e7a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release history Release notifications | RSS feed

This release

1.1.5 This release

2 release files

1.1.3

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page