MCPcopy Create free account
hub / github.com/Yeuoly/0xUBypass / mpn_set_str_other

Function mpn_set_str_other

WindowsShellcodeInjector/mini-gmp.cpp:1355–1391  ·  view source on GitHub ↗

Result is usually normalized, except for all-zero input, in which case a single zero limb is written at *RP, and 1 is returned. */

Source from the content-addressed store, hash-verified

1353/* Result is usually normalized, except for all-zero input, in which
1354 case a single zero limb is written at *RP, and 1 is returned. */
1355static mp_size_t
1356mpn_set_str_other(mp_ptr rp, const unsigned char *sp, size_t sn,
1357 mp_limb_t b, const struct mpn_base_info *info)
1358{
1359 mp_size_t rn;
1360 mp_limb_t w;
1361 unsigned k;
1362 size_t j;
1363
1364 assert(sn > 0);
1365
1366 k = 1 + (sn - 1) % info->exp;
1367
1368 j = 0;
1369 w = sp[j++];
1370 while (--k != 0)
1371 w = w * b + sp[j++];
1372
1373 rp[0] = w;
1374
1375 for (rn = 1; j < sn;)
1376 {
1377 mp_limb_t cy;
1378
1379 w = sp[j++];
1380 for (k = 1; k < info->exp; k++)
1381 w = w * b + sp[j++];
1382
1383 cy = mpn_mul_1(rp, rp, rn, info->bb);
1384 cy += mpn_add_1(rp, rp, rn, w);
1385 if (cy > 0)
1386 rp[rn++] = cy;
1387 }
1388 assert(j == sn);
1389
1390 return rn;
1391}
1392
1393mp_size_t
1394mpn_set_str(mp_ptr rp, const unsigned char *sp, size_t sn, int base)

Callers 2

mpn_set_strFunction · 0.85
mpz_set_strFunction · 0.85

Calls 2

mpn_mul_1Function · 0.85
mpn_add_1Function · 0.85

Tested by

no test coverage detected