]> Cypherpunks repositories - gostls13.git/commitdiff
exp/ssh: add marshal functions for uint32 and uint64 types
authorJonathan Pittman <jmpittman@google.com>
Mon, 16 Jan 2012 00:54:17 +0000 (19:54 -0500)
committerAdam Langley <agl@golang.org>
Mon, 16 Jan 2012 00:54:17 +0000 (19:54 -0500)
R=golang-dev, dave, agl
CC=golang-dev
https://golang.org/cl/5533081

src/pkg/exp/ssh/messages.go

index cebb5609db38711e01f8992923e126b4bb9374f5..34ad131ff64e7f5d927857746e94b4c472c0da24 100644 (file)
@@ -484,6 +484,26 @@ func intLength(n *big.Int) int {
        return length
 }
 
+func marshalUint32(to []byte, n uint32) []byte {
+       to[0] = byte(n >> 24)
+       to[1] = byte(n >> 16)
+       to[2] = byte(n >> 8)
+       to[3] = byte(n)
+       return to[4:]
+}
+
+func marshalUint64(to []byte, n uint64) []byte {
+       to[0] = byte(n >> 56)
+       to[1] = byte(n >> 48)
+       to[2] = byte(n >> 40)
+       to[3] = byte(n >> 32)
+       to[4] = byte(n >> 24)
+       to[5] = byte(n >> 16)
+       to[6] = byte(n >> 8)
+       to[7] = byte(n)
+       return to[8:]
+}
+
 func marshalInt(to []byte, n *big.Int) []byte {
        lengthBytes := to
        to = to[4:]