wrapper-verify.cpp 530 B

1234567891011121314
  1. #include <string>
  2. using std::string;
  3. #include "crypto_onetimeauth.h"
  4. void crypto_onetimeauth_verify(const string &a,const string &m,const string &k)
  5. {
  6. if (k.size() != crypto_onetimeauth_KEYBYTES) throw "incorrect key length";
  7. if (a.size() != crypto_onetimeauth_BYTES) throw "incorrect authenticator length";
  8. if (crypto_onetimeauth_verify(
  9. (const unsigned char *) a.c_str(),
  10. (const unsigned char *) m.c_str(),m.size(),
  11. (const unsigned char *) k.c_str()) == 0) return;
  12. throw "invalid authenticator";
  13. }