STM32F7 19 True random number generator (RNG)

Started by tha, December 16, 2022, 08:26:33 AM

Previous topic - Next topic

tha

Health checks

ส่วนประกอบนี้ทำให้แน่ใจว่า the entire entropy source (พร้อม noise source ของมัน) สตาร์ทจากนั้นทำงานตามที่คาดไว้, ได้รับการประกันว่า failures จะถูกตรวจจับได้อย่างรวดเร็วและด้วยความน่าจะเป็นและความน่าเชื่อถือที่สูง.

The RNG จัดให้มีใช้ the following health check features:
1.  Behavior tests, ถูกนำมาใช้กับ the entropy source ที่ run-time
      –   Repetition count test, ให้แฟล็ค an error เมื่อ :
     a)  หนึ่งใน the noise source จัดให้มีมากกว่า 64 บิตที่ติดต่อกันที่ a constant value ("0" หรือ "1")
     b)  หนึ่งใน the noise sources ส่งมอบมากกว่า 32 การเกิดขึ้นที่ติดต่อกันของ two bits patterns ("01" หรือ "10")
2.  Vendor specific continuous test
     –   Real-time "too slow" sampling clock detector, ให้แฟล็ค an error เมื่อ one RNG clock cycle น้อยกว่า AHB clock
          cycle หารด้วย 16.

The CECS and SECS status bits ใน the RNG_SR register แสดงให้เห็นเมื่อ an error condition ถูกตรวจพบ, ดังที่อธิบายใน Section 19.3.7: Error management.

Note:  An interrupt สามารถถูกสร้างเมื่อ an error ถูกตรวจพบ.

tha

19.3.4 RNG initialization

เมื่อ a hardware reset เกิดขึ้น ห่วงโซ่ของเหตุการณ์ต่อไปนี้จะเกิดขึ้น:
1.  The analog noise source ถูกเปิดใช้งาน, และ logic สตาร์ทการสุ่ม the analog output หลังจาก four RNG clock cycles, เติม
     LFSR shift register และ associated 16-bit post-processing shift register.
2.  The output buffer จะถูกเติมซ้ำโดยอัตโนมัติตาม the RNG usage.

The associated initialization time สามารถดูได้ที่ Section 19.6: RNG processing time.

tha

19.3.5 RNG operation

Normal operations

เพื่อรัน the RNG โดยใช้ interrupts ขั้นตอนต่อไปนี้ถูกแนะนำ:
1.  เปิดใช้งาน the interrupts โดยการเซ็ต the IE bit ใน the RNG_CR register. ในเวลาเดียวกันเปิดใช้งาน the RNG โดยการเซ็ต
     the bit RNGEN=1.
2.  An interrupt จะถูกสร้างเมื่อ a random number พร้อมแล้วหรือเมื่อ an error เกิดขึ้น. ดังนั้นแต่ละ interrupt, ตรวจสอบว่า:
     –   ไม่มี error เกิดขึ้น. The SEIS and CEIS bits ควรถูกเซ็ตเป็น '0' ใน the RNG_SR register.
     –   A random number พร้อมแล้ว. The DRDY bit ต้องถูกเซ็ตเป็น '1' ใน the RNG_SR register.
     –   ถ้าสองเงื่อนไขข้างบนเป็นจริง สิ่งที่บรรจุอยู่ภายในของ the RNG_DR register สามารถถูกอ่าน.

เพื่อรัน the RNG ใน polling mode ขั้นตอนต่อไปนี้ถูกแนะนำ:
1.  เปิดใช้งาน the random number generation โดยการเซ็ต the RNGEN bit เป็น "1" ใน the RNG_CR register.
2.  อ่าน the RNG_SR register และตรวจสอบว่า:
     –   ไม่มี error เกิดขึ้น (the SEIS and CEIS bits ควรถูกเซ็ตเป็น '0')
     –   A random number พร้อมแล้ว (the DRDY bit ควรถูกเซ็ตเป็น '1')
3.  ถ้าเงื่อนไขข้างบนเป็นจริง อ่านสิ่งที่บรรจุอยู่ภายในของ the RNG_DR register.

Note: เมื่อ data ไม่พร้อม (DRDY="0") RNG_DR ส่งคืนกลับศูนย์.


tha

Low-power operations

ถ้า the power consumption เป็นปัญหาต่อ the application, low-power strategies สามารถถูกใช้, ดังที่อธิบายใน Section 19.4: RNG low-power usage on page 549.

Software post-processing

ถ้า a NIST ที่อนุมัติ DRBG ที่มี 128 bits of security strength ถูกต้องการ an approved random generator software ต้องถูกสร้างรอบๆ the RNG true random number generator.

tha

19.3.6 RNG clocking

The RNG รันบน two different clocks: the AHB bus clock และ a dedicated RNG clock.

The AHB clock ถูกใช้เพื่อให้สัญญานนาฬิกา the AHB banked registers และ the post-processing component. The RNG clock ถูกใช้สำหรับ noise source sampling. Recommended clock configurations ถูกให้รายละเอียดใน Section 19.7: Entropy source validation.

Caution: เมื่อ the CED bit ใน the RNG_CR register ถูกเซ็ตเป็น "0", the RNG clock frequency ต้องสูงกว่า AHB clock
                 frequency ที่หารด้วย 16, มิฉะนั้น the clock checker จะให้แฟล็ค a clock error (CECS หรือ CEIS ใน the RNG_SR
                 register) และ the RNG จะหยุดการผลิต random numbers.

ดู Section 19.3.1: RNG block diagram สำหรับรายละเอียด (AHB and RNG clock domains).

tha

19.3.7 Error management

ควบคู่ไปกับ random number generation an health check block จะตรวจสอบ the correct noise source behavior และ the frequency of the RNG source clock ตามที่ให้รายละเอียดในส่วนนี้. Associated error state ถูกอธิบายไว้ด้วย.

Clock error detection

เมื่อ the clock error detection ถูกเปิดใช้งาน (CED = 0) และถ้า the RNG clock frequency ต่ำเกินไป, the RNG จะหยุดการสร้าง random numbers และเซ็ตเป็น "1" ทั้ง the CEIS and CECS bits เพื่อแสดงให้เห็นว่า a clock error เกิดขึ้น. ในกรณีนี้, the application ควรตรวจเช็คว่า the RNG clock ถูกกำหนดค่าอย่างถูกต้อง (ดู Section 19.3.6: RNG clocking) และจากนั้นมันต้องเคลียร์ the CEIS bit interrupt flag. ทันทีที่ the RNG clock ทำงานอย่างถูกต้อง, the CECS bit จะถูกเคลียร์โดยอัตโนมัติ.

The RNG จะทำงานเฉพาะเมื่อ the CECS flag ถูกเซ็ตเป็น "0". อย่างไรก็ตาม โปรดทราบว่า the clock error ไม่มีผลกระทบต่อ the previously generated random numbers, และ the RNG_DR register contents ยังคงสามารถถูกใช้งานได้.

tha

Noise source error detection

เมื่อ a noise source (หรือ seed) error เกิดขึ้น, the RNG จะหยุดการสร้าง random numbers และเซ็ตเป็น "1" ทั้ง the SEIS and SECS bits เพื่อแสดงให้เห็นว่า a seed error เกิดขึ้น. ถ้า a value มีให้ใช้งานใน the RNG_DR register, มันต้องไม่ถูกใช้เนื่องจากมันอาจไม่มี entropy เพียงพอ.

เพื่อกู้คืนอย่างเต็มที่จาก a seed error application ต้องเคลียร์ the SEIS bit โดยการเขียนมันเป็น "0", จากนั้นเคลียร์และเซ็ต the RNGEN bit เพื่อเริ่มต้นใหม่และรีสตาร์ท the RNG.

tha

19.4 RNG low-power usage

ถ้า power consumption คือปัญหา, the RNG สามารถถูกปิดใช้งานทันทีที่ the DRDY bit ถูกเซ็ตเป็น "1" โดยการเซ็ต the RNGEN bit เป็น "0" ใน the RNG_CR register. The 32-bit random value ที่เก็บใน the RNG_DR register จะยังคงมีให้ใช้งาน. ถ้า a new random ถูกต้องการ the application จะจำเป็นต้องเปิดใช้งานใหม่ the RNG และรอเป็นเวลา 42+4 RNG clock cycles.

เมื่อปิดใช้งาน the RNG ผู้ใช้จะทำให้ไม่ทำงานทุก the analog seed generators, ซึ่ง power consumption ถูกให้ไว้ใน the datasheet electrical characteristics section.