Files
threshold/internal/session/util.go
T
s-christoffandJim 6b78108ecf Update primary error functions to take a context, deprecate old functions (#1358)
* add new error funcs which take a ctx and deprecate existing funcs

* use context where available when writing error events

* remove circular internal/errors pkg dep

* suppress some chatty errors using errors.WithoutEvent()

* convert auth oidc funcs to take context where needed to write events

Co-authored-by: Jim <jlambert@hashicorp.com>
2021-07-29 20:52:56 -04:00

29 lines
748 B
Go

package session
import (
"crypto/ed25519"
"github.com/hashicorp/boundary/internal/errors"
"github.com/hashicorp/boundary/internal/kms"
wrapping "github.com/hashicorp/go-kms-wrapping"
)
// DeriveED25519Key generates a key based on the scope's session DEK, the
// requesting user, and the generated job ID.
func DeriveED25519Key(wrapper wrapping.Wrapper, userId, jobId string) (ed25519.PublicKey, ed25519.PrivateKey, error) {
const op = "session.DeriveED25519Key"
var uId, jId []byte
if userId != "" {
uId = []byte(userId)
}
if jobId != "" {
jId = []byte(jobId)
}
reader, err := kms.NewDerivedReader(wrapper, 32, uId, jId)
if err != nil {
return nil, nil, errors.WrapDeprecated(err, op)
}
return ed25519.GenerateKey(reader)
}