Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8158517

Minor optimizations to ISO10126PADDING

    Details

    • Subcomponent:
    • Resolved In Build:
      b149
    • Verification:
      Not verified

      Backports

        Description

        Posted on http://mail.openjdk.java.net/pipermail/security-dev/2016-May/013856.html:

        while looking at ISO10126Padding I noticed a few minor optimizations are possible:

        http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8u40-b25/com/sun/crypto/provider/ISO10126Padding.java?av=f

        unpad() - there is already a int cast done to this value:
        104 int start = off + len - ((int)lastByte & 0x0ff);

        can be changed into "int start = off + len - padValue;"

        padWithLen() - we can request one byte less from PRNG and copy one less:
        71 byte[] padding = new byte[len];
        72 SunJCE.getRandom().nextBytes(padding);
        73 padding[len-1] = paddingOctet;
        74 System.arraycopy(padding, 0, in, off, len);

        byte[] padding = new byte[len-1];
        SunJCE.getRandom().nextBytes(padding);
        System.arraycopy(padding, 0, in, off, len-1);
        in[off+len-1] = paddingOctet;

          Issue Links

            Activity

            Hide
            apetcher Adam Petcher added a comment -
            Issue of contents of padding moved to JDK-8170762.
            Show
            apetcher Adam Petcher added a comment - Issue of contents of padding moved to JDK-8170762 .
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/dev/jdk/rev/b9cdffb87bea
            User: mullan
            Date: 2016-12-07 15:56:27 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/dev/jdk/rev/b9cdffb87bea User: mullan Date: 2016-12-07 15:56:27 +0000
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/b9cdffb87bea
            User: lana
            Date: 2016-12-13 18:25:03 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/b9cdffb87bea User: lana Date: 2016-12-13 18:25:03 +0000

              People

              • Assignee:
                apetcher Adam Petcher
                Reporter:
                mullan Sean Mullan
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: