I extracted the 294 bytes (those which start with 30 82 01 22 30
). To recap, the bytes are found inside the secio handshake. The handshake is protobuf serialized Propose with 5 fields, of which the field pubkey ID=2 is again protobuf serialized PublicKey with 2 fields, of which the field with again ID=2 contains the public key in DER format.
Graphically:
Response -> {nonce, pubkey -> PublicKey {KeyType, Data}, exchanges, ciphers, hashes }
Once you save these bytes to for example publickey.der
, then you can run openssl to check if you exctracted correctly the public key data.
You do it by invoking the following command to CLI:
openssl rsa -text -inform DER -in publickey.der -pubin
For example, I’m giving what I got (you’ll get of course something else):
Public-Key: (2048 bit) Modulus: 00:99:00:93:c8:b3:23:f8:19:31:2a:c6:08:07:1e: 97:ff:09:f3:76:f9:eb:86:28:c0:86:5f:54:53:8f: e3:a7:65:28:a6:51:43:42:7e:73:cb:0f:3f:1c:7a: 96:2f:32:ef:1a:91:7a:b0:48:1b:d9:94:05:88:dd: 95:f9:fb:70:91:2d:71:82:80:99:54:68:70:0d:e7: 12:ef:bd:65:de:7f:38:94:b8:74:e5:49:8c:1b:8c: da:ef:6b:6d:c2:56:92:a3:6c:0a:56:30:26:d3:ad: 07:87:37:a4:33:11:a0:83:65:85:5a:ca:f8:8a:1e: cf:63:7f:e0:19:92:cc:e0:00:01:29:5d:eb:9f:9f: cd:a1:fb:5d:ca:9a:26:70:7f:98:84:95:a7:0c:0f: 39:bf:ff:f6:ee:42:a5:b9:4d:01:6a:3a:d1:1a:61: ad:cb:5b:69:a5:c0:22:a2:c4:d5:4d:17:94:da:d7: d3:fa:4b:6f:aa:c8:d5:09:eb:c7:85:cd:2d:fb:19: a1:1d:75:49:7a:37:5f:b8:fc:68:b6:79:b1:39:b5: 1a:81:35:a7:07:b4:aa:0d:c1:b7:17:0c:cc:df:b2: 2d:e3:6e:b4:a0:a8:17:58:c6:bd:c4:13:b5:dc:c0: 23:8a:2e:d1:35:4f:bb:26:d1:a6:f6:c0:0c:45:5c: 0a:d5 Exponent: 65537 (0x10001) writing RSA key -----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmQCTyLMj+BkxKsYIBx6X /wnzdvnrhijAhl9UU4/jp2UoplFDQn5zyw8/HHqWLzLvGpF6sEgb2ZQFiN2V+ftw kS1xgoCZVGhwDecS771l3n84lLh05UmMG4za72ttwlaSo2wKVjAm060HhzekMxGg g2WFWsr4ih7PY3/gGZLM4AABKV3rn5/NoftdypomcH+YhJWnDA85v//27kKluU0B ajrRGmGty1tppcAiosTVTReU2tfT+ktvqsjVCevHhc0t+xmhHXVJejdfuPxotnmx ObUagTWnB7SqDcG3FwzM37It4260oKgXWMa9xBO13MAjii7RNU+7JtGm9sAMRVwK 1QIDAQAB -----END PUBLIC KEY-----