go_sshkeys/kdf/funcs.go

50 lines
933 B
Go
Raw Permalink Normal View History

2022-03-05 19:22:40 -05:00
package kdf
import (
"strings"
`r00t2.io/sshkeys/kdf/bcrypt`
`r00t2.io/sshkeys/kdf/errs`
`r00t2.io/sshkeys/kdf/null`
2022-03-05 19:22:40 -05:00
)
/*
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{}
2022-03-05 19:22:40 -05:00
default:
err = errs.ErrUnknownKdf
2022-03-05 19:22:40 -05:00
return
}
return
}
/*
UnpackKDF returns a kdf.KDF from raw data as packed in a private key's bytes.
2022-03-05 19:22:40 -05:00
kdf.KDF.Setup must be called on the resulting kdf.KDF.
2022-03-05 19:22:40 -05:00
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))
2022-03-05 19:22:40 -05:00
- a *bytes.Buffer, which supports the same as above
*/
func UnpackKDF(data interface{}) (k KDF, err error) {
// TODO
2022-03-05 19:22:40 -05:00
return
}