slackhq/nebula · error

unsupported encryption algorithm

Error message

unsupported encryption algorithm: %s

What it means

The decrypted payload's EncryptionMetadata.EncryptionAlgorithm is not 'AES-256-GCM', the only algorithm this version of the library supports. After parsing the NebulaEncryptedData structure, the switch over the algorithm falls into the default branch and errors.

Solutions

  1. Inspect the key blob's EncryptionMetadata.EncryptionAlgorithm field and re-encrypt the key with AES-256-GCM (EncryptAndMarshalSigningPrivateKey from a version supporting it)
  2. Upgrade this library to a version that supports the algorithm used in the key file
  3. Regenerate the key with a matching nebula-cert version
Defensive patterns

Strategy: try-catch

Validate before calling

func isSupportedAlgorithm(b []byte) bool {
	blk, _ := pem.Decode(b)
	if blk == nil {
		return false
	}
	ned, err := cert.UnmarshalNebulaEncryptedData(blk.Bytes)
	return err == nil && ned.EncryptionMetadata.EncryptionAlgorithm == "AES-256-GCM"
}

Try / catch

curve, key, rest, err := cert.DecryptAndUnmarshalSigningPrivateKey(pass, b)
if err != nil {
	if strings.Contains(err.Error(), "unsupported encryption algorithm") {
		return fmt.Errorf("key file uses an algorithm this library version does not support; upgrade the library: %w", err)
	}
	return err
}

Prevention

When it happens

Trigger: Decrypting a key file whose embedded EncryptionAlgorithm field is something other than 'AES-256-GCM' — typically a file written by a newer nebula version, a different implementation, or a hand-edited key blob.

Common situations: Forward-compatibility issue: key material created by a newer nebula-cert with a new cipher being read by an older library version; hand-crafted or migrated key files.

Related errors


AI-assisted analysis of slackhq/nebula@dd8f660c0a (2026-09-03). Data as JSON: /api/errors/b8b900c3cbc3ee25. Report an issue: GitHub.

Appendix: source

Thrown at cert/crypto.go:285

		curve = Curve_P256
	default:
		return curve, nil, r, fmt.Errorf("bytes did not contain a proper nebula encrypted Ed25519/ECDSA private key banner")
	}

	ned, err := UnmarshalNebulaEncryptedData(k.Bytes)
	if err != nil {
		return curve, nil, r, err
	}

	var bytes []byte
	switch ned.EncryptionMetadata.EncryptionAlgorithm {
	case "AES-256-GCM":
		bytes, err = aes256Decrypt(passphrase, &ned.EncryptionMetadata.Argon2Parameters, ned.Ciphertext)
		if err != nil {
			return curve, nil, r, err
		}
	default:
		return curve, nil, r, fmt.Errorf("unsupported encryption algorithm: %s", ned.EncryptionMetadata.EncryptionAlgorithm)
	}

	switch curve {
	case Curve_CURVE25519:
		if len(bytes) != ed25519.PrivateKeySize {
			return curve, nil, r, fmt.Errorf("key was not %d bytes, is invalid ed25519 private key", ed25519.PrivateKeySize)
		}
	case Curve_P256:
		if len(bytes) != 32 {
			return curve, nil, r, fmt.Errorf("key was not 32 bytes, is invalid ECDSA P256 private key")
		}
	}

	return curve, bytes, r, nil
}

View on GitHub (pinned to dd8f660c0a)