i'd validate signature on elliptic curve public key received using ecdhe, can't find reference explains bytes signed.
i set tls v1.2 connection google.com using cipher suite tls_ecdhe_rsa_with_aes_128_gcm_sha256 (0xc02f). captured traffic wireshark , can see client hello, server hello, certificate, , server key exchange messages. understanding ec public key google sent signed using private key of certificate google sent (rsa, in case).
here server key exchange message:
160303014d0c0001 490300174104f930
e65768e0587ec7e1 b8b537ccd6ae2500
3a364b84a68ed7c0 47d18dd104afb63c
cc72e800495db3cd d629807f0d4501a4
c043c5c7c52aea45 a66692aa11b60201
01007ec0b1ef4994 30f42f3ed9a7a592
92c0f875ad7cd2f8 5b36a7aec804f602
2959549a8a3d0e5c 5825fefa4d69f360
34eaad7138e5da69 61bdfb88ddb5172c
ba64071de0764fc1 c8b895dbc52ec85c
3b7891c53e6d843b 44f80c481a9beb86
c444b32204e9bc6c 6665e6dd26887c5e
fc4e331fbdd66536 686b6b5f16072b52
ee2fee75ca65e28f a0ee0644b91fba30
783798aa83cf28f1 394b1344b43104cb
89aed55030bd7561 d13ae20d4d7bc17e
682e6c6266f04bf6 31665a547e2f15b3
c79fda548a781d39 5d64f4eea75aac96
9374ce60400fdc11 3a3d5a98b62f63b7
6e5324797c938f39 bc1cc5736b612bd7
7a1bc790841d4e25 dae648cab33273e2
588c
parsing gives:
160303014d - record header
0c - server key exchange message
000149 - length of message
03 - named curve
0017 - secp256r1 curve
41 - length of public key
04 - not sure means
f930e6...04af [32 bytes] - x value of public key
b63ccc...11b6 [32 bytes] - y value of public key
02 - sha-1 hash
01 - rsa signature
0100 - length of signature
7ec0b1...588c [256 bytes] - signature value
using certificate received in certificate message, able perform public key operation on signature of ec public key , looks padded sha-1 hash. however, cannot verify hash value. tried many different combinations of raw ec public key headers, nothing tried hashes properly.
here how retrieved hash:
openssl rsautl -inkey ~/googlepubkey.pem -encrypt -in ~/googleecpubkeysig -pubin -raw | hexdump
0000000 0100 ffff ffff ffff ffff ffff ffff ffff
0000010 ffff ffff ffff ffff ffff ffff ffff ffff
*
00000d0 ffff ffff ffff ffff ffff ffff 3000 3021
00000e0 0609 2b05 030e 1a02 0005 1404 3ac5 fb13
00000f0 9ff8 77f1 6a69 09af 472a 90b2 cac6 b4f8
0000100
the last 20 bytes sha-1 hash, algorithm specified in signature. bytes server key exchange should hashing value? or, there transformation or other data must perform or add prior hashing?
i missing client random , server random. jameskpolk references , related post mentioning 2 random values in 1 of comments: https://security.stackexchange.com/questions/80619/tls-1-2-handshake-how-is-the-ecdhe-public-key-signed-by-server.
the full value hash example above (with hex values in parentheses) is:
client_random (32 bytes) + server_random (32 bytes) + named_curve (0x03) + secp256r1_curve (0x0017) + length_of_public_key (0x41) + first_byte_of_key (0x04) + key_x_value + key_y_value
when used value hash matched , signature verified ok.
Comments
Post a Comment