Encrypting a 64-Bit Block with a 7-Byte Key

Transform the 7-byte key into an 8-byte key as follows:

  1. Let InputKey be the 7-byte key, represented as a zero-base-index array.

  2. Let OutputKey be an 8-byte key, represented as a zero-base-index array.

  3. Let OutputKey be assigned as follows.

     OutputKey[0] = InputKey[0] >> 0x01;
     OutputKey[1] = ((InputKey[0]&0x01)<<6) | (InputKey[1]>>2);
     OutputKey[2] = ((InputKey[1]&0x03)<<5) | (InputKey[2]>>3);
     OutputKey[3] = ((InputKey[2]&0x07)<<4) | (InputKey[3]>>4);
     OutputKey[4] = ((InputKey[3]&0x0F)<<3) | (InputKey[4]>>5);
     OutputKey[5] = ((InputKey[4]&0x1F)<<2) | (InputKey[5]>>6);
     OutputKey[6] = ((InputKey[5]&0x3F)<<1) | (InputKey[6]>>7);
     OutputKey[7] = InputKey[6] & 0x7F;

    The 7-byte InputKey is expanded to 8 bytes by inserting a 0-bit after every seventh bit.

     for( int i=0; i<8; i++ )
        OutputKey[i] = (OutputKey[i] << 1) & 0xfe;
  4. Let the least-significant bit of each byte of OutputKey be a parity bit. That is, if the sum of the preceding seven bits is odd, the eighth bit is 0; otherwise, the eighth bit is 1. The processing starts at the leftmost bit of OutputKey.

Use [FIPS81] to encrypt the 64-bit block using OutputKey. If the higher-level operation is decryption instead of encryption, this is the point at which an implementer MUST specify the decryption intent to [FIPS81].