Imported GNU Classpath 0.90
[official-gcc.git] / libjava / classpath / gnu / javax / net / ssl / provider / SecurityParameters.java
blobaa06680e2006e097e2b5713023ca45da61c3cd51
1 /* SecurityParameters.java -- SSL security parameters.
2 Copyright (C) 2006 Free Software Foundation, Inc.
4 This file is a part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or (at
9 your option) any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
19 USA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package gnu.javax.net.ssl.provider;
41 import javax.net.ssl.SSLException;
43 /**
44 * The interface that all security parameters used by Jessie must implement.
45 * Security parameters handle all transforming of data, including encryption,
46 * authentication, and compression.
48 interface SecurityParameters
51 // Methods.
52 // -------------------------------------------------------------------------
54 /**
55 * Decrypts, verifies, and inflates a fragment received. The fragment is
56 * just the data field of a text object, without the version, type, and
57 * length fields. An exception is thrown if any step fails.
59 * @param fragment The fragment being decrypted.
60 * @param version The version field of the received text.
61 * @param type The type field of the received text.
62 * @return The decrypted fragment.
63 * @throws MacException If the MAC could not be verified, or if the padding
64 * on the decrypted fragment is incorrect.
65 * @throws OverflowException If the processed text overflows the configured
66 * maximum fragment size.
67 * @throws SSLException If any other error occurs.
69 byte[] decrypt (byte[] fragment, ProtocolVersion version, ContentType type)
70 throws MacException, OverflowException, SSLException;
72 /**
73 * Deflates, authenticates, and encrypts a fragment to be sent.
75 * @param buf The fragment being encrypted.
76 * @param off The offset into the buffer to start at.
77 * @param len The number of bytes in this fragment.
78 * @param type The content type of this text.
79 * @return The encrypted fragment.
80 * @throws OverflowException If deflating increases the size of the fragment
81 * too much.
82 * @throws SSLException If any other error occurs.
84 byte[] encrypt (byte[] buf, int off, int len, ContentType type)
85 throws OverflowException, SSLException;
87 /**
88 * Set all crypto primitives to <code>null</code>, meaning that any calls
89 * to {@link #encrypt(byte[],int,int,org.metastatic.jessie.provider.ContentType)} or
90 * {@link #decrypt(byte[],org.metastatic.jessie.provider.ProtocolVersion,org.metastatic.jessie.provider.ContentType})
91 * will perform the identity transformation.
93 void reset();
95 /**
96 * Returns the version of texts being sent.
98 * @return The version.
100 ProtocolVersion getVersion();
103 * Sets the version of texts being sent. This affects the {@link
104 * #encrypt(byte[],int,int,org.metastatic.jessie.provider.ContentType)}
105 * method.
107 * @param version The version to set.
109 void setVersion (ProtocolVersion version);
112 * Turns zlib deflating on or off.
114 * @param deflate Whether or not to deflate outgoing fragments.
116 void setDeflating (boolean deflate);
119 * Turns zlib inflating on or off.
121 * @param inflate Whether or not to inflate incoming fragments.
123 void setInflating (boolean inflate);
126 * Returns the maximum size that plaintext fragments may be.
128 * @return The fragment length.
130 int getFragmentLength();
133 * Sets the maximum size that plaintext fragments may be.
135 * @param fragmentLength The new fragment length.
137 void setFragmentLength (int fragmentLength);
140 * Set the cipher used to decrypt incoming fragments. The parameter must be
141 * appropriate for the implementation.
143 * @param cipher The cipher.
144 * @throws ClassCastException If the argument is not appropriate for the
145 * implementation.
147 void setInCipher (Object cipher);
150 * Set the cipher used to encrypt outgoing fragments. The parameter must be
151 * appropriate for the implementation.
153 * @param cipher The cipher.
154 * @throws ClassCastException If the argument is not appropriate for the
155 * implementation.
157 void setOutCipher (Object cipher);
160 * Set the MAC used to verify incoming fragments. The parameter must be
161 * appropriate for the implementation.
163 * @param mac The MAC.
164 * @throws ClassCastException If the argument is not appropriate for the
165 * implementation.
167 void setInMac (Object mac);
170 * Set the MAC used to authenticating outgoinging fragments. The parameter
171 * must be appropriate for the implementation.
173 * @param mac The MAC.
174 * @throws ClassCastException If the argument is not appropriate for the
175 * implementation.
177 void setOutMac (Object mac);