starting tunnel messages

This commit is contained in:
Hayden Parker
2016-08-04 19:48:25 -07:00
parent 853203fe2d
commit 1bf1d5f9b2
3 changed files with 30 additions and 5 deletions

View File

@ -5,7 +5,7 @@ import (
"crypto/cipher" "crypto/cipher"
) )
type TunnelData [1024]byte type TunnelData [1028]byte
// A symetric key for encrypting tunnel messages // A symetric key for encrypting tunnel messages
type TunnelKey [32]byte type TunnelKey [32]byte

View File

@ -7,14 +7,33 @@ import (
type TunnelID uint32 type TunnelID uint32
// data sent down a tunnel type EncryptedTunnelMessage crypto.TunnelData
type TunnelMessage crypto.TunnelData
func (tm TunnelMessage) ID() (tid TunnelID) { func (tm EncryptedTunnelMessage) ID() (tid TunnelID) {
tid = TunnelID(binary.BigEndian.Uint32(tm[:4])) tid = TunnelID(binary.BigEndian.Uint32(tm[:4]))
return return
} }
func (tm TunnelMessage) IV() crypto.TunnelIV { func (tm EncryptedTunnelMessage) IV() crypto.TunnelIV {
return tm[4:20] return tm[4:20]
} }
func (tm EncryptedTunnelMessage) Data() crypto.TunnelIV {
return tm[24:]
}
type DecryptedTunnelMessage [1028]byte
func (decrypted_tunnel_message DecryptedTunnelMessage) ID() TunnelID {
return TunnelID(binary.BigEndian.Uint32(
decrypted_tunnel_message[:4],
))
}
func (decrypted_tunnel_message DecryptedTunnelMessage) IV() crypto.TunnelIV {
return decrypted_tunnel_message[4:20]
}
func (decrypted_tunnel_message DecryptedTunnelMessage) Checksum() crypto.TunnelIV {
return decrypted_tunnel_message[24:28]
}

View File

@ -0,0 +1,6 @@
package tunnel
import (
//"github.com/stretchr/testify/assert"
//"testing"
)