Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Zig で TLS1.3 を実装している話
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Naoki MATSUMOTO
October 07, 2023
Technology
290
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Zig で TLS1.3 を実装している話
Naoki MATSUMOTO
October 07, 2023
More Decks by Naoki MATSUMOTO
See All by Naoki MATSUMOTO
Rootless な環境における eBPF の活用
mt2naoki
4
1.1k
Mewz on libkrun
mt2naoki
2
1.2k
詳解 bypass4netns: Rootless Containers Network の仕組みと高速化
mt2naoki
2
2.1k
QUIC の仕組み(Handshake)
mt2naoki
1
1k
bypass4netns: Accelerating TCP/IP Communications in Rootless Containers
mt2naoki
0
350
Rootless コンテナはいいぞ
mt2naoki
4
1.6k
コンテナ技術における最新の研究動向
mt2naoki
15
12k
Efficient Container Image Updating in Low-bandwidth Networks with Delta Encoding
mt2naoki
0
1.9k
TLS 1.3 で学ぶ暗号技術
mt2naoki
0
680
Other Decks in Technology
See All in Technology
AI駆動開発における開発環境のセキュリティの考え方
yamahiro
0
230
LambdaWebFunctionsを試してみた / exploring-lambda-web-functions
koukihosaka
1
380
JAWSUG TOHOKU 青森支部 「LoGoチャット」のAWS移行で 乗り越えたこと
taketakekaho
0
370
Kiro Crewで「みのるん式」仕事術やってみた
minorun365
PRO
3
1k
Temporal 最高!でも改めて「日付」について調べたら人類の負債すぎる件
riyaamemiya
0
220
AI駆動開発におけるハーネスエンジニアリングの勘所
tsukuboshi
1
410
Browser Spec: Testing Hotwire with Ruby
takahashim
1
150
AWSDirectConnectの構築の進め方を整理してみた
masa_my
1
120
『SAR衛星データ解析入門』のご紹介とその応用
syuchimu
0
140
野良MCPサーバーを排除せよ!MCPサーバーのガバナンス
yukiogawa
1
140
10年後、Engineering 行為を剥奪されるとして、わたしたちは、どう、何を創ればいいだろうか。 / If Engineering Is Taken Away in 10 Years, How and What Should We Create?
bitkey
PRO
1
220
Persisting Massive Data with Rails ~Designing for 60 billion rows, and fighting the bottlenecks~ Railsで挑む大量データ永続化 〜600億件を永続化するための設計とボトルネックとの戦い〜
occhi
0
770
Featured
See All Featured
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
810
The untapped power of vector embeddings
frankvandijk
2
1.9k
brightonSEO & MeasureFest 2025 - Winning Strategies for Black Friday CRO & PPC - Christian Goodrich
cargoodrich
3
870
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Raft: Consensus for Rubyists
vanstee
142
7.8k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
59k
Git: the NoSQL Database
bkeepers
PRO
433
67k
Why Our Code Smells
bkeepers
PRO
340
58k
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
500
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.8k
Ten Tips & Tricks for a 🌱 transition
stuffmc
1
270
Transcript
Zig で TLS1.3 を 実装している話 京都大学情報学研究科 松本直樹
Zig • シンプル • comptime によるコンパイル時最適化 • マルチプラットフォーム対応 • 組み込みも対象
TLS1.3 • TLS1.2 までの仕様を整理し、新しい TLS として策定(RFC8446) • 1-RTT フルハンドシェイク •
0-RTT Resumption 等
TLS1.3 のフルハンドシェイク • 結構シンプル
実装のポイント1: 鍵導出(Key Schedule) 1. PSKから初期シークレット導出 2. DHでシークレットを共有 3. メッセージのハッシュから ハンドシェイク用の鍵を導出
4. ハンドシェイク完了後、 アプリケーション用の鍵を導出 面倒!
実装のポイント1: 鍵導出(Key Schedule) • TLS1.3 の Test Vector がある(RFC8448) •
Step by Step で鍵導出の実装を検証できる
実装のポイント2: CertificateVerify • 証明書の秘密鍵でハンドシェイクのメッセージを署名 → サーバーが秘密鍵を保持しているか確認 • 実際のステップ 1. 証明書・秘密鍵を読み込む
2. Certificate を送信 3. メッセージのハッシュを生成 4. 署名 5. CertificateVerify を送信 • 簡単そう…?
実装のポイント2: CertificateVerify • Certificate, CertificateVerify に必要な機能 • X.509 証明書を読み込む →
そんなものはない • 秘密鍵を読み込む → そんなものはない • RSA or ECDSA で署名, 検証する • ecdsa_secp256r1_sha256 → ある • rsa_pss_rsae_sha256 → そんなものはない • rsa_pkcs1_sha256 → そんなものはない
いっぱい実装しよう • ASN.1(必要な部分のみ) • X.509(RFC 5280 Section 4.1. Basic Certificate
Fields) • 秘密鍵 • RSA(RFC 8017 Section A.1. RSA Key Representation) • EC(RFC 5915 Section 3. Elliptic Curve Private Key Format) • RSAでの署名,検証(RFC8017, PKCS#1) • RSA自体の実装(モンゴメリ冪乗法 等) • rsa_pss_rsae(Section 8.1. RSASSA-PSS) • MGF1も(Section B.2.1. MGF1) • rsa_pkcs1(Section 8.2. RSASSA-PKCS1-v1_5)
実装した結果 • Client • www.google.com につながった🎉 • Server • chrome
からの接続が可能🎉
GREASE • Chrome で一部のフィールドに無意味なランダムを挿入する → TLS 実装の堅牢化を意図
まとめ • Zig で TLS1.3 を実装した • 既存のWebサイト, ブラウザで接続できた •
TLS, PKI に関する知見が深まった • Zig に対する知見が深まった • たまによく SEGV する • Zig はいいぞ(まだまだ安定してないけど) • https://github.com/shiguredo/tls13-zig