How to use the cryptoauthlib.constant.LOCK_ZONE_CONFIG function in cryptoauthlib

To help you get started, we’ve selected a few cryptoauthlib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dmazzella / ucryptoauthlib / tests / ateccX08a / tests_write.py View on Github external
def run(device=None):
    if not device:
        raise ValueError("device")

    config = _TEST_CONFIG[device.device]

    log.debug("test_config for %s : %s", device.device, hexlify(config))
    # ATEC_UTIL.dump_configuration(config)

    if not device.atcab_is_locked(ATCA_CONSTANTS.LOCK_ZONE_CONFIG):
        device.atcab_write_config_zone(config)
        device.atcab_lock_config_zone()
    else:
        log.debug("configuration zone locked")

    if not device.atcab_is_locked(ATCA_CONSTANTS.LOCK_ZONE_DATA):
        device.atcab_lock_data_zone()
    else:
        log.debug("data zone locked")

    slot = 11
    if not device.atcab_is_slot_locked(slot):
        public_key = _TEST_KEYS["PUBLIC"]
        # # write public_key to slot
        device.atcab_write_pubkey(slot, public_key)
        # # verify wrote public_key
github dmazzella / ucryptoauthlib / tests / ateccX08a / tests_read.py View on Github external
sn0_1, sn8 = packet.response_data[1:1+2], packet.response_data[9+4:9+4+1]
    assert b'\x01#' == sn0_1, hexlify(sn0_1)
    assert b'\xee' == sn8, hexlify(sn8)
    log.debug("atcab_read_serial_number: %s", hexlify(packet.response_data))

    packets = device.atcab_read_config_zone()
    config = b''.join([bytes(packet.response_data[1:-2])
                       for packet in packets])
    log.debug("atcab_read_config_zone %d: %s", len(config), hexlify(config))
    # ATEC_UTIL.dump_configuration(config)

    for slot in range(16):
        slot_locked = device.atcab_is_slot_locked(slot)
        log.debug("atcab_is_slot_locked %d: %s", slot, slot_locked)

    locked_config = device.atcab_is_locked(ATCA_CONSTANTS.LOCK_ZONE_CONFIG)
    log.debug("atcab_is_locked LOCK_ZONE_CONFIG: %r", locked_config)

    locked_data = device.atcab_is_locked(ATCA_CONSTANTS.LOCK_ZONE_DATA)
    log.debug("atcab_is_locked LOCK_ZONE_DATA: %r", locked_data)

    try:
        slot = 11
        public_key = device.atcab_read_pubkey(slot)
        log.debug("atcab_read_pubkey slot %d: %s", slot, hexlify(public_key))
    except ATCA_EXCEPTIONS.ExecutionError:
        pass
github dmazzella / ucryptoauthlib / cryptoauthlib / basic.py View on Github external
def atcab_lock_config_zone_crc(self, crc):
        return self.atcab_lock(ATCA_CONSTANTS.LOCK_ZONE_CONFIG, crc)
github dmazzella / ucryptoauthlib / cryptoauthlib / basic.py View on Github external
if zone not in (
            ATCA_CONSTANTS.LOCK_ZONE_CONFIG,
            ATCA_CONSTANTS.LOCK_ZONE_DATA
        ):
            raise ATCA_EXCEPTIONS.BadArgumentError()

        # Read the word with the lock bytes
        # (UserExtra, Selector, LockValue, LockConfig) (config block = 2, word offset = 5)
        packet = self.atcab_read_zone(
            ATCA_CONSTANTS.ATCA_ZONE_CONFIG,
            slot=0,
            block=2,
            offset=5,
            length=ATCA_CONSTANTS.ATCA_WORD_SIZE
        )
        if zone == ATCA_CONSTANTS.LOCK_ZONE_CONFIG:
            return bool(packet[3+1] != 0x55)
        elif zone == ATCA_CONSTANTS.LOCK_ZONE_DATA:
            return bool(packet[2+1] != 0x55)
github dmazzella / ucryptoauthlib / cryptoauthlib / basic.py View on Github external
def atcab_is_locked(self, zone):
        if zone not in (
            ATCA_CONSTANTS.LOCK_ZONE_CONFIG,
            ATCA_CONSTANTS.LOCK_ZONE_DATA
        ):
            raise ATCA_EXCEPTIONS.BadArgumentError()

        # Read the word with the lock bytes
        # (UserExtra, Selector, LockValue, LockConfig) (config block = 2, word offset = 5)
        packet = self.atcab_read_zone(
            ATCA_CONSTANTS.ATCA_ZONE_CONFIG,
            slot=0,
            block=2,
            offset=5,
            length=ATCA_CONSTANTS.ATCA_WORD_SIZE
        )
        if zone == ATCA_CONSTANTS.LOCK_ZONE_CONFIG:
            return bool(packet[3+1] != 0x55)
        elif zone == ATCA_CONSTANTS.LOCK_ZONE_DATA: