8158517: Minor optimizations to ISO10126PADDING
Co-authored-by: Bernd Eckenfels <ecki@zusammenkunft.net> Reviewed-by: mullan
This commit is contained in:
parent
5c2b3026c2
commit
df8736b785
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -68,10 +68,10 @@ final class ISO10126Padding implements Padding {
|
||||
}
|
||||
|
||||
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 @@ final class ISO10126Padding implements Padding {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int start = off + len - ((int)lastByte & 0x0ff);
|
||||
int start = off + len - padValue;
|
||||
if (start < off) {
|
||||
return -1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user