OpenNHP/opennhp · error

sig algo mismatch: got

Error message

sig algo mismatch: got %d, want %d

What it means

During CSV (China Secure Virtualization / SM-protected) attestation certificate-chain verification, the signature algorithm identifier stored in the certificate blob at bytes 0x418-0x41B (little-endian uint32) does not match the algorithm expected by the caller. It fires in verifyCSVCertInfo, invoked from verifyCertChain, when the parsed cert was signed with a different algorithm (e.g. SM2 vs RSA/ECDSA) than the one the verifier is configured to accept, typically because the platform or firmware provisioned certs with a different signing algorithm or the evidence comes from a mismatched vendor implementation.

Solutions

  1. Confirm the signature algorithm reported by the platform (e.g. via CSV vendor attestation tools) and align the expected sigAlgo parameter passed into verifyCSVCertInfo
  2. Re-provision or re-export the CSV certificate chain so all certs are signed with the expected algorithm (typically SM2 for CSV platforms)
  3. If the cert is legitimately signed with a supported but different algorithm, extend the verifier to accept it and verify the signature with the corresponding crypto implementation
  4. Check for firmware or BIOS updates on the host that may have changed certificate provisioning defaults
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at nhp/core/verifier/csv/csv.go:452 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of OpenNHP/opennhp@6e04ca5ff0 (2026-09-07). Data as JSON: /api/errors/f6be5144de78927b. Report an issue: GitHub.

Appendix: source

Thrown at nhp/core/verifier/csv/csv.go:452

}

func (a *Attestation) verifyCSVCertInfo(csvCert []byte, sigUsage int, sigAlgo int, keyUsage int, keyId []byte) error {
	csvKeyUsage := csvCert[0x08:0x0C]
	csvKeyUsageInt := int(binary.LittleEndian.Uint32(csvKeyUsage))
	if csvKeyUsageInt != keyUsage {
		return fmt.Errorf("key usage mismatch: got %d, want %d", csvKeyUsageInt, sigUsage)
	}

	csvSigUsage := csvCert[0x414:0x418]
	csvSigUsageInt := int(binary.LittleEndian.Uint32(csvSigUsage))
	if csvSigUsageInt != sigUsage {
		return fmt.Errorf("sig usage mismatch: got %d, want %d", csvSigUsageInt, sigAlgo)
	}

	csvSigAlgo := csvCert[0x418:0x41C]
	csvSigAlgoInt := int(binary.LittleEndian.Uint32(csvSigAlgo))
	if csvSigAlgoInt != sigAlgo {
		return fmt.Errorf("sig algo mismatch: got %d, want %d", csvSigAlgoInt, sigAlgo)
	}

	csvCertifyingId := csvCert[0x1a4:0x1b4]
	if !bytes.Equal(csvCertifyingId, keyId) {
		return fmt.Errorf("certifying id mismatch: got %x, want %x", csvCertifyingId, keyId)
	}

	return nil
}

func (a *Attestation) Verify() error {
	if err := a.verifyCertChain(a.GetSerialNumber()); err != nil {
		return err
	}

	pek := a.evidence.CertificateChain.Pek
	attestationReport := a.evidence.AttestationReport
	attestationReportDataLen := unsafe.Sizeof(attestationReport)

View on GitHub (pinned to 6e04ca5ff0)