diff --git a/crypto/lux_key.go b/crypto/lux_key.go index 04df4cf..c155f0b 100644 --- a/crypto/lux_key.go +++ b/crypto/lux_key.go @@ -6,11 +6,14 @@ import ( ) type LuxKey struct { - Type proto.LuxType - Id proto.LuxID - Key []byte + Type proto.LuxType // 2 + Id proto.LuxID // 16 + Key []byte // 32 } +const LUX_KEY_AES_SIZE = 32 +const LUX_PROTO_KEY_SIZE = proto.LUX_PROTO_TYPE_SIZE + proto.LUX_PROTO_ID_SIZE + LUX_KEY_AES_SIZE + func (key *LuxKey) NewLuxKey(keyType proto.LuxType) error { key.Type = keyType key.Id = proto.NewLuxID() diff --git a/proto/lux_id.go b/proto/lux_id.go index 39c3765..2f84f13 100644 --- a/proto/lux_id.go +++ b/proto/lux_id.go @@ -4,6 +4,8 @@ import "github.com/google/uuid" type LuxID struct{ uuid.UUID } +const LUX_PROTO_ID_SIZE = 16 + func NewLuxID() LuxID { return LuxID{uuid.New()} } diff --git a/proto/lux_type.go b/proto/lux_type.go index a619f34..9707544 100644 --- a/proto/lux_type.go +++ b/proto/lux_type.go @@ -7,6 +7,8 @@ const ( LuxTypeNode ) +const LUX_PROTO_TYPE_SIZE = 2 + func (luxType *LuxType) Read(rd *LuxBuffer) error { if val, err := rd.ReadUint16(); err != nil { return err