go_sshkeys/kdf/funcs.go

50 lines
933 B
Go

package kdf
import (
"strings"
`r00t2.io/sshkeys/kdf/bcrypt`
`r00t2.io/sshkeys/kdf/errs`
`r00t2.io/sshkeys/kdf/null`
)
/*
GetKDF returns a KDF from a name of the function.
KDF.Setup must be called on the resulting KDF.
*/
func GetKDF(name string) (k KDF, err error) {
switch strings.ToLower(name) {
case bcrypt.Name:
k = &bcrypt.KDF{}
case null.Name, "":
k = &null.KDF{}
default:
err = errs.ErrUnknownKdf
return
}
return
}
/*
UnpackKDF returns a kdf.KDF from raw data as packed in a private key's bytes.
kdf.KDF.Setup must be called on the resulting kdf.KDF.
data can be:
- a []byte, which can be:
- the full private key bytes
- KDF section (e.g. ED25519 private key block 2.0 + (block 3.0 to block 3.0.0.1) OR
block 2.0.0 + (block 3.0 to block 3.0.0.1))
- a *bytes.Buffer, which supports the same as above
*/
func UnpackKDF(data interface{}) (k KDF, err error) {
// TODO
return
}