示例#1
0
 def __init__(self, cip, cport, sip, sport, lbip, lbport):
     # create an INET, STREAMing socket
     self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     self.sip = sip
     self.sport = sport
     self.cip = cip
     self.cport = cport
     self.lbip = lbip
     self.lbport = lbport
     self.store = KeyStore((self.lbip, self.lbport), (self.cip, self.cport),
                           (self.sip, sport))  # KeyStore
示例#2
0
def add_key(tag):
    if tag.__class__.__name__ != 'NTAG215':
        logger.error(f'Wrong tag type ({tag.__class__.__name__})')
        return

    logger.info('Adding key')
    keystore = KeyStore(args.database_file)
    key = keystore.add_new_key(tag.identifier)
    secret = key[0]
    key = key[1]
    tag.write(6, secret[0:4])
    tag.write(7, secret[4:8])
    tag.write(8, secret[8:12])
    tag.write(9, secret[12:16])
    tag.protect(password=key.get_access_key(),
                read_protect=True,
                protect_from=4)
示例#3
0
def verify_single_block_multi_transaction_blockchain(tx_pool):
    blockchain = Blockchain()
    key_store = KeyStore()

    block_number = 0
    previous_block_hash = blockchain.current_block.block_hash if not blockchain.is_empty(
    ) else None
    header = BlockHeader(block_number, previous_block_hash, key_store,
                         config.MINING_DIFFICULTY)
    txs = [tx_pool.get() for i in xrange(config.BLOCKCHAIN_LENGTH)]
    block = MultiTransactionBlock(header, txs)

    if previous_block_hash:
        blockchain.current_block.header.next_block = block

    blockchain.accept_block(block)

    print block
    logger.info(block)

    blockchain.verify_chain()
示例#4
0
def main():
    args = parser.parse_args()
    key_store = KeyStore(args.project_id)
    kms_client = googleapiclient.discovery.build('cloudkms', 'v1')
    kms = GoogleKMS(kms_client, args.project_id, args.location_id,
                    args.key_ring_id, key_store)

    if args.command == "put":
        kms.put(args.key_id, Config.DEFAULT_DATASTORE_KIND, args.name,
                args.plaintext)
    elif args.command == "get":
        print(kms.get(args.key_id, Config.DEFAULT_DATASTORE_KIND, args.name))
    elif args.command == "get-all":
        print(kms.get_all(args.key_id, Config.DEFAULT_DATASTORE_KIND))
    elif args.command == "create-keyring":
        print(
            kms.create_key_ring(kms_client, args.project_id, args.location_id,
                                args.new_keyring_id))
    elif args.command == "create-key":
        print(
            kms.create_key(kms_client, args.project_id, args.location_id,
                           args.key_ring_id, args.new_key_id))
    else:
        parser.print_help()
示例#5
0
def authenticate_key(tag):
    global currentEvent, pin

    if tag.__class__.__name__ != 'NTAG215':
        logger.error(f'Wrong tag type ({tag.__class__.__name__})')
        return

    logger.info('Authenticating key')
    keystore = KeyStore(args.database_file)
    key = keystore.get_key_from_db(tag.identifier)

    if key is None:
        logger.error('No key found for tag')
        return

    if tag.authenticate(key.access_key) and key.validate(tag.read(6)):
        logger.info('Switching on pin')
        pin.on()
        if pin.is_active:
            logger.info('Renewing scheduler')
            if currentEvent:
                currentEvent.cancel()
        currentEvent = Scheduler(10, pin.off)
        currentEvent.start()
示例#6
0
 def get_conf():
     ks = KeyStore()
     return ks.get_elasticsearch_credentials()
示例#7
0
from ucryptolib import aes
from hashlib import hmac_sha512

from io import BytesIO

reckless_fname = "%s/%s" % (storage_root, "reckless.json")

qr_scanner = QRScanner()
usb_host = USBHost()

# entropy that will be converted to mnemonic
entropy = None
# network we are using
network = None
# our key storage
keystore = KeyStore(storage_root=storage_root)

DEFAULT_XPUBS = []
ALL_XPUBS = []

SUPPORTED_SCRIPTS = {
    "p2wpkh": "Native Segwit",
    "p2sh-p2wpkh": "Nested Segwit",
    "p2wsh-sortedmulti": "Native Segwit Multisig",
    "p2sh-p2wsh-sortedmulti": "Nested Segwit Multisig",
}

def catchit(fn):
    """ Catches an error in the function and 
        displays error screen with exception """
    # Maybe there is a better way... 
 def _retrieve_credentials(self):
     ks = KeyStore()
     creds = ks.get_email_credentials()
     self._user = creds["user"]
     self._password = creds["password"]