mirror of
https://github.com/bjdgyc/anylink.git
synced 2025-08-09 03:41:29 +08:00
添加 github.com/pion/dtls 代码
This commit is contained in:
28
dtls-2.0.9/pkg/protocol/change_cipher_spec.go
Normal file
28
dtls-2.0.9/pkg/protocol/change_cipher_spec.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package protocol
|
||||
|
||||
// ChangeCipherSpec protocol exists to signal transitions in
|
||||
// ciphering strategies. The protocol consists of a single message,
|
||||
// which is encrypted and compressed under the current (not the pending)
|
||||
// connection state. The message consists of a single byte of value 1.
|
||||
// https://tools.ietf.org/html/rfc5246#section-7.1
|
||||
type ChangeCipherSpec struct {
|
||||
}
|
||||
|
||||
// ContentType returns the ContentType of this content
|
||||
func (c ChangeCipherSpec) ContentType() ContentType {
|
||||
return ContentTypeChangeCipherSpec
|
||||
}
|
||||
|
||||
// Marshal encodes the ChangeCipherSpec to binary
|
||||
func (c *ChangeCipherSpec) Marshal() ([]byte, error) {
|
||||
return []byte{0x01}, nil
|
||||
}
|
||||
|
||||
// Unmarshal populates the ChangeCipherSpec from binary
|
||||
func (c *ChangeCipherSpec) Unmarshal(data []byte) error {
|
||||
if len(data) == 1 && data[0] == 0x01 {
|
||||
return nil
|
||||
}
|
||||
|
||||
return errInvalidCipherSpec
|
||||
}
|
Reference in New Issue
Block a user