bcrypt and null kdf done, work on ciphers next (then keytypes)
This commit is contained in:
5
kdf/null/consts.go
Normal file
5
kdf/null/consts.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package null
|
||||
|
||||
const (
|
||||
Name string = "none"
|
||||
)
|
||||
137
kdf/null/funcs.go
Normal file
137
kdf/null/funcs.go
Normal file
@@ -0,0 +1,137 @@
|
||||
package null
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
)
|
||||
|
||||
/*
|
||||
Setup must be called before DeriveKey. It configures a null.KDF.
|
||||
|
||||
Note that this doesn't actually do anything, it's here for interface compat.
|
||||
It is recommended to use nil/zero values.
|
||||
*/
|
||||
func (k *KDF) Setup(secret, salt []byte, rounds, keyLen uint32) (err error) {
|
||||
|
||||
_, _, _, _ = secret, salt, rounds, keyLen
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
/*
|
||||
SetupAuto is used to provide out-of-band configuration if the null.KDF options were found via kdf.UnpackKDF.
|
||||
|
||||
Note that this doesn't actually do anything, it's here for interface compat.
|
||||
It is recommended to use nil/zero values.
|
||||
*/
|
||||
func (k *KDF) SetupAuto(secret []byte, keyLen uint32) (err error) {
|
||||
|
||||
_, _ = secret, keyLen
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
/*
|
||||
DeriveKey returns the derived key from a null.KDF.
|
||||
|
||||
Note that this doesn't actually do anything, it's here for interface compat.
|
||||
key will ALWAYS be a nil byte slice.
|
||||
*/
|
||||
func (k *KDF) DeriveKey() (key []byte, err error) {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Name returns null.Name.
|
||||
func (k *KDF) Name() (name string) {
|
||||
|
||||
name = Name
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// NameBytes returns the byte form of null.Name with leading bytecount allocator.
|
||||
func (k *KDF) NameBytes() (name []byte) {
|
||||
|
||||
var b []byte
|
||||
var s = k.Name()
|
||||
|
||||
b = []byte(s)
|
||||
|
||||
name = make([]byte, 4)
|
||||
binary.BigEndian.PutUint32(name, uint32(len(b)))
|
||||
name = append(name, b...)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// PackedBytes returns block 3.0 and recursed.
|
||||
func (k *KDF) PackedBytes() (buf *bytes.Reader, err error) {
|
||||
|
||||
// This is static.
|
||||
buf = bytes.NewReader([]byte{0x0, 0x0, 0x0, 0x0})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
/*
|
||||
Rounds returns the number of rounds used in derivation.
|
||||
|
||||
Note that this will always return 0; it's here for interface compat.
|
||||
*/
|
||||
func (k *KDF) Rounds() (rounds uint32) {
|
||||
|
||||
rounds = 0
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
/*
|
||||
Salt returns the salt bytes.
|
||||
|
||||
Note that this will always return nil; it's here for interface compat.
|
||||
*/
|
||||
func (k *KDF) Salt() (salt []byte) {
|
||||
|
||||
salt = nil
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
/*
|
||||
AutoOK returns true if a kdf.UnpackKDF call was able to fetch the null.KDF options successfully, in which case the caller may use null.KDF.SetupAuto.
|
||||
|
||||
If false, it will need to be manually configured via null.KDF.Setup.
|
||||
|
||||
Note that this won't actually do anything and ok will always return as true.
|
||||
*/
|
||||
func (k *KDF) AutoOK() (ok bool) {
|
||||
|
||||
ok = true
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// IsPlain indicates if this kdf.KDF actually does derivation (false) or not (true).
|
||||
func (k *KDF) IsPlain() (plain bool) {
|
||||
|
||||
plain = true
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// AddSalt is a no-op, just here for interface compat.
|
||||
func (k *KDF) AddSalt(salt []byte) (err error) {
|
||||
|
||||
_ = salt
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// AddRounds is a no-op; just here for interface compat.
|
||||
func (k *KDF) AddRounds(rounds uint32) (err error) {
|
||||
|
||||
_ = rounds
|
||||
|
||||
return
|
||||
}
|
||||
4
kdf/null/types.go
Normal file
4
kdf/null/types.go
Normal file
@@ -0,0 +1,4 @@
|
||||
package null
|
||||
|
||||
// KDF is a dummy kdf.KDF that is used for unencrypted/plain SSH private keys. It literally does nothing.
|
||||
type KDF struct{}
|
||||
Reference in New Issue
Block a user