diff --git a/scala/ppml/src/main/scala/com/intel/analytics/bigdl/ppml/attestation/AttestationCLI.scala b/scala/ppml/src/main/scala/com/intel/analytics/bigdl/ppml/attestation/AttestationCLI.scala index 4e80d5a889f..5cee47453e1 100644 --- a/scala/ppml/src/main/scala/com/intel/analytics/bigdl/ppml/attestation/AttestationCLI.scala +++ b/scala/ppml/src/main/scala/com/intel/analytics/bigdl/ppml/attestation/AttestationCLI.scala @@ -75,11 +75,14 @@ object AttestationCLI { } val challengeString = params.challenge - if (challengeString.length() > 0) { - val asQuote = as.getQuoteFromServer(challengeString) - // System.out.print(asQuote) + if (challengeString.length() > 0 && params.asType != ATTESTATION_CONVENTION.MODE_DUMMY) { + val asQuote = params.asType match { + case ATTESTATION_CONVENTION.MODE_EHSM_KMS => + Base64.getDecoder().decode(as.getQuoteFromServer(challengeString)) + case _ => throw new AttestationRuntimeException("Wrong Attestation service type") + } val quoteVerifier = new SGXDCAPQuoteVerifierImpl() - val verifyQuoteResult = quoteVerifier.verifyQuote(asQuote.getBytes()) + val verifyQuoteResult = quoteVerifier.verifyQuote(asQuote) if (verifyQuoteResult == 0) { System.out.println("Quote Verification Success!") } else { diff --git a/scala/ppml/src/main/scala/com/intel/analytics/bigdl/ppml/attestation/EHSMAttestationService.scala b/scala/ppml/src/main/scala/com/intel/analytics/bigdl/ppml/attestation/EHSMAttestationService.scala index b9d492c9b13..14c3ae07490 100644 --- a/scala/ppml/src/main/scala/com/intel/analytics/bigdl/ppml/attestation/EHSMAttestationService.scala +++ b/scala/ppml/src/main/scala/com/intel/analytics/bigdl/ppml/attestation/EHSMAttestationService.scala @@ -20,7 +20,6 @@ package com.intel.analytics.bigdl.ppml.attestation import com.intel.analytics.bigdl.dllib.utils.Log4Error import com.intel.analytics.bigdl.ppml.utils.EHSMParams import com.intel.analytics.bigdl.ppml.utils.HTTPUtil.postRequest -import java.util.Base64 import org.apache.logging.log4j.LogManager import org.json.JSONObject @@ -69,8 +68,7 @@ class EHSMAttestationService(kmsServerIP: String, kmsServerPort: String, if (challenge != postResult.getString(RES_CHALLENGE)) { Log4Error.invalidOperationError(false, "Challenge not matched") } - val quote = Base64.getDecoder().decode(postResult.getString(RES_QUOTE)) - new String(quote) + postResult.getString(RES_QUOTE) } override def attestWithServer(quote: String): (Boolean, String) = {