bcrypt and null kdf done, work on ciphers next (then keytypes)

This commit is contained in:
2022-04-25 04:27:24 -04:00
parent 91d5e99404
commit ff3f8243d1
43 changed files with 755 additions and 423 deletions

View File

@@ -2,6 +2,10 @@ package kdf
import (
"strings"
`r00t2.io/sshkeys/kdf/bcrypt`
`r00t2.io/sshkeys/kdf/errs`
`r00t2.io/sshkeys/kdf/null`
)
/*
@@ -12,12 +16,12 @@ import (
func GetKDF(name string) (k KDF, err error) {
switch strings.ToLower(name) {
case BcryptPbkdfName:
k = &BcryptPbkdf{}
case NullName, "":
k = &Null{}
case bcrypt.Name:
k = &bcrypt.KDF{}
case null.Name, "":
k = &null.KDF{}
default:
err = ErrUnknownKdf
err = errs.ErrUnknownKdf
return
}
@@ -25,18 +29,21 @@ func GetKDF(name string) (k KDF, err error) {
}
/*
UnpackKDF returns a KDF from raw data as packed in a private key's bytes.
UnpackKDF returns a kdf.KDF from raw data as packed in a private key's bytes.
KDF.Setup must be called on the resulting KDF.
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. _ref/format.ed25519 2.0 + (3.0 to 3.0.0.1) or 2.0.0 + (3.0 to 3.0.0.1))
- 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
}