2022-03-05 19:22:40 -05:00
|
|
|
package kdf
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
2022-04-25 04:27:24 -04:00
|
|
|
|
|
|
|
`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) {
|
2022-04-25 04:27:24 -04:00
|
|
|
case bcrypt.Name:
|
|
|
|
k = &bcrypt.KDF{}
|
|
|
|
case null.Name, "":
|
|
|
|
k = &null.KDF{}
|
2022-03-05 19:22:40 -05:00
|
|
|
default:
|
2022-04-25 04:27:24 -04:00
|
|
|
err = errs.ErrUnknownKdf
|
2022-03-05 19:22:40 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2022-04-25 04:27:24 -04:00
|
|
|
UnpackKDF returns a kdf.KDF from raw data as packed in a private key's bytes.
|
2022-03-05 19:22:40 -05:00
|
|
|
|
2022-04-25 04:27:24 -04: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
|
2022-04-25 04:27:24 -04:00
|
|
|
- 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) {
|
|
|
|
|
2022-04-25 04:27:24 -04:00
|
|
|
// TODO
|
|
|
|
|
2022-03-05 19:22:40 -05:00
|
|
|
return
|
|
|
|
}
|