Documentation ¶
Overview ¶
Package keyderivation provides implementations of the keyset deriver primitive.
Example ¶
package main import ( "fmt" "log" "github.com/tink-crypto/tink-go/v2/aead" "github.com/tink-crypto/tink-go/v2/keyderivation" "github.com/tink-crypto/tink-go/v2/keyset" "github.com/tink-crypto/tink-go/v2/prf" ) func main() { template, err := keyderivation.CreatePRFBasedKeyTemplate(prf.HKDFSHA256PRFKeyTemplate(), aead.AES128GCMKeyTemplate()) if err != nil { log.Fatal(err) } handle, err := keyset.NewHandle(template) if err != nil { log.Fatal(err) } deriver, err := keyderivation.New(handle) if err != nil { log.Fatal(err) } derivedHandle, err := deriver.DeriveKeyset([]byte("salt")) if err != nil { log.Fatal(err) } // Use the derived keyset. a, err := aead.New(derivedHandle) if err != nil { log.Fatal(err) } ciphertext, err := a.Encrypt([]byte("a secret message"), nil) if err != nil { log.Fatal(err) } plaintext, err := a.Decrypt(ciphertext, nil) if err != nil { log.Fatal(err) } fmt.Println(string(plaintext)) }
Output: a secret message
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreatePRFBasedKeyTemplate ¶
func CreatePRFBasedKeyTemplate(prfKeyTemplate, derivedKeyTemplate *tinkpb.KeyTemplate) (*tinkpb.KeyTemplate, error)
CreatePRFBasedKeyTemplate creates a PRF-Based Deriver key template with the specified PRF and derived key templates. If either the PRF or derived key templates are not supported by the registry, an error is returned.
Types ¶
type KeysetDeriver ¶
KeysetDeriver is the interface used to derive new keysets based on an additional input, the salt.
The salt is used to create the keyset using a pseudorandom function. Implementations must be indistinguishable from ideal KeysetDerivers, which, for every salt, generates a new random keyset and caches it.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
streamingprf
Package streamingprf provides implementations of streaming pseudorandom function families.
|
Package streamingprf provides implementations of streaming pseudorandom function families. |
Click to show internal directories.
Click to hide internal directories.