Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3852954
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:23:42+00:00 2026-05-19T17:23:42+00:00

I’m currently confused as to the behaviour of the DES algorithm provided by the

  • 0

I’m currently confused as to the behaviour of the DES algorithm provided by the GNU Crypto package. Here’s a link to the algorithm in question: GNU Crypto DES algorithm

Originally I was merely wanting to extract the state of the key(s) at certain points, i.e. after PC-1, PC-2, the sub keys, etc. However, this plan’s not going too well as the 56bit key expected after PC-1, appears to be 48 bits, going by the pc1m variable (working on the assumption that representation of the key (pc1m’s value) when converted from decimal to binary is sound). As such I tried to figure out this piece of code:

for (i = 0; i < 56; i++) {
l = PC1[i];
pc1m |= ((kb[l >>> 3] & (0x80 >>> (l & 7))) != 0)
? (1L << (55 – i)) : 0;
}

However, my understanding of the bitwise operations is ropey, and although I have a vague understanding of how it’s evaluating, I can’t see the overall logic to it and how it works (or, rather why it appears to not actually work — although the algorithm does encrypt and decrypt successfully going by the official test vectors). Where can I get the 56 bit permutation after PC-1?

It is also unclear to me what the code does after ” // Encryption key first. “, as the pc1m variable is unchanged, and pcr appears to just copy the value after all that.

On the brightside, it appears clear, that “cooking” the keys creates the subkeys for the Feistel rounds.

As an aside, any other non-copyrighted Java implementations you can reference would be of interest to me, however, I would quite like to work with this implementation.

Any help would be much, much appreciated! Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T17:23:43+00:00Added an answer on May 19, 2026 at 5:23 pm

    The code snippet indeed is reading 56 bits from kb and rearranging them into pc1m (assuming the initial value of pc1m is 0).

    // For each of the 56 bits
    for (i = 0; i < 56; i++)
    {
        L = PC1[i];                 // Get i-th bit index
        L_byte = L >>> 3;           // Get the byte where that bit is stored
        L_mask = 0x80 >>> (L & 7);  // Get the bit mask
        if (kb[L_byte] & L_mask] != 0)
        {
            // The PC1[i]-th bit of kb is set
            // so set bit at position 55-i (i=0 => MSB) in pc1m
            pc1m |= (1L << (55-i));
        }
    }
    

    so the value of kb after the 56-bit permutation described in PC1 will be available in pc1m as a single long integer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am currently running into a problem where an element is coming back from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.