updating refs, finished key gen buffer
This commit is contained in:
@@ -18,9 +18,15 @@
|
||||
|
||||
package sshkeys
|
||||
|
||||
import (
|
||||
`encoding/binary`
|
||||
|
||||
`github.com/go-restruct/restruct`
|
||||
)
|
||||
|
||||
// These are just here to save some typing.
|
||||
func getBytelenStr(s string) []byte {
|
||||
return getByteInt(len(s))
|
||||
return getBytelenByteArr([]byte(s))
|
||||
}
|
||||
|
||||
func getBytelenByteArr(b []byte) []byte {
|
||||
@@ -28,5 +34,15 @@ func getBytelenByteArr(b []byte) []byte {
|
||||
}
|
||||
|
||||
func getByteInt(i int) []byte {
|
||||
return []byte{byte(i)}
|
||||
// This does not work. Despite being a uint32, golang always only writes it as 1 byte instead of 4.
|
||||
// ...Despite it occupying 4 bytes in RAM.
|
||||
// Luckily we can reuse this quick one-liner in getSingleByteInt().
|
||||
// return []byte{byte(i)}
|
||||
b := make([]byte, 4)
|
||||
b, _ = restruct.Pack(binary.BigEndian, uint32(i))
|
||||
return b
|
||||
}
|
||||
|
||||
func getSingleByteInt(i int) []byte {
|
||||
return []byte{byte(uint32(i))}
|
||||
}
|
||||
Reference in New Issue
Block a user