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