diff options
Diffstat (limited to 'nacl/crypto_onetimeauth/wrapper-verify.cpp')
-rw-r--r-- | nacl/crypto_onetimeauth/wrapper-verify.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/nacl/crypto_onetimeauth/wrapper-verify.cpp b/nacl/crypto_onetimeauth/wrapper-verify.cpp new file mode 100644 index 00000000..248239ee --- /dev/null +++ b/nacl/crypto_onetimeauth/wrapper-verify.cpp | |||
@@ -0,0 +1,14 @@ | |||
1 | #include <string> | ||
2 | using std::string; | ||
3 | #include "crypto_onetimeauth.h" | ||
4 | |||
5 | void crypto_onetimeauth_verify(const string &a,const string &m,const string &k) | ||
6 | { | ||
7 | if (k.size() != crypto_onetimeauth_KEYBYTES) throw "incorrect key length"; | ||
8 | if (a.size() != crypto_onetimeauth_BYTES) throw "incorrect authenticator length"; | ||
9 | if (crypto_onetimeauth_verify( | ||
10 | (const unsigned char *) a.c_str(), | ||
11 | (const unsigned char *) m.c_str(),m.size(), | ||
12 | (const unsigned char *) k.c_str()) == 0) return; | ||
13 | throw "invalid authenticator"; | ||
14 | } | ||