WriteMessage creates the next handshake message, encrypting the payload. It returns the message to send to the peer.
(payload []byte)
| 71 | return &Noise{hs: hs, isInitiator: false}, nil |
| 72 | } |
| 73 | |
| 74 | // WriteMessage creates the next handshake message, encrypting the payload. |
| 75 | // It returns the message to send to the peer. |
| 76 | func (nh *Noise) WriteMessage(payload []byte) ([]byte, error) { |
| 77 | msg, cs1, cs2, err := nh.hs.WriteMessage(nil, payload) |
| 78 | if err != nil { |
| 79 | return nil, err |
| 80 | } |
| 81 | // If both cipher states are returned, handshake is complete |
| 82 | if cs1 != nil && cs2 != nil { |
| 83 | nh.cs1, nh.cs2 = cs1, cs2 |
| 84 | nh.isComplete = true |
| 85 | } |
| 86 | return msg, nil |
| 87 | } |