← Home

seed

Seed for cryptographic random bit generators

Address: 0x015 (21) · Privilege: U · Length: 32 · Writable · Defined by: Zkr

The seed CSR provides an interface to a NIST SP 800-90B (Turan et al., 2018) or BSI AIS-31 (Killmann & Schindler, 2011) compliant physical Entropy Source (ES).

The CSR provides up to 16 physical entropy bits that can be used to seed cryptographic random bit generators. The write value is ignored by implementations; the write is used to signal polling and flushing.

Fields

31:2423:1615:87:0
OPST—ENTROPY
BitsFieldAliasDescriptionTypeReset
[31:30]OPSTStatus bits returned by the entropy source. Encodings are: * 0 - BIST * 1 - WAIT * 2 - ES16 * 3 - DEADRW-H0
[15:0]ENTROPYSixteen bits of randomness. This field is valid only when `OPST` is ES16. When `OPST` is not ES16, `ENTROPY` must be zero.RW-H0

Software read

# CSRRS/CSRRC/CSRRSI/CSRRCI are the CSR instructions with funct3[1] set.
# Bits 19:15 hold rs1 for the register forms and uimm for the immediate
# forms, so a single zero check covers rs1 == x0 and uimm == 0.
Boolean read_only_access = ($encoding[13] == 1'b1) && ($encoding[19:15] == 5'b00000);

if (read_only_access) {
  raise(ExceptionCode::IllegalInstruction, mode(), $encoding);
}

if (mode() == PrivilegeMode::U && CSR[mseccfg].USEED == 1'b0) {
  raise(ExceptionCode::IllegalInstruction, mode(), $encoding);
} else if (mode() == PrivilegeMode::S && CSR[mseccfg].SSEED == 1'b0) {
  raise(ExceptionCode::IllegalInstruction, mode(), $encoding);
} else if (mode() == PrivilegeMode::VS || mode() == PrivilegeMode::VU) {
  if (CSR[mseccfg].SSEED == 1'b1) {
    raise(ExceptionCode::VirtualInstruction, mode(), $encoding);
  } else {
    raise(ExceptionCode::IllegalInstruction, mode(), $encoding);
  }
}

# A single poll returns both the status and the entropy it goes with.
return read_seed();

Version af3eaf9+cheriot.f635218

Data from the RISC-V Unified Database, copyright RISC-V International and contributors.

CHERIoT extensions from the CHERIoT specification and Sail model, copyright Microsoft and the CHERIoT Platform contributors.

This site is provided as a community resource and is NOT affiliated with nor endorsed by RISC-V International.