Package: pykeystore
Python KeystoreThis package provides a simple keystore,The keystore is available is three typesSimpleneed too supply the passphres for every secure oprationExtenededneed only onetime supply the passphraseKeyringneed 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;The keystore it self.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 functionsSimpleThis atre the functions in the Keystore classclassmethod 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] ) -> Nonefunction hasAccount( self, account: str ) -> bool:function setPassword( self, account: str, password: str, passphrase: Union[str,bytes], two_fa = None ) -> Nonefunction getPassword( self, account:str, passphrase: Union[str,bytes] ) -> bytesfunction get2fa( self, account:str, passphrase: Union[str,bytes] ) -> bytesfunction getAccount( self, account:str, passphrase: Union[str,bytes] ) -> tuple( account, password [, twofa ] )function hasPrivateKey( self, alias:str, algo:str = 'RSA' ) -> boolfunction setPrivateKey( self, alias:str, key, algo:str, passphrase: Union[str,bytes] ) -> boolfunction getPrivateKey( self, alias:str, algo:str, passphrase: Union[str,bytes] ) -> bytesfunction hasPublicKey( self, alias:str, algo:str = 'RSA' ) -> boolfunction setPublicKey( self, alias:str, key = None, algo:str = 'RSA' ) -> boolfunction getPublicKey( self, alias:str, algo:str = 'RSA' ) -> bytesfunction hasCertificate( self, alias:str, algo:str = 'RSA' ) -> boolfunction setCertificate( self, alias:str, cert, algo:str = 'RSA' ) -> boolfunction getCertificate( self, alias:str, algo:str = 'RSA' ) -> Union[bytes,None]function hasEncriptioneKey( self, alias:str, algo:str ) -> boolfunction setEncriptioneKey( self, alias:str, algo:str, key, passphrase: Union[str,bytes] ) -> Nonefunction getEncriptioneKey( self, algo:str, alias:str, passphrase: Union[str,bytes] ) -> bytesExtendedMost functions are the same as for the simple Keystore, the following functions differ;setPassword( self, account: str, password: str, two_fa = None ) -> NonegetPassword( self, account:str ) -> bytesget2fa( self, account:str ) -> bytesgetAccount( self, account:str ) -> tuplesetPrivateKey( self, alias:str, key, algo:str ) -> boolgetPrivateKey( self, alias:str, algo:str ) -> bytessetEncriptioneKey( self, alias:str, algo:str, key ) - NonegetEncriptioneKey( self, algo:str, alias: str ) -> bytesKeyringMost 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 ) -> NoneExamplesSimpleFor 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  )ExtendedFor 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 )KeyringFor 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' )