apply Error Data packet in challenge status

Change-Id: I629e57ad96d33ad77dcc939a25577a15afcf2886
diff --git a/src/challenge-module/challenge-credential.cpp b/src/challenge-module/challenge-credential.cpp
index fe120eb..1486c30 100644
--- a/src/challenge-module/challenge-credential.cpp
+++ b/src/challenge-module/challenge-credential.cpp
@@ -76,7 +76,7 @@
 }
 
 // For CA
-std::tuple<Error, std::string>
+std::tuple<ErrorCode, std::string>
 ChallengeCredential::handleChallengeRequest(const Block& params, CertificateRequest& request)
 {
   params.parse();
@@ -92,7 +92,7 @@
         credential = io::load<security::v2::Certificate>(ss);
         if (credential == nullptr) {
           _LOG_ERROR("Cannot load challenge parameter: credential");
-          return returnWithError(request, Error::INVALID_PARAMETER, "Cannot challenge credential: credential.");
+          return returnWithError(request, ErrorCode::INVALID_PARAMETER, "Cannot challenge credential: credential.");
         }
       }
       else if (readString(elements[i]) == PARAMETER_KEY_PROOF_OF_PRIVATE_KEY) {
@@ -100,7 +100,7 @@
         selfSigned = io::load<security::v2::Certificate>(ss);
         if (selfSigned == nullptr) {
           _LOG_ERROR("Cannot load challenge parameter: proof of private key");
-          return returnWithError(request, Error::INVALID_PARAMETER, "Cannot load challenge parameter: proof of private key.");
+          return returnWithError(request, ErrorCode::INVALID_PARAMETER, "Cannot load challenge parameter: proof of private key.");
         }
       }
       else {
@@ -122,7 +122,7 @@
   }
 
   _LOG_TRACE("Cannot verify the proof of private key against credential");
-  return returnWithError(request, Error::INVALID_PARAMETER, "Cannot verify the proof of private key against credential.");
+  return returnWithError(request, ErrorCode::INVALID_PARAMETER, "Cannot verify the proof of private key against credential.");
 }
 
 // For Client
diff --git a/src/challenge-module/challenge-credential.hpp b/src/challenge-module/challenge-credential.hpp
index 2afe38e..93838a8 100644
--- a/src/challenge-module/challenge-credential.hpp
+++ b/src/challenge-module/challenge-credential.hpp
@@ -52,7 +52,7 @@
   ChallengeCredential(const std::string& configPath = "");
 
   // For CA
-  std::tuple<Error, std::string>
+  std::tuple<ErrorCode, std::string>
   handleChallengeRequest(const Block& params, CertificateRequest& request) override;
 
   // For Client
diff --git a/src/challenge-module/challenge-email.cpp b/src/challenge-module/challenge-email.cpp
index 7e0134a..cac0084 100644
--- a/src/challenge-module/challenge-email.cpp
+++ b/src/challenge-module/challenge-email.cpp
@@ -47,7 +47,7 @@
 }
 
 // For CA
-std::tuple<Error, std::string>
+std::tuple<ErrorCode, std::string>
 ChallengeEmail::handleChallengeRequest(const Block& params, CertificateRequest& request)
 {
   params.parse();
@@ -56,7 +56,7 @@
     // for the first time, init the challenge
     std::string emailAddress = readString(params.get(tlv_parameter_value));
     if (!isValidEmailAddress(emailAddress)) {
-      return returnWithError(request, Error::INVALID_PARAMETER, "Invalid email address format.");
+      return returnWithError(request, ErrorCode::INVALID_PARAMETER, "Invalid email address format.");
     }
     auto lastComponentRequested = readString(request.m_cert.getIdentity().get(-1));
     if (lastComponentRequested != emailAddress) {
@@ -78,7 +78,7 @@
     auto secret = request.m_challengeSecrets;
     // check if run out of time
     if (currentTime - time::fromIsoString(request.m_challengeTp) >= m_secretLifetime) {
-      return returnWithError(request, Error::OUT_OF_TIME, "Secret expired.");
+      return returnWithError(request, ErrorCode::OUT_OF_TIME, "Secret expired.");
     }
     // check if provided secret is correct
     if (givenCode == secret.get<std::string>(PARAMETER_KEY_CODE)) {
@@ -95,10 +95,10 @@
     else {
       // run out times
       _LOG_TRACE("Wrong secret code provided. Ran out tires. Challenge failed.");
-      return returnWithError(request, Error::OUT_OF_TRIES, "Ran out tires.");
+      return returnWithError(request, ErrorCode::OUT_OF_TRIES, "Ran out tires.");
     }
   }
-  return returnWithError(request, Error::INVALID_PARAMETER, "Unexpected status or challenge status");
+  return returnWithError(request, ErrorCode::INVALID_PARAMETER, "Unexpected status or challenge status");
 }
 
 // For Client
diff --git a/src/challenge-module/challenge-email.hpp b/src/challenge-module/challenge-email.hpp
index f148d06..42a329d 100644
--- a/src/challenge-module/challenge-email.hpp
+++ b/src/challenge-module/challenge-email.hpp
@@ -58,7 +58,7 @@
                  const time::seconds secretLifetime = time::minutes(20));
 
   // For CA
-  std::tuple<Error, std::string>
+  std::tuple<ErrorCode, std::string>
   handleChallengeRequest(const Block& params, CertificateRequest& request) override;
 
   // For Client
diff --git a/src/challenge-module/challenge-pin.cpp b/src/challenge-module/challenge-pin.cpp
index cd20c51..556929f 100644
--- a/src/challenge-module/challenge-pin.cpp
+++ b/src/challenge-module/challenge-pin.cpp
@@ -42,7 +42,7 @@
 }
 
 // For CA
-std::tuple<Error, std::string>
+std::tuple<ErrorCode, std::string>
 ChallengePin::handleChallengeRequest(const Block& params, CertificateRequest& request)
 {
   params.parse();
@@ -63,7 +63,7 @@
     std::string givenCode = readString(params.get(tlv_parameter_value));
     auto secret = request.m_challengeSecrets;
     if (currentTime - time::fromIsoString(request.m_challengeTp) >= m_secretLifetime) {
-      return returnWithError(request, Error::OUT_OF_TIME, "Secret expired.");
+      return returnWithError(request, ErrorCode::OUT_OF_TIME, "Secret expired.");
     }
     if (givenCode == secret.get<std::string>(PARAMETER_KEY_CODE)) {
       _LOG_TRACE("Correct PIN code. Challenge succeeded.");
@@ -78,10 +78,10 @@
     else {
       // run out times
       _LOG_TRACE("Wrong PIN code provided. Ran out tires. Challenge failed.");
-      return returnWithError(request, Error::OUT_OF_TRIES, "Ran out tires.");
+      return returnWithError(request, ErrorCode::OUT_OF_TRIES, "Ran out tires.");
     }
   }
-  return returnWithError(request, Error::INVALID_PARAMETER, "Unexpected status or challenge status");
+  return returnWithError(request, ErrorCode::INVALID_PARAMETER, "Unexpected status or challenge status");
 }
 
 // For Client
diff --git a/src/challenge-module/challenge-pin.hpp b/src/challenge-module/challenge-pin.hpp
index 88cf9bd..9e7d8b0 100644
--- a/src/challenge-module/challenge-pin.hpp
+++ b/src/challenge-module/challenge-pin.hpp
@@ -52,7 +52,7 @@
                const time::seconds& secretLifetime = time::seconds(3600));
 
   // For CA
-  std::tuple<Error, std::string>
+  std::tuple<ErrorCode, std::string>
   handleChallengeRequest(const Block& params, CertificateRequest& request) override;
 
   // For Client