Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions aead/aead_key_templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package aead
import (
"fmt"

"google.golang.org/protobuf/proto"
"github.com/tink-crypto/tink-go/v2/internal/tinkerror"
ctrpb "github.com/tink-crypto/tink-go/v2/proto/aes_ctr_go_proto"
ctrhmacpb "github.com/tink-crypto/tink-go/v2/proto/aes_ctr_hmac_aead_go_proto"
Expand All @@ -28,6 +27,7 @@ import (
kmsenvpb "github.com/tink-crypto/tink-go/v2/proto/kms_envelope_go_proto"
tinkpb "github.com/tink-crypto/tink-go/v2/proto/tink_go_proto"
xaesgcmpb "github.com/tink-crypto/tink-go/v2/proto/x_aes_gcm_go_proto"
"google.golang.org/protobuf/proto"
)

const (
Expand Down Expand Up @@ -185,7 +185,7 @@ func XChaCha20Poly1305KeyTemplate() *tinkpb.KeyTemplate {
//
// There is no need to call registry.RegisterKMSClient anymore.
func CreateKMSEnvelopeAEADKeyTemplate(uri string, dekTemplate *tinkpb.KeyTemplate) (*tinkpb.KeyTemplate, error) {
if !isSupporedKMSEnvelopeDEK(dekTemplate.GetTypeUrl()) {
if !isSupportedKMSEnvelopeDEK(dekTemplate.GetTypeUrl()) {
return nil, fmt.Errorf("unsupported DEK key type %s. Only Tink AEAD key types are supported", dekTemplate.GetTypeUrl())
}

Expand Down
8 changes: 4 additions & 4 deletions aead/kms_envelope_aead.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
"fmt"

"github.com/tink-crypto/tink-go/v2/core/registry"
"github.com/tink-crypto/tink-go/v2/tink"
tinkpb "github.com/tink-crypto/tink-go/v2/proto/tink_go_proto"
"github.com/tink-crypto/tink-go/v2/tink"
)

const (
Expand All @@ -48,7 +48,7 @@ var tinkAEADKeyTypes map[string]bool = map[string]bool{
aesGCMSIVTypeURL: true,
}

func isSupporedKMSEnvelopeDEK(dekKeyTypeURL string) bool {
func isSupportedKMSEnvelopeDEK(dekKeyTypeURL string) bool {
_, found := tinkAEADKeyTypes[dekKeyTypeURL]
return found
}
Expand All @@ -73,7 +73,7 @@ type KMSEnvelopeAEADWithContext struct {
// keyEncryptionAEAD is used to encrypt the DEK, and is usually a remote AEAD
// provided by a KMS.
func NewKMSEnvelopeAEADWithContext(dekTemplate *tinkpb.KeyTemplate, keyEncryptionAEAD tink.AEADWithContext) (*KMSEnvelopeAEADWithContext, error) {
if !isSupporedKMSEnvelopeDEK(dekTemplate.GetTypeUrl()) {
if !isSupportedKMSEnvelopeDEK(dekTemplate.GetTypeUrl()) {
return nil, errors.New("unsupported DEK key type")
}
return &KMSEnvelopeAEADWithContext{
Expand All @@ -96,7 +96,7 @@ func NewKMSEnvelopeAEADWithContext(dekTemplate *tinkpb.KeyTemplate, keyEncryptio
// keyEncryptionAEAD is used to encrypt the DEK, and is usually a remote AEAD
// provided by a KMS. It is preferable to use [NewKMSEnvelopeAEADWithContext] instead.
func NewKMSEnvelopeAEAD2(dekTemplate *tinkpb.KeyTemplate, keyEncryptionAEAD tink.AEAD) *KMSEnvelopeAEAD {
if !isSupporedKMSEnvelopeDEK(dekTemplate.GetTypeUrl()) {
if !isSupportedKMSEnvelopeDEK(dekTemplate.GetTypeUrl()) {
return &KMSEnvelopeAEAD{
kekAEAD: nil,
dekTemplate: nil,
Expand Down
4 changes: 2 additions & 2 deletions aead/kms_envelope_aead_key_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import (
"errors"
"fmt"

"google.golang.org/protobuf/proto"
"github.com/tink-crypto/tink-go/v2/core/registry"
"github.com/tink-crypto/tink-go/v2/keyset"
kmsepb "github.com/tink-crypto/tink-go/v2/proto/kms_envelope_go_proto"
tinkpb "github.com/tink-crypto/tink-go/v2/proto/tink_go_proto"
"google.golang.org/protobuf/proto"
)

const (
Expand Down Expand Up @@ -119,7 +119,7 @@ func (km *kmsEnvelopeAEADKeyManager) validateKey(key *kmsepb.KmsEnvelopeAeadKey)

func (km *kmsEnvelopeAEADKeyManager) validateKeyFormat(keyFormat *kmsepb.KmsEnvelopeAeadKeyFormat) error {
dekKeyType := keyFormat.GetDekTemplate().GetTypeUrl()
if !isSupporedKMSEnvelopeDEK(dekKeyType) {
if !isSupportedKMSEnvelopeDEK(dekKeyType) {
return fmt.Errorf("unsupported DEK key type %s. Only Tink AEAD key types are supported with KMSEnvelopeAEAD", dekKeyType)
}
return nil
Expand Down