Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 27 Dec 2011 22:08:58 +0530
From: Piyush Mittal <>
Subject: Re: Bit slice implementation of DES based hashes


Earlier I thought function DES_bs_get_binary() is simply converting cipher
text into binary form but some more tasks are also associated with it.Can
you please elaborate me what actually this function is trying to do?
However I tried to understand it but specifically I am not getting some
portion of DES_raw_get_binary() linked with it. i.e

if (ciphertext[13]) ofs = 9; else ofs = 2;

    block[0] = block[1] = 0;
    dst = 0;
    for (chr = 0; chr < 11; chr++) {
        value = DES_atoi64[ARCH_INDEX(ciphertext[chr + ofs])];
        mask = 0x20;

        for (src = 0; src < 6; src++) {
            if (value & mask)
                block[dst >> 5] |= 1 << (dst & 0x1F);
            mask >>= 1;

Why here ciphertexr[13] is taken and ignored first 8 bit of cipher text.Is
that because of optimisation (i.e we don't need to compare whole of cipher

Also I have seen Matthew Kwan's code and in that he have not used initial
permutation for Bit slicing DES then what is the concept behind using IP
here in binary function code?

On Fri, Dec 23, 2011 at 9:26 PM, Solar Designer <> wrote:

> On Fri, Dec 23, 2011 at 09:14:19PM +0530, Piyush Mittal wrote:
> > > #define init_depth() \
> > >     int depth; \
> > >     depth = index >> ARCH_BITS_LOG; \
> > >     index &= (ARCH_BITS - 1);
> >
> > 1.Does depth here means word?
> Perhaps, although this depends on what you mean by these words.
> > 2.Why we are using init_depth() even it always led to depth=0
> It does not always lead to depth=0, it may also lead to other values.
> > 3.What is the significance of ARCH_BITS_LOG here?
> Like I said before, we're splitting the index into two components.  Some
> bits of the original index become the native machine word number and
> some bits become the bit number within that word.
> Please re-read the following and try to understand it:
> "DEPTH is a macro that may expand either to empty string or to
> [depth].  The latter is used when we're dealing with SIMD vectors larger
> than machine word size - e.g., 128-bit with SSE2, whereas the native
> word size is just 64 or 32 bits.  In get_hash*() functions, we need to
> extract some bits from just one bit layer.  We do this with regular
> (non-SIMD) operations and machine words (in fact, even these are wider
> than necessary since we're dealing with just one bit layer in these
> functions).  Thus, we split the bit layer index into two components:
> native machine word "depth" (which word in a SIMD vector we're dealing
> with currently) and bit position in that word."
> I don't think I can explain it in a way that would be much easier to
> understand, sorry.
> Alexander

Piyush Mittal
Department of Computer Science and Engineering
National Institute of Technology,Rourkela


Powered by blists - more mailing lists

Your e-mail address:

Powered by Openwall GNU/*/Linux - Powered by OpenVZ