kerberos
มันคืออะไรมันคือ เครื่องมือที่เอาไว้ใช้สำหรับ Authentication
แล้วใช้ที่มีติดมากับ os หรือ app ไม่ได้หรอ
1. เพื่อให้ง่ายสำหรับการ manage password
2. ป้องกันการโดนดักจับ packet ระหว่างทาง
3. ทำ single sign-on
แล้วมันทำงานยังไงหละ
ก่อนอื่น ต้องรู้จักแต่ละ components ก่อน ว่ามีอะไรบ้าง
1. realm หรือ อาณาจักร เอาไว้ระบุว่ามีใครบ้างที่อยู่ใน realm เดียวกัน และ จะติดต่อกันได้เฉพาะภายใน realm เดียวกัน
2. Key Distribute Center (KDC) เก็บ secret key ของทั้ง user , service
(secret key คือ password ผสมกับ HASH โดยใช้ symmetric-key cryptography*)
โดยใน KDC จะประกอบได้ 2 ส่วน คือ
- Autthentication server
- Ticket Granting Server

สมมุติให้เราต้องการที่จะใช้ http service
1. เราต้องยืนยันตัวตนกับ Authentication Server ก่อนเพื่อขอ Ticket จาก Ticket Granting Server ด้วย

- name/ID
- requested service (Ticket Granting Server)
- IP address(es) หรือ null สำหรับ any ip
- requested lifetime TGT
Authentication จะตรวจสอบว่า user นี้มีตัวตนอยู่ KDC database หรือไม่ (no password checking)

โดยจะส่ง messages ออกมา 2 ฉบับ
1.1 Ticket Granting Server Session Key (TGSS)
Message ที่ถูก encrypted โดย Client Secret Key
- TGS name/ID
- Timestamp
- lifetime of TGT

1.2 Ticket Granting Ticket (TGT)
Message ที่ถูก encrypted โดย TGS secret key
- name/ID
- TGS name/ID
- Timestamp
- Source IP address(es)
- lifetime of TGT
- TGS Session key
ระบบจะถาม password (Client Secret Key) เพื่อใช้สำหรับ decrypt TGSS ในข้อ 1.1

2. หลังจากยืนยันตัวเรียบร้อย client จะไปขอ ticket เพื่อให้สามารถใช้งาน HTTP Service
client จะสร้าง message ขึ้นมา 2 ฉบับ และ ส่งไปพร้อมกับ TGT ในข้อ 1.2 ส่งไปยัง TGS
2.1 Plained text Message
- Service name/ID
- lifetime for Service

2.2 Authenticator Message ที่ถูก encrypted โดย TGS Session Key
- name/ID
- Timestamp
- Service name/ID
- lifetime for Service

2.2 Authenticator Message ที่ถูก encrypted โดย TGS Session Key
- name/ID
- Timestamp

Ticket Granting Server decrypt TGT (1.2) ด้วย TGS Secret Key และจะได้ TGS Session Key
เพื่อนำมา decrypt Authenticator (2.2) อีกทีนึง
เมื่อได้ข้อมูลครบถ้วน TGS จะเริ่มตรวจสอบข้อมูลทั้งหมดก่อนจะออก Ticket สำหรับ HTTP Service
- ยืนยันตัวตนจาก name/ID ที่ได้มาจาก TGT และ Authenticator
- เปรียบเทียบ Timestamp ที่ได้จาก TGT และ Authenticator (เวลาห่างกันไม่เกิน 2 นาที)
- ตรวจสอบว่า TGT expired หรือยัง
- ตรวจสอบว่ามี Authenticator ใน cache ของ TGS หรือไม่ เพื่อป้องกัน replay attack
- เปรียบเทียบ Source IP address(es) จาก TGT กับ client
3. เมื่อทุกอย่างเรียบร้อย Ticket Granting Server จะสร้าง messages 2 ฉบับ ส่งกลับมายัง client

- HTTP service/ID
- Timestamp
- lifetime of ticket
- HTTP Service Session Key
3.2 Ticket for HTTP Service ถูก encrypt ด้วย HTTP Service Secret Key (TGS generate)
- name/ID
- HTTP service/ID
- Source IP address(es)
- Timestamp
- lifetime of ticket
- HTTP Service Session Key

4. Client ทำการ decrypt HTTP Service Session Key message (3.1)
โดยใช้ TGS Session Key ใน cache จาก 1.1 และสร้าง Authenticator เพื่อส่งต่อไปยัง HTTP Service
4.1 Authenticator message และ encypt ด้วย HTTP Service Session Key
- name/ID
- Timestamp
และส่ง message 2 ฉบับ ไปยัง HTTP Service

HTTP service ทำการ decrypt Ticket for HTTP Service (3.2) ด้วย HTTP Secret Key
จะได้ HTTP Session Key มาเพื่อนำไป decrypt Authenticator (4.1)
แล้วเริ่มขั้นตอนการตรวจสอบเหมือน TGS อีกรอบนึง
- ยืนยันตัวตนจาก name/ID ที่ได้มาจาก TGT และ Authenticator

- ตรวจสอบว่า TGT expired หรือยัง
- ตรวจสอบว่ามี Authenticator ใน cache ของ HTTP server หรือไม่ เพื่อป้องกัน replay attack
- เปรียบเทียบ Source IP address(es) จาก TGT กับ client
จากนั้น HTTP service จะสร้าง Authenticator message และ encrypt โดย HTTP Session Key

- Timestamp
เมื่อ Client ได้รับจะ decrypt โดยใช้ HTTP Session Key ที่อยู่ใน cache เพื่อยืนยันความถูกต้อง
และ สามารถเริ่มใช้ HTTP Service ได้จนกว่า Ticket จะ expired
สรุป
1. Client --> AS : Check
kinit ไป Authentication Server เพื่อยืนยันว่ามีตัวตนจริง
Client <-- AS : msg1 (Client Secret Key) TGT (TGS Secret Key)
ส่ง 2 msg โดยใช้ passwd สำหรับ decrypt msg1 จะได้ Client Secret Key
2. Client --> TGS : ส่ง Authenticator (TGS Session Key) และ TGT (TGS Secret Key)
Client <-- TGS : msg1 (TGS Sesssion Key) msg2 (Service Secret Key)
ตรวจสอบ service ว่ามีตัวตน และทำการ decrypt TGT ได้ TGS Session Key
decrypt Authenticator ด้วย TGS Session Key
ตรวจสอบ ข้อมูลที่ได้จาก TGT และ Authencator
ส่ง 2 encrypted msg
3. Client --> Service :ส่ง Authenticator (Service Session Key) และ msg2 (Service Secret Key)
decrpyt msg แรก ด้วย TGS Session Key จะได้ Service Session Key
ส่ง 2 encrypted msg
Client <-- Service : Authenticator (Service Session Key)
ทำการ decrypt msg2 ด้วย Service Secret Key จะได้ Service Session Key
decrypt Authenticator ด้วย Service Session Key
ตรวจสอบ ข้อมูลที่ได้จาก msg2 และ Authencator
ส่ง 1 encrypted msg
4. Client decrypt Authenticator ด้วย Service Session Key และสามารถเริ่มใช้งาน Service ได้
*symmetric-key cryptography คือ การเข้ารหัสข้อมูลด้วยกุญแจเดี่ยว ทั้งผู้ส่งและผู้รับ โดยวิธีการนี้ผู้รับกับผู้ส่งต้องตกลงกันก่อนว่าจะใช้รูปแบบไหนในการเข้ารหัสข้อมูล
asymmetric-key cryptography คือ การเข้ารหัสโดยใช้กุญแจคู่ทำการเข้ารหัสและถอดรหัส โดยกุญแจคู่ที่ว่านี้จะประกอบไปด้วย กุญแจส่วนตัว (private key) และกุญแจสาธารณะ (public key) โดยหลักการทำงานจะทำดังนี้ ถ้าใช้กุญแจลูกใดเข้ารหัส ก็ต้องใช้กุญแจอีกลูกหนึ่งถอดรหัส สำหรับการเข้ารหัสและถอดรหัสด้วยกุญแจคู่นี้จะใช้ฟังก์ชันทางคณิตศาสตร์เข้ามาช่วยโดยที่ฟังก์ชันทางคณิตศาสตร์ที่นำมาใช้
credit : วิทยาการเข้ารหัสลับ
credit. http://www.roguelynn.com/words/explain-like-im-5-kerberos/