Move secret code generation function to ChallengeModule base class

Change-Id: I66e46be78b1b924a095ffb749a869dd7477ad005
diff --git a/src/challenge-module.cpp b/src/challenge-module.cpp
index 2170c5f..f1eb5bc 100644
--- a/src/challenge-module.cpp
+++ b/src/challenge-module.cpp
@@ -121,5 +121,21 @@
   return factory;
 }
 
+std::string
+ChallengeModule::generateSecretCode()
+{
+  uint32_t securityCode = 0;
+  do {
+    securityCode = random::generateSecureWord32();
+  }
+  while (securityCode >= 4294000000);
+  securityCode /= 4294;
+  std::string result = std::to_string(securityCode);
+  while (result.length() < 6) {
+    result = "0" + result;
+  }
+  return result;
+}
+
 } // namespace ndncert
 } // namespace ndn
diff --git a/src/challenge-module.hpp b/src/challenge-module.hpp
index 603e2ff..1cc22ad 100644
--- a/src/challenge-module.hpp
+++ b/src/challenge-module.hpp
@@ -146,6 +146,9 @@
   static Name
   genDownloadName(const Name& caName, const std::string& requestId);
 
+  static std::string
+  generateSecretCode();
+
 public:
   const std::string CHALLENGE_TYPE;
   static const std::string WAIT_SELECTION;
diff --git a/src/challenge-module/challenge-pin.cpp b/src/challenge-module/challenge-pin.cpp
index 8c19c97..2dd4acf 100644
--- a/src/challenge-module/challenge-pin.cpp
+++ b/src/challenge-module/challenge-pin.cpp
@@ -50,7 +50,7 @@
   request.setStatus(NEED_CODE);
   request.setChallengeType(CHALLENGE_TYPE);
   request.setChallengeSecrets(generateStoredSecrets(time::system_clock::now(),
-                                                    generateSecureSecretCode(),
+                                                    generateSecretCode(),
                                                     m_maxAttemptTimes));
   return genResponseChallengeJson(request.getRequestId(), CHALLENGE_TYPE, NEED_CODE);
 }
@@ -149,21 +149,5 @@
   return json;
 }
 
-std::string
-ChallengePin::generateSecureSecretCode()
-{
-  uint32_t securityCode = 0;
-  do {
-    securityCode = random::generateSecureWord32();
-  }
-  while (securityCode >= 4294000000);
-  securityCode /= 4294;
-  std::string result = std::to_string(securityCode);
-  while (result.length() < 6) {
-    result = "0" + result;
-  }
-  return result;
-}
-
 } // namespace ndncert
 } // namespace ndn
diff --git a/src/challenge-module/challenge-pin.hpp b/src/challenge-module/challenge-pin.hpp
index b3e9e2e..d6094c7 100644
--- a/src/challenge-module/challenge-pin.hpp
+++ b/src/challenge-module/challenge-pin.hpp
@@ -74,9 +74,6 @@
   generateStoredSecrets(const time::system_clock::TimePoint& tp, const std::string& secretCode,
                         int attempTimes);
 
-  static std::string
-  generateSecureSecretCode();
-
 PUBLIC_WITH_TESTS_ELSE_PRIVATE:
   static const std::string NEED_CODE;
   static const std::string WRONG_CODE;