You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Leo Li (JIRA)" <ji...@apache.org> on 2007/04/03 11:09:32 UTC

[jira] Updated: (HARMONY-3552) [classlib][security]java.security.SecureRandom.next(int bitCount) returns a int which has a longer bit length than required.

     [ https://issues.apache.org/jira/browse/HARMONY-3552?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Leo Li updated HARMONY-3552:
----------------------------

    Estimated Complexity: Moderate
             Description: 
Here is a testcase:

       public void test_Next() throws Exception {
        MySecureRandom mySecureRandom = new MySecureRandom(
                new MySecureRandomSpi(), null);
        int numBits = 29;
        int random = mySecureRandom.getNext(numBits);
        assertEquals(numBits, Integer.bitCount(random));
    }
    
    class MySecureRandom extends SecureRandom {
        private static final long serialVersionUID = 1L;

        public MySecureRandom(SecureRandomSpi secureRandomSpi, Provider provider) {
            super(secureRandomSpi, provider);
        }

        public int getNext(int numBits) {
            return super.next(numBits);
        }
    }

    class MySecureRandomSpi extends SecureRandomSpi {
        private static final long serialVersionUID = 1L;

        @Override
        protected byte[] engineGenerateSeed(int arg0) {
            return null;
        }

        @Override
        protected void engineNextBytes(byte[] bytes) {
            for (int i = 0; i < bytes.length; i++) {
                bytes[i] = (byte) 0xFF;
            }
        }

        @Override
        protected void engineSetSeed(byte[] arg0) {
            return;
        }
    }

RI passes.
Harmony fails with an int with length 32.
                 Summary: [classlib][security]java.security.SecureRandom.next(int bitCount) returns a int which has a longer bit length than required.  (was: [classlib][security]java.security.SecureRandom.next(int bitCount) returns a int which has a longer bit )

> [classlib][security]java.security.SecureRandom.next(int bitCount) returns a int which has a longer bit length than required.
> ----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-3552
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3552
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Leo Li
>
> Here is a testcase:
>        public void test_Next() throws Exception {
>         MySecureRandom mySecureRandom = new MySecureRandom(
>                 new MySecureRandomSpi(), null);
>         int numBits = 29;
>         int random = mySecureRandom.getNext(numBits);
>         assertEquals(numBits, Integer.bitCount(random));
>     }
>     
>     class MySecureRandom extends SecureRandom {
>         private static final long serialVersionUID = 1L;
>         public MySecureRandom(SecureRandomSpi secureRandomSpi, Provider provider) {
>             super(secureRandomSpi, provider);
>         }
>         public int getNext(int numBits) {
>             return super.next(numBits);
>         }
>     }
>     class MySecureRandomSpi extends SecureRandomSpi {
>         private static final long serialVersionUID = 1L;
>         @Override
>         protected byte[] engineGenerateSeed(int arg0) {
>             return null;
>         }
>         @Override
>         protected void engineNextBytes(byte[] bytes) {
>             for (int i = 0; i < bytes.length; i++) {
>                 bytes[i] = (byte) 0xFF;
>             }
>         }
>         @Override
>         protected void engineSetSeed(byte[] arg0) {
>             return;
>         }
>     }
> RI passes.
> Harmony fails with an int with length 32.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.