11 · Security & Cryptography
11 · ความปลอดภัยและวิทยาการรหัสลับ
This chapter is not a floor of the tower but a stairwell cut through all of them — an attacker enters on whichever floor you left unguarded, and is under no obligation to use the door you built.
บทนี้ไม่ใช่ชั้นหนึ่งของหอคอย แต่เป็นช่องบันไดที่เจาะทะลุทุกชั้น — ผู้โจมตีเข้าทางชั้นไหนก็ได้ที่คุณปล่อยไว้ไม่มีคนเฝ้า และไม่มีข้อผูกมัดใดที่จะต้องใช้ประตูที่คุณสร้างไว้
How do strangers build trust over a wire?
คนแปลกหน้าสร้างความไว้ใจกันผ่านสายได้อย่างไร
In November 1976 the IEEE Transactions on Information Theory carried a paper opening with a sentence academics almost never allow themselves: "We stand today on the brink of a revolution in cryptography" (Diffie & Hellman, 1976). The problem it dissolved was thousands of years old, and it was not that codes kept getting broken. It was a delivery problem. Every cipher in history — Caesar's, Mary Stuart's, Enigma's — required that sender and receiver already share a secret key: a courier, a meeting, a locked bag. Scrambling the message was never the hard part. Getting the key to the far end untouched was, and on a planetary network of strangers who will never meet, it looked impossible.
เดือนพฤศจิกายน 1976 วารสาร IEEE Transactions on Information Theory ลงเปเปอร์ที่เปิดด้วยประโยคที่นักวิชาการแทบไม่ยอมให้ตัวเองเขียน — "วันนี้เรากำลังยืนอยู่บนขอบของการปฏิวัติทางวิทยาการรหัสลับ" (We stand today on the brink of a revolution in cryptography) (Diffie & Hellman, 1976) ปัญหาที่มันคลี่คลายมีอายุนับพันปี และไม่ใช่เรื่องที่รหัสถูกถอดได้เรื่อยๆ มันคือปัญหาการส่งมอบ รหัสลับทุกแบบในประวัติศาสตร์ — ของ Caesar, ของ Mary Stuart, ของ Enigma — ต้องการให้ผู้ส่งกับผู้รับถือกุญแจลับ (key) ร่วมกันอยู่ก่อนแล้ว ผ่านคนเดินสาร ผ่านการนัดพบ หรือผ่านกระเป๋าที่ล็อกไว้ การสับข้อความให้อ่านไม่ออกไม่เคยเป็นส่วนที่ยาก ส่วนที่ยากคือส่งกุญแจไปถึงปลายทางโดยไม่มีใครแตะต้อง และบนเครือข่ายระดับดาวเคราะห์ที่เต็มไปด้วยคนแปลกหน้าที่จะไม่มีวันเจอกัน เรื่องนี้ดูเป็นไปไม่ได้
It is not. Two people who have never met can shout across a room where everyone is listening and writing everything down, and finish sharing a number no listener can compute.
มันเป็นไปได้ คนสองคนที่ไม่เคยเจอกันตะโกนข้ามห้องที่ทุกคนฟังอยู่และจดทุกคำไว้ แล้วจบลงด้วยตัวเลขร่วมกันตัวหนึ่งที่ไม่มีผู้ฟังคนไหนคำนวณตามได้
The strangest part of that revolution is that it had already happened, in silence. In a January 1970 report, James Ellis of Britain's GCHQ argued that "non-secret encryption" was possible; Clifford Cocks built a working scheme in 1973 and Malcolm Williamson another in 1974. All of it was classified. GCHQ released the papers on 17 December 1997, the day before Cocks announced them in public — a month after Ellis had died on 25 November 1997, never permitted to say what he had done (GCHQ).
ส่วนที่แปลกที่สุดของการปฏิวัติครั้งนั้นคือมันเกิดขึ้นไปแล้วอย่างเงียบๆ ในรายงานเดือนมกราคม 1970 James Ellis แห่ง GCHQ ของอังกฤษ เสนอว่า "การเข้ารหัสแบบไม่ลับ" (non-secret encryption) เป็นไปได้ Clifford Cocks สร้างสคีมาที่ใช้งานได้จริงในปี 1973 Malcolm Williamson สร้างอีกแบบในปี 1974 ทั้งหมดถูกจัดชั้นเป็นความลับ GCHQ ปล่อยเอกสารออกมาวันที่ 17 ธันวาคม 1997 หนึ่งวันก่อน Cocks ประกาศต่อสาธารณะ — หนึ่งเดือนหลัง Ellis เสียชีวิตเมื่อวันที่ 25 พฤศจิกายน 1997 โดยไม่เคยได้รับอนุญาตให้พูดว่าตัวเองทำอะไรไว้ (GCHQ)
Assume the enemy has your blueprints. In 1883 Auguste Kerckhoffs published six requirements for a field cipher in the Journal des sciences militaires. Five are period furniture. The second has outlived them all: the system "must not require secrecy and can be stolen by the enemy without causing trouble" (Kerckhoffs, 1883). Claude Shannon restated the rule in the 1949 paper that made cryptography a mathematical science (Communication Theory of Secrecy Systems), and modern standards still say it plainly — security "should not depend on the secrecy of the implementation or its components" (NIST SP 800-123). A key can be replaced in seconds by one person; a hidden design baked into a million shipped devices cannot be replaced at all, needing only one captured device to become public. Concentrate the secrecy in the smallest, most replaceable thing you own. That thing is the key.
สมมติว่าศัตรูถือพิมพ์เขียวของคุณอยู่ในมือแล้ว ปี 1883 Auguste Kerckhoffs ตีพิมพ์ข้อกำหนดหกข้อสำหรับรหัสลับภาคสนามใน Journal des sciences militaires ห้าข้อเป็นเฟอร์นิเจอร์ของยุคนั้น ข้อที่สองอยู่รอดมาได้นานกว่าทุกข้อ — ระบบ "ต้องไม่ต้องอาศัยความลับ และต่อให้ถูกศัตรูขโมยไปก็ไม่ก่อปัญหา" (must not require secrecy and can be stolen by the enemy without causing trouble) (Kerckhoffs, 1883) Claude Shannon เขียนกฎข้อนี้ใหม่ในเปเปอร์ปี 1949 ที่ทำให้วิทยาการรหัสลับกลายเป็นศาสตร์เชิงคณิตศาสตร์ (Communication Theory of Secrecy Systems) และมาตรฐานยุคนี้ก็ยังพูดตรงๆ อย่างเดียวกัน — ความปลอดภัย "ไม่ควรขึ้นอยู่กับความลับของการนำไปใช้งานจริงหรือส่วนประกอบของมัน" (should not depend on the secrecy of the implementation or its components) (NIST SP 800-123) คนคนเดียวเปลี่ยนกุญแจใหม่ได้ในไม่กี่วินาที ดีไซน์ที่ซ่อนไว้ในอุปกรณ์นับล้านเครื่องที่ส่งออกไปแล้วเปลี่ยนไม่ได้เลย และอุปกรณ์ถูกยึดไปเครื่องเดียวก็พอให้มันกลายเป็นของสาธารณะ รวมความลับไว้ที่สิ่งที่เล็กที่สุดและเปลี่ยนง่ายที่สุดเท่าที่คุณมี สิ่งนั้นคือกุญแจ
Some doors swing one way. Multiplying two large primes takes a modern processor a fraction of a millisecond. Recovering those primes from the product has no known classical method that finishes in a useful lifetime. Cryptography lives inside gaps like this — computations cheap forward and ruinous backward. Here is the honest part: nobody has proved such functions exist. Their existence would imply P ≠ NP; the reverse implication is not known, so even settling that famous question would not settle this one (status). Every encrypted payment and every signed software update rests on a conjecture that has survived fifty years of attack — which is evidence, not proof.
ประตูบางบานแกว่งได้ทางเดียว การคูณจำนวนเฉพาะขนาดใหญ่สองตัวกินเวลาโปรเซสเซอร์สมัยใหม่แค่เศษเสี้ยวมิลลิวินาที การย้อนหาจำนวนเฉพาะสองตัวนั้นจากผลคูณไม่มีวิธีแบบคลาสสิกวิธีใดที่รู้จักกันแล้วเสร็จได้ในช่วงชีวิตที่ใช้ประโยชน์ได้ วิทยาการรหัสลับอาศัยอยู่ในช่องว่างแบบนี้ — คำนวณไปข้างหน้าถูก ย้อนกลับแพงจนพัง ส่วนที่ต้องพูดตรงๆ คือไม่มีใครพิสูจน์ได้ว่าฟังก์ชันทางเดียว (one-way function) แบบนี้มีอยู่จริง การมีอยู่ของมันจะบอกเป็นนัยว่า P ≠ NP ส่วนนัยกลับด้านนั้นไม่มีใครรู้ ต่อให้ตัดสินคำถามชื่อดังข้อนั้นได้ ก็ยังไม่ได้ตัดสินข้อนี้ (status) การจ่ายเงินที่เข้ารหัสทุกครั้งและการอัปเดตซอฟต์แวร์ที่เซ็นกำกับทุกครั้ง วางอยู่บนข้อสันนิษฐานที่รอดการโจมตีมาห้าสิบปี — นั่นคือหลักฐาน ไม่ใช่บทพิสูจน์
A secret can be agreed in public. The Diffie–Hellman construction is worth understanding once, because it feels like sleight of hand and is not. Both parties agree publicly on a large prime and a base number. Each privately picks an exponent, raises the base to it, and shouts the result. Each then raises the other person's shouted number to their own private exponent. Both arrive at the same value, because exponentiation does not care about the order. An eavesdropper holds both public results and cannot get there, because recovering an exponent from its result — the discrete logarithm — is one of those one-way doors. Two years later, Rivest, Shamir and Adleman turned the same asymmetry the other way round (RSA, 1978): not hiding a message, but signing it, so anyone can check who wrote it and no one can forge it. Diffie and Hellman received the Turing Award for 2015 (ACM).
ความลับตกลงกันในที่แจ้งได้ โครงสร้าง Diffie–Hellman คุ้มที่จะทำความเข้าใจสักครั้ง เพราะมันให้ความรู้สึกเหมือนกลมายากล ทั้งที่ไม่ใช่ ทั้งสองฝ่ายตกลงกันในที่แจ้งเรื่องจำนวนเฉพาะขนาดใหญ่ตัวหนึ่งกับเลขฐานตัวหนึ่ง แต่ละฝ่ายเลือกเลขชี้กำลังของตัวเองเป็นการส่วนตัว ยกเลขฐานขึ้นเป็นเลขชี้กำลังนั้น แล้วตะโกนผลลัพธ์ออกไป ต่อมาแต่ละฝ่ายยกตัวเลขที่ อีกฝ่าย ตะโกนออกมา ขึ้นเป็นเลขชี้กำลังส่วนตัวของตัวเอง ทั้งคู่ได้ค่าเดียวกัน เพราะการยกกำลังไม่สนใจลำดับ คนดักฟังถือผลลัพธ์สาธารณะไว้ทั้งสองค่าแต่ไปต่อไม่ได้ เพราะการย้อนหาเลขชี้กำลังจากผลลัพธ์ของมัน — ลอการิทึมไม่ต่อเนื่อง (discrete logarithm) — ก็เป็นประตูทางเดียวอีกบานหนึ่ง สองปีต่อมา Rivest, Shamir และ Adleman พลิกความไม่สมมาตรอันเดียวกันนี้กลับด้าน (RSA, 1978) ไม่ใช่ซ่อนข้อความ แต่เซ็นกำกับมัน ให้ใครก็ตรวจได้ว่าใครเขียน และไม่มีใครปลอมได้ Diffie กับ Hellman ได้รับรางวัล Turing Award ประจำปี 2015 (ACM)
Encryption is one promise out of three, and usually not the one you needed. Confidentiality means nobody else can read it. Integrity means nobody altered it in flight. Authentication means it came from who it claims. These are separable, and the failure mode is unglamorous: an attacker who cannot read your ciphertext may still flip bits inside it, or replay yesterday's valid message today. Most real protocol disasters are integrity or authentication failures wearing an encrypted coat.
การเข้ารหัสเป็นคำมั่นแค่ข้อเดียวในสามข้อ และมักไม่ใช่ข้อที่คุณต้องการ ความลับ (confidentiality) คือไม่มีใครอื่นอ่านมันออก ความครบถ้วน (integrity) คือไม่มีใครแก้ไขมันระหว่างทาง การพิสูจน์ตัวตน (authentication) คือมันมาจากคนที่มันอ้างว่าเป็น สามอย่างนี้แยกจากกันได้ และรูปแบบความล้มเหลวก็ไม่หวือหวา ผู้โจมตีที่อ่าน ciphertext ของคุณไม่ออก ยังสลับบิตข้างในมันได้ หรือเอาข้อความที่ถูกต้องของเมื่อวานมาเล่นซ้ำวันนี้ ความหายนะของโพรโทคอลในโลกจริงส่วนใหญ่คือความล้มเหลวด้าน integrity หรือ authentication ที่สวมเสื้อคลุมเข้ารหัสไว้
Design against an adversary, not for a user. Every other floor in this tower asks whether a system works. This one asks what happens when someone actively wants it not to — and gets to choose the floor. Saltzer and Schroeder set out the discipline in 1975 in eight principles that have not needed revision: economy of mechanism, fail-safe defaults, complete mediation, open design, separation of privilege, least privilege, least common mechanism, psychological acceptability (Proc. IEEE 63(9)). Least privilege is the one to carry: every component gets exactly the authority its job requires, so a compromise stays local. Heartbleed, disclosed on 7 April 2014, was a missing bounds check in OpenSSL that let any stranger ask a server for a slice of its own memory (CISA) — no cipher was broken; a leak two floors down drained the secrets held above it. That is chapter 00's law of leaky abstractions with an adversary standing at the crack.
ออกแบบเพื่อรับมือฝ่ายตรงข้าม ไม่ใช่เพื่อผู้ใช้ ทุกชั้นอื่นในหอคอยนี้ถามว่าระบบทำงานได้ไหม ชั้นนี้ถามว่าเกิดอะไรขึ้นเมื่อมีคนตั้งใจอยากให้มันทำงานไม่ได้ — และเลือกได้เองว่าจะลงมือที่ชั้นไหน Saltzer กับ Schroeder วางวินัยนี้ไว้ในปี 1975 เป็นหลักการแปดข้อที่ยังไม่ต้องแก้ — economy of mechanism, fail-safe defaults, complete mediation, open design, separation of privilege, least privilege, least common mechanism, psychological acceptability (Proc. IEEE 63(9)) ข้อที่ควรพกติดตัวคือสิทธิ์น้อยที่สุด (least privilege) — แต่ละคอมโพเนนต์ได้อำนาจพอดีกับที่งานของมันต้องใช้ ความเสียหายเมื่อถูกเจาะจึงอยู่แค่จุดเดียว Heartbleed เปิดเผยเมื่อวันที่ 7 เมษายน 2014 คือการลืมตรวจขอบเขต (bounds check) ใน OpenSSL ที่ปล่อยให้คนแปลกหน้าคนไหนก็ได้ขอชิ้นส่วนหน่วยความจำของเซิร์ฟเวอร์ไปดู (CISA) — ไม่มีรหัสลับตัวไหนถูกถอด รอยรั่วต่ำลงไปสองชั้นดูดความลับที่เก็บอยู่ข้างบนออกไปหมด นี่คือกฎว่าด้วย abstraction ที่รั่วเสมอจากบทที่ 00 โดยมีฝ่ายตรงข้ามยืนอยู่ตรงรอยร้าว
The weakest layer is the one made of people. The Morris worm of 2 November 1988 spread through an estimated 6,000 of roughly 60,000 connected machines (FBI) — an estimate, still quoted as one. The ratio has not improved: Verizon's 2026 Data Breach Investigations Report, covering incidents from 1 November 2024 to 31 October 2025, finds a human element in 62% of breaches (DBIR). Mathematics defends the wire. It does not defend the person who is tired at the end of a shift.
ชั้นที่อ่อนแอที่สุดคือชั้นที่ทำจากคน หนอน Morris เมื่อวันที่ 2 พฤศจิกายน 1988 แพร่ไปราว 6,000 เครื่อง จากเครื่องที่เชื่อมต่ออยู่ราว 60,000 เครื่อง (FBI) — เป็นตัวเลขประมาณการ และยังถูกอ้างในฐานะตัวเลขประมาณการอยู่จนวันนี้ สัดส่วนนั้นไม่ดีขึ้นเลย รายงาน Data Breach Investigations Report ปี 2026 ของ Verizon ครอบคลุมเหตุการณ์ตั้งแต่วันที่ 1 พฤศจิกายน 2024 ถึง 31 ตุลาคม 2025 พบปัจจัยจากมนุษย์ใน 62% ของการรั่วไหล (DBIR) คณิตศาสตร์ป้องกันสายส่งได้ มันไม่ป้องกันคนที่เหนื่อยล้าตอนใกล้หมดกะ
A clock is running on all of it. Peter Shor showed in 1994 that a sufficiently large quantum computer would factor integers and compute discrete logarithms efficiently — dissolving exactly the two one-way doors that public-key cryptography stands on. No such machine exists (chapter 14 weighs how far away it is), but encrypted traffic recorded today can be decrypted the day one arrives, a strategy standards bodies now name openly as harvest now, decrypt later (NIST IR 8547). The replacement is already standardized: NIST finalized FIPS 203, 204 and 205 on 13 August 2024, and selected the code-based algorithm HQC as a backup on 11 March 2025 (NIST). The engineering problem is not inventing the new mathematics. It is finding, in a civilization's worth of software, every place the old mathematics was quietly assumed.
นาฬิกาเดินอยู่บนทุกอย่างที่ว่ามา Peter Shor แสดงไว้ในปี 1994 ว่าคอมพิวเตอร์ควอนตัมที่ใหญ่พอจะแยกตัวประกอบจำนวนเต็มและคำนวณลอการิทึมไม่ต่อเนื่องได้อย่างมีประสิทธิภาพ — สลายประตูทางเดียวสองบานที่วิทยาการรหัสลับแบบกุญแจสาธารณะ (public-key) ยืนอยู่บนนั้นพอดี เครื่องแบบนั้นยังไม่มีอยู่จริง (บทที่ 14 ชั่งน้ำหนักว่ามันอีกไกลแค่ไหน) แต่ทราฟฟิกที่เข้ารหัสไว้แล้วบันทึกเก็บไว้วันนี้ ถอดได้ในวันที่เครื่องนั้นมาถึง หน่วยงานมาตรฐานเรียกกลยุทธ์นี้อย่างเปิดเผยแล้วว่า เก็บเกี่ยวตอนนี้ ถอดรหัสทีหลัง (harvest now, decrypt later) (NIST IR 8547) ตัวแทนมีมาตรฐานรองรับเรียบร้อยแล้ว NIST สรุป FIPS 203, 204 และ 205 เป็นทางการเมื่อวันที่ 13 สิงหาคม 2024 และเลือกอัลกอริทึมแบบ code-based ชื่อ HQC เป็นตัวสำรองเมื่อวันที่ 11 มีนาคม 2025 (NIST) โจทย์ทางวิศวกรรมไม่ใช่การคิดคณิตศาสตร์ชุดใหม่ แต่คือการตามหาทุกจุดที่คณิตศาสตร์ชุดเก่าถูกสมมติไว้เงียบๆ ในซอฟต์แวร์ทั้งหมดเท่าที่อารยธรรมหนึ่งเคยเขียนขึ้นมา
Connections
เชื่อมโยง
Below: chapter 03 supplies the raw material — a key is only as good as its unpredictability, which entropy measures. Chapters 04 and 05 hold the roots of trust, since a kernel that can be subverted makes every guarantee above it decorative. Alongside: chapter 09 explains why the internet's naming and routing were built for a cooperative world and had authentication bolted on later, and chapter 10 asks how parties agree when some of them have merely crashed — this chapter's adversary upgrades crashing to lying. Above: chapter 12, where the adversary attacks the training data rather than the wire.
ชั้นล่าง: บทที่ 03 ส่งวัตถุดิบมาให้ — กุญแจดีได้แค่เท่าที่มันคาดเดาไม่ได้ และสิ่งที่วัดความคาดเดาไม่ได้คือเอนโทรปี (entropy) บทที่ 04 กับ 05 ถือรากฐานของความไว้ใจไว้ เพราะเคอร์เนลที่ถูกล้มล้างได้ทำให้การรับประกัน (guarantee) ทุกข้อเหนือมันเหลือเป็นของประดับ ชั้นข้างเคียง: บทที่ 09 อธิบายว่าทำไมการตั้งชื่อและการจัดเส้นทางของอินเทอร์เน็ตถูกสร้างมาเพื่อโลกที่ร่วมมือกัน และเอาการพิสูจน์ตัวตนมาติดเพิ่มทีหลัง บทที่ 10 ถามว่าฝ่ายต่างๆ ตกลงกันได้อย่างไรเมื่อบางฝ่ายแค่ล่มไปเฉยๆ — ฝ่ายตรงข้ามในบทนี้ยกระดับจาก "ล่ม" เป็น "โกหก" ชั้นบน: บทที่ 12 ที่ฝ่ายตรงข้ามโจมตีข้อมูลเทรน ไม่ใช่สายส่ง
Open questions
คำถามที่ยังเปิดอยู่
Do one-way functions exist? Everything in this chapter is a bet that they do. Can the world's deployed cryptography be migrated to post-quantum algorithms before a cryptographically relevant quantum computer exists, given that nobody knows the date of either event? And the question the field keeps failing rather than solving: can systems be made secure and usable, given that Saltzer and Schroeder listed psychological acceptability fifty years ago and it remains the least-honoured of their eight principles?
ฟังก์ชันทางเดียวมีอยู่จริงไหม ทุกอย่างในบทนี้คือการพนันว่ามันมี วิทยาการรหัสลับที่ใช้งานอยู่ทั่วโลกจะย้ายไปใช้อัลกอริทึม post-quantum ได้ทันก่อนคอมพิวเตอร์ควอนตัมระดับที่ทำลายรหัสลับได้จะมีอยู่จริงไหม ในเมื่อไม่มีใครรู้วันที่ของเหตุการณ์ทั้งสองฝั่ง และคำถามที่วงการนี้ทำพลาดซ้ำแล้วซ้ำเล่ามากกว่าจะแก้ได้ — ระบบจะปลอดภัย และ ใช้งานง่ายไปพร้อมกันได้ไหม ในเมื่อ Saltzer กับ Schroeder ระบุ psychological acceptability ไว้ตั้งห้าสิบปีก่อน และมันยังเป็นข้อที่ถูกให้ความสำคัญน้อยที่สุดในแปดข้อของพวกเขา
Go deeper
อ่านต่อ
- Alfred Menezes, Paul van Oorschot & Scott Vanstone, Handbook of Applied Cryptography, CRC Press, 1996 — the standard reference, all chapters free with the publisher's permission at cacr.uwaterloo.ca/hac.
- Whitfield Diffie & Martin Hellman, "New Directions in Cryptography," IEEE Transactions on Information Theory IT-22, no. 6 (1976): 644–654 — PDF.
- Jerome Saltzer & Michael Schroeder, "The Protection of Information in Computer Systems," Proceedings of the IEEE 63, no. 9 (1975): 1278–1308 — PDF.
- Alfred Menezes, Paul van Oorschot & Scott Vanstone, Handbook of Applied Cryptography, CRC Press, 1996 — เอกสารอ้างอิงมาตรฐาน ทุกบทเปิดให้อ่านฟรีโดยได้รับอนุญาตจากสำนักพิมพ์ที่ cacr.uwaterloo.ca/hac
- Whitfield Diffie & Martin Hellman, "New Directions in Cryptography," IEEE Transactions on Information Theory IT-22, no. 6 (1976): 644–654 — PDF
- Jerome Saltzer & Michael Schroeder, "The Protection of Information in Computer Systems," Proceedings of the IEEE 63, no. 9 (1975): 1278–1308 — PDF