updating refs, finished key gen buffer

This commit is contained in:
2020-09-21 01:43:22 -04:00
parent 382aaffa39
commit b80b823c02
15 changed files with 567 additions and 550 deletions

View File

@@ -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))}
}