wrapper-verify.cpp 495 B

1234567891011121314
  1. #include <string>
  2. using std::string;
  3. #include "crypto_auth.h"
  4. void crypto_auth_verify(const string &a,const string &m,const string &k)
  5. {
  6. if (k.size() != crypto_auth_KEYBYTES) throw "incorrect key length";
  7. if (a.size() != crypto_auth_BYTES) throw "incorrect authenticator length";
  8. if (crypto_auth_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. }