← Documents Documentation/admin-guide/hw_random.rst GitHub 원문 ↗

Linux 6.18.37 · Administration / Security

Linux hardware random number generators

hw_random core, /dev/hwrng의 안전한 사용, RNG driver 선택과 Intel Firmware Hub RNG의 동작을 설명합니다.

Source pathDocumentation/admin-guide/hw_random.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

하드웨어 RNG interface

hw_random.rst:1-49

`/dev/hwrng`, rng-tools와 entropy pool의 관계, fitness test 필요성과 sysfs driver 선택을 설명합니다.

Intel Firmware Hub RNG

hw_random.rst:50-104

thermal noise 기반 하드웨어, e820와 MMIO 예약, `request_mem_region` 제거 이유 및 참고 문서를 기록합니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 =================================
2 Hardware random number generators
3 =================================
4
5 Introduction
6 ============
7
8 The hw_random framework is software that makes use of a
9 special hardware feature on your CPU or motherboard,
10 a Random Number Generator (RNG). The software has two parts:
11 a core providing the /dev/hwrng character device and its
12 sysfs support, plus a hardware-specific driver that plugs
13 into that core.
14
15 To make the most effective use of these mechanisms, you
16 should download the support software as well. Download the
17 latest version of the "rng-tools" package from:
18
19 https://github.com/nhorman/rng-tools
20
21 Those tools use /dev/hwrng to fill the kernel entropy pool,
22 which is used internally and exported by the /dev/urandom and
23 /dev/random special files.
24
25 Theory of operation
26 ===================
27
28 CHARACTER DEVICE. Using the standard open()
29 and read() system calls, you can read random data from
30 the hardware RNG device. This data is NOT CHECKED by any
31 fitness tests, and could potentially be bogus (if the
32 hardware is faulty or has been tampered with). Data is only
33 output if the hardware "has-data" flag is set, but nevertheless
34 a security-conscious person would run fitness tests on the
35 data before assuming it is truly random.
36
37 The rng-tools package uses such tests in "rngd", and lets you
38 run them by hand with a "rngtest" utility.
39
40 /dev/hwrng is char device major 10, minor 183.
41
42 CLASS DEVICE. There is a /sys/class/misc/hw_random node with
43 two unique attributes, "rng_available" and "rng_current". The
44 "rng_available" attribute lists the hardware-specific drivers
45 available, while "rng_current" lists the one which is currently
46 connected to /dev/hwrng. If your system has more than one
47 RNG available, you may change the one used by writing a name from
48 the list in "rng_available" into "rng_current".
49
50 ==========================================================================
51
52
53 Hardware driver for Intel/AMD/VIA Random Number Generators (RNG)
54 - Copyright 2000,2001 Jeff Garzik <[email protected]>
55 - Copyright 2000,2001 Philipp Rumpf <[email protected]>
56
57
58 About the Intel RNG hardware, from the firmware hub datasheet
59 =============================================================
60
61 The Firmware Hub integrates a Random Number Generator (RNG)
62 using thermal noise generated from inherently random quantum
63 mechanical properties of silicon. When not generating new random
64 bits the RNG circuitry will enter a low power state. Intel will
65 provide a binary software driver to give third party software
66 access to our RNG for use as a security feature. At this time,
67 the RNG is only to be used with a system in an OS-present state.
68
69 Intel RNG Driver notes
70 ======================
71
72 FIXME: support poll(2)
73
74 .. note::
75
76 request_mem_region was removed, for three reasons:
77
78 1) Only one RNG is supported by this driver;
79 2) The location used by the RNG is a fixed location in
80 MMIO-addressable memory;
81 3) users with properly working BIOS e820 handling will always
82 have the region in which the RNG is located reserved, so
83 request_mem_region calls always fail for proper setups.
84 However, for people who use mem=XX, BIOS e820 information is
85 **not** in /proc/iomem, and request_mem_region(RNG_ADDR) can
86 succeed.
87
88 Driver details
89 ==============
90
91 Based on:
92 Intel 82802AB/82802AC Firmware Hub (FWH) Datasheet
93 May 1999 Order Number: 290658-002 R
94
95 Intel 82802 Firmware Hub:
96 Random Number Generator
97 Programmer's Reference Manual
98 December 1999 Order Number: 298029-001 R
99
100 Intel 82802 Firmware HUB Random Number Generator Driver
101 Copyright (c) 2000 Matt Sottek <[email protected]>
102
103 Special thanks to Matt Sottek. I did the "guts", he
104 did the "brains" and all the testing.
105

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

하드웨어 난수 생성기 소개

1-24

`hw_random` framework는 CPU 또는 motherboard의 특수 하드웨어 기능인 Random Number Generator(RNG)를 사용합니다. 소프트웨어는 `/dev/hwrng` character device와 sysfs 지원을 제공하는 core, 그리고 core에 연결되는 하드웨어 전용 드라이버로 구성됩니다.

이 메커니즘을 효과적으로 사용하려면 최신 `rng-tools` package를 `https://github.com/nhorman/rng-tools`에서 내려받는 것이 좋습니다.

이 도구들은 `/dev/hwrng`를 사용해 커널 entropy pool을 채웁니다. 이 pool은 커널 내부에서 사용되고 `/dev/urandom`과 `/dev/random` special file을 통해 공개됩니다.

동작 원리와 장치 선택

25-49

표준 `open()`과 `read()` 시스템 호출로 하드웨어 RNG character device에서 난수 데이터를 읽습니다. 이 데이터에는 fitness test가 전혀 적용되지 않으므로 하드웨어가 고장 났거나 변조되면 잘못된 값일 수 있습니다. 하드웨어의 `has-data` flag가 설정됐을 때만 출력되지만 보안을 중시한다면 진짜 난수라고 가정하기 전에 fitness test를 수행해야 합니다.

`rng-tools` package의 `rngd`는 이런 test를 사용하며 `rngtest` utility로 직접 실행할 수도 있습니다.

`/dev/hwrng`는 character device major 10, minor 183입니다.

sysfs attribute설명
/sys/class/misc/hw_random/rng_available사용 가능한 하드웨어 전용 RNG driver 목록입니다.
/sys/class/misc/hw_random/rng_current현재 `/dev/hwrng`에 연결된 driver를 보여 줍니다. RNG가 여러 개면 `rng_available`의 이름 하나를 여기에 써서 선택을 바꿀 수 있습니다.

Intel/AMD/VIA RNG 드라이버와 Intel 하드웨어

50-68

Intel/AMD/VIA RNG 하드웨어 드라이버 절입니다. 원문은 Jeff Garzik과 Philipp Rumpf의 2000~2001년 저작권을 기록합니다.

Firmware Hub는 silicon의 본질적으로 무작위인 양자역학적 특성에서 생기는 thermal noise를 사용하는 RNG를 통합합니다. 새 random bit를 만들지 않을 때 RNG 회로는 저전력 상태로 들어갑니다.

Intel은 보안 기능으로 RNG를 제3자 소프트웨어가 사용할 수 있게 binary software driver를 제공한다고 설명합니다. 원문 작성 시점의 RNG는 OS가 실행 중인 상태의 시스템에서만 사용하도록 되어 있습니다.

Intel RNG 드라이버 주의사항

69-87

`poll(2)` 지원은 원문에서 FIXME로 남아 있습니다.

`request_mem_region` 호출은 다음 세 이유로 제거되었습니다.

  • 이 드라이버는 RNG 하나만 지원합니다.
  • RNG가 사용하는 위치는 MMIO로 접근 가능한 메모리의 고정 위치입니다.
  • BIOS e820 처리가 올바른 시스템은 RNG가 있는 영역을 항상 reserved로 표시하므로 정상 구성에서 `request_mem_region` 호출은 늘 실패합니다.

`mem=XX`를 사용하는 경우 BIOS e820 정보가 `/proc/iomem`에 없으므로 `request_mem_region(RNG_ADDR)`가 성공할 수 있습니다.

드라이버 참고 문서와 기여

88-104
자료세부 정보
Intel 82802AB/82802AC Firmware Hub (FWH) DatasheetMay 1999, Order Number 290658-002 R
Intel 82802 Firmware Hub Random Number Generator Programmer's Reference ManualDecember 1999, Order Number 298029-001 R
Intel 82802 Firmware HUB Random Number Generator DriverCopyright (c) 2000 Matt Sottek <[email protected]>

원문 저자는 Matt Sottek에게 특별히 감사하며, 자신은 드라이버의 핵심 구현을 맡고 Matt는 설계 아이디어와 모든 시험을 맡았다고 적었습니다.