diff options
author | irungentoo <irungentoo@gmail.com> | 2013-07-02 09:53:34 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2013-07-02 09:53:34 -0400 |
commit | e2967396ac73cb7410787886cdaf072a184ffc49 (patch) | |
tree | 527a74d25a4a0705fc641994fd35bfab22662034 /nacl/crypto_auth/wrapper-verify.cpp | |
parent | 8928c817df345f29aa0b194743595aa11bd6a8ba (diff) |
Added NaCl crypto library.
Diffstat (limited to 'nacl/crypto_auth/wrapper-verify.cpp')
-rw-r--r-- | nacl/crypto_auth/wrapper-verify.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/nacl/crypto_auth/wrapper-verify.cpp b/nacl/crypto_auth/wrapper-verify.cpp new file mode 100644 index 00000000..57e25a26 --- /dev/null +++ b/nacl/crypto_auth/wrapper-verify.cpp | |||
@@ -0,0 +1,14 @@ | |||
1 | #include <string> | ||
2 | using std::string; | ||
3 | #include "crypto_auth.h" | ||
4 | |||
5 | void crypto_auth_verify(const string &a,const string &m,const string &k) | ||
6 | { | ||
7 | if (k.size() != crypto_auth_KEYBYTES) throw "incorrect key length"; | ||
8 | if (a.size() != crypto_auth_BYTES) throw "incorrect authenticator length"; | ||
9 | if (crypto_auth_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 | } | ||