message_finished.go 858 B

123456789101112131415161718192021222324252627282930
  1. // SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
  2. // SPDX-License-Identifier: MIT
  3. package handshake
  4. // MessageFinished is a DTLS Handshake Message
  5. // this message is the first one protected with the just
  6. // negotiated algorithms, keys, and secrets. Recipients of Finished
  7. // messages MUST verify that the contents are correct.
  8. //
  9. // https://tools.ietf.org/html/rfc5246#section-7.4.9
  10. type MessageFinished struct {
  11. VerifyData []byte
  12. }
  13. // Type returns the Handshake Type
  14. func (m MessageFinished) Type() Type {
  15. return TypeFinished
  16. }
  17. // Marshal encodes the Handshake
  18. func (m *MessageFinished) Marshal() ([]byte, error) {
  19. return append([]byte{}, m.VerifyData...), nil
  20. }
  21. // Unmarshal populates the message from encoded data
  22. func (m *MessageFinished) Unmarshal(data []byte) error {
  23. m.VerifyData = append([]byte{}, data...)
  24. return nil
  25. }