+
+struct _auth_obj new_authobj(const char *userid, const char *password,
+ const char *nonce,
+ const unsigned char *secret, const int secsize,
+ const unsigned char *payload, const int paysize)
+{
+ struct _auth_obj ao = {0};
+ struct _hash_obj ho_chal, ho_key;
+
+ ho_chal = make_challenge(userid, password, nonce);
+ if (ho_chal.err) {
+ ao.err = ho_chal.err;
+ return ao;
+ }
+ ho_key = make_key(ho_chal.hash, sizeof(ho_chal.hash), secret, secsize);
+ if (ho_key.err) {
+ ao.err = ho_key.err;
+ return ao;
+ }
+ ao = make_authobj(ho_key.hash, sizeof(ho_key.hash),
+ secret, secsize, payload, paysize);
+ memset(&ho_chal, 0, sizeof(ho_chal));
+ memset(&ho_key, 0, sizeof(ho_key));
+ return ao;
+}
+
+struct _auth_obj verify_authobj(const char *userid, const char *password,
+ const char *oldnonce, const char *newnonce,
+ const unsigned char *authobj, const int authsize)
+{
+ struct _auth_obj ao = {0};
+ struct _hash_obj ho_chal, ho_key;
+
+ ho_chal = make_challenge(userid, password, oldnonce);
+ if (ho_chal.err) {
+ ao.err = ho_chal.err;
+ return ao;
+ }
+ ho_key = fetch_key(ho_chal.hash, sizeof(ho_chal.hash));
+ if (ho_key.err) {
+ ao.err = ho_key.err;
+ return ao;
+ }
+ memset(&ho_chal, 0, sizeof(ho_chal));
+ memset(&ho_key, 0, sizeof(ho_key));
+ return ao;
+}
+
+struct _auth_obj reload_authobj(const char *userid, const char *password,
+ const char *oldnonce, const char *newnonce,
+ const unsigned char *authobj, const int authsize,
+ const unsigned char *payload, const int paysize)
+{
+ struct _auth_obj ao = {0};
+ struct _hash_obj ho_chal, ho_key;
+
+ ho_chal = make_challenge(userid, password, oldnonce);
+ if (ho_chal.err) {
+ ao.err = ho_chal.err;
+ return ao;
+ }
+ ho_key = fetch_key(ho_chal.hash, sizeof(ho_chal.hash));
+ if (ho_key.err) {
+ ao.err = ho_key.err;
+ return ao;
+ }
+ memset(&ho_chal, 0, sizeof(ho_chal));
+ memset(&ho_key, 0, sizeof(ho_key));
+ return ao;
+}