func (k *keystore) ImportKey(der []byte, kt kms.KeyType, kid string) (string, error) {
	var privateKey interface{}

	switch kt { //nolint:exhaustive // default catches the rest
	case
		kms.ED25519Type,
		kms.ECDSAP256TypeDER,
		kms.ECDSAP384TypeDER,
		kms.ECDSAP521TypeDER,
		kms.ECDSAP256TypeIEEEP1363,
		kms.ECDSAP384TypeIEEEP1363,
		kms.ECDSAP521TypeIEEEP1363:
		key, err := x509.ParsePKCS8PrivateKey(der)
		if err != nil {
			return "", fmt.Errorf("import key: %w", err)
		}

		privateKey = key
	default:
		return "", fmt.Errorf("import key: not supported key type %q", kt)
	}

	var opts []kms.PrivateKeyOpts

	if kid != "" {
		opts = append(opts, kms.WithKeyID(kid))
	}

	keyID, _, err := k.keyManager.ImportPrivateKey(privateKey, kt, opts...)
	if err != nil {
		return "", fmt.Errorf("import key: %w", err)
	}

	return keyID, nil
}
// ImportKey imports private key bytes (in DER format) of kt type into KMS and returns key ID.
// Optionally, key ID can be specified by kid parameter.
ImportKey imports private key bytes (in DER format) of kt type into KMS and returns key ID.
Optionally, key ID can be specified by kid parameter.
// ImportKey imports private key bytes ( in DER format ) of kt type into KMS and returns key ID . // Optionally key ID can be specified by kid parameter .
func (k *keystore) ImportKey(der []byte, kt kms.KeyType, kid string) (string, error) {
	var privateKey interface{}
	switch kt { 
	case
		kms.ED25519Type,
		kms.ECDSAP256TypeDER,
		kms.ECDSAP384TypeDER,
		kms.ECDSAP521TypeDER,
		kms.ECDSAP256TypeIEEEP1363,
		kms.ECDSAP384TypeIEEEP1363,
		kms.ECDSAP521TypeIEEEP1363:
		key, err := x509.ParsePKCS8PrivateKey(der)
		if err != nil {
			return "", fmt.Errorf("import key: %w", err)
		}
		privateKey = key
	default:
		return "", fmt.Errorf("import key: not supported key type %q", kt)
	}
	var opts []kms.PrivateKeyOpts
	if kid != "" {
		opts = append(opts, kms.WithKeyID(kid))
	}
	keyID, _, err := k.keyManager.ImportPrivateKey(privateKey, kt, opts...)
	if err != nil {
		return "", fmt.Errorf("import key: %w", err)
	}
	return keyID, nil
}
func ( k * keystore ) ImportKey ( der [ ] byte , kt kms . KeyType , kid string ) ( string , error ) { var privateKey interface { } switch kt { case kms . ED25519Type , kms . ECDSAP256TypeDER , kms . ECDSAP384TypeDER , kms . ECDSAP521TypeDER , kms . ECDSAP256TypeIEEEP1363 , kms . ECDSAP384TypeIEEEP1363 , kms . ECDSAP521TypeIEEEP1363 : key , err := x509 . ParsePKCS8PrivateKey ( der ) if err != nil { return " " , fmt . Errorf ( " " , err ) } privateKey = key default : return " " , fmt . Errorf ( " " , kt ) } var opts [ ] kms . PrivateKeyOpts if kid != " " { opts = append ( opts , kms . WithKeyID ( kid ) ) } keyID , _ , err := k . keyManager . ImportPrivateKey ( privateKey , kt , opts ... ) if err != nil { return " " , fmt . Errorf ( " " , err ) } return keyID , nil }
ImportKey imports private key bytes (in DER format) of kt type into KMS and returns key ID.
ImportKey imports private key bytes ( in DER format ) of kt type into KMS and returns key ID .
//nolint:exhaustive // default catches the rest