"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.QuoteGenerationError = exports.PkiServiceError = exports.QuoteSecurityValidationError = exports.QuoteValidationError = exports.AttestationDcapQuoteVerifyEnclaveError = void 0;
const consts_1 = require("./consts");
class AttestationDcapQuoteVerifyEnclaveError extends Error {
    constructor(msg) {
        super(msg);
        this.name = AttestationDcapQuoteVerifyEnclaveError.name;
    }
}
exports.AttestationDcapQuoteVerifyEnclaveError = AttestationDcapQuoteVerifyEnclaveError;
class QuoteValidationError extends AttestationDcapQuoteVerifyEnclaveError {
    constructor(verifyResult) {
        super();
        this.verifyResult = verifyResult;
        this.criticalError = false;
        this.verifyResult = verifyResult;
        this.criticalError = false;
        switch (verifyResult) {
            case 0xa001:
                this.message = `The SGX platform firmware and SW are at the latest security patching level but there are
                platform hardware configurations may expose the enclave to vulnerabilities.`;
                break;
            case 0xa002:
            case 0xa003:
            case 0xa004:
                this.message = `The SGX platform firmware and SW are not at the latest security patching level. The
                platform needs to be patched with firmware and/or software patches.`;
                break;
            case 0xa007:
            case 0xa008:
                this.message = `The SGX platform firmware and SW are at the latest security patching level but there
                are certain vulnerabilities that can only be mitigated with software mitigations implemented by the enclave.`;
                break;
            default:
                this.criticalError = true;
                this.message = `Quote verification failed. Verification result: 0x${Number(verifyResult).toString(16)}`;
                break;
        }
    }
}
exports.QuoteValidationError = QuoteValidationError;
class QuoteSecurityValidationError extends AttestationDcapQuoteVerifyEnclaveError {
    constructor(verifyResult) {
        super();
        this.verifyResult = verifyResult;
        this.verifyResult = verifyResult;
        this.message = "Invalid CPU settings are being used.";
        if (verifyResult.smtEnabled === consts_1.PckFlag.PCK_FLAG_TRUE) {
            this.message = " HyperThreading (SMT) is enabled. Please disable it in BIOS.";
        }
    }
}
exports.QuoteSecurityValidationError = QuoteSecurityValidationError;
class PkiServiceError extends Error {
    constructor(msg) {
        super(msg);
        this.name = PkiServiceError.name;
    }
}
exports.PkiServiceError = PkiServiceError;
class QuoteGenerationError extends Error {
    constructor(msg) {
        super(msg);
        this.name = QuoteGenerationError.name;
    }
}
exports.QuoteGenerationError = QuoteGenerationError;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXJyb3JzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3NneC1uYXRpdmUtbW9kdWxlL2Vycm9ycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSxxQ0FBZ0U7QUFFaEUsTUFBYSxzQ0FBdUMsU0FBUSxLQUFLO0lBQzdELFlBQVksR0FBWTtRQUNwQixLQUFLLENBQUMsR0FBRyxDQUFDLENBQUM7UUFDWCxJQUFJLENBQUMsSUFBSSxHQUFHLHNDQUFzQyxDQUFDLElBQUksQ0FBQztJQUM1RCxDQUFDO0NBQ0o7QUFMRCx3RkFLQztBQUVELE1BQWEsb0JBQXFCLFNBQVEsc0NBQXNDO0lBRTVFLFlBQTRCLFlBQW9CO1FBQzVDLEtBQUssRUFBRSxDQUFDO1FBRGdCLGlCQUFZLEdBQVosWUFBWSxDQUFRO1FBRHpDLGtCQUFhLEdBQUcsS0FBSyxDQUFDO1FBR3pCLElBQUksQ0FBQyxZQUFZLEdBQUcsWUFBWSxDQUFDO1FBQ2pDLElBQUksQ0FBQyxhQUFhLEdBQUcsS0FBSyxDQUFDO1FBRTNCLFFBQVEsWUFBWSxFQUFFLENBQUM7WUFDbkIsS0FBSyxNQUFNO2dCQUNQLElBQUksQ0FBQyxPQUFPLEdBQUc7NEZBQzZELENBQUM7Z0JBQzdFLE1BQU07WUFDVixLQUFLLE1BQU0sQ0FBQztZQUNaLEtBQUssTUFBTSxDQUFDO1lBQ1osS0FBSyxNQUFNO2dCQUNQLElBQUksQ0FBQyxPQUFPLEdBQUc7b0ZBQ3FELENBQUM7Z0JBQ3JFLE1BQU07WUFDVixLQUFLLE1BQU0sQ0FBQztZQUNaLEtBQUssTUFBTTtnQkFDUCxJQUFJLENBQ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