DTLS-PSK算法抓包解析_1

本文详细介绍了DTLS-PSK的完整握手和会话恢复流程,通过模拟程序抓包分析,深入理解DTLS协议中PSK的身份认证和密钥交换过程。内容包括ClientHello、HelloVerifyRequest、ServerHello等多个步骤的解析,以及相关参考资源。
摘要由CSDN通过智能技术生成

一、DTLS -PSK

PSK 是DTLS 定义的密钥交换方案之一,相对于公钥证书方案(如 ECDHA_RSA) 来说,其具备更加轻量化、高效的优点;
而目前 PSK方案应用也比较广泛。 关于DTLS协议可以看看前面的文章 DTLS要点解析

本次通过模拟的DTLS程序,对DTLS-PSK 握手流程进行抓包分析,以期加深对协议本身的理解。

二、完整握手

流程

         Client                                               Server
         ------                                               ------
         1.ClientHello                 -------->

                                     <--------    2..HelloVerifyRequest
                                                   (contains cookie)

         3.ClientHello                  -------->
         (with cookie)
                                                         4.ServerHello
                                      <--------      5.ServerHelloDone
         6.ClientKeyExchange
         7.ChangeCipherSpec
         8.Finished                     -------->
                                                    9.ChangeCipherSpec
                                      <--------             10.Finished

         Application Data             <------->     Application Data

步骤解析

~1. Client 发送ClientHello

==[ DTLS Record ]==============================================
Content Type: Handshake (22)
Peer address: localhost/127.0.0.1:5684
Version: 254, 253
Epoch: 0
Sequence Number: 0
Length: 82
Fragment:
    Handshake Protocol
    Type: CLIENT_HELLO (1)
    Peer: localhost/127.0.0.1:5684
    Message Sequence No: 0
    Fragment Offset: 0
    Fragment Length: 70
    Length: 70
        Version: 254, 253
        Random: 
            GMT Unix Time: Mon Jan 30 22:45:32 CST 2017
            Random Bytes: 4B 8B 3C CF 0F 62 57 99 94 E9 86 0A 46 68 BF 44 00 D1 34 45 FC 81 C3 AC BC 55 7E DB
        Session ID Length: 0
        Cookie Length: 0
        Cipher Suites Length: 4
        Cipher Suites (2 suites)
            Cipher Suite: TLS_PSK_WITH_AES_128_CCM_8
            Cipher Suite: TLS_PSK_WITH_AES_128_CBC_SHA256
        Compression Methods Length: 1
        Compression Methods (1 method)
            Compression Method: NULL
        Extensions Length: 24
            Extension: elliptic_curves (10)
                Length: 8
                Elliptic Curves Length: 6
                Elliptic Curves (3 curves):
                    Elliptic Curve: secp256r1 (23)
                    Elliptic Curve: secp384r1 (24)
                    Elliptic Curve: secp521r1 (25)
            Extension: ec_point_formats (11)
                Length: 2
                EC point formats length: 1
                Elliptic Curves Point Formats (1):
                    EC point format: uncompressed (0)
            Extension: server_certificate_type (20)
                Server certificate type: RAW_PUBLIC_KEY

===============================================================

此时没有携带Cookie,SessionID未生成;
Cipher Suites 携带了用于协商的算法集。

~2. Server 回复HelloVerifyRequest

    Handshake Protocol
    Type: HELLO_VERIFY_REQUEST (3)
    Peer: localhost/127.0.0.1:5684
    Message Sequence No: 0
    Fragment Offset: 0
    Fragment Length: 35
    Length: 35
        Server Version: 254, 253
        Cookie Length: 32
        Cookie: 77 25 7E 96 9E BD 39 42 94 5F 27 6C 8A 6D 9D D2 1A C9 A3 B8 62 1A 34 86 76 1D D7 AA F4 28 98 6D

Request中携带了32字节的Cookie。

~3. Client 再次发送ClientHello

==[ DTLS Record ]==============================================
Content Type: Handshake (22)
Peer address: localhost/127.0.0.1:5684
Version: 254, 253
Epoch: 0
Sequence Number: 1
Length: 114
Fragment:
    Handshake Protocol
    Type: CLIENT_HELLO (1)
    Peer: localhost/127.0.0.1:5684
    Message Sequence No: 1
    Fragment Offset: 0
    Fragment Length: 102
    Length: 102
        Version: 254, 253
        Random: 
            GMT Unix Time: Mon Jan 30 22:45:32 CST 2017
            Random Bytes: 4B 8B 3C CF 0F 62 57 99 94 E9 86 0A 46 68 BF 44 00 D1 34 45 FC 81 C3 AC BC 55 7E DB
        Session ID Length: 0
        Cookie Length: 32
        Cookie: 77 25 7E 96 9E BD 39 42 94 5F 27 6C 8A 6D 9D D2 1A C9 A3 B8 62 1A 34 86 76 1D D7 AA F4 28 98 6D
        Cipher Suites Length: 4
        Cipher Suites (2 suites)
            Cipher Suite: TLS_PSK_WITH_AES_128_CCM_8
            
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值