Comments (1)
There are multiple algorithms to perform key exchange. RSA is one, Diffie-Hellman is another. The algorithm used in this handshake is ECDHE, which is Elliptical Curve Diffie-Hellman with Ephemeral keys. The specific EC function used is X25519 (multiplication using Curve25519).
X25519 is defined in this RFC: https://tools.ietf.org/html/rfc7748#section-5 and its use in ECDH is defined in https://tools.ietf.org/html/rfc7748#section-6 . The last "E" refers to generating a new key for every connection (ephemeral), which doesn't change the algorithm.
The comment that you quoted from curve25519-mult.c refers to a trick that the coder is using - PEM files are a base64 encoding of a binary format called DER. DER encodes things in a binary format of type
+length
+data
, and it would take a bit of code to write a proper DER parser. However, if you know the format is fixed and that the data you want is the last field (and you know its length is 32), you can shortcut all that and just read the last 32 bytes without parsing DER at all. To see the DER data try the following command on a pem file:
$ openssl asn1parse -in server-ephemeral-private.key -inform PEM
0:d=0 hl=2 l= 46 cons: SEQUENCE
2:d=1 hl=2 l= 1 prim: INTEGER :00
5:d=1 hl=2 l= 5 cons: SEQUENCE
7:d=2 hl=2 l= 3 prim: OBJECT :X25519
12:d=1 hl=2 l= 34 prim: OCTET STRING [HEX DUMP]:0420909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAF
I believe the ASN.1 definition for these key files is in PKCS#8: https://tools.ietf.org/html/rfc5208
from illustrated-tls12.
Related Issues (17)
- Is it supposed to say 5 bytes here, or 4? HOT 2
- Question about https://tls.ulfheim.net/ HOT 4
- why sha256 = 256 bytes? HOT 2
- Highlighting hex parts with different colors
- Why not an online tls parser? HOT 1
- Question about a source of a claim HOT 1
- Wrong verify_data? HOT 4
- Support for TLS 1.1, etc? HOT 1
- Make each step "linkable" HOT 3
- Question about tls1.2 using rsa and dhe HOT 2
- TLS_ECDHE_RSA_AES_128_GCM_SHA256 HOT 1
- Support for TLS v1.3 HOT 3
- corresponding openssl -vvvv lines
- Server encryption keys calculation typos HOT 1
- Mutual Authentication HOT 1
- Use <details> and <summary> for spoilers instead of JavaScript
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from illustrated-tls12.