[PATCH] 8158517: Minor optimizations to ISO10126PADDING

Bernd Eckenfels ecki at zusammenkunft.net
Wed Dec 7 20:23:30 UTC 2016


Thanks for committing, looks fine with me as well.

Gruss
Bernd





On Wed, Dec 7, 2016 at 5:25 PM +0100, "Sean Mullan" <sean.mullan at oracle.com> wrote:










Looks good. Minor comment - update the copyright to include 2016 as the 
last year it was updated, ex:

  * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights 
reserved.

Send me the updated diffs and I will push it for you.

--Sean

On 12/7/16 9:14 AM, Adam Petcher wrote:
>
> Minor improvement/optimization to ISO10126Padding. Simplifies the code a
> bit and requests one fewer random byte. No regression test is provided
> because this is a code cleanup, and the functionality is covered by
> existing tests.
>
> Bug: https://bugs.openjdk.java.net/browse/JDK-8158517
>
> Diff:
>
> diff --git
> a/src/java.base/share/classes/com/sun/crypto/provider/ISO10126Padding.java
> b/src/java.base/share/classes/com/sun/crypto/provider/ISO10126Padding.java
> ---
> a/src/java.base/share/classes/com/sun/crypto/provider/ISO10126Padding.java
> +++
> b/src/java.base/share/classes/com/sun/crypto/provider/ISO10126Padding.java
> @@ -68,10 +68,10 @@
>          }
>
>          byte paddingOctet = (byte) (len & 0xff);
> -        byte[] padding = new byte[len];
> +        byte[] padding = new byte[len - 1];
>          SunJCE.getRandom().nextBytes(padding);
> -        padding[len-1] = paddingOctet;
> -        System.arraycopy(padding, 0, in, off, len);
> +        System.arraycopy(padding, 0, in, off, len - 1);
> +        in[off + len - 1] = paddingOctet;
>          return;
>      }
>
> @@ -101,7 +101,7 @@
>              return -1;
>          }
>
> -        int start = off + len - ((int)lastByte & 0x0ff);
> +        int start = off + len - padValue;
>          if (start < off) {
>              return -1;
>          }





-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/security-dev/attachments/20161207/be091a73/attachment.htm>


More information about the security-dev mailing list