aboutsummaryrefslogtreecommitdiffstats
path: root/sample
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <herumi@nifty.com>2016-08-30 15:31:55 +0800
committerMITSUNARI Shigeo <herumi@nifty.com>2016-08-30 15:31:55 +0800
commitfc24f6c8a3fdd0a11aa93ea524e34b33f5a4c4cb (patch)
tree4254c7e627600a93a15e95ee3c3c98d011d3ca93 /sample
parent0a6548f5e2027c217c550d72d08673f67cb1f161 (diff)
downloaddexon-bls-fc24f6c8a3fdd0a11aa93ea524e34b33f5a4c4cb.tar
dexon-bls-fc24f6c8a3fdd0a11aa93ea524e34b33f5a4c4cb.tar.gz
dexon-bls-fc24f6c8a3fdd0a11aa93ea524e34b33f5a4c4cb.tar.bz2
dexon-bls-fc24f6c8a3fdd0a11aa93ea524e34b33f5a4c4cb.tar.lz
dexon-bls-fc24f6c8a3fdd0a11aa93ea524e34b33f5a4c4cb.tar.xz
dexon-bls-fc24f6c8a3fdd0a11aa93ea524e34b33f5a4c4cb.tar.zst
dexon-bls-fc24f6c8a3fdd0a11aa93ea524e34b33f5a4c4cb.zip
retry to read if message is emtpy
Diffstat (limited to 'sample')
-rw-r--r--sample/bls_tool.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/sample/bls_tool.cpp b/sample/bls_tool.cpp
index 626d68f..2dae6d4 100644
--- a/sample/bls_tool.cpp
+++ b/sample/bls_tool.cpp
@@ -24,11 +24,14 @@ void strip(std::string& str)
void readLine(std::string& str)
{
- if (std::getline(std::cin, str)) {
+ str.clear();
+ // retry once if blank line exists
+ for (size_t i = 0; i < 2; i++) {
+ std::getline(std::cin, str);
strip(str);
- } else {
- throw std::runtime_error("can't readLine");
+ if (!str.empty()) return;
}
+ throw std::runtime_error("readLine:message is empty");
}
void init()
@@ -53,6 +56,7 @@ void sign()
read(sec);
std::string m;
readLine(m);
+ fprintf(stderr, "sign `%s`\n", m.c_str());
bls::Sign s;
sec.sign(s, m);
write(s);
@@ -66,8 +70,9 @@ void verify()
read(pub);
std::string m;
readLine(m);
+ fprintf(stderr, "verify `%s`\n", m.c_str());
bool b = s.verify(pub, m);
- write(int(b));
+ write(b ? "1" : "0");
}
void share_pub()