|
Message-ID: <20150309103630.GB26663@openwall.com> Date: Mon, 9 Mar 2015 13:36:30 +0300 From: Solar Designer <solar@...nwall.com> To: john-dev@...ts.openwall.com Subject: Re: 256/128 bit integer arithmatic > On 2015-03-08 16:26, Sayantan Datta wrote: > > Is there any way to natively perform 128 bit or 256 bit integer arithmetic, > > such as add, divide, subtract ? Mostly no. Except for 64x64->128 multiply and 128/64->64 divide, there's no native 128-bit integer support on x86-64. > > Maybe with AVX/SSE registers and using them without SIMD? No. On Sun, Mar 08, 2015 at 08:37:57PM +0100, magnum wrote: > gcc provides int128 for 64-bit builds (but not for 32-bit builds). Look > at our mpz_int128.h which mimics GMP but actually uses saturated 128-bit > integer (the latter is a lot faster - but GMP can go way beyond 128 bits). I also used __uint128_t here: http://openwall.info/wiki/john/policy > They are emulated though, probably similar to using hi/lo 64-bit structs. > > One caveat is you can't have constants larger than 64-bit. So to load a > 128-bit constant you'd need to do something like this > > uint128_t foo = 0xabcd0123deadcafeULL << 64 + 0xdeadcafeabcd0123ULL "Something like", yes, but this specific example has two bugs: need braces, and need a typecast to uint128_t since otherwise the left shift would be performed on the 64-bit value and would result in zero. __uint128_t foo = ((__uint128_t)0xabcd0123deadcafeULL << 64) + 0xdeadcafeabcd0123ULL; Alexander
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.