*/
// clang-format off
+
+#include <cstddef>
+
#ifdef WIN32
#include <windows.h>
#include <wincrypt.h>
#else
- #include <time.h>
+ #include <ctime>
+
#endif
// clang-format on
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
+#include <cstdlib>
+#include <cstring>
+#include <cstdio>
+#include <cstdint>
#include <config.h>
-#if USE_SYSTEM_GMP || defined (__ANDROID__) || defined (ANDROID)
+#if USE_SYSTEM_GMP
#include <gmp.h>
#else
- #include <gmp/mini-gmp.h>
+ #include <mini-gmp.h>
#endif
#include <util/sha2.h>
}
static SRP_Result H_ns(mpz_t result, SRP_HashAlgorithm alg, const unsigned char *n,
- size_t len_n, const unsigned char *bytes, size_t len_bytes)
+ size_t len_n, const unsigned char *bytes, uint32_t len_bytes)
{
unsigned char buff[SHA512_DIGEST_LENGTH];
size_t nbytes = len_n + len_bytes;
if (!fp) return SRP_ERR;
- if (fread(g_rand_buff, sizeof(g_rand_buff), 1, fp) != 1) return SRP_ERR;
+ if (fread(g_rand_buff, sizeof(g_rand_buff), 1, fp) != 1) { fclose(fp); return SRP_ERR; }
if (fclose(fp)) return SRP_ERR;
#endif
return SRP_OK;
if (fill_buff() != SRP_OK) goto error_and_exit;
*bytes_s = (unsigned char *)srp_alloc(size_to_fill);
if (!*bytes_s) goto error_and_exit;
- memcpy(*bytes_s, &g_rand_buff + g_rand_idx, size_to_fill);
+ memcpy(*bytes_s, &g_rand_buff[g_rand_idx], size_to_fill);
g_rand_idx += size_to_fill;
}
goto cleanup_and_exit;
}
- memcpy((char *)ver->username, username, ulen);
+ memcpy(ver->username, username, ulen);
ver->authenticated = 0;
mpz_clear(usr->a);
mpz_clear(usr->A);
mpz_clear(usr->S);
- if (usr->ng) delete_ng(usr->ng);
+ delete_ng(usr->ng);
srp_free(usr->username);
srp_free(usr->username_verifier);
if (usr->password) {