How to use the cryptoauthlib.constant.NONCE_MODE_SEED_UPDATE 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_nonce.py View on Github external
def run(device=None):
    if not device:
        raise ValueError("device")

    numbers = b'\x00' * 32

    packet = device.atcab_nonce_base(NONCE_MODE_SEED_UPDATE, numbers=numbers)
    log.debug("atcab_nonce_base NONCE_MODE_SEED_UPDATE: %s", hexlify(packet.response_data))

    packet = device.atcab_nonce_base(NONCE_MODE_NO_SEED_UPDATE, numbers=numbers)
    log.debug("atcab_nonce_base NONCE_MODE_NO_SEED_UPDATE: %s", hexlify(packet.response_data))

    packet = device.atcab_nonce_base(NONCE_MODE_PASSTHROUGH, numbers=numbers)
    log.debug("atcab_nonce_base NONCE_MODE_PASSTHROUGH: %s", hexlify(packet.response_data))

    packet = device.atcab_nonce(numbers=numbers)
    log.debug("atcab_nonce: %s", hexlify(packet.response_data))

    packet = device.atcab_nonce_load(NONCE_MODE_TARGET_TEMPKEY, numbers=numbers)
    log.debug("atcab_nonce_load NONCE_MODE_TARGET_TEMPKEY: %s", hexlify(packet.response_data))

    packet = device.atcab_nonce_load(NONCE_MODE_TARGET_MSGDIGBUF, numbers=numbers)
    log.debug("atcab_nonce_load NONCE_MODE_TARGET_MSGDIGBUF: %s", hexlify(packet.response_data))
github dmazzella / ucryptoauthlib / cryptoauthlib / basic.py View on Github external
def atcab_nonce_base(self, mode, zero=0, numbers=None):
        nonce_mode = mode & ATCA_CONSTANTS.NONCE_MODE_MASK
        if nonce_mode not in (
            ATCA_CONSTANTS.NONCE_MODE_SEED_UPDATE,
            ATCA_CONSTANTS.NONCE_MODE_NO_SEED_UPDATE,
            ATCA_CONSTANTS.NONCE_MODE_PASSTHROUGH
        ):
            raise ATCA_EXCEPTIONS.BadArgumentError()

        if not isinstance(numbers, _BYTES_LIKE_OBJECT):
            raise ATCA_EXCEPTIONS.BadArgumentError()

        txsize = 0
        if nonce_mode in (
            ATCA_CONSTANTS.NONCE_MODE_SEED_UPDATE,
            ATCA_CONSTANTS.NONCE_MODE_NO_SEED_UPDATE
        ):
            txsize = ATCA_CONSTANTS.NONCE_COUNT_SHORT
        elif nonce_mode == ATCA_CONSTANTS.NONCE_MODE_PASSTHROUGH:
            nonce_mode_input = mode & ATCA_CONSTANTS.NONCE_MODE_INPUT_LEN_MASK
            if nonce_mode_input == ATCA_CONSTANTS.NONCE_MODE_INPUT_LEN_64:
                txsize = ATCA_CONSTANTS.NONCE_COUNT_LONG_64
            else:
                txsize = ATCA_CONSTANTS.NONCE_COUNT_LONG
        else:
            raise ATCA_EXCEPTIONS.BadArgumentError()

        n_mv = memoryview(numbers)
        if len(n_mv) < txsize-ATCA_CONSTANTS.ATCA_CMD_SIZE_MIN:
            raise ATCA_EXCEPTIONS.BadArgumentError()
github dmazzella / ucryptoauthlib / cryptoauthlib / basic.py View on Github external
def atcab_challenge_seed_update(self, numbers=None):
        return self.atcab_nonce_base(
            ATCA_CONSTANTS.NONCE_MODE_SEED_UPDATE,
            numbers=numbers
        )
github dmazzella / ucryptoauthlib / cryptoauthlib / basic.py View on Github external
def atcab_nonce_base(self, mode, zero=0, numbers=None):
        nonce_mode = mode & ATCA_CONSTANTS.NONCE_MODE_MASK
        if nonce_mode not in (
            ATCA_CONSTANTS.NONCE_MODE_SEED_UPDATE,
            ATCA_CONSTANTS.NONCE_MODE_NO_SEED_UPDATE,
            ATCA_CONSTANTS.NONCE_MODE_PASSTHROUGH
        ):
            raise ATCA_EXCEPTIONS.BadArgumentError()

        if not isinstance(numbers, _BYTES_LIKE_OBJECT):
            raise ATCA_EXCEPTIONS.BadArgumentError()

        txsize = 0
        if nonce_mode in (
            ATCA_CONSTANTS.NONCE_MODE_SEED_UPDATE,
            ATCA_CONSTANTS.NONCE_MODE_NO_SEED_UPDATE
        ):
            txsize = ATCA_CONSTANTS.NONCE_COUNT_SHORT
        elif nonce_mode == ATCA_CONSTANTS.NONCE_MODE_PASSTHROUGH:
            nonce_mode_input = mode & ATCA_CONSTANTS.NONCE_MODE_INPUT_LEN_MASK