mirror of
https://github.com/go-i2p/go-i2p.git
synced 2025-07-05 14:13:30 -04:00
starting tunnel messages
This commit is contained in:
@ -5,7 +5,7 @@ import (
|
||||
"crypto/cipher"
|
||||
)
|
||||
|
||||
type TunnelData [1024]byte
|
||||
type TunnelData [1028]byte
|
||||
|
||||
// A symetric key for encrypting tunnel messages
|
||||
type TunnelKey [32]byte
|
||||
|
@ -7,14 +7,33 @@ import (
|
||||
|
||||
type TunnelID uint32
|
||||
|
||||
// data sent down a tunnel
|
||||
type TunnelMessage crypto.TunnelData
|
||||
type EncryptedTunnelMessage crypto.TunnelData
|
||||
|
||||
func (tm TunnelMessage) ID() (tid TunnelID) {
|
||||
func (tm EncryptedTunnelMessage) ID() (tid TunnelID) {
|
||||
tid = TunnelID(binary.BigEndian.Uint32(tm[:4]))
|
||||
return
|
||||
}
|
||||
|
||||
func (tm TunnelMessage) IV() crypto.TunnelIV {
|
||||
func (tm EncryptedTunnelMessage) IV() crypto.TunnelIV {
|
||||
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]
|
||||
}
|
||||
|
6
lib/tunnel/message_test.go
Normal file
6
lib/tunnel/message_test.go
Normal file
@ -0,0 +1,6 @@
|
||||
package tunnel
|
||||
|
||||
import (
|
||||
//"github.com/stretchr/testify/assert"
|
||||
//"testing"
|
||||
)
|
Reference in New Issue
Block a user