aboutsummaryrefslogtreecommitdiff
path: root/games/mesetint/mods/default/textures
ModeNameSize
-rw-r--r--crack.png1076logplain
-rw-r--r--default_apple.png203logplain
-rw-r--r--default_book.png292logplain
-rw-r--r--default_bookshelf.png597logplain
-rw-r--r--default_brick.png604logplain
-rw-r--r--default_cactus_side.png279logplain
-rw-r--r--default_cactus_top.png236logplain
-rw-r--r--default_chest_front.png167logplain
-rw-r--r--default_chest_lock.png224logplain
-rw-r--r--default_chest_side.png151logplain
-rw-r--r--default_chest_top.png142logplain
-rw-r--r--default_clay.png613logplain
-rw-r--r--default_clay_brick.png249logplain
-rw-r--r--default_clay_lump.png210logplain
-rw-r--r--default_cloud.png118logplain
-rw-r--r--default_coal_lump.png933logplain
-rw-r--r--default_cobble.png830logplain
-rw-r--r--default_dirt.png1586logplain
-rw-r--r--default_fence.png539logplain
-rw-r--r--default_furnace_front.png246logplain
-rw-r--r--default_furnace_side.png236logplain
-rw-r--r--default_glass.png978logplain
-rw-r--r--default_grass.png874logplain
-rw-r--r--default_grass_footsteps.png856logplain
-rw-r--r--default_grass_side.png878logplain
-rw-r--r--default_gravel.png591logplain
-rw-r--r--default_iron_lump.png936logplain
-rw-r--r--default_junglegrass.png672logplain
-rw-r--r--default_jungletree.png502logplain
-rw-r--r--default_jungletree_top.png507logplain
-rw-r--r--default_ladder.png395logplain
-rw-r--r--default_lava.png357logplain
-rw-r--r--default_leaves.png1689logplain
-rw-r--r--default_mese.png203logplain
-rw-r--r--default_mineral_coal.png952logplain
-rw-r--r--default_mineral_iron.png1614logplain
-rw-r--r--default_mossycobble.png965logplain
-rw-r--r--default_nc_back.png303logplain
-rw-r--r--default_nc_front.png410logplain
-rw-r--r--default_nc_rb.png203logplain
-rw-r--r--default_nc_side.png260logplain
-rw-r--r--default_paper.png242logplain
-rw-r--r--default_papyrus.png366logplain
-rw-r--r--default_rail.png507logplain
-rw-r--r--default_rail_crossing.png555logplain
-rw-r--r--default_rail_curved.png545logplain
-rw-r--r--default_rail_t_junction.png542logplain
-rw-r--r--default_sand.png1381logplain
-rw-r--r--default_sandstone.png772logplain
-rw-r--r--default_sapling.png502logplain
-rw-r--r--default_scorched_stuff.png233logplain
-rw-r--r--default_sign_wall.png489logplain
-rw-r--r--default_steel_block.png219logplain
-rw-r--r--default_steel_ingot.png207logplain
-rw-r--r--default_stick.png182logplain
-rw-r--r--default_stone.png806logplain
-rw-r--r--default_tnt_bottom.png161logplain
-rw-r--r--default_tnt_side.png186logplain
-rw-r--r--default_tnt_top.png264logplain
-rw-r--r--default_tool_mesepick.png252logplain
-rw-r--r--default_tool_steelaxe.png927logplain
-rw-r--r--default_tool_steelpick.png271logplain
-rw-r--r--default_tool_steelshovel.png216logplain
-rw-r--r--default_tool_steelsword.png291logplain
-rw-r--r--default_tool_stoneaxe.png931logplain
-rw-r--r--default_tool_stonepick.png262logplain
-rw-r--r--default_tool_stoneshovel.png203logplain
-rw-r--r--default_tool_stonesword.png301logplain
-rw-r--r--default_tool_woodaxe.png927logplain
-rw-r--r--default_tool_woodpick.png245logplain
-rw-r--r--default_tool_woodshovel.png203logplain
-rw-r--r--default_tool_woodsword.png255logplain
-rw-r--r--default_torch.png925logplain
-rw-r--r--default_torch_on_ceiling.png913logplain
-rw-r--r--default_torch_on_floor.png917logplain
-rw-r--r--default_tree.png1445logplain
-rw-r--r--default_tree_top.png1024logplain
-rw-r--r--default_water.png518logplain
-rw-r--r--default_wood.png1400logplain
-rw-r--r--heart.png308logplain
-rw-r--r--player.png212logplain
-rw-r--r--player_back.png201logplain
-rw-r--r--treeprop.png1055logplain
-rw-r--r--wieldhand.png384logplain
span class="hl opt">; g_hex = global_Ng_constants[ng_type].g_hex; } int rv = 0; rv = mpz_set_str(ng->N, n_hex, 16); rv = rv | mpz_set_str(ng->g, g_hex, 16); if (rv) { delete_ng(ng); return 0; } return ng; } typedef union { SHA_CTX sha; SHA256_CTX sha256; // SHA512_CTX sha512; } HashCTX; struct SRPVerifier { SRP_HashAlgorithm hash_alg; NGConstant *ng; char *username; unsigned char *bytes_B; int authenticated; unsigned char M[SHA512_DIGEST_LENGTH]; unsigned char H_AMK[SHA512_DIGEST_LENGTH]; unsigned char session_key[SHA512_DIGEST_LENGTH]; }; struct SRPUser { SRP_HashAlgorithm hash_alg; NGConstant *ng; mpz_t a; mpz_t A; mpz_t S; unsigned char *bytes_A; int authenticated; char *username; char *username_verifier; unsigned char *password; size_t password_len; unsigned char M[SHA512_DIGEST_LENGTH]; unsigned char H_AMK[SHA512_DIGEST_LENGTH]; unsigned char session_key[SHA512_DIGEST_LENGTH]; }; // clang-format off static int hash_init(SRP_HashAlgorithm alg, HashCTX *c) { switch (alg) { #ifdef CSRP_USE_SHA1 case SRP_SHA1: return SHA1_Init(&c->sha); #endif /* case SRP_SHA224: return SHA224_Init(&c->sha256); */ #ifdef CSRP_USE_SHA256 case SRP_SHA256: return SHA256_Init(&c->sha256); #endif /* case SRP_SHA384: return SHA384_Init(&c->sha512); case SRP_SHA512: return SHA512_Init(&c->sha512); */ default: return -1; }; } static int hash_update( SRP_HashAlgorithm alg, HashCTX *c, const void *data, size_t len ) { switch (alg) { #ifdef CSRP_USE_SHA1 case SRP_SHA1: return SHA1_Update(&c->sha, data, len); #endif /* case SRP_SHA224: return SHA224_Update(&c->sha256, data, len); */ #ifdef CSRP_USE_SHA256 case SRP_SHA256: return SHA256_Update(&c->sha256, data, len); #endif /* case SRP_SHA384: return SHA384_Update(&c->sha512, data, len); case SRP_SHA512: return SHA512_Update(&c->sha512, data, len); */ default: return -1; }; } static int hash_final( SRP_HashAlgorithm alg, HashCTX *c, unsigned char *md ) { switch (alg) { #ifdef CSRP_USE_SHA1 case SRP_SHA1: return SHA1_Final(md, &c->sha); #endif /* case SRP_SHA224: return SHA224_Final(md, &c->sha256); */ #ifdef CSRP_USE_SHA256 case SRP_SHA256: return SHA256_Final(md, &c->sha256); #endif /* case SRP_SHA384: return SHA384_Final(md, &c->sha512); case SRP_SHA512: return SHA512_Final(md, &c->sha512); */ default: return -1; }; } static unsigned char *hash(SRP_HashAlgorithm alg, const unsigned char *d, size_t n, unsigned char *md) { switch (alg) { #ifdef CSRP_USE_SHA1 case SRP_SHA1: return SHA1(d, n, md); #endif /* case SRP_SHA224: return SHA224( d, n, md ); */ #ifdef CSRP_USE_SHA256 case SRP_SHA256: return SHA256(d, n, md); #endif /* case SRP_SHA384: return SHA384( d, n, md ); case SRP_SHA512: return SHA512( d, n, md ); */ default: return 0; }; } static size_t hash_length(SRP_HashAlgorithm alg) { switch (alg) { #ifdef CSRP_USE_SHA1 case SRP_SHA1: return SHA_DIGEST_LENGTH; #endif /* case SRP_SHA224: return SHA224_DIGEST_LENGTH; */ #ifdef CSRP_USE_SHA256 case SRP_SHA256: return SHA256_DIGEST_LENGTH; #endif /* case SRP_SHA384: return SHA384_DIGEST_LENGTH; case SRP_SHA512: return SHA512_DIGEST_LENGTH; */ default: return -1; }; } // clang-format on inline static int mpz_num_bytes(const mpz_t op) { return (mpz_sizeinbase(op, 2) + 7) / 8; } inline static void mpz_to_bin(const mpz_t op, unsigned char *to) { mpz_export(to, NULL, 1, 1, 1, 0, op); } inline static void mpz_from_bin(const unsigned char *s, size_t len, mpz_t ret) { mpz_import(ret, len, 1, 1, 1, 0, s); } // set op to (op1 * op2) mod d, using tmp for the calculation inline static void mpz_mulm( mpz_t op, const mpz_t op1, const mpz_t op2, const mpz_t d, mpz_t tmp) { mpz_mul(tmp, op1, op2); mpz_mod(op, tmp, d); } // set op to (op1 + op2) mod d, using tmp for the calculation inline static void mpz_addm( mpz_t op, const mpz_t op1, const mpz_t op2, const mpz_t d, mpz_t tmp) { mpz_add(tmp, op1, op2); mpz_mod(op, tmp, d); } // set op to (op1 - op2) mod d, using tmp for the calculation inline static void mpz_subm( mpz_t op, const mpz_t op1, const mpz_t op2, const mpz_t d, mpz_t tmp) { mpz_sub(tmp, op1, op2); mpz_mod(op, tmp, d); } static SRP_Result H_nn( mpz_t result, SRP_HashAlgorithm alg, const mpz_t N, const mpz_t n1, const mpz_t n2) { unsigned char buff[SHA512_DIGEST_LENGTH]; size_t len_N = mpz_num_bytes(N); size_t len_n1 = mpz_num_bytes(n1); size_t len_n2 = mpz_num_bytes(n2); size_t nbytes = len_N + len_N; unsigned char *bin = (unsigned char *)srp_alloc(nbytes); if (!bin) return SRP_ERR; if (len_n1 > len_N || len_n2 > len_N) { srp_free(bin); return SRP_ERR; } memset(bin, 0, nbytes); mpz_to_bin(n1, bin + (len_N - len_n1)); mpz_to_bin(n2, bin + (len_N + len_N - len_n2)); hash(alg, bin, nbytes, buff); srp_free(bin); mpz_from_bin(buff, hash_length(alg), result); return SRP_OK; } 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) { unsigned char buff[SHA512_DIGEST_LENGTH]; size_t nbytes = len_n + len_bytes; unsigned char *bin = (unsigned char *)srp_alloc(nbytes); if (!bin) return SRP_ERR; memcpy(bin, n, len_n); memcpy(bin + len_n, bytes, len_bytes); hash(alg, bin, nbytes, buff); srp_free(bin); mpz_from_bin(buff, hash_length(alg), result); return SRP_OK; } static int calculate_x(mpz_t result, SRP_HashAlgorithm alg, const unsigned char *salt, size_t salt_len, const char *username, const unsigned char *password, size_t password_len) { unsigned char ucp_hash[SHA512_DIGEST_LENGTH]; HashCTX ctx; hash_init(alg, &ctx); srp_dbg_data((char *)username, strlen(username), "Username for x: "); srp_dbg_data((char *)password, password_len, "Password for x: "); hash_update(alg, &ctx, username, strlen(username)); hash_update(alg, &ctx, ":", 1); hash_update(alg, &ctx, password, password_len); hash_final(alg, &ctx, ucp_hash); return H_ns(result, alg, salt, salt_len, ucp_hash, hash_length(alg)); } static SRP_Result update_hash_n(SRP_HashAlgorithm alg, HashCTX *ctx, const mpz_t n) { size_t len = mpz_num_bytes(n); unsigned char *n_bytes = (unsigned char *)srp_alloc(len); if (!n_bytes) return SRP_ERR; mpz_to_bin(n, n_bytes); hash_update(alg, ctx, n_bytes, len); srp_free(n_bytes); return SRP_OK; } static SRP_Result hash_num(SRP_HashAlgorithm alg, const mpz_t n, unsigned char *dest) { int nbytes = mpz_num_bytes(n); unsigned char *bin = (unsigned char *)srp_alloc(nbytes); if (!bin) return SRP_ERR; mpz_to_bin(n, bin); hash(alg, bin, nbytes, dest); srp_free(bin); return SRP_OK; } static SRP_Result calculate_M(SRP_HashAlgorithm alg, NGConstant *ng, unsigned char *dest, const char *I, const unsigned char *s_bytes, size_t s_len, const mpz_t A, const mpz_t B, const unsigned char *K) { unsigned char H_N[SHA512_DIGEST_LENGTH]; unsigned char H_g[SHA512_DIGEST_LENGTH]; unsigned char H_I[SHA512_DIGEST_LENGTH]; unsigned char H_xor[SHA512_DIGEST_LENGTH]; HashCTX ctx; size_t i = 0; size_t hash_len = hash_length(alg); if (!hash_num(alg, ng->N, H_N)) return SRP_ERR; if (!hash_num(alg, ng->g, H_g)) return SRP_ERR; hash(alg, (const unsigned char *)I, strlen(I), H_I); for (i = 0; i < hash_len; i++) H_xor[i] = H_N[i] ^ H_g[i]; hash_init(alg, &ctx); hash_update(alg, &ctx, H_xor, hash_len); hash_update(alg, &ctx, H_I, hash_len); hash_update(alg, &ctx, s_bytes, s_len); if (!update_hash_n(alg, &ctx, A)) return SRP_ERR; if (!update_hash_n(alg, &ctx, B)) return SRP_ERR; hash_update(alg, &ctx, K, hash_len); hash_final(alg, &ctx, dest); return SRP_OK; } static SRP_Result calculate_H_AMK(SRP_HashAlgorithm alg, unsigned char *dest, const mpz_t A, const unsigned char *M, const unsigned char *K) { HashCTX ctx; hash_init(alg, &ctx); if (!update_hash_n(alg, &ctx, A)) return SRP_ERR; hash_update(alg, &ctx, M, hash_length(alg)); hash_update(alg, &ctx, K, hash_length(alg)); hash_final(alg, &ctx, dest); return SRP_OK; } static SRP_Result fill_buff() { g_rand_idx = 0; #ifdef WIN32 HCRYPTPROV wctx; #else FILE *fp = 0; #endif #ifdef WIN32 if (!CryptAcquireContext(&wctx, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) return SRP_ERR; if (!CryptGenRandom(wctx, sizeof(g_rand_buff), (BYTE *)g_rand_buff)) return SRP_ERR; if (!CryptReleaseContext(wctx, 0)) return SRP_ERR; #else fp = fopen("/dev/urandom", "r"); if (!fp) 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; } static SRP_Result mpz_fill_random(mpz_t num) { // was call: BN_rand(num, 256, -1, 0); if (RAND_BUFF_MAX - g_rand_idx < 32) if (fill_buff() != SRP_OK) return SRP_ERR; mpz_from_bin((const unsigned char *)(&g_rand_buff[g_rand_idx]), 32, num); g_rand_idx += 32; return SRP_OK; } static SRP_Result init_random() { if (g_initialized) return SRP_OK; SRP_Result ret = fill_buff(); g_initialized = (ret == SRP_OK); return ret; } #define srp_dbg_num(num, text) ; /*void srp_dbg_num(mpz_t num, char * prevtext) { int len_num = mpz_num_bytes(num); char *bytes_num = (char*) srp_alloc(len_num); mpz_to_bin(num, (unsigned char *) bytes_num); srp_dbg_data(bytes_num, len_num, prevtext); srp_free(bytes_num); }*/ /*********************************************************************************************************** * * Exported Functions * ***********************************************************************************************************/ // clang-format off SRP_Result srp_create_salted_verification_key( SRP_HashAlgorithm alg, SRP_NGType ng_type, const char *username_for_verifier, const unsigned char *password, size_t len_password, unsigned char **bytes_s, size_t *len_s, unsigned char **bytes_v, size_t *len_v, const char *n_hex, const char *g_hex ) { SRP_Result ret = SRP_OK; mpz_t v; mpz_init(v); mpz_t x; mpz_init(x); // clang-format on NGConstant *ng = new_ng(ng_type, n_hex, g_hex); if (!ng) goto error_and_exit; if (init_random() != SRP_OK) /* Only happens once */ goto error_and_exit; if (*bytes_s == NULL) { size_t size_to_fill = 16; *len_s = size_to_fill; if (RAND_BUFF_MAX - g_rand_idx < size_to_fill) 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); g_rand_idx += size_to_fill; } if (!calculate_x( x, alg, *bytes_s, *len_s, username_for_verifier, password, len_password)) goto error_and_exit; srp_dbg_num(x, "Server calculated x: "); mpz_powm(v, ng->g, x, ng->N); *len_v = mpz_num_bytes(v); *bytes_v = (unsigned char *)srp_alloc(*len_v); if (!*bytes_v) goto error_and_exit; mpz_to_bin(v, *bytes_v); cleanup_and_exit: delete_ng(ng); mpz_clear(v); mpz_clear(x); return ret; error_and_exit: ret = SRP_ERR; goto cleanup_and_exit; } // clang-format off /* Out: bytes_B, len_B. * * On failure, bytes_B will be set to NULL and len_B will be set to 0 */ struct SRPVerifier *srp_verifier_new(SRP_HashAlgorithm alg, SRP_NGType ng_type, const char *username, const unsigned char *bytes_s, size_t len_s, const unsigned char *bytes_v, size_t len_v, const unsigned char *bytes_A, size_t len_A, const unsigned char *bytes_b, size_t len_b, unsigned char **bytes_B, size_t *len_B, const char *n_hex, const char *g_hex ) { mpz_t v; mpz_init(v); mpz_from_bin(bytes_v, len_v, v); mpz_t A; mpz_init(A); mpz_from_bin(bytes_A, len_A, A); mpz_t u; mpz_init(u); mpz_t B; mpz_init(B); mpz_t S; mpz_init(S); mpz_t b; mpz_init(b); mpz_t k; mpz_init(k); mpz_t tmp1; mpz_init(tmp1); mpz_t tmp2; mpz_init(tmp2); mpz_t tmp3; mpz_init(tmp3); // clang-format on size_t ulen = strlen(username) + 1; NGConstant *ng = new_ng(ng_type, n_hex, g_hex); struct SRPVerifier *ver = 0; *len_B = 0; *bytes_B = 0; if (!ng) goto cleanup_and_exit;