Xu Yaning created DIRKRB-220:
--------------------------------

             Summary: Fix random2Key function in Des3KeyMaker.java
                 Key: DIRKRB-220
                 URL: https://issues.apache.org/jira/browse/DIRKRB-220
             Project: Directory Kerberos
          Issue Type: Bug
            Reporter: Xu Yaning


There is a problem  in random2Key function that it dosen't calculate the 8th 
byte for every 7 bytes.
{code}
  byte[] key = new byte[encProvider().keySize()];
        byte[] tmp1 = new byte[7];
        byte[] tmp2;
        for (int i = 0; i < 3; i++) {
            System.arraycopy(randomBits, i * 7, key, i * 8, 7);
            System.arraycopy(randomBits, i * 7, tmp1, 0, 7);
            tmp2 = getEightBits(tmp1);
            key[8 * (i + 1) - 1] = tmp2[7];
            int nthByte = i * 8;
            key[nthByte + 7] = (byte) (((key[nthByte + 0] & 1) << 1) |
                    ((key[nthByte + 1] & 1) << 2) |
                    ((key[nthByte + 2] & 1) << 3) |
                    ((key[nthByte + 3] & 1) << 4) |
                    ((key[nthByte + 4] & 1) << 5) |
                    ((key[nthByte + 5] & 1) << 6) |
                    ((key[nthByte + 6] & 1) << 7));

            for (int j = 0; j < 8; j++) {
                int tmp = key[nthByte + j] & 0xfe;
                tmp |= (Integer.bitCount(tmp) & 1) ^ 1;
                key[nthByte + j] = (byte) tmp;
            }
        }

{code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to