Cryptnox Docs

Generate Trng Random Command

This command is used to retrieve secure random bytes directly from the chip’s internal True Random Number Generator (TRNG). This command is particularly useful when a host system requires high-entropy randomness for operations such as mnemonic generation, nonces, or secure key creation—without altering any state within the card.

The TRNG Random Command does not store, derive, or modify any cryptographic material on the card. It is a read-only operation that provides entropy sourced directly from the hardware. 


def gen_random(self, size: int): card.gen_random(size: int) # For example: gen_random(16)

📘

Note

  • A secure channel must be opened prior to using this command.
  • This is a read-only command — no internal state is changed on the card.

TRNG Random and Application Protocol Data Unit (APDU) Components

The following table outlines the components of the Application Protocol Data Unit (APDU).

Field

Description

Value

CLA

This field specifies the class of the instruction.

0x80

INS

This field specifies the particular command or operation that the smart card or secure element should execute.

0xD3

P1

First parameter of the instruction that specifies the details about the operation being requested.

random output data size in bytes (between 16 and 64, mod 4)

P2

First parameter of the instruction that specifies additional details about the operation being requested.

0x00

Data

Key data

raw data

Response

The following table outlines the possible responses that you will receive:

Response Code

Description

0x9000

Success

0x6A86

P1 is invalid