diff options
Diffstat (limited to 'libjava/classpath/gnu/javax/net')
78 files changed, 704 insertions, 704 deletions
diff --git a/libjava/classpath/gnu/javax/net/ssl/AbstractSessionContext.java b/libjava/classpath/gnu/javax/net/ssl/AbstractSessionContext.java index bdd7f274e06..96a4e6dd090 100644 --- a/libjava/classpath/gnu/javax/net/ssl/AbstractSessionContext.java +++ b/libjava/classpath/gnu/javax/net/ssl/AbstractSessionContext.java @@ -54,7 +54,7 @@ import javax.net.ssl.SSLSessionContext; * be subclassed to add extended functionality to session contexts, such * as by storing sessions in files on disk, or by sharing contexts * across different JVM instances. - * + * * <p>In order to securely store sessions, along with private key data, * the abstract methods {@lnk {@link #load(char[])} and {@link #store(char[])} * come into play. When storing sessions, a session context implementation @@ -62,10 +62,10 @@ import javax.net.ssl.SSLSessionContext; * before either writing the {@link java.io.Serializable} session to the * underlying store, or getting the opaque {@link Session#privateData()} * class from the session, and storing that. - * + * * <p>As a simple example, that writes sessions to some object output * stream: - * + * * <pre> char[] password = ...; ObjectOutputStream out = ...; @@ -75,12 +75,12 @@ import javax.net.ssl.SSLSessionContext; s.prepare(password); out.writeObject(s); }</pre> - * + * * <p>The reverse must be done when deserializing sessions, by using the * {@link Session#repair(char[])} method, possibly by first calling * {@link Session#setPrivateData(java.io.Serializable)} with the read, * opaque private data type. Thus an example of reading may be: - * + * * <pre> char[] password = ...; ObjectInputStream in = ...; @@ -91,19 +91,19 @@ import javax.net.ssl.SSLSessionContext; s.repair(password); addToThisStore(s); }</pre> - * + * * @author Casey Marshall (csm@gnu.org) */ public abstract class AbstractSessionContext implements SSLSessionContext { protected long timeout; - private static Class<? extends AbstractSessionContext> + private static Class<? extends AbstractSessionContext> implClass = SimpleSessionContext.class; /** * Create a new instance of a session context, according to the configured * implementation class. - * + * * @return The new session context. * @throws SSLException If an error occurs in creating the instance. */ @@ -126,12 +126,12 @@ public abstract class AbstractSessionContext implements SSLSessionContext /** * Reconfigure this instance to use a different session context * implementation. - * + * * <p><strong>Note:</strong> this method requires that the caller have * {@link SSLPermission} with target * <code>gnu.javax.net.ssl.AbstractSessionContext</code> and action * <code>setImplClass</code>. - * + * * @param clazz The new implementation class. * @throws SecurityException If the caller does not have permission to * change the session context. @@ -183,7 +183,7 @@ public abstract class AbstractSessionContext implements SSLSessionContext } return s; } - + public final SSLSession getSession(String host, int port) { for (Enumeration e = getIds(); e.hasMoreElements(); ) @@ -203,18 +203,18 @@ public abstract class AbstractSessionContext implements SSLSessionContext int port2 = s.getPeerPort(); if (port != port2) continue; - + // Else, a match. return s; } - + return null; } - + /** * To be implemented by subclasses. Subclasses do not need to check * timeouts in this method. - * + * * @param sessionId The session ID. * @return The session, or <code>null</code> if the requested session * was not found. @@ -225,7 +225,7 @@ public abstract class AbstractSessionContext implements SSLSessionContext { return (int) (timeout / 1000); } - + /** * Load this session store from the underlying media, if supported * by the implementation. @@ -265,7 +265,7 @@ public abstract class AbstractSessionContext implements SSLSessionContext public abstract void remove (byte[] sessionId); /** - * + * */ public final void setSessionTimeout(int seconds) { @@ -273,7 +273,7 @@ public abstract class AbstractSessionContext implements SSLSessionContext throw new IllegalArgumentException("timeout may not be negative"); this.timeout = (long) seconds * 1000; } - + /** * Commit this session store to the underlying media. For session * store implementations that support saving sessions across @@ -285,4 +285,4 @@ public abstract class AbstractSessionContext implements SSLSessionContext * in this store. */ public abstract void store (char[] password) throws SessionStoreException; -}
\ No newline at end of file +} diff --git a/libjava/classpath/gnu/javax/net/ssl/PreSharedKeyManager.java b/libjava/classpath/gnu/javax/net/ssl/PreSharedKeyManager.java index ba6500a27d4..2c9fd2aeae7 100644 --- a/libjava/classpath/gnu/javax/net/ssl/PreSharedKeyManager.java +++ b/libjava/classpath/gnu/javax/net/ssl/PreSharedKeyManager.java @@ -1,4 +1,4 @@ -/* PreSharedKeyManager.java -- +/* PreSharedKeyManager.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -49,6 +49,6 @@ import javax.net.ssl.KeyManager; public interface PreSharedKeyManager extends KeyManager { SecretKey getKey(String name) throws KeyManagementException; - + String chooseIdentityHint(); -}
\ No newline at end of file +} diff --git a/libjava/classpath/gnu/javax/net/ssl/PreSharedKeyManagerParameters.java b/libjava/classpath/gnu/javax/net/ssl/PreSharedKeyManagerParameters.java index 1b1d492b1ae..fe3c9e89b7a 100644 --- a/libjava/classpath/gnu/javax/net/ssl/PreSharedKeyManagerParameters.java +++ b/libjava/classpath/gnu/javax/net/ssl/PreSharedKeyManagerParameters.java @@ -1,4 +1,4 @@ -/* PreSharedKeyManagerParameters.java -- +/* PreSharedKeyManagerParameters.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -51,7 +51,7 @@ public class PreSharedKeyManagerParameters implements ManagerFactoryParameters { private final LinkedHashMap<String, SecretKey> keys; - + public PreSharedKeyManagerParameters() { keys = new LinkedHashMap<String, SecretKey>(); @@ -62,20 +62,20 @@ public class PreSharedKeyManagerParameters name.getClass(); return keys.get(name); } - + public void putKey(String name, SecretKey key) { name.getClass(); key.getClass(); keys.put(name, key); } - + public boolean removeKey(String name) { name.getClass(); return keys.remove(name) != null; } - + public Iterator<String> identities() { return keys.keySet().iterator(); diff --git a/libjava/classpath/gnu/javax/net/ssl/SSLCipherSuite.java b/libjava/classpath/gnu/javax/net/ssl/SSLCipherSuite.java index a3ab8771389..80068e5cbba 100644 --- a/libjava/classpath/gnu/javax/net/ssl/SSLCipherSuite.java +++ b/libjava/classpath/gnu/javax/net/ssl/SSLCipherSuite.java @@ -56,7 +56,7 @@ public abstract class SSLCipherSuite private final byte[] id; private final SSLProtocolVersion version; private Provider provider; - + protected SSLCipherSuite (final String algorithm, final byte[] id, final SSLProtocolVersion version) { @@ -66,20 +66,20 @@ public abstract class SSLCipherSuite this.id = (byte[]) id.clone (); this.version = version; } - + public static final SSLCipherSuite getInstance (SSLProtocolVersion version, byte[] id) throws NoSuchAlgorithmException { return getInstance (version + "-" + ((id[0] & 0xFF) + "/" + (id[1] & 0xFF))); } - + public static final SSLCipherSuite getInstance (SSLProtocolVersion version, byte[] id, Provider provider) throws NoSuchAlgorithmException { return getInstance (version + "-" + (id[0] & 0xFF) + "/" + (id[1] & 0xFF), provider); } - + public static final SSLCipherSuite getInstance (String name) throws NoSuchAlgorithmException { @@ -95,10 +95,10 @@ public abstract class SSLCipherSuite // Ignore. } } - + throw new NoSuchAlgorithmException (SERVICE + ": " + name); } - + public static final SSLCipherSuite getInstance (String name, Provider provider) throws NoSuchAlgorithmException { @@ -117,26 +117,26 @@ public abstract class SSLCipherSuite } return suite; } - + public final String getAlgorithm () { return algorithm; } - + public final byte[] getId () { return (byte[]) id.clone (); } - + public final Provider getProvider () { return provider; } - + public final SSLProtocolVersion getProtocolVersion () { return version; } - + public abstract void encipher (ByteBuffer in, ByteBuffer out); } diff --git a/libjava/classpath/gnu/javax/net/ssl/SSLRecordHandler.java b/libjava/classpath/gnu/javax/net/ssl/SSLRecordHandler.java index 3ce56eab5fe..8a44245ce28 100644 --- a/libjava/classpath/gnu/javax/net/ssl/SSLRecordHandler.java +++ b/libjava/classpath/gnu/javax/net/ssl/SSLRecordHandler.java @@ -97,4 +97,4 @@ public abstract class SSLRecordHandler { return contentType & 0xFF; } -}
\ No newline at end of file +} diff --git a/libjava/classpath/gnu/javax/net/ssl/Session.java b/libjava/classpath/gnu/javax/net/ssl/Session.java index 09b50eef069..3acf9932d48 100644 --- a/libjava/classpath/gnu/javax/net/ssl/Session.java +++ b/libjava/classpath/gnu/javax/net/ssl/Session.java @@ -69,7 +69,7 @@ public abstract class Session implements SSLSession, Serializable protected final long creationTime; protected long lastAccessedTime; protected int applicationBufferSize; - + protected ID sessionId; protected Certificate[] localCerts; protected Certificate[] peerCerts; @@ -141,12 +141,12 @@ public abstract class Session implements SSLSession, Serializable } return null; } - + public int getPacketBufferSize() { return applicationBufferSize + 2048; } - + public Certificate[] getPeerCertificates() throws SSLPeerUnverifiedException { if (!peerVerified) @@ -165,17 +165,17 @@ public abstract class Session implements SSLSession, Serializable return null; return (X509Certificate[]) peerCertChain.clone(); } - + public String getPeerHost() { return peerHost; } - + public int getPeerPort() { return peerPort; } - + public Principal getPeerPrincipal() throws SSLPeerUnverifiedException { if (!peerVerified) @@ -184,33 +184,33 @@ public abstract class Session implements SSLSession, Serializable return null; return peerCertChain[0].getSubjectDN(); } - + public SSLSessionContext getSessionContext() { return context; } - + public String[] getValueNames() { Set<String> keys = this.values.keySet(); return keys.toArray(new String[keys.size()]); } - + public Object getValue(String name) { return values.get(name); } - + public void invalidate() { valid = false; } - + public boolean isValid() { return valid; } - + public void putValue(String name, Object value) { values.put(name, value); @@ -224,7 +224,7 @@ public abstract class Session implements SSLSession, Serializable { } } - + public void removeValue(String name) { Object value = values.remove(name); @@ -236,9 +236,9 @@ public abstract class Session implements SSLSession, Serializable } catch (Exception x) { - } + } } - + public final boolean isTruncatedMac() { return truncatedMac; @@ -248,31 +248,31 @@ public abstract class Session implements SSLSession, Serializable * Prepare this session for serialization. Private data will be encrypted * with the given password, and this object will then be ready to be * serialized. - * + * * @param password The password to protect this session with. * @throws SSLException If encrypting this session's private data fails. */ public abstract void prepare (char[] password) throws SSLException; - + /** * Repair this session's private data after deserialization. This method * will decrypt this session's private data, and prepare the session for * use in new SSL connections. - * + * * @param password The password to decrypt the private data with. * @throws SSLException */ public abstract void repair(char[] password) throws SSLException; - + /** * Get the private data of this session. This method may only be called * after first calling {@link #prepare(char[])}. - * + * * @return The sealed private data. * @throws SSLException If the private data have not been sealed. */ public abstract SealedObject privateData() throws SSLException; - + /** * Set the private data of this session. * @param data diff --git a/libjava/classpath/gnu/javax/net/ssl/SessionStoreException.java b/libjava/classpath/gnu/javax/net/ssl/SessionStoreException.java index 5dcf3d02887..4d8ef97d08d 100644 --- a/libjava/classpath/gnu/javax/net/ssl/SessionStoreException.java +++ b/libjava/classpath/gnu/javax/net/ssl/SessionStoreException.java @@ -46,12 +46,12 @@ public class SessionStoreException extends SSLException { super (message); } - + public SessionStoreException (final String message, final Throwable cause) { super (message, cause); } - + public SessionStoreException (final Throwable cause) { super (cause); diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/AbstractHandshake.java b/libjava/classpath/gnu/javax/net/ssl/provider/AbstractHandshake.java index d80a5bb789b..bf03ed77fe4 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/AbstractHandshake.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/AbstractHandshake.java @@ -97,9 +97,9 @@ public abstract class AbstractHandshake protected static final byte[] SERVER_FINISHED = new byte[] { 115, 101, 114, 118, 101, 114, 32, 102, 105, 110, 105, 115, - 104, 101, 100 + 104, 101, 100 }; - + /** * "client finished" -- TLS 1.0 and later */ @@ -108,14 +108,14 @@ public abstract class AbstractHandshake 99, 108, 105, 101, 110, 116, 32, 102, 105, 110, 105, 115, 104, 101, 100 }; - + /** * "key expansion" -- TLS 1.0 and later */ private static final byte[] KEY_EXPANSION = new byte[] { 107, 101, 121, 32, 101, 120, 112, 97, 110, 115, 105, 111, 110 }; - + /** * "master secret" -- TLS 1.0 and later */ @@ -123,7 +123,7 @@ public abstract class AbstractHandshake = new byte[] { 109, 97, 115, 116, 101, 114, 32, 115, 101, 99, 114, 101, 116 }; - + /** * "client write key" -- TLS 1.0 exportable whitener. */ @@ -132,7 +132,7 @@ public abstract class AbstractHandshake 99, 108, 105, 101, 110, 116, 32, 119, 114, 105, 116, 101, 32, 107, 101, 121 }; - + /** * "server write key" -- TLS 1.0 exportable whitener. */ @@ -141,30 +141,30 @@ public abstract class AbstractHandshake 115, 101, 114, 118, 101, 114, 32, 119, 114, 105, 116, 101, 32, 107, 101, 121 }; - + private static final byte[] IV_BLOCK = new byte[] { 73, 86, 32, 98, 108, 111, 99, 107 }; - + /** * SSL 3.0; the string "CLNT" */ private static final byte[] SENDER_CLIENT = new byte[] { 0x43, 0x4C, 0x4E, 0x54 }; - + /** * SSL 3.0; the string "SRVR" */ private static final byte[] SENDER_SERVER = new byte[] { 0x53, 0x52, 0x56, 0x52 }; - + /** * SSL 3.0; the value 0x36 40 (for SHA-1 hashes) or 48 (for MD5 hashes) * times. */ protected static final byte[] PAD1 = new byte[48]; - + /** * SSL 3.0; the value 0x5c 40 (for SHA-1 hashes) or 48 (for MD5 hashes) * times. @@ -176,7 +176,7 @@ public abstract class AbstractHandshake Arrays.fill(PAD1, SSLHMac.PAD1); Arrays.fill(PAD2, SSLHMac.PAD2); } - + /** * The currently-read handshake messages. There may be zero, or * multiple, handshake messages in this buffer. @@ -191,7 +191,7 @@ public abstract class AbstractHandshake protected MessageDigest sha; protected MessageDigest md5; - + protected final SSLEngineImpl engine; protected KeyAgreement keyAgreement; protected byte[] preMasterSecret; @@ -210,7 +210,7 @@ public abstract class AbstractHandshake md5 = MessageDigest.getInstance("MD5"); tasks = new LinkedList<DelegatedTask>(); } - + /** * Handles the next input message in the handshake. This is called * in response to a call to {@link javax.net.ssl.SSLEngine#unwrap} @@ -265,13 +265,13 @@ public abstract class AbstractHandshake /** * Called to process more handshake data. This method will be called * repeatedly while there is remaining handshake data, and while the - * status is + * status is * @return * @throws SSLException */ protected abstract HandshakeStatus implHandleInput() throws SSLException; - + /** * Produce more handshake output. This is called in response to a * call to {@link javax.net.ssl.SSLEngine#wrap}, when the handshake @@ -301,27 +301,27 @@ public abstract class AbstractHandshake } return status; } - + /** * Called to implement the underlying output handling. The callee should * attempt to fill the given buffer as much as it can; this can include * multiple, and even partial, handshake messages. - * + * * @param fragment The buffer the callee should write handshake messages to. * @return The new status of the handshake. * @throws SSLException If an error occurs processing the output message. */ protected abstract SSLEngineResult.HandshakeStatus implHandleOutput (ByteBuffer fragment) throws SSLException; - + /** * Return a new instance of input security parameters, initialized with * the session key. It is, of course, only valid to invoke this method * once the handshake is complete, and the session keys established. - * + * * <p>In the presence of a well-behaving peer, this should be called once * the <code>ChangeCipherSpec</code> message is recieved. - * + * * @return The input parameters for the newly established session. * @throws SSLException If the handshake is not complete. */ @@ -335,7 +335,7 @@ public abstract class AbstractHandshake * Return a new instance of output security parameters, initialized with * the session key. This should be called after the * <code>ChangeCipherSpec</code> message is sent to the peer. - * + * * @return The output parameters for the newly established session. * @throws SSLException If the handshake is not complete. */ @@ -344,7 +344,7 @@ public abstract class AbstractHandshake checkKeyExchange(); return outParams; } - + /** * Fetch a delegated task waiting to run, if any. * @@ -356,21 +356,21 @@ public abstract class AbstractHandshake return null; return tasks.removeFirst(); } - + /** * Used by the skeletal code to query the current status of the handshake. * This <em>should</em> be the same value as returned by the previous call * to {@link #implHandleOutput(ByteBuffer)} or {@link * #implHandleInput(ByteBuffer)}. - * + * * @return The current handshake status. */ abstract HandshakeStatus status(); - + /** * Check if the key exchange completed successfully, throwing an exception * if not. - * + * * <p>Note that we assume that the caller of our SSLEngine is correct, and * that they did run the delegated tasks that encapsulate the key exchange. * What we are primarily checking, therefore, is that no error occurred in the @@ -379,14 +379,14 @@ public abstract class AbstractHandshake * @throws SSLException If the key exchange did not complete successfully. */ abstract void checkKeyExchange() throws SSLException; - + /** * Handle an SSLv2 client hello. This is only used by SSL servers. - * + * * @param hello The hello message. */ abstract void handleV2Hello(ByteBuffer hello) throws SSLException; - + /** * Attempt to read the next handshake message from the given * record. If only a partial handshake message is available, then @@ -418,13 +418,13 @@ public abstract class AbstractHandshake if (Debug.DEBUG) logger.logv(Component.SSL_HANDSHAKE, "inserting {0} into {1}", fragment, handshakeBuffer); - + // Put the fragment into the buffer. handshakeBuffer.put(fragment); return hasMessage(); } - + protected boolean doHash() { return true; @@ -501,9 +501,9 @@ public abstract class AbstractHandshake * algorithm was used to generate this value was subtly different than * that used in TLSv1.0 and later. In TLSv1.0 and later, this value is * just the digest over the handshake messages. - * + * * <p>SSLv3 uses the algorithm: - * + * * <pre> CertificateVerify.signature.md5_hash MD5(master_secret + pad_2 + @@ -511,7 +511,7 @@ CertificateVerify.signature.md5_hash Certificate.signature.sha_hash SHA(master_secret + pad_2 + SHA(handshake_messages + master_secret + pad_1));</pre> - * + * * @param md5 The running MD5 hash of the handshake. * @param sha The running SHA-1 hash of the handshake. * @param session The current session being negotiated. @@ -533,7 +533,7 @@ Certificate.signature.sha_hash md5.update(tmp); md5value = md5.digest(); } - + sha.update(session.privateData.masterSecret); sha.update(PAD1, 0, 40); byte[] tmp = sha.digest(); @@ -542,16 +542,16 @@ Certificate.signature.sha_hash sha.update(PAD2, 0, 40); sha.update(tmp); byte[] shavalue = sha.digest(); - + if (md5value != null) return Util.concat(md5value, shavalue); - + return shavalue; } - + /** * Generate the session keys from the computed master secret. - * + * * @param clientRandom The client's nonce. * @param serverRandom The server's nonce. * @param session The session being established. @@ -570,7 +570,7 @@ Certificate.signature.sha_hash if (session.suite.cipherAlgorithm() == CipherAlgorithm.AES) ivlen = 16; int keylen = session.suite.keyLength(); - + byte[][] keys = new byte[6][]; keys[0] = new byte[maclen]; // client_write_MAC_secret keys[1] = new byte[maclen]; // server_write_MAC_secret @@ -578,7 +578,7 @@ Certificate.signature.sha_hash keys[3] = new byte[keylen]; // server_write_key keys[4] = new byte[ivlen]; // client_write_iv keys[5] = new byte[ivlen]; // server_write_iv - + IRandom prf = null; if (session.version == ProtocolVersion.SSL_3) { @@ -604,14 +604,14 @@ Certificate.signature.sha_hash clientRandom.buffer().get(seed, (KEY_EXPANSION.length + serverRandom.length()), clientRandom.length()); - + prf = new TLSRandom(); HashMap<String,byte[]> attr = new HashMap<String,byte[]>(2); attr.put(TLSRandom.SECRET, session.privateData.masterSecret); attr.put(TLSRandom.SEED, seed); prf.init(attr); } - + try { prf.nextBytes(keys[0], 0, keys[0].length); @@ -666,7 +666,7 @@ Certificate.signature.sha_hash prf2.init(attr); keys[2] = new byte[8]; prf2.nextBytes(keys[2], 0, keys[2].length); - + attr.put(TLSRandom.SECRET, keys[3]); seed = new byte[SERVER_WRITE_KEY.length + serverRandom.length() + @@ -682,7 +682,7 @@ Certificate.signature.sha_hash prf2.init(attr); keys[3] = new byte[8]; prf2.nextBytes(keys[3], 0, keys[3].length); - + attr.put(TLSRandom.SECRET, new byte[0]); seed = new byte[IV_BLOCK.length + clientRandom.length() + @@ -714,7 +714,7 @@ Certificate.signature.sha_hash { throw new Error(nsae); } - + if (Debug.DEBUG_KEY_EXCHANGE) logger.logv(Component.SSL_KEY_EXCHANGE, "keys generated;\n [0]: {0}\n [1]: {1}\n [2]: {2}\n" + @@ -727,12 +727,12 @@ Certificate.signature.sha_hash Util.toHexString(keys[5], ':')); return keys; } - + /** * Generate a "finished" message. The hashes passed in are modified * by this function, so they should be clone copies of the digest if * the hash function needs to be used more. - * + * * @param md5 The MD5 computation. * @param sha The SHA-1 computation. * @param isClient Whether or not the client-side finished message is @@ -797,22 +797,22 @@ Certificate.signature.sha_hash // finishedBuffer = ByteBuffer.allocate(36); - + md5.update(isClient ? SENDER_CLIENT : SENDER_SERVER); md5.update(session.privateData.masterSecret); md5.update(PAD1); - + byte[] tmp = md5.digest(); md5.reset(); md5.update(session.privateData.masterSecret); md5.update(PAD2); md5.update(tmp); finishedBuffer.put(md5.digest()); - + sha.update(isClient ? SENDER_CLIENT : SENDER_SERVER); sha.update(session.privateData.masterSecret); sha.update(PAD1, 0, 40); - + tmp = sha.digest(); sha.reset(); sha.update(session.privateData.masterSecret); @@ -822,7 +822,7 @@ Certificate.signature.sha_hash } return finishedBuffer; } - + protected void initDiffieHellman(DHPrivateKey dhKey, SecureRandom random) throws SSLException { @@ -840,7 +840,7 @@ Certificate.signature.sha_hash throw new SSLException(nsae); } } - + protected void generateMasterSecret(Random clientRandom, Random serverRandom, SessionImpl session) @@ -849,11 +849,11 @@ Certificate.signature.sha_hash assert(clientRandom != null); assert(serverRandom != null); assert(session != null); - + if (Debug.DEBUG_KEY_EXCHANGE) logger.logv(Component.SSL_KEY_EXCHANGE, "preMasterSecret:\n{0}", new ByteArray(preMasterSecret)); - + if (session.version == ProtocolVersion.SSL_3) { try @@ -861,7 +861,7 @@ Certificate.signature.sha_hash MessageDigest _md5 = MessageDigest.getInstance("MD5"); MessageDigest _sha = MessageDigest.getInstance("SHA"); session.privateData.masterSecret = new byte[48]; - + _sha.update((byte) 'A'); _sha.update(preMasterSecret); _sha.update(clientRandom.buffer()); @@ -869,7 +869,7 @@ Certificate.signature.sha_hash _md5.update(preMasterSecret); _md5.update(_sha.digest()); _md5.digest(session.privateData.masterSecret, 0, 16); - + _sha.update((byte) 'B'); _sha.update((byte) 'B'); _sha.update(preMasterSecret); @@ -914,20 +914,20 @@ Certificate.signature.sha_hash attr.put(TLSRandom.SECRET, preMasterSecret); attr.put(TLSRandom.SEED, seed); prf.init(attr); - + session.privateData.masterSecret = new byte[48]; prf.nextBytes(session.privateData.masterSecret, 0, 48); } - + if (Debug.DEBUG_KEY_EXCHANGE) logger.log(Component.SSL_KEY_EXCHANGE, "master_secret: {0}", new ByteArray(session.privateData.masterSecret)); - + // Wipe out the preMasterSecret. for (int i = 0; i < preMasterSecret.length; i++) preMasterSecret[i] = 0; } - + protected void setupSecurityParameters(byte[][] keys, boolean isClient, SSLEngineImpl engine, CompressionMethod compression) @@ -943,7 +943,7 @@ Certificate.signature.sha_hash Cipher inCipher = s.cipher(); Mac inMac = s.mac(engine.session().version); Inflater inflater = (compression == CompressionMethod.ZLIB - ? new Inflater() : null); + ? new Inflater() : null); inCipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(keys[isClient ? 3 : 2], s.cipherAlgorithm().toString()), @@ -953,7 +953,7 @@ Certificate.signature.sha_hash inParams = new InputSecurityParameters(inCipher, inMac, inflater, engine.session(), s); - + Cipher outCipher = s.cipher(); Mac outMac = s.mac(engine.session().version); Deflater deflater = (compression == CompressionMethod.ZLIB @@ -1025,23 +1025,23 @@ Certificate.signature.sha_hash preMasterSecret[6] = (byte) engine.session().random().nextInt(); preMasterSecret[7] = (byte) engine.session().random().nextInt(); } - + if (Debug.DEBUG_KEY_EXCHANGE) logger.logv(Component.SSL_KEY_EXCHANGE, "PSK identity {0} key {1}", identity, key); - + generateMasterSecret(clientRandom, serverRandom, engine.session()); byte[][] keys = generateKeys(clientRandom, serverRandom, engine.session()); setupSecurityParameters(keys, isClient, engine, compression); } - + protected class DHPhase extends DelegatedTask { private final DHPublicKey key; private final boolean full; - + protected DHPhase(DHPublicKey key) { this(key, true); @@ -1065,7 +1065,7 @@ Certificate.signature.sha_hash } } } - + protected class CertVerifier extends DelegatedTask { private final boolean clientSide; @@ -1077,12 +1077,12 @@ Certificate.signature.sha_hash this.clientSide = clientSide; this.chain = chain; } - + boolean verified() { return verified; } - + protected void implRun() { X509TrustManager tm = engine.contextImpl.trustManager; @@ -1153,18 +1153,18 @@ Certificate.signature.sha_hash verified = false; } } - + if (verified) engine.session().setPeerVerified(true); } } - + protected class DHE_PSKGen extends DelegatedTask { private final DHPublicKey dhKey; private final SecretKey psKey; private final boolean isClient; - + protected DHE_PSKGen(DHPublicKey dhKey, SecretKey psKey, boolean isClient) { this.dhKey = dhKey; @@ -1187,7 +1187,7 @@ Certificate.signature.sha_hash psSecret = new byte[8]; engine.session().random().nextBytes(psSecret); } - + preMasterSecret = new byte[dhSecret.length + psSecret.length + 4]; preMasterSecret[0] = (byte) (dhSecret.length >>> 8); preMasterSecret[1] = (byte) dhSecret.length; @@ -1196,10 +1196,10 @@ Certificate.signature.sha_hash preMasterSecret[dhSecret.length + 3] = (byte) psSecret.length; System.arraycopy(psSecret, 0, preMasterSecret, dhSecret.length + 4, psSecret.length); - + generateMasterSecret(clientRandom, serverRandom, engine.session()); byte[][] keys = generateKeys(clientRandom, serverRandom, engine.session()); setupSecurityParameters(keys, isClient, engine, compression); } } -}
\ No newline at end of file +} diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/Alert.java b/libjava/classpath/gnu/javax/net/ssl/provider/Alert.java index 12c86b0a402..0ceb96bbb85 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/Alert.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/Alert.java @@ -73,7 +73,7 @@ public final class Alert implements Constructed { this.buffer = buffer; } - + public Alert (final Level level, final Description description) { level.getClass (); @@ -171,7 +171,7 @@ public final class Alert implements Constructed { WARNING (1), FATAL (2); - + private final int value; private Level(int value) @@ -231,7 +231,7 @@ public final class Alert implements Constructed BAD_CERTIFICATE_HASH_VALUE (114), UNKNOWN_SRP_USERNAME (120), MISSING_SRP_USERNAME (121); - + private final int value; private Description(int value) diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/AlertException.java b/libjava/classpath/gnu/javax/net/ssl/provider/AlertException.java index 291de2700c9..90eaaf4306c 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/AlertException.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/AlertException.java @@ -66,14 +66,14 @@ public class AlertException extends SSLException { this(alert, true); } - + public AlertException(Alert alert, boolean isLocal, Throwable cause) { super(alert.description().toString(), cause); this.alert = alert; this.isLocal = isLocal; } - + public AlertException(Alert alert, Throwable cause) { this(alert, true, cause); @@ -93,7 +93,7 @@ public class AlertException extends SSLException { return alert; } - + public boolean isLocal() { return isLocal; diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/Builder.java b/libjava/classpath/gnu/javax/net/ssl/provider/Builder.java index baaba8aecf6..070c51b7614 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/Builder.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/Builder.java @@ -46,11 +46,11 @@ import java.nio.ByteBuffer; * buffer that grows to fit the object being built; the allocated size of * this buffer may be larger than the built object needs, but the general * effort will be not to allocate too large a buffer. - * + * * <p>Once the object is built, through various <em>setters</em> for * the object's attributes, the final buffer may be retrieved with the * {@link #buffer()} method. - * + * * @author Casey Marshall (csm@gnu.org) */ public interface Builder extends Constructed @@ -59,7 +59,7 @@ public interface Builder extends Constructed * Returns the final buffer, possibly containing the built object. The * returned buffer will be "trimmed" to size: its position will be zero, * and its limit and capacity set to the length of the built object. - * + * * @return The underlying buffer. */ ByteBuffer buffer(); diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/Certificate.java b/libjava/classpath/gnu/javax/net/ssl/provider/Certificate.java index 8ff91e5579e..68de1304dfd 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/Certificate.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/Certificate.java @@ -57,7 +57,7 @@ import java.util.List; /** * The certificate object. This is used by both the client and the server * to send their certificates (if any) to one another. - * + * * <pre>opaque ASN.1Cert<1..2^24-1>; struct { diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/CertificateBuilder.java b/libjava/classpath/gnu/javax/net/ssl/provider/CertificateBuilder.java index b60ad556ac9..1126e6fcc79 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/CertificateBuilder.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/CertificateBuilder.java @@ -1,4 +1,4 @@ -/* CertificateBuilder.java -- +/* CertificateBuilder.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -46,7 +46,7 @@ import java.security.cert.CertificateException; /** * Builder for {@link Certificate} objects. - * + * * @author Casey Marshall (csm@gnu.org) */ public class CertificateBuilder extends Certificate implements Builder diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/CertificateRequest.java b/libjava/classpath/gnu/javax/net/ssl/provider/CertificateRequest.java index b7a22b20400..fd9d65be5db 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/CertificateRequest.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/CertificateRequest.java @@ -62,7 +62,7 @@ public class CertificateRequest implements Handshake.Body // ------------------------------------------------------------------------- protected ByteBuffer buffer; - + // Constructor. // ------------------------------------------------------------------------- diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/CertificateRequestBuilder.java b/libjava/classpath/gnu/javax/net/ssl/provider/CertificateRequestBuilder.java index 8c059854e4a..f32c52acfa3 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/CertificateRequestBuilder.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/CertificateRequestBuilder.java @@ -1,4 +1,4 @@ -/* CertificateRequestBuilder.java -- +/* CertificateRequestBuilder.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -47,7 +47,7 @@ import javax.security.auth.x500.X500Principal; /** * Builder for {@link CertificateRequest} objects. - * + * * @author Casey Marshall (csm@gnu.org) */ public class CertificateRequestBuilder extends CertificateRequest @@ -74,7 +74,7 @@ public class CertificateRequestBuilder extends CertificateRequest for (ClientCertificateType type : types) b.put((byte) type.getValue()); } - + public void setAuthorities(List<X500Principal> authorities) { ByteArrayOutputStream out = new ByteArrayOutputStream(1024); @@ -99,7 +99,7 @@ public class CertificateRequestBuilder extends CertificateRequest buffer.putShort(typesLen, (short) auths.length); ((ByteBuffer) buffer.duplicate().position(typesLen + 2)).put(auths); } - + public void ensureCapacity(final int capacity) { if (buffer.capacity() >= capacity) diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/CertificateStatusRequest.java b/libjava/classpath/gnu/javax/net/ssl/provider/CertificateStatusRequest.java index 059c6ec47ba..e66373620ec 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/CertificateStatusRequest.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/CertificateStatusRequest.java @@ -71,12 +71,12 @@ opaque Extensions<0..2^16-1>;</pre> public class CertificateStatusRequest extends Value implements Iterable<byte[]> { private ByteBuffer buffer; - + public CertificateStatusRequest(final ByteBuffer buffer) { this.buffer = buffer; } - + public CertificateStatusRequest(CertificateStatusType type, List<byte[]> responderIdList, byte[] requestExtensions) @@ -106,12 +106,12 @@ public class CertificateStatusRequest extends Value implements Iterable<byte[]> int l = 3 + (buffer.getShort(1) & 0xFFFF); return l + (buffer.getShort(l) & 0xFFFF) + 2; } - + public ByteBuffer buffer() { return (ByteBuffer) buffer.duplicate().limit(length()); } - + public CertificateStatusType statusType() { int x = buffer.get(0) & 0xFF; @@ -132,7 +132,7 @@ public class CertificateStatusRequest extends Value implements Iterable<byte[]> } return n; } - + public byte[] responderId(int index) { int len = buffer.getShort(1) & 0xFFFF; @@ -152,7 +152,7 @@ public class CertificateStatusRequest extends Value implements Iterable<byte[]> } throw new IndexOutOfBoundsException(); } - + public byte[] requestExtensions() { int l = 2 + (buffer.getShort(0) & 0xFFFF); @@ -161,19 +161,19 @@ public class CertificateStatusRequest extends Value implements Iterable<byte[]> ((ByteBuffer) buffer.duplicate().position(ll+2)).get(b); return b; } - + public void setStatusType(CertificateStatusType type) { buffer.put(0, (byte) type.value); } - + public void setRequestIdListLength(int newLength) { if (newLength < 0 || newLength > 0xFFFF) throw new IllegalArgumentException("length out of range"); buffer.putShort(1, (short) newLength); } - + public void putRequestId(int index, byte[] id) { if (id.length > 0xFFFF) @@ -192,7 +192,7 @@ public class CertificateStatusRequest extends Value implements Iterable<byte[]> buffer.putShort(i, (short) id.length); ((ByteBuffer) buffer.duplicate().position(i)).put(id); } - + public void setRequestExtensions(int index, byte[] ext) { if (ext.length > 0xFFFF) @@ -201,17 +201,17 @@ public class CertificateStatusRequest extends Value implements Iterable<byte[]> buffer.putShort(off, (short) ext.length); ((ByteBuffer) buffer.duplicate().position(off+2)).put(ext); } - + public Iterator<byte[]> iterator() { return new ResponderIdIterator(); } - + public String toString() { return toString(null); } - + public String toString(String prefix) { StringWriter str = new StringWriter(); @@ -237,16 +237,16 @@ public class CertificateStatusRequest extends Value implements Iterable<byte[]> out.print("} CertificateStatus;"); return str.toString(); } - + public class ResponderIdIterator implements Iterator<byte[]> { private int index; - + public ResponderIdIterator() { index = 0; } - + public byte[] next() throws NoSuchElementException { try @@ -258,12 +258,12 @@ public class CertificateStatusRequest extends Value implements Iterable<byte[]> throw new NoSuchElementException(); } } - + public boolean hasNext() { return index < size(); } - + public void remove() { throw new UnsupportedOperationException(); diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/CertificateStatusType.java b/libjava/classpath/gnu/javax/net/ssl/provider/CertificateStatusType.java index 7cddf168f94..0d52b27781c 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/CertificateStatusType.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/CertificateStatusType.java @@ -3,9 +3,9 @@ package gnu.javax.net.ssl.provider; public enum CertificateStatusType { OCSP (1); - + public final int value; - + private CertificateStatusType (final int value) { this.value = value; diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/CertificateURL.java b/libjava/classpath/gnu/javax/net/ssl/provider/CertificateURL.java index 0bc1c428b48..737efcacdb7 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/CertificateURL.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/CertificateURL.java @@ -52,7 +52,7 @@ import java.util.NoSuchElementException; /** * The CertificateURL extension value. - * + * * <pre> enum { individual_certs(0), pkipath(1), (255) @@ -84,12 +84,12 @@ opaque SHA1Hash[20];</pre> public class CertificateURL extends Value implements Iterable<CertificateURL.URLAndOptionalHash> { private ByteBuffer buffer; - + public CertificateURL(final ByteBuffer buffer) { this.buffer = buffer; } - + public CertificateURL(CertChainType type, List<URLAndOptionalHash> urls) { int length = 3; @@ -102,12 +102,12 @@ public class CertificateURL extends Value implements Iterable<CertificateURL.URL buffer.put(url.buffer()); buffer.rewind(); } - + public int length() { return 3 + (buffer.getShort(1) & 0xFFFF); } - + public ByteBuffer buffer() { return (ByteBuffer) buffer.duplicate().limit(length()); @@ -122,7 +122,7 @@ public class CertificateURL extends Value implements Iterable<CertificateURL.URL } throw new IllegalArgumentException("unknown certificate URL type"); } - + public int size() { int len = buffer.getShort(1) & 0xFFFF; @@ -137,7 +137,7 @@ public class CertificateURL extends Value implements Iterable<CertificateURL.URL } return n; } - + public URLAndOptionalHash get(int index) { int len = buffer.getShort(1) & 0xFFFF; @@ -156,7 +156,7 @@ public class CertificateURL extends Value implements Iterable<CertificateURL.URL throw new IndexOutOfBoundsException(); return new URLAndOptionalHash(((ByteBuffer) buffer.duplicate().position(i).limit(i+l)).slice()); } - + public void set(int index, URLAndOptionalHash url) { int len = buffer.getShort(1) & 0xFFFF; @@ -179,19 +179,19 @@ public class CertificateURL extends Value implements Iterable<CertificateURL.URL if (url.hashPresent()) ((ByteBuffer) buffer.duplicate().position(i+l+3)).put (url.sha1Hash()); } - + public void setLength(final int length) { if (length < 0 || length > 65535) throw new IllegalArgumentException("length must be between 0 and 65535"); buffer.putShort(1, (short) length); } - + public String toString() { return toString(null); } - + public String toString(String prefix) { StringWriter str = new StringWriter(); @@ -221,16 +221,16 @@ public class CertificateURL extends Value implements Iterable<CertificateURL.URL { return new Iterator(); } - + public class Iterator implements java.util.Iterator<URLAndOptionalHash> { private int index; - + public Iterator() { index = 0; } - + public URLAndOptionalHash next() throws NoSuchElementException { try @@ -242,49 +242,49 @@ public class CertificateURL extends Value implements Iterable<CertificateURL.URL throw new NoSuchElementException(); } } - + public boolean hasNext() { return index < size(); } - + public void remove() { throw new UnsupportedOperationException(); } } - + public static enum CertChainType { INDIVIDUAL_CERTS (0), PKIPATH (1); - + private final int value; - + private CertChainType (final int value) { this.value = value; } - + public int getValue() { return value; } } - + public static class URLAndOptionalHash implements Builder, Constructed { private ByteBuffer buffer; - + public URLAndOptionalHash (final ByteBuffer buffer) { this.buffer = buffer.duplicate().order(ByteOrder.BIG_ENDIAN); } - + public URLAndOptionalHash(String url) { this(url, null); } - + public URLAndOptionalHash(String url, byte[] hash) { if (hash != null && hash.length < 20) @@ -302,35 +302,35 @@ public class CertificateURL extends Value implements Iterable<CertificateURL.URL buffer.put(hash, 0, 20); buffer.rewind(); } - + public int length() { return ((buffer.getShort(0) & 0xFFFF) + (hashPresent() ? 23 : 3)); } - + public ByteBuffer buffer() { return (ByteBuffer) buffer.duplicate().limit(length()); } - + public String url() { Charset cs = Charset.forName("ASCII"); return cs.decode(urlBuffer()).toString(); } - + public int urlLength() { return buffer.getShort(0) & 0xFFFF; } - + public ByteBuffer urlBuffer() { int len = urlLength(); return ((ByteBuffer) buffer.duplicate().position(2).limit(2+len)).slice(); } - + public boolean hashPresent() { int i = (buffer.getShort(0) & 0xFFFF) + 2; @@ -341,7 +341,7 @@ public class CertificateURL extends Value implements Iterable<CertificateURL.URL return true; throw new IllegalArgumentException("expecting 0 or 1: " + (b & 0xFF)); } - + public byte[] sha1Hash() { int i = (buffer.getShort(0) & 0xFFFF) + 2; @@ -352,12 +352,12 @@ public class CertificateURL extends Value implements Iterable<CertificateURL.URL ((ByteBuffer) buffer.duplicate().position(i+1)).get(buf); return buf; } - + public String toString() { return toString(null); } - + public String toString(final String prefix) { StringWriter str = new StringWriter(); diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/CertificateVerify.java b/libjava/classpath/gnu/javax/net/ssl/provider/CertificateVerify.java index b63f5e4ef0c..dfa5f602884 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/CertificateVerify.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/CertificateVerify.java @@ -52,7 +52,7 @@ public class CertificateVerify extends Signature implements Handshake.Body { super(buffer, sigAlg); } - + public CertificateVerify(final byte[] sigVal, final SignatureAlgorithm sigAlg) { super(sigVal, sigAlg); diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/CipherSuite.java b/libjava/classpath/gnu/javax/net/ssl/provider/CipherSuite.java index af3041e9403..1c59231290b 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/CipherSuite.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/CipherSuite.java @@ -313,7 +313,7 @@ public final class CipherSuite implements Constructed SignatureAlgorithm.DSA, MacAlgorithm.SHA, 32, 0x00, 0x58, "TLS_SRP_SHA_DSS_WITH_AES_256_CBC_SHA");*/ - + // Pre-shared key suites. public static final CipherSuite TLS_PSK_WITH_RC4_128_SHA = new CipherSuite(CipherAlgorithm.RC4, @@ -364,7 +364,7 @@ public final class CipherSuite implements Constructed SignatureAlgorithm.ANONYMOUS, MacAlgorithm.SHA, 32, 0x00, 0x91, "TLS_DHE_PSK_WITH_AES_256_CBC_SHA"); - + public static final CipherSuite TLS_RSA_PSK_WITH_RC4_128_SHA = new CipherSuite(CipherAlgorithm.RC4, KeyExchangeAlgorithm.RSA_PSK, @@ -629,7 +629,7 @@ public final class CipherSuite implements Constructed throw new NoSuchAlgorithmException(toString() + ": unresolved cipher suite"); if (macAlgorithm == MacAlgorithm.NULL) return null; - + String macAlg = null; if (version == ProtocolVersion.SSL_3) { @@ -642,7 +642,7 @@ public final class CipherSuite implements Constructed if (macAlgorithm == MacAlgorithm.SHA) macAlg = "HMac-SHA1"; } - + GetSecurityPropertyAction gspa = new GetSecurityPropertyAction ("jessie.jce.provider"); final String provider = AccessController.doPrivileged (gspa); @@ -689,7 +689,7 @@ public final class CipherSuite implements Constructed { buf.put (id); } - + public CipherSuite resolve() { if (id[0] == 0x00) switch (id[1] & 0xFF) @@ -764,7 +764,7 @@ public final class CipherSuite implements Constructed } return this; } - + public boolean isResolved() { return isResolved; diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/CipherSuiteList.java b/libjava/classpath/gnu/javax/net/ssl/provider/CipherSuiteList.java index 0e96b31443a..a123046987b 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/CipherSuiteList.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/CipherSuiteList.java @@ -194,7 +194,7 @@ public final class CipherSuiteList implements Iterable<CipherSuite> { return new Iterator (); } - + /** * An iterator for the elements in this list. The iterator supports * only the <code>set</code> method out of the optional methods, diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/ClientCertificateTypeList.java b/libjava/classpath/gnu/javax/net/ssl/provider/ClientCertificateTypeList.java index 1a1886b888c..4dd64f09f54 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/ClientCertificateTypeList.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/ClientCertificateTypeList.java @@ -74,7 +74,7 @@ public class ClientCertificateTypeList implements Iterable<ClientCertificateType return CertificateRequest.ClientCertificateType.forValue (buffer.get (index + 1) & 0xFF); } - + public java.util.Iterator<ClientCertificateType> iterator() { return new Iterator(); @@ -224,4 +224,4 @@ public class ClientCertificateTypeList implements Iterable<ClientCertificateType put (index, type); } } -}
\ No newline at end of file +} diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/ClientDHE_PSKParameters.java b/libjava/classpath/gnu/javax/net/ssl/provider/ClientDHE_PSKParameters.java index e63e03c0aa7..e2362e02916 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/ClientDHE_PSKParameters.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/ClientDHE_PSKParameters.java @@ -1,4 +1,4 @@ -/* ClientDHE_PSKParameters.java -- +/* ClientDHE_PSKParameters.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -60,7 +60,7 @@ public class ClientDHE_PSKParameters extends ExchangeKeys implements Builder, Co { super(buffer); } - + public ClientDHE_PSKParameters(String identity, ClientDiffieHellmanPublic dh) { super(null); @@ -80,12 +80,12 @@ public class ClientDHE_PSKParameters extends ExchangeKeys implements Builder, Co { return (ByteBuffer) buffer.duplicate().rewind().limit(length()); } - + private int identityLength() { return (buffer.getShort(0) & 0xFFFF) + 2; } - + public String identity() { Charset utf8 = Charset.forName("UTF-8"); @@ -109,7 +109,7 @@ public class ClientDHE_PSKParameters extends ExchangeKeys implements Builder, Co return new ClientDiffieHellmanPublic(((ByteBuffer) buffer.duplicate() .position(identityLength()).limit(length())).slice()); } - + /* (non-Javadoc) * @see gnu.javax.net.ssl.provider.Constructed#toString(java.lang.String) */ diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/ClientDiffieHellmanPublic.java b/libjava/classpath/gnu/javax/net/ssl/provider/ClientDiffieHellmanPublic.java index 8af8b850ba2..393313a2f9d 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/ClientDiffieHellmanPublic.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/ClientDiffieHellmanPublic.java @@ -54,7 +54,7 @@ struct { case implicit: struct { }; case explicit: opaque dh_Yc<1..2^16-1>; } dh_public; -} ClientDiffieHellmanPublic;</pre> +} ClientDiffieHellmanPublic;</pre> */ public class ClientDiffieHellmanPublic extends ExchangeKeys implements Builder { @@ -62,12 +62,12 @@ public class ClientDiffieHellmanPublic extends ExchangeKeys implements Builder { super(buffer); } - + public ClientDiffieHellmanPublic(final BigInteger Yc) { super(wrap(Yc)); } - + private static ByteBuffer wrap(BigInteger Yc) { byte[] b = Util.trim(Yc); @@ -81,7 +81,7 @@ public class ClientDiffieHellmanPublic extends ExchangeKeys implements Builder { return (ByteBuffer) buffer.duplicate().rewind().limit(length()); } - + public BigInteger publicValue() { int len = length() - 2; diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/ClientHandshake.java b/libjava/classpath/gnu/javax/net/ssl/provider/ClientHandshake.java index fdbf262122b..c938e284af6 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/ClientHandshake.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/ClientHandshake.java @@ -1,4 +1,4 @@ -/* ClientHandshake.java -- +/* ClientHandshake.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -103,27 +103,27 @@ public class ClientHandshake extends AbstractHandshake WRITE_FINISHED (false, true), READ_FINISHED (true, false), DONE (false, false); - + private final boolean isWriteState; private final boolean isReadState; - + private State(boolean isReadState, boolean isWriteState) { this.isReadState = isReadState; this.isWriteState = isWriteState; } - + boolean isReadState() { return isReadState; } - + boolean isWriteState() { return isWriteState; } } - + private State state; private ByteBuffer outBuffer; private boolean continuedSession; @@ -134,14 +134,14 @@ public class ClientHandshake extends AbstractHandshake private MaxFragmentLength maxFragmentLengthSent; private boolean truncatedHMacSent; private ProtocolVersion sentVersion; - + // Delegated tasks. private CertVerifier certVerifier; private ParamsVerifier paramsVerifier; private DelegatedTask keyExchange; private CertLoader certLoader; private GenCertVerify genCertVerify; - + public ClientHandshake(SSLEngineImpl engine) throws NoSuchAlgorithmException { super(engine); @@ -160,7 +160,7 @@ public class ClientHandshake extends AbstractHandshake if (state.isWriteState() || (outBuffer != null && outBuffer.hasRemaining())) return HandshakeStatus.NEED_WRAP; - + // Copy the current buffer, and prepare it for reading. ByteBuffer buffer = handshakeBuffer.duplicate (); buffer.flip(); @@ -169,7 +169,7 @@ public class ClientHandshake extends AbstractHandshake Handshake handshake = new Handshake(buffer.slice(), engine.session().suite, engine.session().version); - + if (Debug.DEBUG) logger.logv(Component.SSL_HANDSHAKE, "processing in state {0}:\n{1}", state, handshake); @@ -241,7 +241,7 @@ public class ClientHandshake extends AbstractHandshake state = READ_CERTIFICATE_REQUEST; } break; - + // Server Certificate. case READ_CERTIFICATE: { @@ -274,7 +274,7 @@ public class ClientHandshake extends AbstractHandshake engine.session().setPeerCertificates(chain); certVerifier = new CertVerifier(true, chain); tasks.add(certVerifier); - + // If we are doing an RSA key exchange, generate our parameters. KeyExchangeAlgorithm kea = engine.session().suite.keyExchangeAlgorithm(); if (kea == RSA || kea == RSA_PSK) @@ -290,7 +290,7 @@ public class ClientHandshake extends AbstractHandshake state = READ_SERVER_KEY_EXCHANGE; } break; - + // Server Key Exchange. case READ_SERVER_KEY_EXCHANGE: { @@ -301,7 +301,7 @@ public class ClientHandshake extends AbstractHandshake && kexalg != DHE_PSK && kexalg != PSK && kexalg != RSA_PSK) throw new AlertException(new Alert(Level.FATAL, Description.UNEXPECTED_MESSAGE)); - + if (handshake.type() != Handshake.Type.SERVER_KEY_EXCHANGE) { if (kexalg != RSA_PSK && kexalg != PSK) @@ -320,14 +320,14 @@ public class ClientHandshake extends AbstractHandshake paramsBuffer = ByteBuffer.allocate(b.remaining()); paramsBuffer.put(b); } - + if (s.signatureAlgorithm() != SignatureAlgorithm.ANONYMOUS) { byte[] signature = skex.signature().signature(); paramsVerifier = new ParamsVerifier(paramsBuffer, signature); tasks.add(paramsVerifier); } - + if (kexalg == DHE_DSS || kexalg == DHE_RSA || kexalg == DH_anon) { ServerDHParams dhParams = (ServerDHParams) skex.params(); @@ -357,7 +357,7 @@ public class ClientHandshake extends AbstractHandshake state = READ_CERTIFICATE_REQUEST; } break; - + // Certificate Request. case READ_CERTIFICATE_REQUEST: { @@ -366,23 +366,23 @@ public class ClientHandshake extends AbstractHandshake state = READ_SERVER_HELLO_DONE; return HandshakeStatus.NEED_UNWRAP; } - + CertificateRequest req = (CertificateRequest) handshake.body(); ClientCertificateTypeList types = req.types(); LinkedList<String> typeList = new LinkedList<String>(); for (ClientCertificateType t : types) typeList.add(t.name()); - + X500PrincipalList issuers = req.authorities(); LinkedList<X500Principal> issuerList = new LinkedList<X500Principal>(); for (X500Principal p : issuers) issuerList.add(p); - + certLoader = new CertLoader(typeList, issuerList); tasks.add(certLoader); } break; - + // Server Hello Done. case READ_SERVER_HELLO_DONE: { @@ -392,7 +392,7 @@ public class ClientHandshake extends AbstractHandshake state = WRITE_CERTIFICATE; } break; - + // Finished. case READ_FINISHED: { @@ -422,7 +422,7 @@ public class ClientHandshake extends AbstractHandshake if (Debug.DEBUG) logger.logv(Component.SSL_HANDSHAKE, "clientFinished: {0}", clientFinished); - + if (engine.session().version == ProtocolVersion.SSL_3) { if (!Arrays.equals(clientFinished.md5Hash(), @@ -453,13 +453,13 @@ public class ClientHandshake extends AbstractHandshake state = DONE; } break; - + default: throw new IllegalStateException("invalid state: " + state); } - + handshakeOffset += handshake.length() + 4; - + if (!tasks.isEmpty()) return HandshakeStatus.NEED_TASK; if (state.isWriteState() @@ -488,7 +488,7 @@ public class ClientHandshake extends AbstractHandshake fragment.put((ByteBuffer) outBuffer.duplicate().limit(outBuffer.position() + l)); outBuffer.position(outBuffer.position() + l); } - + if (!fragment.hasRemaining()) { if (state.isWriteState() || outBuffer.hasRemaining()) @@ -518,7 +518,7 @@ outer_loop: // that ID. if (continued != null) sid = continued.id(); - + hello.setSessionId(sid.id()); sentVersion = chooseVersion(); hello.setVersion(sentVersion); @@ -551,7 +551,7 @@ outer_loop: extensions.add(new Extension(Extension.Type.SERVER_NAME, names)); } - + if (truncatedHMac()) { extensions.add(new Extension(Extension.Type.TRUNCATED_HMAC, @@ -564,7 +564,7 @@ outer_loop: } else hello.setDisableExtensions(true); - + if (Debug.DEBUG) logger.logv(Component.SSL_HANDSHAKE, "{0}", hello); @@ -579,7 +579,7 @@ outer_loop: state = READ_SERVER_HELLO; } break; - + case WRITE_CERTIFICATE: { java.security.cert.Certificate[] chain @@ -598,12 +598,12 @@ outer_loop: Description.INTERNAL_ERROR), ce); } - + outBuffer = cert.buffer(); - + fragment.putInt((Handshake.Type.CERTIFICATE.getValue() << 24) | (cert.length() & 0xFFFFFF)); - + int l = Math.min(fragment.remaining(), outBuffer.remaining()); fragment.put((ByteBuffer) outBuffer.duplicate() .limit(outBuffer.position() + l)); @@ -612,7 +612,7 @@ outer_loop: state = WRITE_CLIENT_KEY_EXCHANGE; } break; - + case WRITE_CLIENT_KEY_EXCHANGE: { KeyExchangeAlgorithm kea = engine.session().suite.keyExchangeAlgorithm(); @@ -698,10 +698,10 @@ outer_loop: engine.session().suite); engine.session().privateData.masterSecret = new byte[0]; } - + if (Debug.DEBUG) logger.logv(Component.SSL_HANDSHAKE, "{0}", ckex); - + outBuffer = ckex.buffer(); if (Debug.DEBUG) logger.logv(Component.SSL_HANDSHAKE, "client kex buffer {0}", outBuffer); @@ -726,28 +726,28 @@ outer_loop: // Both states terminate in a NEED_TASK, or a need to change cipher // specs; so we can't write any more messages here. break outer_loop; - + case WRITE_CERTIFICATE_VERIFY: { assert(genCertVerify != null); assert(genCertVerify.hasRun()); CertificateVerify verify = new CertificateVerify(genCertVerify.signed(), engine.session().suite.signatureAlgorithm()); - + outBuffer = verify.buffer(); fragment.putInt((Handshake.Type.CERTIFICATE_VERIFY.getValue() << 24) | (verify.length() & 0xFFFFFF)); int l = Math.min(fragment.remaining(), outBuffer.remaining()); fragment.put((ByteBuffer) outBuffer.duplicate().limit(outBuffer.position() + l)); outBuffer.position(outBuffer.position() + l); - + // XXX This is a potential problem: we may not have drained // outBuffer, but set the changeCipherSpec toggle. engine.changeCipherSpec(); state = WRITE_FINISHED; } break outer_loop; - + case WRITE_FINISHED: { MessageDigest md5copy = null; @@ -766,10 +766,10 @@ outer_loop: outBuffer = generateFinished(md5copy, shacopy, true, engine.session()); - + fragment.putInt((Handshake.Type.FINISHED.getValue() << 24) | outBuffer.remaining() & 0xFFFFFF); - + int l = Math.min(outBuffer.remaining(), fragment.remaining()); fragment.put((ByteBuffer) outBuffer.duplicate().limit(outBuffer.position() + l)); outBuffer.position(outBuffer.position() + l); @@ -777,10 +777,10 @@ outer_loop: if (continuedSession) state = DONE; else - state = READ_FINISHED; + state = READ_FINISHED; } break; - + default: throw new IllegalStateException("invalid state: " + state); } @@ -808,7 +808,7 @@ outer_loop: return HandshakeStatus.NEED_WRAP; return HandshakeStatus.FINISHED; } - + @Override void checkKeyExchange() throws SSLException { // XXX implement. @@ -821,7 +821,7 @@ outer_loop: { throw new SSLException("this should be impossible"); } - + private ProtocolVersion chooseVersion() throws SSLException { // Select the highest enabled version, for our initial key exchange. @@ -839,13 +839,13 @@ outer_loop: continue; } } - + if (version == null) throw new SSLException("no suitable enabled versions"); - + return version; } - + private List<CipherSuite> getSuites() throws SSLException { List<CipherSuite> suites = new LinkedList<CipherSuite>(); @@ -859,7 +859,7 @@ outer_loop: throw new SSLException("no cipher suites enabled"); return suites; } - + private List<CompressionMethod> getCompressionMethods() { List<CompressionMethod> methods = new LinkedList<CompressionMethod>(); @@ -869,14 +869,14 @@ outer_loop: methods.add(CompressionMethod.NULL); return methods; } - + private boolean enableExtensions() { GetSecurityPropertyAction action = new GetSecurityPropertyAction("jessie.client.enable.extensions"); return Boolean.valueOf(AccessController.doPrivileged(action)); } - + private MaxFragmentLength maxFragmentLength() { GetSecurityPropertyAction action @@ -905,35 +905,35 @@ outer_loop: } return null; } - + private boolean truncatedHMac() { GetSecurityPropertyAction action = new GetSecurityPropertyAction("jessie.client.truncatedHMac"); return Boolean.valueOf(AccessController.doPrivileged(action)); } - + private String getPSKIdentity() { GetSecurityPropertyAction action = new GetSecurityPropertyAction("jessie.client.psk.identity"); return AccessController.doPrivileged(action); } - + // Delegated tasks. - + class ParamsVerifier extends DelegatedTask { private final ByteBuffer paramsBuffer; private final byte[] signature; private boolean verified; - + ParamsVerifier(ByteBuffer paramsBuffer, byte[] signature) { this.paramsBuffer = paramsBuffer; this.signature = signature; } - + public void implRun() throws InvalidKeyException, NoSuchAlgorithmException, SSLPeerUnverifiedException, SignatureException @@ -949,26 +949,26 @@ outer_loop: notifyAll(); } } - + boolean verified() { return verified; } } - + class ClientDHGen extends DelegatedTask { private final DHPublicKey serverKey; private final DHParameterSpec params; private final boolean full; - + ClientDHGen(DHPublicKey serverKey, DHParameterSpec params, boolean full) { this.serverKey = serverKey; this.params = params; this.full = full; } - + public void implRun() throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, SSLException @@ -1006,24 +1006,24 @@ outer_loop: if (phase.thrown() != null) throw new SSLException(phase.thrown()); } - + DHPublicKey serverKey() { return serverKey; } } - + class CertLoader extends DelegatedTask { private final List<String> keyTypes; private final List<X500Principal> issuers; - + CertLoader(List<String> keyTypes, List<X500Principal> issuers) { this.keyTypes = keyTypes; this.issuers = issuers; } - + public void implRun() { X509ExtendedKeyManager km = engine.contextImpl.keyManager; @@ -1041,17 +1041,17 @@ outer_loop: { private byte[] encryptedPreMasterSecret; private final boolean full; - + RSAGen() { this(true); } - + RSAGen(boolean full) { this.full = full; } - + public void implRun() throws BadPaddingException, IllegalBlockSizeException, InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, @@ -1087,7 +1087,7 @@ outer_loop: } rsa.init(Cipher.ENCRYPT_MODE, cert.getPublicKey()); encryptedPreMasterSecret = rsa.doFinal(preMasterSecret); - + // Generate our session keys, because we can. if (full) { @@ -1096,18 +1096,18 @@ outer_loop: setupSecurityParameters(keys, true, engine, compression); } } - + byte[] encryptedSecret() { return encryptedPreMasterSecret; } } - + class GenCertVerify extends DelegatedTask { private final MessageDigest md5, sha; private byte[] signed; - + GenCertVerify(MessageDigest md5, MessageDigest sha) { try @@ -1137,14 +1137,14 @@ outer_loop: else toSign = sha.digest(); } - + java.security.Signature sig = java.security.Signature.getInstance(engine.session().suite.signatureAlgorithm().name()); sig.initSign(privateKey); sig.update(toSign); signed = sig.sign(); } - + byte[] signed() { return signed; diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/ClientHello.java b/libjava/classpath/gnu/javax/net/ssl/provider/ClientHello.java index 54d7f8b4d74..a58dc5d7a3c 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/ClientHello.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/ClientHello.java @@ -149,7 +149,7 @@ public class ClientHello implements Handshake.Body .limit (buffer.capacity ())).slice (); return new CompressionMethodList (listBuf); } - + public boolean hasExtensions() { int offset = getExtensionsOffset(); @@ -168,7 +168,7 @@ public class ClientHello implements Handshake.Body .limit(offset + len + 2)).slice (); return new ExtensionList(ebuf); } - + public int extensionsLength() { if (hasExtensions()) diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/ClientHelloBuilder.java b/libjava/classpath/gnu/javax/net/ssl/provider/ClientHelloBuilder.java index 81e3dd72f71..90405c45b42 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/ClientHelloBuilder.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/ClientHelloBuilder.java @@ -1,4 +1,4 @@ -/* ClientHelloBuilder.java -- +/* ClientHelloBuilder.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -43,7 +43,7 @@ import java.util.List; /** * Builder for {@link ClientHello} objects. - * + * * @author Casey Marshall (csm@gnu.org) */ public class ClientHelloBuilder extends ClientHello implements Builder @@ -80,7 +80,7 @@ public class ClientHelloBuilder extends ClientHello implements Builder this.buffer.position (SESSID_OFFSET2); this.buffer.put (buffer, offset, len); } - + public void setCipherSuites(List<CipherSuite> suites) { int off = getCipherSuitesOffset(); @@ -93,7 +93,7 @@ public class ClientHelloBuilder extends ClientHello implements Builder i += 2; } } - + public void setCompressionMethods(List<CompressionMethod> methods) { int off = getCompressionMethodsOffset(); @@ -112,19 +112,19 @@ public class ClientHelloBuilder extends ClientHello implements Builder ensureCapacity(needed); buffer.putShort(getExtensionsOffset(), (short) length); } - + public void setExtensions(ByteBuffer extensions) { int elen = extensions.getShort(0) & 0xFFFF; setExtensionsLength(elen); ((ByteBuffer) buffer.duplicate().position(getExtensionsOffset())).put(extensions); } - + public void setDisableExtensions(boolean disableExtensions) { this.disableExtensions = disableExtensions; } - + public void ensureCapacity(final int length) { if (buffer.capacity() >= length) diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/ClientHelloV2.java b/libjava/classpath/gnu/javax/net/ssl/provider/ClientHelloV2.java index a514d9ad37c..6009d52a3f2 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/ClientHelloV2.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/ClientHelloV2.java @@ -155,4 +155,4 @@ class ClientHelloV2 implements Constructed out.println (Util.toHexString (challenge (), ':')); return str.toString (); } -}
\ No newline at end of file +} diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/ClientKeyExchangeBuilder.java b/libjava/classpath/gnu/javax/net/ssl/provider/ClientKeyExchangeBuilder.java index ebebdcc0e03..a4387351085 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/ClientKeyExchangeBuilder.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/ClientKeyExchangeBuilder.java @@ -1,4 +1,4 @@ -/* ClientKeyExchangeBuilder.java -- +/* ClientKeyExchangeBuilder.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -42,7 +42,7 @@ import java.nio.ByteBuffer; /** * Builder for {@link ClientKeyExchange} objects. - * + * * @author Casey Marshall (csm@gnu.org) */ public class ClientKeyExchangeBuilder extends ClientKeyExchange @@ -60,11 +60,11 @@ public class ClientKeyExchangeBuilder extends ClientKeyExchange { return ((ByteBuffer) buffer.duplicate().position(0).limit(length())).slice(); } - + public void setExchangeKeys(ByteBuffer exchangeKeys) { // For SSLv3 and RSA key exchange, the message is sent without length. - // So we use the precise capacity of the buffer to signal the size of + // So we use the precise capacity of the buffer to signal the size of // the message. if (buffer.capacity() < exchangeKeys.remaining() || (suite.keyExchangeAlgorithm() == KeyExchangeAlgorithm.RSA diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/ClientPSKParameters.java b/libjava/classpath/gnu/javax/net/ssl/provider/ClientPSKParameters.java index f08ec7f9062..22c6333e913 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/ClientPSKParameters.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/ClientPSKParameters.java @@ -1,4 +1,4 @@ -/* ClientPSKParameters.java -- +/* ClientPSKParameters.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -73,7 +73,7 @@ public class ClientPSKParameters extends ExchangeKeys implements Builder, Constr buffer.put(idBuf); buffer.rewind(); } - + /* (non-Javadoc) * @see gnu.javax.net.ssl.provider.Builder#buffer() */ @@ -89,13 +89,13 @@ public class ClientPSKParameters extends ExchangeKeys implements Builder, Constr { return (buffer.getShort(0) & 0xFFFF) + 2; } - + public String identity() { Charset utf8 = Charset.forName("UTF-8"); return utf8.decode((ByteBuffer) buffer.duplicate().position(2).limit(length())).toString(); } - + public @Override String toString() { return toString(null); diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/ClientRSA_PSKParameters.java b/libjava/classpath/gnu/javax/net/ssl/provider/ClientRSA_PSKParameters.java index 860cc731f7a..842e911d075 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/ClientRSA_PSKParameters.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/ClientRSA_PSKParameters.java @@ -1,4 +1,4 @@ -/* ClientRSA_PSKParameters.java -- +/* ClientRSA_PSKParameters.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -72,14 +72,14 @@ public class ClientRSA_PSKParameters extends ExchangeKeys implements Builder, Co { return (ByteBuffer) buffer.duplicate().rewind().limit(length()); } - + public String identity() { Charset utf8 = Charset.forName("UTF-8"); return utf8.decode((ByteBuffer) buffer.duplicate().position(2).limit (identityLength())).toString(); } - + private int identityLength() { return (buffer.getShort(0) & 0xFFFF) + 2; @@ -92,7 +92,7 @@ public class ClientRSA_PSKParameters extends ExchangeKeys implements Builder, Co { return identityLength() + secret().length(); } - + public EncryptedPreMasterSecret secret() { return new EncryptedPreMasterSecret diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/CompressionMethod.java b/libjava/classpath/gnu/javax/net/ssl/provider/CompressionMethod.java index 6c57e840c65..3005dd9fc1a 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/CompressionMethod.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/CompressionMethod.java @@ -55,10 +55,10 @@ public enum CompressionMethod { case 0: return NULL; case 1: return ZLIB; - + // Note: we can't throw an exception here, because we get these values // over the wire, and need to just ignore ones we don't recognize. - default: return null; + default: return null; } } diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/CompressionMethodList.java b/libjava/classpath/gnu/javax/net/ssl/provider/CompressionMethodList.java index 47ba5484c3f..b57e0c6a6d0 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/CompressionMethodList.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/CompressionMethodList.java @@ -192,7 +192,7 @@ public final class CompressionMethodList implements Iterable<CompressionMethod> { return new Iterator (); } - + /** * An iterator for the elements in this list. The iterator supports * only the <code>set</code> method out of the optional methods, diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/Constructed.java b/libjava/classpath/gnu/javax/net/ssl/provider/Constructed.java index 3a3545b226e..23ff68812e6 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/Constructed.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/Constructed.java @@ -40,9 +40,9 @@ package gnu.javax.net.ssl.provider; /** * The base interface to SSL constructed types. - * + * * <p><b>Contract for ByteBuffer-based constructed types:</b> - * + * * <p>Most implementations of this interface supported by this library * take a "view" of an underlying ByteBuffer. The general contract of * such classes is that they <em>will not</em> modify the position or @@ -54,12 +54,12 @@ package gnu.javax.net.ssl.provider; * the object, so the limit isn't useful in such cases. Of course, if the * limit is set to something other than the object's length, it must be * larger than the object length). - * + * * <p>Setter methods (usually in a class that implements the {@link Builder} * interface) may modify the limit, but the general contract remains that * the position remain at zero, and that the limit be at least as large as * the object length. - * + * * <p>Thus, very often the code will use <em>absolute</em> getters and setters * for primitive types, or it will use the {@link java.nio.ByteBuffer#duplicate()} * method, and sometimes the {@link java.nio.ByteBuffer#slice()} method, and diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/Debug.java b/libjava/classpath/gnu/javax/net/ssl/provider/Debug.java index 6d0f7c3a519..308ef67a003 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/Debug.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/Debug.java @@ -40,7 +40,7 @@ package gnu.javax.net.ssl.provider; /** * Debug constants for Jessie. - * + * * @author Casey Marshall (csm@gnu.org) */ public final class Debug @@ -50,13 +50,13 @@ public final class Debug * logger. */ public static final boolean DEBUG = true; - + /** * Set to true to dump out info about the SSL key exchange. Since this * MAY contain sensitive data, it is a separate value. */ public static final boolean DEBUG_KEY_EXCHANGE = true; - + /** * Set to true to turn on dumping of decrypted packets. Since this will * log potentially-sensitive information (i.e., decrypted messages), only diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/DelegatedTask.java b/libjava/classpath/gnu/javax/net/ssl/provider/DelegatedTask.java index 200d4d457cf..34fd39d1987 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/DelegatedTask.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/DelegatedTask.java @@ -1,4 +1,4 @@ -/* DelegatedTask.java -- +/* DelegatedTask.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -49,12 +49,12 @@ public abstract class DelegatedTask implements Runnable private static final SystemLogger logger = SystemLogger.SYSTEM; private boolean hasRun; protected Throwable thrown; - + protected DelegatedTask() { hasRun = false; } - + public final void run() { if (hasRun) @@ -79,15 +79,15 @@ public abstract class DelegatedTask implements Runnable } } - public final boolean hasRun() + public final boolean hasRun() { return hasRun; } - + public final Throwable thrown() { return thrown; } - + protected abstract void implRun() throws Throwable; } diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/EmptyExchangeKeys.java b/libjava/classpath/gnu/javax/net/ssl/provider/EmptyExchangeKeys.java index acf4cfa03a9..55b59998df0 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/EmptyExchangeKeys.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/EmptyExchangeKeys.java @@ -1,4 +1,4 @@ -/* EmptyExchangeKeys.java -- +/* EmptyExchangeKeys.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -64,7 +64,7 @@ public class EmptyExchangeKeys { return toString(null); } - + /* (non-Javadoc) * @see gnu.javax.net.ssl.provider.Constructed#toString(java.lang.String) */ diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/EncryptedPreMasterSecret.java b/libjava/classpath/gnu/javax/net/ssl/provider/EncryptedPreMasterSecret.java index 85769cffcf2..a40223dd0d9 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/EncryptedPreMasterSecret.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/EncryptedPreMasterSecret.java @@ -61,7 +61,7 @@ public final class EncryptedPreMasterSecret extends ExchangeKeys implements Buil version.getClass(); this.version = version; } - + public EncryptedPreMasterSecret(byte[] encryptedSecret, ProtocolVersion version) { this(ByteBuffer.allocate(version == ProtocolVersion.SSL_3 @@ -72,7 +72,7 @@ public final class EncryptedPreMasterSecret extends ExchangeKeys implements Buil b.putShort((short) encryptedSecret.length); b.put(encryptedSecret); } - + public ByteBuffer buffer() { return (ByteBuffer) buffer.duplicate().rewind(); @@ -145,4 +145,4 @@ public final class EncryptedPreMasterSecret extends ExchangeKeys implements Buil out.print("} EncryptedPreMasterSecret;"); return str.toString(); } -}
\ No newline at end of file +} diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/ExchangeKeys.java b/libjava/classpath/gnu/javax/net/ssl/provider/ExchangeKeys.java index f161f484a57..a6664b85683 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/ExchangeKeys.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/ExchangeKeys.java @@ -51,4 +51,4 @@ public abstract class ExchangeKeys implements Constructed if (buffer != null) this.buffer = buffer.duplicate().order(ByteOrder.BIG_ENDIAN); } -}
\ No newline at end of file +} diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/Extension.java b/libjava/classpath/gnu/javax/net/ssl/provider/Extension.java index c79e58832b8..5cbcd579056 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/Extension.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/Extension.java @@ -46,13 +46,13 @@ import java.nio.ByteOrder; /** * An SSL hello extension. - * + * * <pre> * struct { * ExtensionType extension_type; * opaque extension_data<0..2^16-1>; * } Extension;</pre> - * + * * @author csm@gnu.org */ public final class Extension implements Builder, Constructed @@ -70,7 +70,7 @@ public final class Extension implements Builder, Constructed { this.buffer = buffer.duplicate().order(ByteOrder.BIG_ENDIAN); } - + public Extension(final Type type, final Value value) { ByteBuffer valueBuffer = value.buffer(); @@ -89,7 +89,7 @@ public final class Extension implements Builder, Constructed { return (buffer.getShort (2) & 0xFFFF) + 4; } - + public ByteBuffer buffer() { return (ByteBuffer) buffer.duplicate().limit(length()); @@ -107,20 +107,20 @@ public final class Extension implements Builder, Constructed ((ByteBuffer) buffer.duplicate ().position (4)).get (value); return value; } - + public ByteBuffer valueBuffer() { int len = buffer.getShort(2) & 0xFFFF; return ((ByteBuffer) buffer.duplicate().position(4).limit(len+4)).slice(); } - + public Value value() { switch (type ()) { case SERVER_NAME: return new ServerNameList(valueBuffer()); - + case MAX_FRAGMENT_LENGTH: switch (valueBuffer().get() & 0xFF) { @@ -131,32 +131,32 @@ public final class Extension implements Builder, Constructed default: throw new IllegalArgumentException("invalid max_fragment_len"); } - + case TRUNCATED_HMAC: return new TruncatedHMAC(); case CLIENT_CERTIFICATE_URL: return new CertificateURL(valueBuffer()); - + case TRUSTED_CA_KEYS: return new TrustedAuthorities(valueBuffer()); - + case STATUS_REQUEST: return new CertificateStatusRequest(valueBuffer()); - + case SRP: case CERT_TYPE: } return new UnresolvedExtensionValue(valueBuffer()); } - + public void setLength (final int newLength) { if (newLength < 0 || newLength > 65535) throw new IllegalArgumentException ("length is out of bounds"); buffer.putShort (2, (short) newLength); } - + public void setType (final Type type) { buffer.putShort(0, (short) type.getValue()); @@ -166,14 +166,14 @@ public final class Extension implements Builder, Constructed { setValue (value, 0, value.length); } - + public void setValue (final byte[] value, final int offset, final int length) { if (length != length ()) throw new IllegalArgumentException ("length is different than claimed length"); ((ByteBuffer) buffer.duplicate().position(4)).put(value, offset, length); } - + public String toString() { return toString(null); @@ -233,13 +233,13 @@ public final class Extension implements Builder, Constructed default: return null; } } - + public int getValue() { return value; } } - + public static abstract class Value implements Builder, Constructed { } diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/ExtensionList.java b/libjava/classpath/gnu/javax/net/ssl/provider/ExtensionList.java index d5aaad62155..fb7b12d9ec9 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/ExtensionList.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/ExtensionList.java @@ -13,9 +13,9 @@ import java.util.NoSuchElementException; /** * A list of extensions, that may appear in either the {@link ClientHello} or * {@link ServerHello}. The form of the extensions list is: - * + * * <tt> Extension extensions_list<1..2^16-1></tt> - * + * * @author csm */ public class ExtensionList implements Builder, Iterable<Extension> @@ -28,7 +28,7 @@ public class ExtensionList implements Builder, Iterable<Extension> this.buffer = buffer.duplicate().order(ByteOrder.BIG_ENDIAN); modCount = 0; } - + public ExtensionList(List<Extension> extensions) { int length = 2; @@ -40,7 +40,7 @@ public class ExtensionList implements Builder, Iterable<Extension> buffer.put(extension.buffer()); buffer.rewind(); } - + public ByteBuffer buffer() { return (ByteBuffer) buffer.duplicate().limit(length()); @@ -63,10 +63,10 @@ public class ExtensionList implements Builder, Iterable<Extension> ByteBuffer b = (ByteBuffer) buffer.duplicate().position(i).limit(i+el+4); return new Extension(b.slice()); } - + /** * Returns the number of extensions this list contains. - * + * * @return The number of extensions. */ public int size () @@ -86,14 +86,14 @@ public class ExtensionList implements Builder, Iterable<Extension> /** * Returns the length of this extension list, in bytes. - * + * * @return The length of this extension list, in bytes. */ public int length () { return (buffer.getShort (0) & 0xFFFF) + 2; } - + /** * Sets the extension at index <i>i</i> to <i>e</i>. Note that setting an * element at an index <b>may</b> invalidate any other elements that come @@ -101,10 +101,10 @@ public class ExtensionList implements Builder, Iterable<Extension> * move existing elements in this list, and since extensions are variable * length, you can <em>not</em> guarantee that extensions later in the list * will still be valid. - * + * * <p>Thus, elements of this list <b>must</b> be set in order of increasing * index. - * + * * @param index The index to set the extension at. * @param e The extension. * @throws java.nio.BufferOverflowException If setting the extension overflows @@ -136,12 +136,12 @@ public class ExtensionList implements Builder, Iterable<Extension> ((ByteBuffer) buffer.duplicate().position(i+4)).put (e.valueBuffer()); modCount++; } - + /** * Reserve space for an extension at index <i>i</i> in the list. In other * words, this does the job of {@link #set(int, Extension)}, but does not * copy the extension value to the underlying buffer. - * + * * @param index The index of the extension to reserve space for. * @param t The type of the extension. * @param eLength The number of bytes to reserve for this extension. The total @@ -168,10 +168,10 @@ public class ExtensionList implements Builder, Iterable<Extension> buffer.putShort(i+2, (short) eLength); modCount++; } - + /** * Set the total length of this list, in bytes. - * + * * @param newLength The new list length. */ public void setLength (final int newLength) @@ -181,7 +181,7 @@ public class ExtensionList implements Builder, Iterable<Extension> buffer.putShort (0, (short) newLength); modCount++; } - + public Iterator<Extension> iterator() { return new ExtensionsIterator(); @@ -191,7 +191,7 @@ public class ExtensionList implements Builder, Iterable<Extension> { return toString (null); } - + public String toString(final String prefix) { StringWriter str = new StringWriter(); @@ -214,7 +214,7 @@ public class ExtensionList implements Builder, Iterable<Extension> /** * List iterator interface to an extensions list. - * + * * @author csm@gnu.org */ public final class ExtensionsIterator implements ListIterator<Extension> @@ -222,7 +222,7 @@ public class ExtensionList implements Builder, Iterable<Extension> private final int modCount; private int index; private final int size; - + public ExtensionsIterator () { this.modCount = ExtensionList.this.modCount; diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/Handshake.java b/libjava/classpath/gnu/javax/net/ssl/provider/Handshake.java index dd36f2b3fc5..31f142d3e24 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/Handshake.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/Handshake.java @@ -266,7 +266,7 @@ public final class Handshake implements Constructed /** * Convert a raw handshake type value to a type enum value. - * + * * @return The corresponding enum value for the raw integer value. * @throws IllegalArgumentException If the value is not a known handshake * type. diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/InputSecurityParameters.java b/libjava/classpath/gnu/javax/net/ssl/provider/InputSecurityParameters.java index cf5ca6099ff..1d3da833a8f 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/InputSecurityParameters.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/InputSecurityParameters.java @@ -83,7 +83,7 @@ public class InputSecurityParameters /** * Decrypt a record, storing the decrypted fragment into the given array * of byte buffers. - * + * * @param record The input record. * @param output The output buffers. * @param offset The offset of the first buffer to use. @@ -94,7 +94,7 @@ public class InputSecurityParameters * and the input fragment is not a multiple of the block size. * @throws MacException If verifying the MAC fails. * @throws SSLException ??? - * @throws ShortBufferException + * @throws ShortBufferException */ public int decrypt(Record record, ByteBuffer[] output, int offset, int length) throws DataFormatException, IllegalBlockSizeException, @@ -102,11 +102,11 @@ public class InputSecurityParameters { return decrypt(record, output, offset, length, null); } - + /** * Decrypt a record, storing the decrypted fragment into the given growable * buffer. - * + * * @param record The input record. * @param outputStream The output buffer. * @return The number of bytes put into the output buffer. @@ -122,7 +122,7 @@ public class InputSecurityParameters { return decrypt(record, null, 0, 0, outputStream); } - + private int decrypt(Record record, ByteBuffer[] output, int offset, int length, ByteBufferOutputStream outputStream) throws DataFormatException, IllegalBlockSizeException, @@ -142,7 +142,7 @@ public class InputSecurityParameters if (Debug.DEBUG_DECRYPTION) logger.logv(Component.SSL_RECORD_LAYER, "decrypted fragment:\n{0}", Util.hexDump((ByteBuffer) fragment.duplicate().position(0), " >> ")); - + int fragmentLength = record.length(); int maclen = 0; if (mac != null) @@ -178,14 +178,14 @@ public class InputSecurityParameters logger.logv(Component.SSL_RECORD_LAYER, "TLSv1.x padding\n{0}", new ByteArray(pad)); } - + if (Debug.DEBUG) logger.logv(Component.SSL_RECORD_LAYER, "padding bad? {0}", badPadding); if (!badPadding) fragmentLength = fragmentLength - padRemoveLen; } - + int ivlen = 0; if (session.version.compareTo(ProtocolVersion.TLS_1_1) >= 0 && !suite.isStreamCipher()) @@ -244,7 +244,7 @@ public class InputSecurityParameters else fragment.position(0); fragment.limit(fragmentLength); - + while (!done) { int l; @@ -259,7 +259,7 @@ public class InputSecurityParameters out.write(outbuffer, 0, l); done = !fragment.hasRemaining() && inflater.finished(); } - + ByteBuffer outbuf = out.buffer(); if (outputStream != null) { @@ -323,10 +323,10 @@ public class InputSecurityParameters } sequence++; - + return produced; } - + CipherSuite cipherSuite () { return suite; diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/Jessie.java b/libjava/classpath/gnu/javax/net/ssl/provider/Jessie.java index 6bd68b3850f..d3fb3a65888 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/Jessie.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/Jessie.java @@ -90,11 +90,11 @@ public class Jessie extends Provider put("Mac.SSLv3HMac-MD5", SSLv3HMacMD5Impl.class.getName()); put("Mac.SSLv3HMac-SHA", SSLv3HMacSHAImpl.class.getName()); - + put("Signature.TLSv1.1-RSA", SSLRSASignatureImpl.class.getName()); put("Alg.Alias.Signature.TLSv1-RSA", "TLSv1.1-RSA"); put("Alg.Alias.Signature.SSLv3-RSA", "TLSv1.1-RSA"); - + return null; } }); diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/MaxFragmentLength.java b/libjava/classpath/gnu/javax/net/ssl/provider/MaxFragmentLength.java index eb63958b839..acbfedff178 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/MaxFragmentLength.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/MaxFragmentLength.java @@ -5,7 +5,7 @@ import gnu.javax.net.ssl.provider.Extension.Value; import java.nio.ByteBuffer; /** - * Extension value + * Extension value * @author csm */ public class MaxFragmentLength extends Value @@ -14,21 +14,21 @@ public class MaxFragmentLength extends Value public static final MaxFragmentLength LEN_2_10 = new MaxFragmentLength(2, 1 << 10); public static final MaxFragmentLength LEN_2_11 = new MaxFragmentLength(3, 1 << 11); public static final MaxFragmentLength LEN_2_12 = new MaxFragmentLength(4, 1 << 12); - + private final int value; private final int length; - + private MaxFragmentLength(int value, int length) { this.value = value; this.length = length; } - + public ByteBuffer buffer() { return ByteBuffer.allocate(1).put(0, (byte) value); } - + public int length() { return 1; @@ -38,17 +38,17 @@ public class MaxFragmentLength extends Value { return value; } - + public int maxLength() { return length; } - + public String toString() { return toString(null); } - + public String toString(String prefix) { String s = "max_fragment_length = "; diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/OutputSecurityParameters.java b/libjava/classpath/gnu/javax/net/ssl/provider/OutputSecurityParameters.java index 228071a393d..c6ed7d5876a 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/OutputSecurityParameters.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/OutputSecurityParameters.java @@ -1,4 +1,4 @@ -/* OutputSecurityParameters.java -- +/* OutputSecurityParameters.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -88,12 +88,12 @@ public class OutputSecurityParameters if (offset < 0 || offset >= input.length || length <= 0 || offset + length > input.length) throw new IndexOutOfBoundsException(); - + if (Debug.DEBUG) for (int i = offset; i < offset+length; i++) logger.logv(Component.SSL_RECORD_LAYER, "encrypting record [{0}]: {1}", i-offset, input[i]); - + int maclen = 0; if (mac != null) maclen = session.isTruncatedMac() ? 10 : mac.getMacLength (); @@ -107,7 +107,7 @@ public class OutputSecurityParameters iv = new byte[ivlen]; session.random().nextBytes(iv); } - + int padaddlen = 0; if (!suite.isStreamCipher() && session.version.compareTo(ProtocolVersion.TLS_1) >= 0) @@ -115,7 +115,7 @@ public class OutputSecurityParameters padaddlen = (session.random().nextInt(255 / cipher.getBlockSize()) * cipher.getBlockSize()); } - + int fragmentLength = 0; ByteBuffer[] fragments = null; // Compress the content, if needed. @@ -126,10 +126,10 @@ public class OutputSecurityParameters byte[] inbuf = new byte[1024]; byte[] outbuf = new byte[1024]; int written = 0; - + // Here we use the guarantee that the deflater won't increase the // output size by more than 1K -- we resign ourselves to only deflate - // as much data as we have space for *uncompressed*, + // as much data as we have space for *uncompressed*, int limit = output.remaining() - (maclen + ivlen + padaddlen) - 1024; for (int i = offset; i < length && written < limit; i++) @@ -241,7 +241,7 @@ public class OutputSecurityParameters outrecord.setContentType(contentType); outrecord.setVersion(session.version); outrecord.setLength(fragmentLength); - + int consumed = 0; ByteBuffer outfragment = outrecord.fragment(); @@ -279,16 +279,16 @@ public class OutputSecurityParameters if (macValue != null) outfragment.put(macValue); } - + // Advance the output buffer's position. output.position(output.position() + outrecord.length() + 5); sequence++; return new int[] { consumed, fragmentLength + 5 }; } - + CipherSuite suite() { return suite; } -}
\ No newline at end of file +} diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/PreSharedKeyManagerFactoryImpl.java b/libjava/classpath/gnu/javax/net/ssl/provider/PreSharedKeyManagerFactoryImpl.java index aa1f97853cf..16263fb3740 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/PreSharedKeyManagerFactoryImpl.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/PreSharedKeyManagerFactoryImpl.java @@ -1,4 +1,4 @@ -/* PreSharedKeyManagerFactory.java -- +/* PreSharedKeyManagerFactory.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -106,7 +106,7 @@ public class PreSharedKeyManagerFactoryImpl { return params.getKey(name); } - + public String chooseIdentityHint() { Iterator<String> it = params.identities(); diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/Random.java b/libjava/classpath/gnu/javax/net/ssl/provider/Random.java index f89acc1f8f5..bd5c037f57b 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/Random.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/Random.java @@ -83,7 +83,7 @@ public class Random implements Builder, Constructed { return RANDOM_LENGTH + 4; } - + public ByteBuffer buffer() { return ((ByteBuffer) buffer.duplicate().position(0).limit(length())).slice(); diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/SSLContextImpl.java b/libjava/classpath/gnu/javax/net/ssl/provider/SSLContextImpl.java index cf7c8e4e3d6..50bbdb61b18 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/SSLContextImpl.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/SSLContextImpl.java @@ -1,4 +1,4 @@ -/* SSLContextImpl.java -- +/* SSLContextImpl.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -68,14 +68,14 @@ import javax.net.ssl.X509TrustManager; /** * Our implementation of {@link SSLContextSpi}. - * + * * @author Casey Marshall (csm@gnu.org) */ public final class SSLContextImpl extends SSLContextSpi { AbstractSessionContext serverContext; AbstractSessionContext clientContext; - + PreSharedKeyManager pskManager; X509ExtendedKeyManager keyManager; X509TrustManager trustManager; @@ -85,7 +85,7 @@ public final class SSLContextImpl extends SSLContextSpi public SSLContextImpl() { } - + /* (non-Javadoc) * @see javax.net.ssl.SSLContextSpi#engineCreateSSLEngine() */ @@ -210,11 +210,11 @@ public final class SSLContextImpl extends SSLContextSpi this.random = defaultRandom(); } } - + /** * Create and return a default key manager. The default is the JessieX509 * algorithm, loaded from either the jssecerts file, or the cacerts file. - * + * * @return The default key manager instance. * @throws KeyManagementException If the instance cannot be created. */ @@ -257,7 +257,7 @@ public final class SSLContextImpl extends SSLContextSpi /** * Create and return a default trust manager. The default is the JessieX509 * algorithm, loaded from either the jssecerts file, or the cacerts file. - * + * * @return The default trust manager instance. * @throws KeyManagementException If the instance cannot be created. */ @@ -290,7 +290,7 @@ public final class SSLContextImpl extends SSLContextSpi * property, or Fortuna if that property is not set. If none of these * algorithms can be found, and instance created with the SecureRandom * constructor is returned. - * + * * @return The default secure PRNG instance. */ private SecureRandom defaultRandom() @@ -312,4 +312,4 @@ public final class SSLContextImpl extends SSLContextSpi return rand; } -}
\ No newline at end of file +} diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/SSLEngineImpl.java b/libjava/classpath/gnu/javax/net/ssl/provider/SSLEngineImpl.java index 4a7f924e87d..b63fb2f20f2 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/SSLEngineImpl.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/SSLEngineImpl.java @@ -84,7 +84,7 @@ public final class SSLEngineImpl extends SSLEngine private String[] enabledSuites; private String[] enabledProtocols; - + /** * We can receive any message chunked across multiple records, * including alerts, even though all alert messages are only two @@ -100,7 +100,7 @@ public final class SSLEngineImpl extends SSLEngine private Mode mode; private enum Mode { SERVER, CLIENT } - + SSLEngineImpl (SSLContextImpl contextImpl, String host, int port) { super(host, port); @@ -113,11 +113,11 @@ public final class SSLEngineImpl extends SSLEngine contextImpl.random.nextBytes(sid); session.setId(new Session.ID(sid)); session.setRandom(contextImpl.random); - + if (Debug.DEBUG) logger.logv(Component.SSL_RECORD_LAYER, "generated session ID {0} with random {1}", session.id(), contextImpl.random); - + // Begin with no encryption. insec = new InputSecurityParameters (null, null, null, session, CipherSuite.TLS_NULL_WITH_NULL_NULL); @@ -134,7 +134,7 @@ public final class SSLEngineImpl extends SSLEngine lastAlert = null; handshakeStatus = SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING; changeCipherSpec = false; - + // Set up default protocols and suites. enabledProtocols = new String[] { ProtocolVersion.TLS_1_1.toString(), @@ -143,7 +143,7 @@ public final class SSLEngineImpl extends SSLEngine }; enabledSuites = defaultSuites(); } - + static String[] defaultSuites() { return new String[] { @@ -204,7 +204,7 @@ public final class SSLEngineImpl extends SSLEngine if (mode == null) throw new IllegalStateException("setUseClientMode was never used"); - + switch (mode) { case SERVER: @@ -219,7 +219,7 @@ public final class SSLEngineImpl extends SSLEngine throw new SSLException(nsae); } break; - + case CLIENT: try { @@ -244,7 +244,7 @@ public final class SSLEngineImpl extends SSLEngine { lastAlert = new Alert(Alert.Level.WARNING, Alert.Description.CLOSE_NOTIFY); } - + @Override public Runnable getDelegatedTask() { @@ -252,13 +252,13 @@ public final class SSLEngineImpl extends SSLEngine return null; return handshake.getTask(); } - + @Override public String[] getEnabledCipherSuites() { return (String[]) enabledSuites.clone(); } - + @Override public String[] getEnabledProtocols() { @@ -270,7 +270,7 @@ public final class SSLEngineImpl extends SSLEngine { return createSessions; } - + @Override public HandshakeStatus getHandshakeStatus() { @@ -278,43 +278,43 @@ public final class SSLEngineImpl extends SSLEngine return HandshakeStatus.NOT_HANDSHAKING; return handshake.status(); } - + @Override public boolean getNeedClientAuth() { return needClientAuth; } - + @Override public SSLSession getSession() { return session; } - + @Override public boolean getUseClientMode () { return (mode == Mode.CLIENT); } - + @Override public boolean getWantClientAuth() { return wantClientAuth; } - + @Override public boolean isInboundDone() { return inClosed; } - + @Override public boolean isOutboundDone() { return outClosed; } - + @Override public void setEnableSessionCreation(final boolean createSessions) { @@ -336,16 +336,16 @@ public final class SSLEngineImpl extends SSLEngine throw new IllegalArgumentException("need at least one protocol"); enabledProtocols = (String[]) protocols.clone(); } - + @Override public String[] getSupportedCipherSuites() { // XXX if we ever want to support "pluggable" cipher suites, we'll need // to figure this out. - + return CipherSuite.availableSuiteNames().toArray(new String[0]); } - + @Override public String[] getSupportedProtocols() { @@ -359,7 +359,7 @@ public final class SSLEngineImpl extends SSLEngine { this.needClientAuth = needClientAuth; } - + @Override public void setUseClientMode (final boolean clientMode) { @@ -368,7 +368,7 @@ public final class SSLEngineImpl extends SSLEngine else mode = Mode.SERVER; } - + public @Override void setWantClientAuth(final boolean wantClientAuth) { this.wantClientAuth = wantClientAuth; @@ -385,13 +385,13 @@ public final class SSLEngineImpl extends SSLEngine if (inClosed) return new SSLEngineResult(SSLEngineResult.Status.CLOSED, handshakeStatus, 0, 0); - + if (source.remaining() < 5) { return new SSLEngineResult(SSLEngineResult.Status.BUFFER_UNDERFLOW, handshakeStatus, 0, 0); } - + Record record = null; boolean helloV2 = false; @@ -410,15 +410,15 @@ public final class SSLEngineImpl extends SSLEngine if (Debug.DEBUG) logger.log (Component.SSL_RECORD_LAYER, "converting SSLv2 client hello to version 3 hello"); - + source.getShort(); // skip length ClientHelloV2 v2 = new ClientHelloV2(source.slice()); - + if (Debug.DEBUG) logger.log(Component.SSL_RECORD_LAYER, "v2 hello: {0}", v2); - + List<CipherSuite> suites = v2.cipherSpecs(); - + ClientHelloBuilder hello = new ClientHelloBuilder(); hello.setVersion(v2.version ()); @@ -448,31 +448,31 @@ public final class SSLEngineImpl extends SSLEngine record.setContentType(ContentType.HANDSHAKE); record.setVersion(v2.version()); record.setLength(hello.length() + 4); - + Handshake handshake = new Handshake(record.fragment()); handshake.setLength(hello.length()); handshake.setType(Handshake.Type.CLIENT_HELLO); - + handshake.bodyBuffer().put(hello.buffer()); source.position(source.position() + hellolen); helloV2 = true; } else record = new Record(source); - + ContentType type = record.contentType (); - + if (Debug.DEBUG) logger.log(Component.SSL_RECORD_LAYER, "input record:\n{0}", record); - + if (record.length() > session.getPacketBufferSize() - 5) { lastAlert = new Alert(Alert.Level.FATAL, Alert.Description.RECORD_OVERFLOW); throw new AlertException(lastAlert); } - - ByteBufferOutputStream sysMsg = null; + + ByteBufferOutputStream sysMsg = null; ByteBuffer msg = null; int produced = 0; @@ -492,7 +492,7 @@ public final class SSLEngineImpl extends SSLEngine insec.decrypt(record, sysMsg); } } - + // Advance the input buffer past the record we just read. if (!helloV2) source.position(source.position() + record.length() + 5); @@ -532,7 +532,7 @@ public final class SSLEngineImpl extends SSLEngine } SSLEngineResult result = null; - + // If we need to handle the output here, do it. Otherwise, the output // has been stored in the supplied output buffers. if (sysMsg != null) @@ -541,7 +541,7 @@ public final class SSLEngineImpl extends SSLEngine logger.logv(Component.SSL_RECORD_LAYER, "sysmessage {0}", sysMsg); msg = sysMsg.buffer(); } - + if (type == ContentType.CHANGE_CIPHER_SPEC) { // We *may* get a partial message, even though the message is only @@ -665,7 +665,7 @@ public final class SSLEngineImpl extends SSLEngine if (Debug.DEBUG) logger.logv(Component.SSL_RECORD_LAYER, "return result: {0}", result); - + return result; } @@ -679,7 +679,7 @@ public final class SSLEngineImpl extends SSLEngine if (outClosed) return new SSLEngineResult(SSLEngineResult.Status.CLOSED, handshakeStatus, 0, 0); - + ContentType type = null; ByteBuffer sysMessage = null; if (Debug.DEBUG) @@ -720,7 +720,7 @@ public final class SSLEngineImpl extends SSLEngine new Record((ByteBuffer) sink.duplicate().position(orig))); SSLEngineResult result = new SSLEngineResult(SSLEngineResult.Status.OK, handshakeStatus, 0, produced); - + // Note, this will only happen if we transition from // TLS_NULL_WITH_NULL_NULL *to* TLS_NULL_WITH_NULL_NULL, which // doesn't make a lot of sense, but we support it anyway. @@ -731,7 +731,7 @@ public final class SSLEngineImpl extends SSLEngine } return result; } - + // Rough guideline; XXX. sysMessage = ByteBuffer.allocate(sink.remaining() - 2048); type = ContentType.HANDSHAKE; @@ -753,7 +753,7 @@ public final class SSLEngineImpl extends SSLEngine int produced = 0; int consumed = 0; - + try { int orig = sink.position(); @@ -773,7 +773,7 @@ public final class SSLEngineImpl extends SSLEngine consumed = inout[0]; produced = inout[1]; } - + if (Debug.DEBUG) logger.logv(Component.SSL_RECORD_LAYER, "emitting record:\n{0}", new Record((ByteBuffer) sink.duplicate().position(orig).limit(produced))); @@ -798,14 +798,14 @@ public final class SSLEngineImpl extends SSLEngine lastAlert = new Alert(Alert.Level.FATAL, Alert.Description.INTERNAL_ERROR); return new SSLEngineResult(SSLEngineResult.Status.OK, handshakeStatus, 0, 0); } - + if (lastAlert != null && lastAlert.level() == Alert.Level.FATAL) { AlertException ae = new AlertException(lastAlert); lastAlert = null; throw ae; } - + if (changeCipherSpec) { outsec = handshake.getOutputParams(); @@ -829,14 +829,14 @@ public final class SSLEngineImpl extends SSLEngine { return session; } - + void setSession(SessionImpl session) { this.session = session; } - + void changeCipherSpec() { changeCipherSpec = true; } -}
\ No newline at end of file +} diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/SSLRSASignatureImpl.java b/libjava/classpath/gnu/javax/net/ssl/provider/SSLRSASignatureImpl.java index e6981c9c79d..105b4d5d74b 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/SSLRSASignatureImpl.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/SSLRSASignatureImpl.java @@ -58,7 +58,7 @@ import java.util.Arrays; /** * An implementation of of the RSA signature algorithm; this is an RSA * encrypted MD5 hash followed by a SHA-1 hash. - * + * * @author Casey Marshall (csm@gnu.org) */ public class SSLRSASignatureImpl extends SignatureSpi @@ -69,7 +69,7 @@ public class SSLRSASignatureImpl extends SignatureSpi private final MessageDigest md5, sha; private boolean initSign = false; private boolean initVerify = false; - + public SSLRSASignatureImpl() throws NoSuchAlgorithmException { md5 = MessageDigest.getInstance("MD5"); @@ -149,7 +149,7 @@ public class SSLRSASignatureImpl extends SignatureSpi @Override protected byte[] engineSign() throws SignatureException { // FIXME we need to add RSA blinding to this, somehow. - + if (!initSign) throw new SignatureException("not initialized for signing"); // Pad the hash results with RSA block type 1. diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/SSLServerSocketFactoryImpl.java b/libjava/classpath/gnu/javax/net/ssl/provider/SSLServerSocketFactoryImpl.java index dc80dc78248..67620d173a6 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/SSLServerSocketFactoryImpl.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/SSLServerSocketFactoryImpl.java @@ -1,4 +1,4 @@ -/* SSLServerSocketFactoryImpl.java -- +/* SSLServerSocketFactoryImpl.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -50,7 +50,7 @@ import javax.net.ssl.SSLServerSocketFactory; public class SSLServerSocketFactoryImpl extends SSLServerSocketFactory { private final SSLContextImpl contextImpl; - + public SSLServerSocketFactoryImpl(SSLContextImpl contextImpl) { this.contextImpl = contextImpl; diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/SSLServerSocketImpl.java b/libjava/classpath/gnu/javax/net/ssl/provider/SSLServerSocketImpl.java index 41ef5f1cf46..5b07017f0a8 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/SSLServerSocketImpl.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/SSLServerSocketImpl.java @@ -1,4 +1,4 @@ -/* SSLServerSocketImpl.java -- +/* SSLServerSocketImpl.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -48,7 +48,7 @@ import javax.net.ssl.SSLServerSocket; public class SSLServerSocketImpl extends SSLServerSocket { private final SSLContextImpl contextImpl; - + private boolean enableSessionCreation; private String[] enabledCipherSuites; private String[] enabledProtocols; @@ -183,7 +183,7 @@ public class SSLServerSocketImpl extends SSLServerSocket { wantClientAuth = wantAuth; } - + @Override public SSLSocketImpl accept() throws IOException { SSLSocketImpl socketImpl = new SSLSocketImpl(contextImpl, null, -1); diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/SSLSocketFactoryImpl.java b/libjava/classpath/gnu/javax/net/ssl/provider/SSLSocketFactoryImpl.java index 2915941db6e..d5dd54bce31 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/SSLSocketFactoryImpl.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/SSLSocketFactoryImpl.java @@ -1,4 +1,4 @@ -/* SSLSocketFactoryImpl.java -- +/* SSLSocketFactoryImpl.java -- Copyright (C) 2006, 2007 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -55,7 +55,7 @@ public class SSLSocketFactoryImpl extends SSLSocketFactory * The SSLContextImpl that created us. */ private final SSLContextImpl contextImpl; - + public SSLSocketFactoryImpl(SSLContextImpl contextImpl) { this.contextImpl = contextImpl; diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/SSLSocketImpl.java b/libjava/classpath/gnu/javax/net/ssl/provider/SSLSocketImpl.java index eead7258bbc..9072c288666 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/SSLSocketImpl.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/SSLSocketImpl.java @@ -73,7 +73,7 @@ public class SSLSocketImpl extends SSLSocket { private final ByteBuffer buffer; private final OutputStream out; - + SocketOutputStream() throws IOException { buffer = ByteBuffer.wrap(new byte[getSession().getPacketBufferSize()]); @@ -112,12 +112,12 @@ public class SSLSocketImpl extends SSLSocket } } } - + @Override public void write(int b) throws IOException { write(new byte[] { (byte) b }); } - + @Override public void close() throws IOException { SSLSocketImpl.this.close(); @@ -197,12 +197,12 @@ public class SSLSocketImpl extends SSLSocket private IOException handshakeException; private boolean initialHandshakeDone = false; private final boolean autoClose; - + public SSLSocketImpl(SSLContextImpl contextImpl, String host, int port) { this(contextImpl, host, port, new Socket(), true); } - + public SSLSocketImpl(SSLContextImpl contextImpl, String host, int port, Socket underlyingSocket, boolean autoClose) { @@ -361,7 +361,7 @@ public class SSLSocketImpl extends SSLSocket if (handshakeException != null) throw handshakeException; - + Thread t = new Thread(new Runnable() { public void run() @@ -378,7 +378,7 @@ public class SSLSocketImpl extends SSLSocket }, "HandshakeThread@" + System.identityHashCode(this)); t.start(); } - + void doHandshake() throws IOException { synchronized (engine) @@ -396,13 +396,13 @@ public class SSLSocketImpl extends SSLSocket } isHandshaking = true; } - + if (initialHandshakeDone) throw new SSLException("rehandshaking not yet implemented"); long now = -System.currentTimeMillis(); engine.beginHandshake(); - + HandshakeStatus status = engine.getHandshakeStatus(); assert(status != HandshakeStatus.NOT_HANDSHAKING); @@ -411,10 +411,10 @@ public class SSLSocketImpl extends SSLSocket ByteBuffer outBuffer = ByteBuffer.wrap(new byte[getSession().getPacketBufferSize()]); ByteBuffer emptyBuffer = ByteBuffer.allocate(0); SSLEngineResult result = null; - + DataInputStream sockIn = new DataInputStream(underlyingSocket.getInputStream()); OutputStream sockOut = underlyingSocket.getOutputStream(); - + try { while (status != HandshakeStatus.NOT_HANDSHAKING @@ -477,7 +477,7 @@ public class SSLSocketImpl extends SSLSocket throw new SSLException("unexpected SSL status " + result.getStatus()); outBuffer.flip(); - sockOut.write(outBuffer.array(), outBuffer.position(), + sockOut.write(outBuffer.array(), outBuffer.position(), outBuffer.limit()); } break; @@ -536,14 +536,14 @@ public class SSLSocketImpl extends SSLSocket } } } - + // Methods overriding Socket. @Override public void bind(SocketAddress bindpoint) throws IOException { underlyingSocket.bind(bindpoint); } - + @Override public void connect(SocketAddress endpoint) throws IOException { underlyingSocket.connect(endpoint); @@ -559,12 +559,12 @@ public class SSLSocketImpl extends SSLSocket { return underlyingSocket.getInetAddress(); } - + @Override public InetAddress getLocalAddress() { return underlyingSocket.getLocalAddress(); } - + @Override public int getPort() { return underlyingSocket.getPort(); diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/SSLv3HMacMD5Impl.java b/libjava/classpath/gnu/javax/net/ssl/provider/SSLv3HMacMD5Impl.java index 763bbaf3b77..5ef84ca1cc8 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/SSLv3HMacMD5Impl.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/SSLv3HMacMD5Impl.java @@ -1,4 +1,4 @@ -/* SSLv3HMacMD5.java -- +/* SSLv3HMacMD5.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -59,7 +59,7 @@ public class SSLv3HMacMD5Impl extends MacSpi { adaptee = new SSLHMac("MD5"); } - + /* (non-Javadoc) * @see javax.crypto.MacSpi#engineDoFinal() */ diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/SSLv3HMacSHAImpl.java b/libjava/classpath/gnu/javax/net/ssl/provider/SSLv3HMacSHAImpl.java index 008a21c049d..6b9c9e9ccef 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/SSLv3HMacSHAImpl.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/SSLv3HMacSHAImpl.java @@ -1,4 +1,4 @@ -/* SSLv3HMacSHA.java -- +/* SSLv3HMacSHA.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -59,7 +59,7 @@ public class SSLv3HMacSHAImpl extends MacSpi { adaptee = new SSLHMac("SHA-160"); } - + /* (non-Javadoc) * @see javax.crypto.MacSpi#engineDoFinal() */ diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/ServerDHE_PSKParameters.java b/libjava/classpath/gnu/javax/net/ssl/provider/ServerDHE_PSKParameters.java index 2d21d9d4554..1de3f81245a 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/ServerDHE_PSKParameters.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/ServerDHE_PSKParameters.java @@ -1,4 +1,4 @@ -/* ServerDHE_PSKParameters.java -- +/* ServerDHE_PSKParameters.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -60,12 +60,12 @@ import java.nio.charset.Charset; public class ServerDHE_PSKParameters implements Constructed, Builder, ServerKeyExchangeParams { private ByteBuffer buffer; - + public ServerDHE_PSKParameters(ByteBuffer buffer) { this.buffer = buffer.duplicate().order(ByteOrder.BIG_ENDIAN); } - + public ServerDHE_PSKParameters(String identityHint, ServerDHParams dhParams) { this(identityHint, dhParams.buffer()); @@ -78,7 +78,7 @@ public class ServerDHE_PSKParameters implements Constructed, Builder, ServerKeyE buffer = ByteBuffer.allocate(2 + hintBuf.remaining() + dhParams.remaining()); buffer.putShort((short) hintBuf.remaining()); buffer.put(hintBuf); - buffer.put(dhParams); + buffer.put(dhParams); } public KeyExchangeAlgorithm algorithm() @@ -93,19 +93,19 @@ public class ServerDHE_PSKParameters implements Constructed, Builder, ServerKeyE { return (buffer.getShort(0) & 0xFFFF) + 2 + params().length(); } - + private int hintLength() { return (buffer.getShort(0) & 0xFFFF) + 2; } - + public String identityHint() { Charset utf8 = Charset.forName("UTF-8"); return utf8.decode((ByteBuffer) buffer.duplicate().position(2).limit (hintLength())).toString(); } - + public ServerDHParams params() { return new ServerDHParams(((ByteBuffer) buffer.duplicate().position @@ -119,7 +119,7 @@ public class ServerDHE_PSKParameters implements Constructed, Builder, ServerKeyE { return (ByteBuffer) buffer.duplicate().rewind().limit(length()); } - + public @Override String toString() { return toString(null); diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/ServerDHParams.java b/libjava/classpath/gnu/javax/net/ssl/provider/ServerDHParams.java index 55d4a41da94..0e2c3488131 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/ServerDHParams.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/ServerDHParams.java @@ -64,7 +64,7 @@ public class ServerDHParams implements Builder, ServerKeyExchangeParams { this.buffer = buffer.duplicate().order(ByteOrder.BIG_ENDIAN); } - + public ServerDHParams (final BigInteger p, final BigInteger g, final BigInteger y) { @@ -72,7 +72,7 @@ public class ServerDHParams implements Builder, ServerKeyExchangeParams byte[] g_bytes = g.toByteArray(); byte[] y_bytes = y.toByteArray(); int len = p_bytes.length + g_bytes.length + y_bytes.length + 6; - + int p_off = 0; if (p_bytes[0] == 0x00) { @@ -94,7 +94,7 @@ public class ServerDHParams implements Builder, ServerKeyExchangeParams int p_len = p_bytes.length - p_off; int g_len = g_bytes.length - g_off; int y_len = y_bytes.length - y_off; - + buffer = ByteBuffer.allocate(len); buffer.putShort((short) p_len); buffer.put(p_bytes, p_off, p_len); @@ -121,7 +121,7 @@ public class ServerDHParams implements Builder, ServerKeyExchangeParams { return (ByteBuffer) buffer.duplicate().position(0).limit(length()); } - + /** * Returns the server's prime modulus. * diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/ServerHandshake.java b/libjava/classpath/gnu/javax/net/ssl/provider/ServerHandshake.java index e30f04241a0..d69fa120d10 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/ServerHandshake.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/ServerHandshake.java @@ -90,7 +90,7 @@ import javax.net.ssl.SSLEngineResult.HandshakeStatus; import javax.security.auth.x500.X500Principal; class ServerHandshake extends AbstractHandshake -{ +{ /** * Handshake state enumeration. */ @@ -109,21 +109,21 @@ class ServerHandshake extends AbstractHandshake READ_CERTIFICATE_VERIFY (false, true), READ_FINISHED (false, true), DONE (false, false); - + private final boolean isWriteState; private final boolean isReadState; - + private State(final boolean isWriteState, final boolean isReadState) { this.isWriteState = isWriteState; this.isReadState = isReadState; } - + boolean isReadState() { return isReadState; } - + boolean isWriteState() { return isWriteState; @@ -143,7 +143,7 @@ class ServerHandshake extends AbstractHandshake private boolean helloV2 = false; private KeyPair dhPair; private PrivateKey serverKey; - + // Delegated tasks we use. private GenDH genDH; private CertVerifier certVerifier; @@ -224,11 +224,11 @@ class ServerHandshake extends AbstractHandshake kexes.add(DHE_PSK); kexes.add(PSK); } - + if (Debug.DEBUG) logger.logv(Component.SSL_HANDSHAKE, "we have certs for key exchange algorithms {0}", kexes); - + HashSet<CipherSuite> suites = new HashSet<CipherSuite>(); for (String s : enabledSuites) { @@ -247,7 +247,7 @@ class ServerHandshake extends AbstractHandshake if (suites.contains(resolved)) return resolved; } - + // We didn't find a match? throw new AlertException(new Alert(Alert.Level.FATAL, Alert.Description.INSUFFICIENT_SECURITY)); @@ -283,7 +283,7 @@ class ServerHandshake extends AbstractHandshake throw new SSLException ("no supported compression method"); } - + protected @Override boolean doHash() { boolean b = helloV2; @@ -308,7 +308,7 @@ class ServerHandshake extends AbstractHandshake Handshake handshake = new Handshake(buffer.slice(), engine.session().suite, engine.session().version); - + if (Debug.DEBUG) logger.logv(Component.SSL_HANDSHAKE, "processing in state {0}:\n{1}", state, handshake); @@ -328,7 +328,7 @@ class ServerHandshake extends AbstractHandshake if (handshake.type () != CLIENT_HELLO) throw new AlertException(new Alert(Alert.Level.FATAL, Alert.Description.UNEXPECTED_MESSAGE)); - + { ClientHello hello = (ClientHello) handshake.body (); engine.session().version @@ -366,7 +366,7 @@ class ServerHandshake extends AbstractHandshake engine.session().maxLength = len; engine.session().setApplicationBufferSize(len.maxLength()); break; - + case SERVER_NAME: requestedNames = (ServerNameList) e.value(); List<String> names @@ -426,7 +426,7 @@ class ServerHandshake extends AbstractHandshake state = READ_CLIENT_KEY_EXCHANGE; return HandshakeStatus.NEED_UNWRAP; } - + Certificate cert = (Certificate) handshake.body(); try { @@ -472,7 +472,7 @@ class ServerHandshake extends AbstractHandshake if (handshake.type() != CLIENT_KEY_EXCHANGE) throw new SSLException("expecting client key exchange"); ClientKeyExchange kex = (ClientKeyExchange) handshake.body(); - + KeyExchangeAlgorithm alg = engine.session().suite.keyExchangeAlgorithm(); switch (alg) { @@ -500,7 +500,7 @@ class ServerHandshake extends AbstractHandshake tasks.add(keyExchangeTask); } break; - + case PSK: { ClientPSKParameters params = (ClientPSKParameters) @@ -508,7 +508,7 @@ class ServerHandshake extends AbstractHandshake generatePSKSecret(params.identity(), null, false); } break; - + case DHE_PSK: { ClientDHE_PSKParameters params = (ClientDHE_PSKParameters) @@ -530,7 +530,7 @@ class ServerHandshake extends AbstractHandshake tasks.add(keyExchangeTask); } break; - + case RSA_PSK: { ClientRSA_PSKParameters params = (ClientRSA_PSKParameters) @@ -554,7 +554,7 @@ class ServerHandshake extends AbstractHandshake tasks.add(keyExchangeTask); } break; - + case NONE: { Inflater inflater = null; @@ -575,7 +575,7 @@ class ServerHandshake extends AbstractHandshake break; } // XXX SRP - + if (clientCert != null) state = READ_CERTIFICATE_VERIFY; else @@ -595,7 +595,7 @@ class ServerHandshake extends AbstractHandshake { if (handshake.type() != CERTIFICATE_VERIFY) throw new SSLException("expecting certificate verify message"); - + CertificateVerify verify = (CertificateVerify) handshake.body(); try { @@ -617,7 +617,7 @@ class ServerHandshake extends AbstractHandshake state = READ_FINISHED; } break; - + // Finished. // // This message is sent immediately following the change cipher @@ -637,7 +637,7 @@ class ServerHandshake extends AbstractHandshake Description.UNEXPECTED_MESSAGE)); Finished clientFinished = (Finished) handshake.body(); - + MessageDigest md5copy = null; MessageDigest shacopy = null; try @@ -659,7 +659,7 @@ class ServerHandshake extends AbstractHandshake if (Debug.DEBUG) logger.log(Component.SSL_HANDSHAKE, "server finished: {0}", serverFinished); - + if (engine.session().version == ProtocolVersion.SSL_3) { if (!Arrays.equals(clientFinished.md5Hash(), @@ -680,7 +680,7 @@ class ServerHandshake extends AbstractHandshake throw new SSLException("session verify failed"); } } - + if (continuedSession) state = DONE; else @@ -711,7 +711,7 @@ class ServerHandshake extends AbstractHandshake logger.logv(Component.SSL_HANDSHAKE, "handle output state: {0}; output fragment: {1}", state, fragment); - + // Drain the output buffer, if it needs it. if (outBuffer != null && outBuffer.hasRemaining()) { @@ -719,7 +719,7 @@ class ServerHandshake extends AbstractHandshake fragment.put((ByteBuffer) outBuffer.duplicate().limit(outBuffer.position() + l)); outBuffer.position(outBuffer.position() + l); } - + if (!fragment.hasRemaining()) { if (state.isWriteState() || outBuffer.hasRemaining()) @@ -727,7 +727,7 @@ class ServerHandshake extends AbstractHandshake else return HandshakeStatus.NEED_UNWRAP; } - + // XXX what we need to do here is generate a "stream" of handshake // messages, and insert them into fragment amounts that we have available. // A handshake message can span multiple records, and we can put @@ -808,7 +808,7 @@ output_loop: state = READ_CLIENT_HELLO; } break output_loop; // XXX temporary - + // Server Hello. // // This message is sent immediately following the client hello. @@ -834,7 +834,7 @@ output_loop: } else // Don't send any extensions. hello.setDisableExtensions(true); - + if (Debug.DEBUG) logger.log(Component.SSL_HANDSHAKE, "{0}", hello); @@ -921,7 +921,7 @@ output_loop: logger.logv(Component.SSL_HANDSHAKE, "my cert:\n{0}", localCert); logger.logv(Component.SSL_HANDSHAKE, "{0}", cert); } - + int typeLen = ((CERTIFICATE.getValue() << 24) | (cert.length() & 0xFFFFFF)); fragment.putInt(typeLen); @@ -961,7 +961,7 @@ output_loop: case WRITE_SERVER_KEY_EXCHANGE: { KeyExchangeAlgorithm kex = engine.session().suite.keyExchangeAlgorithm(); - + ByteBuffer paramBuffer = null; ByteBuffer sigBuffer = null; if (kex == DHE_DSS || kex == DHE_RSA || kex == DH_anon @@ -978,7 +978,7 @@ output_loop: engine.session().random()); paramBuffer = genDH.paramsBuffer; sigBuffer = genDH.sigBuffer; - + if (kex == DHE_PSK) { String identityHint @@ -1009,7 +1009,7 @@ output_loop: } } // XXX handle SRP - + if (paramBuffer != null) { ServerKeyExchangeBuilder ske @@ -1017,10 +1017,10 @@ output_loop: ske.setParams(paramBuffer); if (sigBuffer != null) ske.setSignature(sigBuffer); - + if (Debug.DEBUG) logger.log(Component.SSL_HANDSHAKE, "{0}", ske); - + outBuffer = ske.buffer(); int l = Math.min(fragment.remaining(), outBuffer.remaining()); fragment.putInt((SERVER_KEY_EXCHANGE.getValue() << 24) @@ -1029,7 +1029,7 @@ output_loop: (outBuffer.position() + l)); outBuffer.position(outBuffer.position() + l); } - + if (engine.getWantClientAuth() || engine.getNeedClientAuth()) state = WRITE_CERTIFICATE_REQUEST; else @@ -1048,7 +1048,7 @@ output_loop: case WRITE_CERTIFICATE_REQUEST: { CertificateRequestBuilder req = new CertificateRequestBuilder(); - + List<ClientCertificateType> types = new ArrayList<ClientCertificateType>(4); types.add(ClientCertificateType.RSA_SIGN); @@ -1056,7 +1056,7 @@ output_loop: types.add(ClientCertificateType.DSS_SIGN); types.add(ClientCertificateType.DSS_FIXED_DH); req.setTypes(types); - + X509Certificate[] anchors = engine.contextImpl.trustManager.getAcceptedIssuers(); List<X500Principal> issuers @@ -1064,18 +1064,18 @@ output_loop: for (X509Certificate cert : anchors) issuers.add(cert.getIssuerX500Principal()); req.setAuthorities(issuers); - + if (Debug.DEBUG) logger.log(Component.SSL_HANDSHAKE, "{0}", req); - + fragment.putInt((CERTIFICATE_REQUEST.getValue() << 24) | (req.length() & 0xFFFFFF)); - + outBuffer = req.buffer(); int l = Math.min(outBuffer.remaining(), fragment.remaining()); fragment.put((ByteBuffer) outBuffer.duplicate().limit(outBuffer.position() + l)); outBuffer.position(outBuffer.position() + l); - + state = WRITE_SERVER_HELLO_DONE; } break; @@ -1097,7 +1097,7 @@ output_loop: state = READ_CERTIFICATE; } break output_loop; // XXX temporary - + // Finished. // // This is always sent by the server to verify the keys that the @@ -1129,10 +1129,10 @@ output_loop: outBuffer = generateFinished(md5copy, shacopy, false, engine.session()); - + fragment.putInt((FINISHED.getValue() << 24) | outBuffer.remaining() & 0xFFFFFF); - + int l = Math.min(outBuffer.remaining(), fragment.remaining()); fragment.put((ByteBuffer) outBuffer.duplicate().limit(outBuffer.position() + l)); outBuffer.position(outBuffer.position() + l); @@ -1151,10 +1151,10 @@ output_loop: return HandshakeStatus.NEED_WRAP; if (state.isReadState()) return HandshakeStatus.NEED_UNWRAP; - + return HandshakeStatus.FINISHED; } - + @Override HandshakeStatus status() { if (!tasks.isEmpty()) @@ -1163,7 +1163,7 @@ output_loop: return HandshakeStatus.NEED_UNWRAP; if (state.isWriteState()) return HandshakeStatus.NEED_WRAP; - + return HandshakeStatus.FINISHED; } @@ -1185,7 +1185,7 @@ output_loop: Alert.Description.HANDSHAKE_FAILURE), keyExchangeTask.thrown()); } - + @Override void handleV2Hello(ByteBuffer hello) { int len = hello.getShort(0) & 0x7FFF; @@ -1211,7 +1211,7 @@ output_loop: Signature signature = new Signature(sigVal, engine.session().suite.signatureAlgorithm()); return signature.buffer(); } - + private void verifyClient(byte[] sigValue) throws SSLException, SignatureException { MessageDigest md5copy = null; @@ -1236,7 +1236,7 @@ output_loop: else toSign = shacopy.digest(); } - + try { java.security.Signature sig = java.security.Signature.getInstance(engine.session().suite.signatureAlgorithm().toString()); @@ -1253,7 +1253,7 @@ output_loop: throw new SSLException(nsae); } } - + // Delegated tasks. class CertLoader extends DelegatedTask @@ -1261,7 +1261,7 @@ output_loop: CertLoader() { } - + public void implRun() throws SSLException { KeyExchangeAlgorithm kexalg = engine.session().suite.keyExchangeAlgorithm(); @@ -1279,7 +1279,7 @@ output_loop: km.getPrivateKey(keyAlias)); } } - + /** * Delegated task for generating Diffie-Hellman parameters. */ @@ -1297,13 +1297,13 @@ output_loop: dhGen.initialize(dhparams, engine.session().random()); dhPair = dhGen.generateKeyPair(); DHPublicKey pub = (DHPublicKey) dhPair.getPublic(); - + // Generate the parameters message. ServerDHParams params = new ServerDHParams(pub.getParams().getP(), pub.getParams().getG(), pub.getY()); paramsBuffer = params.buffer(); - + // Sign the parameters, if needed. if (engine.session().suite.signatureAlgorithm() != SignatureAlgorithm.ANONYMOUS) { @@ -1316,7 +1316,7 @@ output_loop: dhPair.getPublic(), dhPair.getPrivate()); } } - + class RSAKeyExchange extends DelegatedTask { private final byte[] encryptedPreMasterSecret; @@ -1325,7 +1325,7 @@ output_loop: { this.encryptedPreMasterSecret = encryptedPreMasterSecret; } - + public void implRun() throws BadPaddingException, IllegalBlockSizeException, InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, SSLException @@ -1339,18 +1339,18 @@ output_loop: setupSecurityParameters(keys, false, engine, compression); } } - + class RSA_PSKExchange extends DelegatedTask { private final byte[] encryptedPreMasterSecret; private final SecretKey psKey; - + RSA_PSKExchange(byte[] encryptedPreMasterSecret, SecretKey psKey) { this.encryptedPreMasterSecret = encryptedPreMasterSecret; this.psKey = psKey; } - + public @Override void implRun() throws BadPaddingException, IllegalBlockSizeException, InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, SSLException @@ -1368,7 +1368,7 @@ output_loop: preMasterSecret[rsaSecret.length + 3] = (byte) psSecret.length; System.arraycopy(psSecret, 0, preMasterSecret, rsaSecret.length+4, psSecret.length); - + generateMasterSecret(clientRandom, serverRandom, engine.session()); byte[][] keys = generateKeys(clientRandom, serverRandom, engine.session()); setupSecurityParameters(keys, false, engine, compression); diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/ServerHello.java b/libjava/classpath/gnu/javax/net/ssl/provider/ServerHello.java index 2bbce37fb3d..944194b3e86 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/ServerHello.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/ServerHello.java @@ -74,7 +74,7 @@ public class ServerHello implements Handshake.Body protected ByteBuffer buffer; protected boolean disableExtensions; - + // Constructor. // ------------------------------------------------------------------------- @@ -170,7 +170,7 @@ public class ServerHello implements Handshake.Body return 0; return buffer.getShort(offset) & 0xFFFF; } - + public ExtensionList extensions () { int offset = SESSID_OFFSET2 + (buffer.get (SESSID_OFFSET) & 0xFF) + 3; diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/ServerHelloBuilder.java b/libjava/classpath/gnu/javax/net/ssl/provider/ServerHelloBuilder.java index 09ad1d9e8a9..47bce29ee63 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/ServerHelloBuilder.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/ServerHelloBuilder.java @@ -1,4 +1,4 @@ -/* ServerHelloBuilder.java -- +/* ServerHelloBuilder.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -57,11 +57,11 @@ public class ServerHelloBuilder extends ServerHello implements Builder { return ((ByteBuffer) buffer.duplicate().position(0).limit(length())).slice(); } - + // We don't reallocate the buffer in any of the following methods, // because we always allocate a large enough buffer for the base // object in the constructor. - + public void setVersion (final ProtocolVersion version) { buffer.putShort (0, (short) version.rawValue ()); @@ -95,12 +95,12 @@ public class ServerHelloBuilder extends ServerHello implements Builder } // For extensions, we do reallocate the buffer. - + public void setDisableExtensions(boolean disable) { disableExtensions = disable; } - + public void setExtensionsLength (final int length) { if (length < 0 || length > 16384) @@ -111,7 +111,7 @@ public class ServerHelloBuilder extends ServerHello implements Builder buffer.putShort (SESSID_OFFSET2 + (buffer.get (SESSID_OFFSET) & 0xFF) + 3, (short) length); } - + public void setExtensions(ByteBuffer extensions) { extensions = (ByteBuffer) @@ -120,7 +120,7 @@ public class ServerHelloBuilder extends ServerHello implements Builder + (buffer.get(SESSID_OFFSET) & 0xFF) )).put(extensions); } - + public void ensureCapacity(int newCapacity) { ByteBuffer newBuffer = ByteBuffer.allocate(newCapacity); diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/ServerHelloDone.java b/libjava/classpath/gnu/javax/net/ssl/provider/ServerHelloDone.java index e09772250a5..987b51c56c2 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/ServerHelloDone.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/ServerHelloDone.java @@ -63,4 +63,4 @@ public class ServerHelloDone implements Handshake.Body return ((prefix != null ? prefix : "") + "struct { } ServerHelloDone;"); } -}
\ No newline at end of file +} diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/ServerKeyExchangeBuilder.java b/libjava/classpath/gnu/javax/net/ssl/provider/ServerKeyExchangeBuilder.java index d4b6fa39736..658ae228a59 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/ServerKeyExchangeBuilder.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/ServerKeyExchangeBuilder.java @@ -1,4 +1,4 @@ -/* ServerKeyExchangeBuilder.java -- +/* ServerKeyExchangeBuilder.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -42,7 +42,7 @@ import java.nio.ByteBuffer; /** * Builder for {@link ServerKeyExchange} objects. - * + * * @author Casey Marshall (csm@gnu.org) */ public class ServerKeyExchangeBuilder extends ServerKeyExchange @@ -68,7 +68,7 @@ public class ServerKeyExchangeBuilder extends ServerKeyExchange ensureCapacity(params.remaining()); buffer.duplicate().put(params); } - + public void setSignature(ByteBuffer signature) { if (suite.keyExchangeAlgorithm() == KeyExchangeAlgorithm.NONE) @@ -77,7 +77,7 @@ public class ServerKeyExchangeBuilder extends ServerKeyExchange ensureCapacity(paramsLen + signature.remaining()); ((ByteBuffer) buffer.duplicate().position(paramsLen)).put(signature); } - + public void ensureCapacity(int capacity) { if (buffer.capacity() >= capacity) diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/ServerNameList.java b/libjava/classpath/gnu/javax/net/ssl/provider/ServerNameList.java index 5a268f542ab..38f092476cc 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/ServerNameList.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/ServerNameList.java @@ -54,7 +54,7 @@ import java.util.NoSuchElementException; /** * The ServerName extension. - * + * * <pre> struct { NameType name_type; @@ -82,12 +82,12 @@ struct { public class ServerNameList extends Value implements Iterable<ServerNameList.ServerName> { private ByteBuffer buffer; - + public ServerNameList (final ByteBuffer buffer) { this.buffer = buffer.duplicate().order(ByteOrder.BIG_ENDIAN); } - + public ServerNameList(List<ServerName> names) { int length = 2; @@ -104,12 +104,12 @@ public class ServerNameList extends Value implements Iterable<ServerNameList.Ser { return (buffer.getShort(0) & 0xFFFF) + 2; } - + public ByteBuffer buffer() { return (ByteBuffer) buffer.duplicate().limit(length()); } - + public int size() { int n = 0; @@ -122,7 +122,7 @@ public class ServerNameList extends Value implements Iterable<ServerNameList.Ser } return n; } - + public ServerName get (int index) { final int len = length(); @@ -142,14 +142,14 @@ public class ServerNameList extends Value implements Iterable<ServerNameList.Ser ByteBuffer buf = ((ByteBuffer) buffer.duplicate().position(i).limit(i+l+3)).slice(); return new ServerName (buf); } - + public void setLength(final int newLength) { if (newLength < 0 || newLength > 65535) throw new IllegalArgumentException("length must be between 0 and 65535"); buffer.putShort(0, (short) newLength); } - + public String toString() { return toString(null); @@ -172,7 +172,7 @@ public class ServerNameList extends Value implements Iterable<ServerNameList.Ser out.print ("};"); return str.toString(); } - + public java.util.Iterator<ServerName> iterator() { return new Iterator(); @@ -181,17 +181,17 @@ public class ServerNameList extends Value implements Iterable<ServerNameList.Ser public class Iterator implements java.util.Iterator<ServerName> { private int index; - + public Iterator() { index = 0; } - + public boolean hasNext() { return index < size(); } - + public ServerName next() throws NoSuchElementException { try @@ -203,7 +203,7 @@ public class ServerNameList extends Value implements Iterable<ServerNameList.Ser throw new NoSuchElementException(); } } - + public void remove() { throw new UnsupportedOperationException(); @@ -213,12 +213,12 @@ public class ServerNameList extends Value implements Iterable<ServerNameList.Ser public static class ServerName implements Constructed { private ByteBuffer buffer; - + public ServerName(final ByteBuffer buffer) { this.buffer = buffer.duplicate().order(ByteOrder.BIG_ENDIAN); } - + public ServerName(NameType type, String name) { CharsetEncoder utf8 = Charset.forName("UTF-8").newEncoder(); @@ -239,12 +239,12 @@ public class ServerNameList extends Value implements Iterable<ServerNameList.Ser buffer.put(nameBuf); buffer.rewind(); } - + public int length() { return (buffer.getShort(1) & 0xFFFF) + 3; } - + public ByteBuffer buffer() { return (ByteBuffer) buffer.duplicate().limit(length()); @@ -259,19 +259,19 @@ public class ServerNameList extends Value implements Iterable<ServerNameList.Ser } throw new IllegalArgumentException ("illegal name type: " + v); } - + public String name() { int len = length(); Charset cs = Charset.forName ("UTF-8"); return cs.decode(((ByteBuffer) buffer.duplicate().position(3).limit(len))).toString(); } - + public String toString() { return toString (null); } - + public String toString(String prefix) { StringWriter str = new StringWriter(); @@ -295,14 +295,14 @@ public class ServerNameList extends Value implements Iterable<ServerNameList.Ser public static enum NameType { HOST_NAME (0); - + private final int value; - + private NameType (int value) { this.value = value; } - + public int getValue() { return value; diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/ServerPSKParameters.java b/libjava/classpath/gnu/javax/net/ssl/provider/ServerPSKParameters.java index 8acce6dde51..9ecedb5136f 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/ServerPSKParameters.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/ServerPSKParameters.java @@ -1,4 +1,4 @@ -/* ServerPSKParameters.java -- +/* ServerPSKParameters.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is a part of GNU Classpath. @@ -59,12 +59,12 @@ import java.nio.charset.Charset; public class ServerPSKParameters implements Builder, Constructed, ServerKeyExchangeParams { private ByteBuffer buffer; - + public ServerPSKParameters(ByteBuffer buffer) { this.buffer = buffer.duplicate().order(ByteOrder.BIG_ENDIAN); } - + public ServerPSKParameters(String identityHint) { Charset utf8 = Charset.forName("UTF-8"); @@ -74,7 +74,7 @@ public class ServerPSKParameters implements Builder, Constructed, ServerKeyExcha buffer.put(identityHintBuffer); buffer.rewind(); } - + public KeyExchangeAlgorithm algorithm() { return KeyExchangeAlgorithm.PSK; @@ -95,7 +95,7 @@ public class ServerPSKParameters implements Builder, Constructed, ServerKeyExcha { return (buffer.getShort(0) & 0xFFFF) + 2; } - + public String identityHint() { Charset utf8 = Charset.forName("UTF-8"); diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/ServerRSA_PSKParameters.java b/libjava/classpath/gnu/javax/net/ssl/provider/ServerRSA_PSKParameters.java index 0d7b590d27f..0895afe96b5 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/ServerRSA_PSKParameters.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/ServerRSA_PSKParameters.java @@ -1,4 +1,4 @@ -/* ServerRSA_PSKParameters.java -- +/* ServerRSA_PSKParameters.java -- Copyright (C) 2006 Free Software Foundation, Inc. This file is a part of GNU Classpath. diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/SessionImpl.java b/libjava/classpath/gnu/javax/net/ssl/provider/SessionImpl.java index 6a4020117ec..6eb070efc21 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/SessionImpl.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/SessionImpl.java @@ -60,25 +60,25 @@ public class SessionImpl extends Session byte[] privateDataSalt; SealedObject sealedPrivateData; MaxFragmentLength maxLength; - + transient PrivateData privateData; - + public SessionImpl() { super(); privateData = new PrivateData(); } - + SecureRandom random () { return random; } - + public String getProtocol() { return version.toString(); } - + public void prepare(char[] passwd) throws SSLException { try @@ -111,7 +111,7 @@ public class SessionImpl extends Session throw new SSLException(nspe); } } - + public void repair(char[] passwd) throws SSLException { try @@ -136,14 +136,14 @@ public class SessionImpl extends Session throw new SSLException(nsae); } } - + public SealedObject privateData() throws SSLException { if (privateData == null) throw new SSLException("this session has not been prepared"); return sealedPrivateData; } - + public void setPrivateData(SealedObject so) throws SSLException { this.sealedPrivateData = so; @@ -153,37 +153,37 @@ public class SessionImpl extends Session { applicationBufferSize = size; } - + void setRandom(SecureRandom random) { this.random = random; } - + void setTruncatedMac(boolean truncatedMac) { this.truncatedMac = truncatedMac; } - + void setId(Session.ID id) { this.sessionId = id; } - + void setLocalCertificates(java.security.cert.Certificate[] chain) { this.localCerts = chain; } - + void setPeerCertificates(java.security.cert.Certificate[] chain) { this.peerCerts = chain; } - + void setPeerVerified(boolean peerVerified) { this.peerVerified = peerVerified; } - + static class PrivateData implements Serializable { static final long serialVersionUID = -8040597659545984581L; diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/Signature.java b/libjava/classpath/gnu/javax/net/ssl/provider/Signature.java index d95e181370e..160dd805f8e 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/Signature.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/Signature.java @@ -81,7 +81,7 @@ public class Signature implements Builder, Constructed this.buffer = buffer; this.alg = alg; } - + public Signature (final byte[] sigValue, final SignatureAlgorithm alg) { buffer = ByteBuffer.allocate(sigValue.length + 2); @@ -100,7 +100,7 @@ public class Signature implements Builder, Constructed return 0; return (buffer.getShort (0) & 0xFFFF) + 2; } - + public ByteBuffer buffer() { return (ByteBuffer) buffer.duplicate().limit(length()); diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/SignatureAlgorithm.java b/libjava/classpath/gnu/javax/net/ssl/provider/SignatureAlgorithm.java index a789576db90..79cff5626bc 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/SignatureAlgorithm.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/SignatureAlgorithm.java @@ -41,12 +41,12 @@ package gnu.javax.net.ssl.provider; public enum SignatureAlgorithm { ANONYMOUS, RSA, DSA; - + /** * Returns the algorithm name for this signature algorithm, which can * be used with the JCA API to get a {@link java.security.Signature} for * that algorithm. - * + * * @return The algorithm name. */ public String algorithm() diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/SimpleSessionContext.java b/libjava/classpath/gnu/javax/net/ssl/provider/SimpleSessionContext.java index 20503d3cabe..8d57450614d 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/SimpleSessionContext.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/SimpleSessionContext.java @@ -48,7 +48,7 @@ import java.util.Map; /** * A simple, non-persistent SessionContext. - * + * * @author csm */ public final class SimpleSessionContext @@ -58,17 +58,17 @@ public final class SimpleSessionContext * By default, sessions last for 5 minutes. */ public static final int DEFAULT_TIMEOUT = 300; - + private final HashMap<Session.ID, Session> store; private int storeLimit; - + public SimpleSessionContext() { super(DEFAULT_TIMEOUT); storeLimit = 0; store = new HashMap<Session.ID, Session>(); } - + @Override protected Session implGet(byte[] sessionId) { @@ -116,12 +116,12 @@ public final class SimpleSessionContext return new Enumeration() { Iterator<Session.ID> it = store.keySet().iterator(); - + public boolean hasMoreElements() { return it.hasNext(); } - + public Object nextElement() { return it.next().id(); diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/TruncatedHMAC.java b/libjava/classpath/gnu/javax/net/ssl/provider/TruncatedHMAC.java index 0595f87a7a6..97fff98dce2 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/TruncatedHMAC.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/TruncatedHMAC.java @@ -45,7 +45,7 @@ import java.nio.ByteBuffer; /** * The value type for the {@link Extension.Type#TRUNCATED_HMAC} extension. * This extension has an empty value; this class is thusly empty. - * + * * @author csm */ public class TruncatedHMAC extends Value @@ -55,12 +55,12 @@ public class TruncatedHMAC extends Value { return 0; } - + public ByteBuffer buffer() { return ByteBuffer.wrap(new byte[0]); } - + public String toString() { return toString(null); diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/TrustedAuthorities.java b/libjava/classpath/gnu/javax/net/ssl/provider/TrustedAuthorities.java index 85e359675a7..72d07273951 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/TrustedAuthorities.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/TrustedAuthorities.java @@ -51,7 +51,7 @@ import javax.security.auth.x500.X500Principal; /** * The trusted authorities hello extension. - * + * * <pre> struct { TrustedAuthority trusted_authorities_list<0..2^16-1>; @@ -73,7 +73,7 @@ enum { } IdentifierType; opaque DistinguishedName<1..2^16-1>;</pre> - * + * * @author csm */ public class TrustedAuthorities extends Value @@ -85,19 +85,19 @@ public class TrustedAuthorities extends Value { this.buffer = buffer.duplicate().order(ByteOrder.BIG_ENDIAN); } - + // XXX really implement Builder. - + public int length() { return 2 + (buffer.getShort(0) & 0xFFFF); } - + public ByteBuffer buffer() { return (ByteBuffer) buffer.duplicate().limit(length()); } - + public int size() { int len = buffer.getShort(0) & 0xFFFF; @@ -128,12 +128,12 @@ public class TrustedAuthorities extends Value } throw new IndexOutOfBoundsException(); } - + public String toString() { return toString(null); } - + public String toString(String prefix) { StringWriter str = new StringWriter(); @@ -149,21 +149,21 @@ public class TrustedAuthorities extends Value out.print("} TrustedAuthorities;"); return str.toString(); } - + public Iterator<TrustedAuthority> iterator() { return new AuthoritiesIterator(); } - + public class AuthoritiesIterator implements Iterator<TrustedAuthority> { private int index; - + public AuthoritiesIterator() { index = 0; } - + public TrustedAuthority next() throws NoSuchElementException { try @@ -175,12 +175,12 @@ public class TrustedAuthorities extends Value throw new NoSuchElementException(); } } - + public boolean hasNext() { return index < size(); } - + public void remove() { throw new UnsupportedOperationException(); @@ -190,12 +190,12 @@ public class TrustedAuthorities extends Value public static class TrustedAuthority implements Constructed { private final ByteBuffer buffer; - + public TrustedAuthority(final ByteBuffer buffer) { this.buffer = buffer; } - + public int length() { switch (type().getValue()) @@ -207,7 +207,7 @@ public class TrustedAuthorities extends Value } throw new IllegalArgumentException("unknown authority type"); } - + public byte[] sha1Hash() { IdentifierType t = type(); @@ -218,7 +218,7 @@ public class TrustedAuthorities extends Value ((ByteBuffer) buffer.duplicate().position(1)).get(b); return b; } - + public X500Principal name() { int len = buffer.getShort(1) & 0xFFFF; @@ -226,7 +226,7 @@ public class TrustedAuthorities extends Value ((ByteBuffer) buffer.duplicate().position(3)).get(b); return new X500Principal(b); } - + public IdentifierType type() { switch (buffer.get(0)) @@ -236,15 +236,15 @@ public class TrustedAuthorities extends Value case 2: return IdentifierType.X509_NAME; case 3: return IdentifierType.CERT_SHA1_HASH; } - + throw new IllegalArgumentException("invalid IdentifierType"); } - + public String toString() { return toString(null); } - + public String toString(String prefix) { StringWriter str = new StringWriter(); @@ -265,7 +265,7 @@ public class TrustedAuthorities extends Value out.print(Util.toHexString(sha1Hash(), ':')); out.println(";"); break; - + case 2: if (prefix != null) out.print(prefix); out.print(" name = "); @@ -277,18 +277,18 @@ public class TrustedAuthorities extends Value return str.toString(); } } - + public static enum IdentifierType { PRE_AGREED (0), KEY_SHA1_HASH (1), X509_NAME (2), CERT_SHA1_HASH (3); - + private final int value; - + private IdentifierType(final int value) { this.value = value; } - + public int getValue() { return value; diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/UnresolvedExtensionValue.java b/libjava/classpath/gnu/javax/net/ssl/provider/UnresolvedExtensionValue.java index f54dda5bc6d..94cd091c5ed 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/UnresolvedExtensionValue.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/UnresolvedExtensionValue.java @@ -45,32 +45,32 @@ import java.nio.ByteBuffer; public class UnresolvedExtensionValue extends Value { private final ByteBuffer buffer; - + public UnresolvedExtensionValue (final ByteBuffer buffer) { this.buffer = buffer; } - + public int length() { return buffer.limit(); } - + public ByteBuffer buffer() { return value(); } - + public ByteBuffer value() { return buffer.slice(); } - + public String toString() { return toString(null); } - + public String toString(final String prefix) { String s = Util.hexDump(buffer); diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/Util.java b/libjava/classpath/gnu/javax/net/ssl/provider/Util.java index 57f637c1849..a2004b7aa63 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/Util.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/Util.java @@ -77,29 +77,29 @@ public final class Util { return wrapBuffer(buffer, ""); } - + public static Object wrapBuffer(ByteBuffer buffer, String prefix) { return new WrappedBuffer(buffer, prefix); } - + private static class WrappedBuffer { private final ByteBuffer buffer; private final String prefix; - + WrappedBuffer(ByteBuffer buffer, String prefix) { this.buffer = buffer; this.prefix = prefix; } - + public String toString() { return hexDump(buffer, prefix); } } - + /** * Convert a hexadecimal string into its byte representation. * diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/X500PrincipalList.java b/libjava/classpath/gnu/javax/net/ssl/provider/X500PrincipalList.java index 1c88479cbbc..ffdcbbad2ec 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/X500PrincipalList.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/X500PrincipalList.java @@ -188,7 +188,7 @@ public final class X500PrincipalList implements Iterable<X500Principal> { return new Iterator(); } - + public class Iterator implements ListIterator<X500Principal> { private final int modCount; @@ -269,4 +269,4 @@ public final class X500PrincipalList implements Iterable<X500Principal> throw new UnsupportedOperationException (); } } -}
\ No newline at end of file +} diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/X509KeyManagerFactory.java b/libjava/classpath/gnu/javax/net/ssl/provider/X509KeyManagerFactory.java index c3b7e5f4b8f..a63cb2cbeb5 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/X509KeyManagerFactory.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/X509KeyManagerFactory.java @@ -270,7 +270,7 @@ public class X509KeyManagerFactory extends KeyManagerFactorySpi } return null; } - + public @Override String chooseEngineClientAlias(String[] keyTypes, Principal[] issuers, SSLEngine engine) @@ -297,7 +297,7 @@ public class X509KeyManagerFactory extends KeyManagerFactorySpi return s[0]; return null; } - + public @Override String chooseEngineServerAlias(String keyType, Principal[] issuers, SSLEngine engine) diff --git a/libjava/classpath/gnu/javax/net/ssl/provider/X509TrustManagerFactory.java b/libjava/classpath/gnu/javax/net/ssl/provider/X509TrustManagerFactory.java index 1a0591284a4..ddd2f9c8b52 100644 --- a/libjava/classpath/gnu/javax/net/ssl/provider/X509TrustManagerFactory.java +++ b/libjava/classpath/gnu/javax/net/ssl/provider/X509TrustManagerFactory.java @@ -83,7 +83,7 @@ public class X509TrustManagerFactory extends TrustManagerFactorySpi private static final String sep = AccessController.doPrivileged(new GetPropertyAction("file.separator")); - + /** * The location of the JSSE key store. */ @@ -253,7 +253,7 @@ public class X509TrustManagerFactory extends TrustManagerFactorySpi throws CertificateException { CertPathValidator validator = null; - + try { validator = CertPathValidator.getInstance("PKIX"); @@ -262,9 +262,9 @@ public class X509TrustManagerFactory extends TrustManagerFactorySpi { throw new CertificateException(nsae); } - + CertPath path = new X509CertPath(Arrays.asList(chain)); - + PKIXParameters params = null; try { @@ -277,7 +277,7 @@ public class X509TrustManagerFactory extends TrustManagerFactorySpi { throw new CertificateException(iape); } - + try { validator.validate(path, params); |