Documentation
¶
Overview ¶
Package echeck provides Intel SGX quote verification for Go applications. It can extract and validate SGX quotes embedded in X.509 certificates.
Index ¶
- Constants
- func ComputePublicKeyHash(pubKeyDER []byte) []byte
- func GetIntelSGXCertPool() (*x509.CertPool, error)
- func VerifyQuote(cert *x509.Certificate, quote *Quote) error
- type ErrCertChainVerification
- type ErrInvalidQuoteFormat
- type ErrReportDataMismatch
- type PCKCertChain
- type Quote
- func (q *Quote) ExtractPCKCertChain() (*PCKCertChain, error)
- func (q *Quote) GetQuoteInfo() QuoteInfo
- func (q *Quote) VerifyAttestationKey() error
- func (q *Quote) VerifyAttestationKeyCertification(pckCert *x509.Certificate) error
- func (q *Quote) VerifyECDSASignature() error
- func (q *Quote) VerifyMeasurements(expectedMREnclave, expectedMRSigner []byte) bool
- type QuoteInfo
- type SGXAuthData
- type SGXECDSASignatureData
- type SGXQuote
- type SGXQuoteHeader
- type SGXReportBody
Constants ¶
const (
// SGXQuoteOID is the OID for Intel SGX quote extensions in X.509 certificates
SGXQuoteOID = "1.3.6.1.4.1.311.105.1"
)
Variables ¶
This section is empty.
Functions ¶
func ComputePublicKeyHash ¶ added in v0.1.1
ComputePublicKeyHash computes SHA-256 hash of a public key in DER format
func GetIntelSGXCertPool ¶
GetIntelSGXCertPool returns a certificate pool pre-initialized with Intel's SGX Root CA
func VerifyQuote ¶
func VerifyQuote(cert *x509.Certificate, quote *Quote) error
VerifyQuote performs comprehensive verification of an SGX quote against its certificate. Returns nil if verification succeeds, or a specific error if any check fails.
Types ¶
type ErrCertChainVerification ¶
type ErrCertChainVerification struct {
Reason string
}
ErrCertChainVerification indicates certificate chain verification failed
func (ErrCertChainVerification) Error ¶
func (e ErrCertChainVerification) Error() string
type ErrInvalidQuoteFormat ¶
ErrInvalidQuoteFormat indicates the quote format or version is invalid
func (ErrInvalidQuoteFormat) Error ¶
func (e ErrInvalidQuoteFormat) Error() string
type ErrReportDataMismatch ¶
ErrReportDataMismatch indicates the report data doesn't match the certificate's public key hash
func (ErrReportDataMismatch) Error ¶
func (e ErrReportDataMismatch) Error() string
type PCKCertChain ¶
type PCKCertChain struct {
PCKCert *x509.Certificate // Leaf PCK certificate
IntermediateCert *x509.Certificate // Intermediate certificate (optional)
Certificates []*x509.Certificate // All certificates in the chain
}
PCKCertChain represents the extracted PCK certificate chain from a quote
func (*PCKCertChain) VerifyCertificateChain ¶
func (chain *PCKCertChain) VerifyCertificateChain(trustedCAs *x509.CertPool) error
VerifyCertificateChain verifies the PCK certificate chain against trusted Intel CAs
func (*PCKCertChain) VerifyWithIntelCAs ¶
func (chain *PCKCertChain) VerifyWithIntelCAs() error
VerifyWithIntelCAs verifies the PCK certificate chain against Intel's trusted CAs
type Quote ¶
Quote represents an extracted SGX quote with its raw data
func ExtractQuote ¶
func ExtractQuote(cert *x509.Certificate) (*Quote, error)
ExtractQuote extracts an SGX quote from an X.509 certificate
func (*Quote) ExtractPCKCertChain ¶
func (q *Quote) ExtractPCKCertChain() (*PCKCertChain, error)
ExtractPCKCertChain extracts the PCK certificate chain from an SGX quote's signature data
func (*Quote) GetQuoteInfo ¶
GetQuoteInfo extracts the essential information from a quote
func (*Quote) VerifyAttestationKey ¶ added in v0.1.1
VerifyAttestationKey verifies that the attestation key in the quote can be properly extracted and is a valid ECDSA key. This is a basic structural check. For full certification verification, use VerifyAttestationKeyCertification with the PCK certificate.
func (*Quote) VerifyAttestationKeyCertification ¶ added in v0.1.2
func (q *Quote) VerifyAttestationKeyCertification(pckCert *x509.Certificate) error
VerifyAttestationKeyCertification performs the critical cryptographic verification that links the attestation key to Intel's chain of trust. This verifies:
- QE Report Signature: The QE Report is signed by the PCK certificate's private key, proving the QE Report was generated by genuine Intel SGX hardware certified by Intel.
- Attestation Key Binding: The QE Report's report_data contains SHA256(attestation_key || auth_data), proving the attestation key is bound to the certified QE Report.
Without these verifications, an attacker could substitute their own attestation key and generate fake quotes that would appear valid.
func (*Quote) VerifyECDSASignature ¶ added in v0.1.1
VerifyECDSASignature verifies the ECDSA signature of the quote
func (*Quote) VerifyMeasurements ¶
VerifyMeasurements verifies a quote against expected MRENCLAVE and MRSIGNER values
type QuoteInfo ¶
type QuoteInfo struct {
MREnclave [32]byte // MRENCLAVE value (32 bytes)
MRSigner [32]byte // MRSIGNER value (32 bytes)
ISVProdID uint16 // ISV Product ID
ISVSVN uint16 // ISV SVN (Security Version Number)
ReportData [64]byte // Report data from the quote
}
QuoteInfo contains the essential measurements extracted from an SGX quote
type SGXAuthData ¶
type SGXAuthData struct {
AuthDataSize uint16 // Size of auth data (typically 0x0020)
AuthData [32]byte // 32 bytes of auth data
CertType uint16 // Certificate type (typically 0x0005)
CertDataSize uint32 // Size of certificate data (4 bytes)
CertData []byte // Certificate data (PEM formatted PCK certs)
}
SGXAuthData represents the authentication data structure in quote signatures
type SGXECDSASignatureData ¶ added in v0.1.1
type SGXECDSASignatureData struct {
Signature [64]byte // ECDSA signature (r=32 bytes, s=32 bytes)
AttestationPubKey [64]byte // Attestation public key (x=32 bytes, y=32 bytes)
QEReport SGXReportBody // QE report (384 bytes)
QEReportSignature [64]byte // QE report signature (64 bytes)
}
SGXECDSASignatureData represents the ECDSA signature data structure for SGX quotes
type SGXQuote ¶
type SGXQuote struct {
Version uint16 // Quote version
SignType uint16 // Signature type
EPIDGroupID [4]byte // EPID Group ID
QESVN uint16 // QE SVN
PCESVN uint16 // PCE SVN
XEID uint32 // Extended Enclave ID
Basename [32]byte // Basename
ReportBody SGXReportBody // Report body (384 bytes)
SignatureLen uint32 // Length of signature data
SignatureData []byte // Variable-length signature data
}
SGXQuote represents the complete SGX quote structure
type SGXQuoteHeader ¶
type SGXQuoteHeader struct {
Version uint32 // Version of the header structure
Type uint32 // Type of quote or data that follows
Size uint32 // Size of the data after this header
Reserved uint32 // Reserved field, possibly for alignment or future use
}
SGXQuoteHeader represents the header structure that precedes SGX quote data
type SGXReportBody ¶
type SGXReportBody struct {
CPUSVN [16]byte // Security Version of the CPU
MiscSelect uint32 // Which fields defined in SSA.MISC
Reserved1 [12]byte // Reserved field 1
ISVExtProdID [16]byte // ISV assigned Extended Product ID
Attributes [16]byte // Any special Capabilities the Enclave possess
MREnclave [32]byte // The value of the enclave's ENCLAVE measurement
Reserved2 [32]byte // Reserved field 2
MRSigner [32]byte // The value of the enclave's SIGNER measurement
Reserved3 [32]byte // Reserved field 3
ConfigID [64]byte // CONFIGID
ISVProdID uint16 // Product ID of the Enclave
ISVSVN uint16 // Security Version of the Enclave
ConfigSVN uint16 // CONFIGSVN
Reserved4 [42]byte // Reserved field 4
ISVFamilyID [16]byte // ISV assigned Family ID
ReportData [64]byte // Data provided by the user
}
SGXReportBody represents the SGX report body structure (384 bytes)