mirror of
https://github.com/go-i2p/go-i2p.git
synced 2025-07-05 06:05:16 -04:00
starting tunnel messages
This commit is contained in:
@ -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
|
||||||
|
@ -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]
|
||||||
|
}
|
||||||
|
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