-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhandshake_message_certificate_request_test.go
41 lines (37 loc) · 1.37 KB
/
handshake_message_certificate_request_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package dtls
import (
"reflect"
"testing"
)
func TestHandshakeMessageCertificateRequest(t *testing.T) {
rawCertificateRequest := []byte{
0x02, 0x01, 0x40, 0x00, 0x0C, 0x04, 0x03, 0x04, 0x01, 0x05,
0x03, 0x05, 0x01, 0x06, 0x01, 0x02, 0x01, 0x00, 0x00,
}
parsedCertificateRequest := &handshakeMessageCertificateRequest{
certificateTypes: []clientCertificateType{
clientCertificateTypeRSASign,
clientCertificateTypeECDSASign,
},
signatureHashAlgorithms: []signatureHashAlgorithm{
{hash: hashAlgorithmSHA256, signature: signatureAlgorithmECDSA},
{hash: hashAlgorithmSHA256, signature: signatureAlgorithmRSA},
{hash: hashAlgorithmSHA384, signature: signatureAlgorithmECDSA},
{hash: hashAlgorithmSHA384, signature: signatureAlgorithmRSA},
{hash: hashAlgorithmSHA512, signature: signatureAlgorithmRSA},
{hash: hashAlgorithmSHA1, signature: signatureAlgorithmRSA},
},
}
c := &handshakeMessageCertificateRequest{}
if err := c.Unmarshal(rawCertificateRequest); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(c, parsedCertificateRequest) {
t.Errorf("parsedCertificateRequest unmarshal: got %#v, want %#v", c, parsedCertificateRequest)
}
raw, err := c.Marshal()
if err != nil {
t.Error(err)
} else if !reflect.DeepEqual(raw, rawCertificateRequest) {
t.Errorf("parsedCertificateRequest marshal: got %#v, want %#v", raw, rawCertificateRequest)
}
}