diff options
Diffstat (limited to 'libjava/classpath/gnu/java/security/util')
10 files changed, 139 insertions, 139 deletions
diff --git a/libjava/classpath/gnu/java/security/util/ByteArray.java b/libjava/classpath/gnu/java/security/util/ByteArray.java index 51449204397..a9b9e5d0066 100644 --- a/libjava/classpath/gnu/java/security/util/ByteArray.java +++ b/libjava/classpath/gnu/java/security/util/ByteArray.java @@ -65,23 +65,23 @@ public final class ByteArray int len = value.length; while (i < len) { - out.print (formatInt (i, 16, 8)); - out.print (" "); - int l = Math.min (16, len - i); - String s = toHexString (value, i, l, ' '); - out.print (s); - for (int j = 56 - (56 - s.length ()); j < 56; j++) - out.print (" "); - for (int j = 0; j < l; j++) - { - byte b = value[i+j]; - if ((b & 0xFF) < 0x20 || (b & 0xFF) > 0x7E) - out.print ("."); - else - out.print ((char) (b & 0xFF)); - } - out.println (); - i += 16; + out.print (formatInt (i, 16, 8)); + out.print (" "); + int l = Math.min (16, len - i); + String s = toHexString (value, i, l, ' '); + out.print (s); + for (int j = 56 - (56 - s.length ()); j < 56; j++) + out.print (" "); + for (int j = 0; j < l; j++) + { + byte b = value[i+j]; + if ((b & 0xFF) < 0x20 || (b & 0xFF) > 0x7E) + out.print ("."); + else + out.print ((char) (b & 0xFF)); + } + out.println (); + i += 16; } return str.toString (); } @@ -91,8 +91,8 @@ public final class ByteArray CPStringBuilder str = new CPStringBuilder(); for (int i = 0; i < len; i++) { - str.append (Character.forDigit (buf[i+off] >>> 4 & 0x0F, 16)); - str.append (Character.forDigit (buf[i+off] & 0x0F, 16)); + str.append (Character.forDigit (buf[i+off] >>> 4 & 0x0F, 16)); + str.append (Character.forDigit (buf[i+off] & 0x0F, 16)); if (i < len - 1) str.append(sep); } diff --git a/libjava/classpath/gnu/java/security/util/ByteBufferOutputStream.java b/libjava/classpath/gnu/java/security/util/ByteBufferOutputStream.java index be4d0a98d67..642ccdf68f8 100644 --- a/libjava/classpath/gnu/java/security/util/ByteBufferOutputStream.java +++ b/libjava/classpath/gnu/java/security/util/ByteBufferOutputStream.java @@ -47,18 +47,18 @@ import java.nio.ByteBuffer; /** * An output stream that writes bytes to a ByteBuffer, which will be resized * if more space is needed. - * + * * @author Casey Marshall (csm@gnu.org) */ public class ByteBufferOutputStream extends OutputStream { private ByteBuffer buffer; - + public ByteBufferOutputStream() { this(256); } - + public ByteBufferOutputStream(int initialCapacity) { buffer = ByteBuffer.allocate(initialCapacity); @@ -71,16 +71,16 @@ public class ByteBufferOutputStream extends OutputStream { if (!buffer.hasRemaining()) growBuffer(); - buffer.put((byte) b); + buffer.put((byte) b); } - + public @Override synchronized void write(byte[] b, int offset, int length) { if (buffer.remaining() < length) growBuffer(); buffer.put(b, offset, length); } - + public @Override void write(byte[] b) { write(b, 0, b.length); @@ -90,19 +90,19 @@ public class ByteBufferOutputStream extends OutputStream * Get the current state of the buffer. The returned buffer will have * its position set to zero, its capacity set to the current limit, * and its limit set to its capacity. - * + * * @return The buffer. */ public ByteBuffer buffer() { return ((ByteBuffer) buffer.duplicate().flip()).slice(); } - + public String toString() { return super.toString() + " [ buffer: " + buffer + " ]"; } - + private void growBuffer() { int newCapacity = buffer.capacity(); diff --git a/libjava/classpath/gnu/java/security/util/ExpirableObject.java b/libjava/classpath/gnu/java/security/util/ExpirableObject.java index e0c4e6b5984..e24af249aa5 100644 --- a/libjava/classpath/gnu/java/security/util/ExpirableObject.java +++ b/libjava/classpath/gnu/java/security/util/ExpirableObject.java @@ -57,7 +57,7 @@ import javax.security.auth.Destroyable; * <p> * Note that if a {@link DestroyFailedException} occurs when the timeout * expires, it will not be reported. - * + * * @see Destroyable */ public abstract class ExpirableObject @@ -89,7 +89,7 @@ public abstract class ExpirableObject /** * Create a new expirable object that will expire after the specified timeout. - * + * * @param delay The delay before expiration. * @throws IllegalArgumentException If <i>delay</i> is negative, or if * <code>delay + System.currentTimeMillis()</code> is negative. @@ -104,7 +104,7 @@ public abstract class ExpirableObject * Destroys this object. This method calls {@link #doDestroy}, then, if no * exception is thrown, cancels the task that would destroy this object when * the timeout is reached. - * + * * @throws DestroyFailedException If this operation fails. */ public final void destroy() throws DestroyFailedException @@ -116,7 +116,7 @@ public abstract class ExpirableObject /** * Subclasses must implement this method instead of the {@link * Destroyable#destroy()} method. - * + * * @throws DestroyFailedException If this operation fails. */ protected abstract void doDestroy() throws DestroyFailedException; diff --git a/libjava/classpath/gnu/java/security/util/FormatUtil.java b/libjava/classpath/gnu/java/security/util/FormatUtil.java index eed669cc3a4..35da322b813 100644 --- a/libjava/classpath/gnu/java/security/util/FormatUtil.java +++ b/libjava/classpath/gnu/java/security/util/FormatUtil.java @@ -53,7 +53,7 @@ public class FormatUtil /** * Returns the fully qualified name of the designated encoding ID. - * + * * @param formatID the unique identifier of the encoding format. * @return the fully qualified name of the designated format. Returns * <code>null</code> if no such encoding format is known. @@ -83,7 +83,7 @@ public class FormatUtil /** * Returns the short name of the designated encoding ID. This is used by the * JCE Adapters. - * + * * @param formatID the unique identifier of the encoding format. * @return the short name of the designated format. Returns <code>null</code> * if no such encoding format is known. @@ -112,7 +112,7 @@ public class FormatUtil /** * Returns the identifier of the encoding format given its short name. - * + * * @param name the case-insensitive canonical short name of an encoding * format. * @return the identifier of the designated encoding format, or <code>0</code> @@ -134,7 +134,7 @@ public class FormatUtil result = Registry.X509_ENCODING_ID; else if (name.equalsIgnoreCase(Registry.PKCS8_ENCODING_SHORT_NAME)) result = Registry.PKCS8_ENCODING_ID; - + return result; } } diff --git a/libjava/classpath/gnu/java/security/util/IntegerUtil.java b/libjava/classpath/gnu/java/security/util/IntegerUtil.java index f071308084c..106dc4d6653 100644 --- a/libjava/classpath/gnu/java/security/util/IntegerUtil.java +++ b/libjava/classpath/gnu/java/security/util/IntegerUtil.java @@ -71,7 +71,7 @@ public abstract class IntegerUtil * This method MUST be used in the gnu.java.security and gnu.javax.crypto * packages to ensure they would work with a version 1.4 only of the Java * class library API. - * + * * @param aString a string representation of an integer. * @return the {@link Integer} object representing the designated string. */ @@ -98,7 +98,7 @@ public abstract class IntegerUtil * This method MUST be used in the gnu.java.security and gnu.javax.crypto * packages to ensure they would work with a version 1.4 only of the Java * class library API. - * + * * @param anInt a decimal integer. * @return the {@link Integer} object representing the designated primitive. */ diff --git a/libjava/classpath/gnu/java/security/util/PRNG.java b/libjava/classpath/gnu/java/security/util/PRNG.java index 7bb27cbf452..1bed04dcd0f 100644 --- a/libjava/classpath/gnu/java/security/util/PRNG.java +++ b/libjava/classpath/gnu/java/security/util/PRNG.java @@ -47,7 +47,7 @@ import gnu.java.security.prng.MDGenerator; /** * A useful hash-based (SHA) pseudo-random number generator used throughout this * library. - * + * * @see MDGenerator */ public class PRNG @@ -57,7 +57,7 @@ public class PRNG /** * Private constructor to enforce using the Factory method. - * + * * @param delegate the undelying {@link IRandom} object used. */ private PRNG(IRandom delegate) @@ -93,7 +93,7 @@ public class PRNG /** * Completely fills the designated <code>buffer</code> with random data * generated by the underlying delegate. - * + * * @param buffer the place holder of random bytes generated by the underlying * delegate. On output, the contents of <code>buffer</code> are * replaced with pseudo-random data, iff the <code>buffer</code> @@ -108,7 +108,7 @@ public class PRNG * Fills the designated <code>buffer</code>, starting from byte at position * <code>offset</code> with, at most, <code>length</code> bytes of random * data generated by the underlying delegate. - * + * * @see IRandom#nextBytes */ public void nextBytes(byte[] buffer, int offset, int length) diff --git a/libjava/classpath/gnu/java/security/util/Prime.java b/libjava/classpath/gnu/java/security/util/Prime.java index e493ce67503..82c584ff42a 100644 --- a/libjava/classpath/gnu/java/security/util/Prime.java +++ b/libjava/classpath/gnu/java/security/util/Prime.java @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -55,49 +55,49 @@ public final class Prime BigInteger p = new BigInteger( (pmax + pmin)/2, new Random() ); if( p.compareTo( BigInteger.valueOf( 1 ).shiftLeft( pmin ) ) <= 0 ) { - p = p.add( BigInteger.valueOf( 1 ).shiftLeft( pmin ).subtract( p ) ); + p = p.add( BigInteger.valueOf( 1 ).shiftLeft( pmin ).subtract( p ) ); } - + //Step 2 - test for even if( p.mod( BigInteger.valueOf(2) ).compareTo( BigInteger.valueOf( 0 )) == 0) p = p.add( BigInteger.valueOf( 1 ) ); for(;;) { - //Step 3 - if( p.compareTo( BigInteger.valueOf( 1 ).shiftLeft( pmax)) > 0) - { - //Step 3.1 - p = p.subtract( BigInteger.valueOf( 1 ).shiftLeft( pmax) ); - p = p.add( BigInteger.valueOf( 1 ).shiftLeft( pmin) ); - p = p.subtract( BigInteger.valueOf( 1 ) ); - - //Step 3.2 - // put step 2 code here so looping code is cleaner - //Step 2 - test for even - if( p.mod( BigInteger.valueOf(2) ).compareTo( BigInteger.valueOf( 0 )) == 0) - p = p.add( BigInteger.valueOf( 1 ) ); - continue; - } - - //Step 4 - compute GCD - d = p.subtract( BigInteger.valueOf(1) ); - d = d.gcd( f ); - - //Step 5 - test d - if( d.compareTo( BigInteger.valueOf( 1 ) ) == 0) - { - //Step 5.1 - test primality - if( p.isProbablePrime( 1 ) == true ) - { - //Step 5.2; - return p; - } - } - //Step 6 - p = p.add( BigInteger.valueOf( 2 ) ); - - //Step 7 + //Step 3 + if( p.compareTo( BigInteger.valueOf( 1 ).shiftLeft( pmax)) > 0) + { + //Step 3.1 + p = p.subtract( BigInteger.valueOf( 1 ).shiftLeft( pmax) ); + p = p.add( BigInteger.valueOf( 1 ).shiftLeft( pmin) ); + p = p.subtract( BigInteger.valueOf( 1 ) ); + + //Step 3.2 + // put step 2 code here so looping code is cleaner + //Step 2 - test for even + if( p.mod( BigInteger.valueOf(2) ).compareTo( BigInteger.valueOf( 0 )) == 0) + p = p.add( BigInteger.valueOf( 1 ) ); + continue; + } + + //Step 4 - compute GCD + d = p.subtract( BigInteger.valueOf(1) ); + d = d.gcd( f ); + + //Step 5 - test d + if( d.compareTo( BigInteger.valueOf( 1 ) ) == 0) + { + //Step 5.1 - test primality + if( p.isProbablePrime( 1 ) == true ) + { + //Step 5.2; + return p; + } + } + //Step 6 + p = p.add( BigInteger.valueOf( 2 ) ); + + //Step 7 } } @@ -122,43 +122,43 @@ public final class Prime //Step 4 - test for even if( p.mod( BigInteger.valueOf(2) ).compareTo( BigInteger.valueOf( 0 )) == 0) - p = p.add( r ); + p = p.add( r ); for(;;) - { - //Step 5 - if( p.compareTo( BigInteger.valueOf( 1 ).shiftLeft( pmax)) > 0) - { - //Step 5.1 - p = p.subtract( BigInteger.valueOf( 1 ).shiftLeft( pmax) ); - p = p.add( BigInteger.valueOf( 1 ).shiftLeft( pmin) ); - p = p.subtract( BigInteger.valueOf( 1 ) ); - - //Step 5.2 - goto to Step 2 - break steptwo; - } - - //Step 6 - d = p.subtract( BigInteger.valueOf(1) ); - d = d.gcd( f ); - - //Step 7 - test d - if( d.compareTo( BigInteger.valueOf( 1 ) ) == 0) - { - //Step 7.1 - test primality - if( p.isProbablePrime( 1 ) == true ) - { - //Step 7.2; - return p; - } - } - //Step 8 - p = p.add( r.multiply( BigInteger.valueOf(2) ) ); - - //Step 9 - } + { + //Step 5 + if( p.compareTo( BigInteger.valueOf( 1 ).shiftLeft( pmax)) > 0) + { + //Step 5.1 + p = p.subtract( BigInteger.valueOf( 1 ).shiftLeft( pmax) ); + p = p.add( BigInteger.valueOf( 1 ).shiftLeft( pmin) ); + p = p.subtract( BigInteger.valueOf( 1 ) ); + + //Step 5.2 - goto to Step 2 + break steptwo; + } + + //Step 6 + d = p.subtract( BigInteger.valueOf(1) ); + d = d.gcd( f ); + + //Step 7 - test d + if( d.compareTo( BigInteger.valueOf( 1 ) ) == 0) + { + //Step 7.1 - test primality + if( p.isProbablePrime( 1 ) == true ) + { + //Step 7.2; + return p; + } + } + //Step 8 + p = p.add( r.multiply( BigInteger.valueOf(2) ) ); + + //Step 9 + } } //Should never reach here but makes the compiler happy - return BigInteger.valueOf(0); + return BigInteger.valueOf(0); } } diff --git a/libjava/classpath/gnu/java/security/util/Sequence.java b/libjava/classpath/gnu/java/security/util/Sequence.java index 5e3a64eaf3e..63086d2bd0f 100644 --- a/libjava/classpath/gnu/java/security/util/Sequence.java +++ b/libjava/classpath/gnu/java/security/util/Sequence.java @@ -55,7 +55,7 @@ public final class Sequence * through all positive integers then negative integers until the end value is * reached. Naturally, this will result in an enormous object, so don't do * this. - * + * * @param end The ending value. */ public Sequence(int end) @@ -68,7 +68,7 @@ public final class Sequence * increment of 1. If <i>end</i> is less than <i>start</i>, then the * sequence will wrap around until the end value is reached. Naturally, this * will result in an enormous object, so don't do this. - * + * * @param start The starting value. * @param end The ending value. */ @@ -88,7 +88,7 @@ public final class Sequence * If <i>span</i> is 0, then the sequence will contain {<i>start</i>, * <i>end</i>} if <i>start</i> != <i>end</i>, or just the singleton * <i>start</i> if <i>start</i> == <i>end</i>. - * + * * @param start The starting value. * @param end The ending value. * @param span The increment value. diff --git a/libjava/classpath/gnu/java/security/util/SimpleList.java b/libjava/classpath/gnu/java/security/util/SimpleList.java index 74f3bafcead..15d54c988ab 100644 --- a/libjava/classpath/gnu/java/security/util/SimpleList.java +++ b/libjava/classpath/gnu/java/security/util/SimpleList.java @@ -54,7 +54,7 @@ public final class SimpleList /** * Create a singleton list. - * + * * @param element The first element. */ public SimpleList(final Object element) @@ -65,7 +65,7 @@ public final class SimpleList /** * Create an ordered pair (2-tuple). - * + * * @param e1 The first element. * @param e2 The second element. */ @@ -78,7 +78,7 @@ public final class SimpleList /** * Create a 3-tuple. - * + * * @param e1 The first element. * @param e2 The second element. * @param e3 The third element. @@ -93,7 +93,7 @@ public final class SimpleList /** * Create a 4-tuple. - * + * * @param e1 The first element. * @param e2 The second element. * @param e3 The third element. @@ -121,7 +121,7 @@ public final class SimpleList * Create an n-tuple of arbitrary size. Even if the supplied collection has no * natural order, the created n-tuple will have the order that the elements * are returned by the collection's iterator. - * + * * @param c The collection. */ public SimpleList(Collection c) diff --git a/libjava/classpath/gnu/java/security/util/Util.java b/libjava/classpath/gnu/java/security/util/Util.java index 50d4466d539..ef3d480a0b6 100644 --- a/libjava/classpath/gnu/java/security/util/Util.java +++ b/libjava/classpath/gnu/java/security/util/Util.java @@ -70,7 +70,7 @@ public class Util * <pre> * toString(ba, 0, ba.length); * </pre> - * + * * @param ba the byte array to convert. * @return a string of hexadecimal characters (two for each byte) representing * the designated input byte array. @@ -84,7 +84,7 @@ public class Util * Returns a string of hexadecimal digits from a byte array, starting at * <code>offset</code> and consisting of <code>length</code> bytes. Each * byte is converted to 2 hex symbols; zero(es) included. - * + * * @param ba the byte array to convert. * @param offset the index from which to start considering the bytes to * convert. @@ -114,7 +114,7 @@ public class Util * <pre> * toReversedString(ba, 0, ba.length); * </pre> - * + * * @param ba the byte array to convert. * @return a string of hexadecimal characters (two for each byte) representing * the designated input byte array. @@ -131,7 +131,7 @@ public class Util * <p> * The byte array is treated as a large little-endian integer, and is returned * as a large big-endian integer. - * + * * @param ba the byte array to convert. * @param offset the index from which to start considering the bytes to * convert. @@ -156,7 +156,7 @@ public class Util * <p> * Returns a byte array from a string of hexadecimal digits. * </p> - * + * * @param s a string of hexadecimal ASCII characters * @return the decoded byte array from the input hexadecimal string. */ @@ -179,7 +179,7 @@ public class Util * Returns a byte array from a string of hexadecimal digits, interpreting them * as a large big-endian integer and returning it as a large little-endian * integer. - * + * * @param s a string of hexadecimal ASCII characters * @return the decoded byte array from the input hexadecimal string. */ @@ -201,7 +201,7 @@ public class Util /** * Returns a number from <code>0</code> to <code>15</code> corresponding * to the designated hexadecimal digit. - * + * * @param c a hexadecimal ASCII symbol. */ public static int fromDigit(char c) @@ -219,7 +219,7 @@ public class Util /** * Returns a string of 8 hexadecimal digits (most significant digit first) * corresponding to the unsigned integer <code>n</code>. - * + * * @param n the unsigned integer to convert. * @return a hexadecimal string 8-character long. */ @@ -260,7 +260,7 @@ public class Util /** * Returns a string of 16 hexadecimal digits (most significant digit first) * corresponding to the unsigned long <code>n</code>. - * + * * @param n the unsigned long to convert. * @return a hexadecimal string 16-character long. */ @@ -280,7 +280,7 @@ public class Util * escape character is inserted before every pair of bytes. Useful to * externalise byte arrays that will be constructed later from such strings; * eg. s-box values. - * + * * @throws ArrayIndexOutOfBoundsException if the length is odd. */ public static String toUnicodeString(byte[] ba) @@ -293,7 +293,7 @@ public class Util * escape character is inserted before every pair of bytes. Useful to * externalise byte arrays that will be constructed later from such strings; * eg. s-box values. - * + * * @throws ArrayIndexOutOfBoundsException if the length is odd. */ public static final String toUnicodeString(byte[] ba, int offset, int length) @@ -324,7 +324,7 @@ public class Util * escape character is inserted before every pair of bytes. Useful to * externalise integer arrays that will be constructed later from such * strings; eg. s-box values. - * + * * @throws ArrayIndexOutOfBoundsException if the length is not a multiple of * 4. */ @@ -376,7 +376,7 @@ public class Util * If <code>offset</code> and <code>length</code> are omitted, the whole * array is used. If <code>m</code> is omitted, nothing is prepended to each * line. - * + * * @param data the byte array to be dumped. * @param offset the offset within <i>data</i> to start from. * @param length the number of bytes to dump. @@ -433,7 +433,7 @@ public class Util /** * Returns a string of 2 hexadecimal digits (most significant digit first) * corresponding to the lowest 8 bits of <code>n</code>. - * + * * @param n the byte value to convert. * @return a string of 2 hex characters representing the input. */ @@ -449,7 +449,7 @@ public class Util * '.' (dot) shall be used instead of "+' (plus). * <p> * Used by SASL password file manipulation primitives. - * + * * @param buffer an arbitrary sequence of bytes to represent in Base-64. * @return unpadded (without the '=' character(s)) Base-64 representation of * the input. @@ -525,7 +525,7 @@ public class Util * <p> * Converts a string representing the encoding of some bytes in Base-64 to * their original form. - * + * * @param str the Base-64 encoded representation of some byte(s). * @return the bytes represented by the <code>str</code>. * @throws NumberFormatException if <code>str</code> is <code>null</code>, @@ -597,7 +597,7 @@ public class Util * Treats the input as the MSB representation of a number, and discards * leading zero elements. For efficiency, the input is simply returned if no * leading zeroes are found. - * + * * @param n the {@link BigInteger} to trim. * @return the byte array representation of the designated {@link BigInteger} * with no leading 0-bytes. @@ -618,7 +618,7 @@ public class Util /** * Returns a hexadecimal dump of the trimmed bytes of a {@link BigInteger}. - * + * * @param x the {@link BigInteger} to display. * @return the string representation of the designated {@link BigInteger}. */ |