Skip to content

Commit

Permalink
[PPML] Fix format error of quote from attestation service (#5732)
Browse files Browse the repository at this point in the history
* Fix format error of quote fom attestatioon service

* Refine

* Refine

* skip dummy verify

Co-authored-by: xiangyuT <[email protected]>
  • Loading branch information
xiangyuT and xiangyuT authored Sep 13, 2022
1 parent ccec13e commit 0bfc0d7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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) = {
Expand Down

0 comments on commit 0bfc0d7

Please sign in to comment.