diff options
| author | mark <mark@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-08-14 23:12:35 +0000 |
|---|---|---|
| committer | mark <mark@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-08-14 23:12:35 +0000 |
| commit | ffde862e033a0825e1e9972a89c0f1f80b261a8e (patch) | |
| tree | 97037d2c09c8384d80531f67ec36a01205df6bdb /libjava/classpath/gnu/javax/crypto/mode/OFB.java | |
| parent | b415ff10527e977c3758234fd930e2c027bfa17d (diff) | |
| download | ppe42-gcc-ffde862e033a0825e1e9972a89c0f1f80b261a8e.tar.gz ppe42-gcc-ffde862e033a0825e1e9972a89c0f1f80b261a8e.zip | |
2006-08-14 Mark Wielaard <mark@klomp.org>
Imported GNU Classpath 0.92
* HACKING: Add more importing hints. Update automake version
requirement.
* configure.ac (gconf-peer): New enable AC argument.
Add --disable-gconf-peer and --enable-default-preferences-peer
to classpath configure when gconf is disabled.
* scripts/makemake.tcl: Set gnu/java/util/prefs/gconf and
gnu/java/awt/dnd/peer/gtk to bc. Classify
gnu/java/security/Configuration.java as generated source file.
* gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java,
gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java,
gnu/java/lang/management/VMClassLoadingMXBeanImpl.java,
gnu/java/lang/management/VMRuntimeMXBeanImpl.java,
gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java,
gnu/java/lang/management/VMThreadMXBeanImpl.java,
gnu/java/lang/management/VMMemoryMXBeanImpl.java,
gnu/java/lang/management/VMCompilationMXBeanImpl.java: New VM stub
classes.
* java/lang/management/VMManagementFactory.java: Likewise.
* java/net/VMURLConnection.java: Likewise.
* gnu/java/nio/VMChannel.java: Likewise.
* java/lang/Thread.java (getState): Add stub implementation.
* java/lang/Class.java (isEnum): Likewise.
* java/lang/Class.h (isEnum): Likewise.
* gnu/awt/xlib/XToolkit.java (getClasspathTextLayoutPeer): Removed.
* javax/naming/spi/NamingManager.java: New override for StackWalker
functionality.
* configure, sources.am, Makefile.in, gcj/Makefile.in,
include/Makefile.in, testsuite/Makefile.in: Regenerated.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@116139 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath/gnu/javax/crypto/mode/OFB.java')
| -rw-r--r-- | libjava/classpath/gnu/javax/crypto/mode/OFB.java | 128 |
1 files changed, 54 insertions, 74 deletions
diff --git a/libjava/classpath/gnu/javax/crypto/mode/OFB.java b/libjava/classpath/gnu/javax/crypto/mode/OFB.java index 68065d10b9c..c8b6d7e97e7 100644 --- a/libjava/classpath/gnu/javax/crypto/mode/OFB.java +++ b/libjava/classpath/gnu/javax/crypto/mode/OFB.java @@ -39,33 +39,33 @@ exception statement from your version. */ package gnu.javax.crypto.mode; import gnu.java.security.Registry; - import gnu.javax.crypto.cipher.IBlockCipher; /** - * <p>The Output Feedback (OFB) mode is a confidentiality mode that requires a + * The Output Feedback (OFB) mode is a confidentiality mode that requires a * unique <code>IV</code> for every message that is ever encrypted under the - * given key. The OFB mode is defined as follows:</p> - * + * given key. The OFB mode is defined as follows: + * <ul> + * <li>OFB Encryption: * <ul> - * <li>OFB Encryption: - * <ul> - * <li>I<sub>1</sub> = IV;</li> - * <li>I<sub>j</sub> = O<sub>j -1</sub> for j = 2...n;</li> - * <li>O<sub>j</sub> = CIPH<sub>K</sub>(I<sub>j</sub>) for j = 1, 2...n;</li> - * <li>C<sub>j</sub> = P<sub>j</sub> XOR O<sub>j</sub> for j = 1, 2...n.</li> - * </ul></li> + * <li>I<sub>1</sub> = IV;</li> + * <li>I<sub>j</sub> = O<sub>j -1</sub> for j = 2...n;</li> + * <li>O<sub>j</sub> = CIPH<sub>K</sub>(I<sub>j</sub>) for j = 1, 2...n;</li> + * <li>C<sub>j</sub> = P<sub>j</sub> XOR O<sub>j</sub> for j = 1, 2...n.</li> + * </ul> + * </li> * <li>OFB Decryption: - * <ul> - * <li>I<sub>1</sub> = IV;</li> - * <li>I<sub>j</sub> = O<sub>j -1</sub> for j = 2...n;</li> - * <li>O<sub>j</sub> = CIPH<sub>K</sub>(I<sub>j</sub>) for j = 1, 2...n;</li> - * <li>P<sub>j</sub> = C<sub>j</sub> XOR O<sub>j</sub> for j = 1, 2...n.</li> - * </ul></li> + * <ul> + * <li>I<sub>1</sub> = IV;</li> + * <li>I<sub>j</sub> = O<sub>j -1</sub> for j = 2...n;</li> + * <li>O<sub>j</sub> = CIPH<sub>K</sub>(I<sub>j</sub>) for j = 1, 2...n;</li> + * <li>P<sub>j</sub> = C<sub>j</sub> XOR O<sub>j</sub> for j = 1, 2...n.</li> * </ul> - * - * <p>In OFB encryption, the <code>IV</code> is transformed by the forward - * cipher function to produce the first output block. The first output block is + * </li> + * </ul> + * <p> + * In OFB encryption, the <code>IV</code> is transformed by the forward cipher + * function to produce the first output block. The first output block is * exclusive-ORed with the first plaintext block to produce the first ciphertext * block. The first output block is then transformed by the forward cipher * function to produce the second output block. The second output block is @@ -74,9 +74,9 @@ import gnu.javax.crypto.cipher.IBlockCipher; * cipher function to produce the third output block. Thus, the successive * output blocks are produced from enciphering the previous output blocks, and * the output blocks are exclusive-ORed with the corresponding plaintext blocks - * to produce the ciphertext blocks.</p> - * - * <p>In OFB decryption, the <code>IV</code> is transformed by the forward cipher + * to produce the ciphertext blocks. + * <p> + * In OFB decryption, the <code>IV</code> is transformed by the forward cipher * function to produce the first output block. The first output block is * exclusive-ORed with the first ciphertext block to recover the first plaintext * block. The first output block is then transformed by the forward cipher @@ -86,51 +86,46 @@ import gnu.javax.crypto.cipher.IBlockCipher; * forward cipher function to produce the third output block. Thus, the * successive output blocks are produced from enciphering the previous output * blocks, and the output blocks are exclusive-ORed with the corresponding - * ciphertext blocks to recover the plaintext blocks.</p> - * - * <p>In both OFB encryption and OFB decryption, each forward cipher function + * ciphertext blocks to recover the plaintext blocks. + * <p> + * In both OFB encryption and OFB decryption, each forward cipher function * (except the first) depends on the results of the previous forward cipher - * function; therefore, multiple forward cipher functions cannot be performed - * in parallel. However, if the <code>IV</code> is known, the output blocks can - * be generated prior to the availability of the plaintext or ciphertext data.</p> - * - * <p>The OFB mode requires a unique <code>IV</code> for every message that is + * function; therefore, multiple forward cipher functions cannot be performed in + * parallel. However, if the <code>IV</code> is known, the output blocks can + * be generated prior to the availability of the plaintext or ciphertext data. + * <p> + * The OFB mode requires a unique <code>IV</code> for every message that is * ever encrypted under the given key. If, contrary to this requirement, the * same <code>IV</code> is used for the encryption of more than one message, * then the confidentiality of those messages may be compromised. In particular, * if a plaintext block of any of these messages is known, say, the j<sup>th</sup> * plaintext block, then the j<sup>th</sup> output of the forward cipher - * function can be determined easily from the j<sup>th</sup> ciphertext block of - * the message. This information allows the j<sup>th</sup> plaintext block of - * any other message that is encrypted using the same <code>IV</code> to be - * easily recovered from the jth ciphertext block of that message.</p> - * - * <p>Confidentiality may similarly be compromised if any of the input blocks to + * function can be determined easily from the j<sup>th</sup> ciphertext block + * of the message. This information allows the j<sup>th</sup> plaintext block + * of any other message that is encrypted using the same <code>IV</code> to be + * easily recovered from the jth ciphertext block of that message. + * <p> + * Confidentiality may similarly be compromised if any of the input blocks to * the forward cipher function for the encryption of a message is used as the - * <code>IV</code> for the encryption of another message under the given key.</p> - * - * <p>References:</p> - * + * <code>IV</code> for the encryption of another message under the given key. + * <p> + * References: * <ol> - * <li><a href="http://csrc.nist.gov/encryption/modes/Recommendation/Modes01.pdf"> - * Recommendation for Block Cipher Modes of Operation Methods and Techniques</a>, - * Morris Dworkin.</li> + * <li><a + * href="http://csrc.nist.gov/encryption/modes/Recommendation/Modes01.pdf"> + * Recommendation for Block Cipher Modes of Operation Methods and Techniques</a>, + * Morris Dworkin.</li> * </ol> */ -public class OFB extends BaseMode implements Cloneable +public class OFB + extends BaseMode + implements Cloneable { - - // Constants and variables - // ------------------------------------------------------------------------- - private byte[] outputBlock; - // Constructor(s) - // ------------------------------------------------------------------------- - /** - * <p>Trivial package-private constructor for use by the Factory class.</p> - * + * Trivial package-private constructor for use by the Factory class. + * * @param underlyingCipher the underlying cipher implementation. * @param cipherBlockSize the underlying cipher block size to use. */ @@ -140,8 +135,8 @@ public class OFB extends BaseMode implements Cloneable } /** - * <p>Private constructor for cloning purposes.</p> - * + * Private constructor for cloning purposes. + * * @param that the mode to clone. */ private OFB(OFB that) @@ -149,28 +144,15 @@ public class OFB extends BaseMode implements Cloneable this((IBlockCipher) that.cipher.clone(), that.cipherBlockSize); } - // Class methods - // ------------------------------------------------------------------------- - - // Instance methods - // ------------------------------------------------------------------------- - - // java.lang.Cloneable interface implementation ---------------------------- - public Object clone() { return new OFB(this); } - // Implementation of abstract methods in BaseMode -------------------------- - public void setup() { if (modeBlockSize != cipherBlockSize) - { - throw new IllegalArgumentException(IMode.MODE_BLOCK_SIZE); - } - + throw new IllegalArgumentException(IMode.MODE_BLOCK_SIZE); outputBlock = (byte[]) iv.clone(); } @@ -182,13 +164,11 @@ public class OFB extends BaseMode implements Cloneable { cipher.encryptBlock(outputBlock, 0, outputBlock, 0); for (int j = 0; j < cipherBlockSize;) - { - out[o++] = (byte) (in[i++] ^ outputBlock[j++]); - } + out[o++] = (byte)(in[i++] ^ outputBlock[j++]); } public void decryptBlock(byte[] in, int i, byte[] out, int o) { this.encryptBlock(in, i, out, o); } -}
\ No newline at end of file +} |

