mirror of
https://github.com/hanzozt/dilithium.git
synced 2026-10-30 20:38:17 +00:00
Global rebrand of all OpenZiti references to Hanzo ZT: - Go module paths: github.com/openziti/* → github.com/hanzozt/* - Docker images: openziti/* → hanzozt/* - Java packages: org.openziti.* → org.hanzozt.* - Brand: OpenZiti → Hanzo ZT - URLs: openziti.io → hanzozt.dev
28 lines
595 B
Go
28 lines
595 B
Go
package dilithium
|
|
|
|
import (
|
|
"github.com/hanzozt/dilithium/util"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
type hello struct {
|
|
version uint32
|
|
}
|
|
|
|
func encodeHello(hello hello, data []byte) (n uint32, err error) {
|
|
dataSize := len(data)
|
|
if dataSize < 4 {
|
|
return 0, errors.Errorf("hello too large [%d < 4]", dataSize)
|
|
}
|
|
util.WriteUint32(data, hello.version)
|
|
return 4, nil
|
|
}
|
|
|
|
func decodeHello(data []byte) (hello, uint32, error) {
|
|
dataSize := len(data)
|
|
if dataSize < 5 {
|
|
return hello{}, 0, errors.Errorf("short hello decode buffer [%d < 4]", dataSize)
|
|
}
|
|
return hello{util.ReadUint32(data)}, 4, nil
|
|
}
|