Repository navigation
docs: Add PQC (ML-KEM, ML-DSA) documentation #1131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
junaruga
wants to merge
2
commits into
ruby:master
Choose a base branch
from
junaruga:wip/doc-pqc
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1012,6 +1012,211 @@ ossl_crypto_fixed_length_secure_compare(VALUE dummy, VALUE str1, VALUE str2) | |
| * If the server certificate is invalid or <tt>context.ca_file</tt> is not set | ||
| * when verifying peers an OpenSSL::SSL::SSLError will be raised. | ||
| * | ||
| * === Post-Quantum Cryptography | ||
| * | ||
| * Post-quantum cryptography (PQC) secures electronic information against | ||
| * attacks by quantum computers. PQC is available in \OpenSSL >= 3.5.0. | ||
| * | ||
| * Two aspects of a TLS connection can use PQC algorithms: | ||
| * | ||
| * * Key exchange - ML-KEM specifying via OpenSSL::SSL::SSLContext#groups= and | ||
| * getting via OpenSSL::SSL::SSLSocket#group. | ||
| * * Signature - ML-DSA specifying via | ||
| * OpenSSL::SSL::SSLContext#sigalgs= and getting via | ||
| * OpenSSL::SSL::SSLSocket#sigalg and OpenSSL::SSL::SSLSocket#peer_sigalg. | ||
| * | ||
| * ==== PQC Server and Client | ||
| * | ||
| * A server using an ML-KEM key exchange and ML-DSA signature (X25519MLKEM768 | ||
| * is a hybrid algorithm (X25519 + ML-KEM-768), a variant of ML-KEM, ML-DSA-65 | ||
| * is a variant of ML-DSA): | ||
| * | ||
| * require 'socket' | ||
| * | ||
| * # ML-DSA-65 server certificate and key | ||
| * cert = OpenSSL::X509::Certificate.new(File.read('mldsa65_server_cert.pem')) | ||
| * key = OpenSSL::PKey.read(File.read('mldsa65_server_key.pem')) | ||
| * | ||
| * context = OpenSSL::SSL::SSLContext.new | ||
| * # Set the allowed TLS group with X25519MLKEM768 | ||
| * context.groups = 'X25519MLKEM768' | ||
| * context.add_certificate(cert, key) | ||
| * | ||
| * tcp_server = TCPServer.new('localhost', 5000) | ||
| * | ||
| * loop do | ||
| * tcp_connection = tcp_server.accept | ||
| * ssl_connection = OpenSSL::SSL::SSLSocket.new(tcp_connection, context) | ||
| * ssl_connection.accept | ||
| * | ||
| * p ssl_connection.group # => "X25519MLKEM768" | ||
| * p ssl_connection.sigalg # => "mldsa65" | ||
| * p ssl_connection.peer_sigalg # => nil | ||
| * | ||
| * ssl_connection.close | ||
| * tcp_connection.close | ||
| * end | ||
| * | ||
| * A client connecting to the server: | ||
| * | ||
| * require 'socket' | ||
| * | ||
| * context = OpenSSL::SSL::SSLContext.new | ||
| * context.ca_file = 'mldsa65_ca_cert.pem' | ||
| * context.verify_mode = OpenSSL::SSL::VERIFY_PEER | ||
| * | ||
| * tcp_socket = TCPSocket.new('localhost', 5000) | ||
| * ssl_client = OpenSSL::SSL::SSLSocket.new(tcp_socket, context) | ||
| * ssl_client.connect | ||
| * | ||
| * p ssl_client.group # => "X25519MLKEM768" | ||
| * p ssl_client.sigalg # => nil | ||
| * p ssl_client.peer_sigalg # => "mldsa65" | ||
| * | ||
| * ssl_client.close | ||
| * tcp_socket.close | ||
| * | ||
| * ==== Multiple Key Exchanges (PQC and Classical) Server and Clients | ||
| * | ||
| * A server can be configured with both ML-KEM (PQC) and X25519 (classical) key | ||
| * exchange groups, so that it can serve both PQC-capable and classical clients. | ||
| * \OpenSSL automatically selects the appropriate key exchange group based on | ||
| * the client's capabilities. | ||
| * | ||
| * require 'socket' | ||
| * | ||
| * # ML-DSA-65 server certificate and key | ||
| * cert = OpenSSL::X509::Certificate.new(File.read('mldsa65_server_cert.pem')) | ||
| * key = OpenSSL::PKey.read(File.read('mldsa65_server_key.pem')) | ||
| * | ||
| * context = OpenSSL::SSL::SSLContext.new | ||
| * # Set the allowed TLS group with X25519MLKEM768 and X25519 | ||
| * context.groups = 'X25519MLKEM768:X25519' | ||
| * context.add_certificate(cert, key) | ||
| * | ||
| * tcp_server = TCPServer.new('localhost', 5000) | ||
| * | ||
| * loop do | ||
| * tcp_connection = tcp_server.accept | ||
| * ssl_connection = OpenSSL::SSL::SSLSocket.new(tcp_connection, context) | ||
| * ssl_connection.accept | ||
| * | ||
| * p ssl_connection.group | ||
| * p ssl_connection.sigalg | ||
| * p ssl_connection.peer_sigalg | ||
| * | ||
| * ssl_connection.close | ||
| * tcp_connection.close | ||
| * end | ||
| * | ||
| * A client connecting with X25519MLKEM768 key exchange group to the server: | ||
| * | ||
| * require 'socket' | ||
| * | ||
| * context = OpenSSL::SSL::SSLContext.new | ||
| * context.groups = 'X25519MLKEM768' | ||
| * context.ca_file = 'mldsa65_ca_cert.pem' | ||
| * context.verify_mode = OpenSSL::SSL::VERIFY_PEER | ||
| * | ||
| * tcp_socket = TCPSocket.new('localhost', 5000) | ||
| * ssl_client = OpenSSL::SSL::SSLSocket.new(tcp_socket, context) | ||
| * ssl_client.connect | ||
| * | ||
| * p ssl_client.group # => "X25519MLKEM768" | ||
| * | ||
| * ssl_client.close | ||
| * tcp_socket.close | ||
| * | ||
| * A client connecting with X25519 key exchange group to the server: | ||
| * | ||
| * require 'socket' | ||
| * | ||
| * context = OpenSSL::SSL::SSLContext.new | ||
| * context.groups = 'X25519' | ||
| * context.ca_file = 'mldsa65_ca_cert.pem' | ||
| * context.verify_mode = OpenSSL::SSL::VERIFY_PEER | ||
| * | ||
| * tcp_socket = TCPSocket.new('localhost', 5000) | ||
| * ssl_client = OpenSSL::SSL::SSLSocket.new(tcp_socket, context) | ||
| * ssl_client.connect | ||
| * | ||
| * p ssl_client.group # => "X25519" | ||
| * | ||
| * ssl_client.close | ||
| * tcp_socket.close | ||
| * | ||
| * ==== Multiple Certificates (PQC and Classical) Server and Clients | ||
| * | ||
| * A server can be configured with both ML-DSA (PQC) and RSA (classical) | ||
| * certificates, so that it can serve both PQC-capable and classical clients. | ||
| * \OpenSSL automatically selects the appropriate certificate based on the | ||
| * client's capabilities. | ||
|
junaruga marked this conversation as resolved.
Resolved
|
||
| * | ||
| * require 'socket' | ||
| * | ||
| * # ML-DSA-65 server certificate and key | ||
| * mldsa_cert = OpenSSL::X509::Certificate.new(File.read('mldsa65_server_cert.pem')) | ||
| * mldsa_key = OpenSSL::PKey.read(File.read('mldsa65_server_key.pem')) | ||
| * # RSA server certificate and key | ||
| * rsa_cert = OpenSSL::X509::Certificate.new(File.read('rsa_server_cert.pem')) | ||
| * rsa_key = OpenSSL::PKey::RSA.new(File.read('rsa_server_key.pem')) | ||
| * | ||
| * context = OpenSSL::SSL::SSLContext.new | ||
| * context.add_certificate(mldsa_cert, mldsa_key) | ||
| * context.add_certificate(rsa_cert, rsa_key) | ||
| * | ||
| * tcp_server = TCPServer.new('localhost', 5000) | ||
| * | ||
| * loop do | ||
| * tcp_connection = tcp_server.accept | ||
| * ssl_connection = OpenSSL::SSL::SSLSocket.new(tcp_connection, context) | ||
| * ssl_connection.accept | ||
| * | ||
| * p ssl_connection.sigalg | ||
| * p ssl_connection.peer_sigalg | ||
| * | ||
| * ssl_connection.close | ||
| * tcp_connection.close | ||
| * end | ||
| * | ||
| * A client connecting with ML-DSA signature to the server: | ||
| * | ||
| * require 'socket' | ||
| * | ||
| * context = OpenSSL::SSL::SSLContext.new | ||
| * context.sigalgs = 'mldsa65' | ||
| * context.ca_file = 'mldsa65_ca_cert.pem' | ||
| * context.verify_mode = OpenSSL::SSL::VERIFY_PEER | ||
| * | ||
| * tcp_socket = TCPSocket.new('localhost', 5000) | ||
| * ssl_client = OpenSSL::SSL::SSLSocket.new(tcp_socket, context) | ||
| * ssl_client.connect | ||
| * | ||
| * p ssl_client.sigalg # => nil | ||
| * p ssl_client.peer_sigalg # => "mldsa65" | ||
| * | ||
| * ssl_client.close | ||
| * tcp_socket.close | ||
| * | ||
| * A client connecting with RSA signature to the server: | ||
| * | ||
| * require 'socket' | ||
| * | ||
| * context = OpenSSL::SSL::SSLContext.new | ||
| * context.sigalgs = 'rsa_pss_rsae_sha256' | ||
| * context.ca_file = 'rsa_ca_cert.pem' | ||
| * context.verify_mode = OpenSSL::SSL::VERIFY_PEER | ||
| * | ||
| * tcp_socket = TCPSocket.new('localhost', 5000) | ||
| * ssl_client = OpenSSL::SSL::SSLSocket.new(tcp_socket, context) | ||
| * ssl_client.connect | ||
| * | ||
| * p ssl_client.sigalg # => nil | ||
| * p ssl_client.peer_sigalg # => "rsa_pss_rsae_sha256" | ||
| * | ||
| * ssl_client.close | ||
| * tcp_socket.close | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we reduce some of the repetitive boilerplate and focus more on the interesting settings? Runnable examples are often useful, but I feel this goes a bit too far. |
||
| * | ||
| */ | ||
| void | ||
| Init_openssl(void) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example code in this section seems redundant now with the following sections.