From 53e57085de728ff9f23734f64e1a877ee39a327c Mon Sep 17 00:00:00 2001
From: Peter Dettman
* It can be found at ftp://ftp.funet.fi/pub/crypt/cryptography/symmetric/idea/ - *
+ * *- * Note 1: This algorithm is patented in the USA, Japan, and Europe including + * Note 1: This algorithm is patented in the USA, Japan, and Europe including * at least Austria, France, Germany, Italy, Netherlands, Spain, Sweden, Switzerland * and the United Kingdom. Non-commercial use is free, however any commercial * products are liable for royalties. Please see * www.mediacrypt.com for * further details. This announcement has been included at the request of * the patent holders. - *
- *- * Note 2: Due to the requests concerning the above, this algorithm is now only - * included in the extended assembly. It is not included in the default distributions. - *
+ * + *+ * Note 2: Due to the requests concerning the above, this algorithm is now only + * included in the extended assembly. It is not included in the default distributions. + *
*/ public class IdeaEngine - : IBlockCipher + : IBlockCipher { private const int BLOCK_SIZE = 8; private int[] workingKey; @@ -54,28 +52,28 @@ namespace Org.BouncyCastle.Crypto.Engines ICipherParameters parameters) { if (!(parameters is KeyParameter)) - throw new ArgumentException("invalid parameter passed to IDEA init - " + parameters.GetType().ToString()); + throw new ArgumentException("invalid parameter passed to IDEA init - " + parameters.GetType().ToString()); - workingKey = GenerateWorkingKey(forEncryption, - ((KeyParameter)parameters).GetKey()); + workingKey = GenerateWorkingKey(forEncryption, + ((KeyParameter)parameters).GetKey()); } - public string AlgorithmName + public string AlgorithmName { get { return "IDEA"; } } - public bool IsPartialBlockOkay - { - get { return false; } - } + public bool IsPartialBlockOkay + { + get { return false; } + } - public int GetBlockSize() + public int GetBlockSize() { return BLOCK_SIZE; } - public int ProcessBlock( + public int ProcessBlock( byte[] input, int inOff, byte[] output, @@ -228,7 +226,7 @@ namespace Org.BouncyCastle.Crypto.Engines * Common Divisor algorithm. Zero and one are self inverse. ** i.e. x * MulInv(x) == 1 (modulo BASE) - *
+ * */ private int MulInv( int x) @@ -261,7 +259,7 @@ namespace Org.BouncyCastle.Crypto.Engines * Return the additive inverse of x. ** i.e. x + AddInv(x) == 0 - *
+ * */ int AddInv( int x) @@ -337,5 +335,3 @@ namespace Org.BouncyCastle.Crypto.Engines } } } - -#endif diff --git a/crypto/src/security/CipherUtilities.cs b/crypto/src/security/CipherUtilities.cs index cda769535..cdb711f69 100644 --- a/crypto/src/security/CipherUtilities.cs +++ b/crypto/src/security/CipherUtilities.cs @@ -389,11 +389,9 @@ namespace Org.BouncyCastle.Security case CipherAlgorithm.HC256: streamCipher = new HC256Engine(); break; -#if INCLUDE_IDEA case CipherAlgorithm.IDEA: blockCipher = new IdeaEngine(); break; -#endif case CipherAlgorithm.NOEKEON: blockCipher = new NoekeonEngine(); break; @@ -716,9 +714,7 @@ namespace Org.BouncyCastle.Security case CipherAlgorithm.DES: return new DesEngine(); case CipherAlgorithm.DESEDE: return new DesEdeEngine(); case CipherAlgorithm.GOST28147: return new Gost28147Engine(); -#if INCLUDE_IDEA case CipherAlgorithm.IDEA: return new IdeaEngine(); -#endif case CipherAlgorithm.NOEKEON: return new NoekeonEngine(); case CipherAlgorithm.RC2: return new RC2Engine(); case CipherAlgorithm.RC5: return new RC532Engine(); diff --git a/crypto/src/security/MacUtilities.cs b/crypto/src/security/MacUtilities.cs index 49162fb57..77d141411 100644 --- a/crypto/src/security/MacUtilities.cs +++ b/crypto/src/security/MacUtilities.cs @@ -185,7 +185,6 @@ namespace Org.BouncyCastle.Security { return new CfbBlockCipherMac(new SkipjackEngine()); } -#if INCLUDE_IDEA if (mechanism == "IDEAMAC") { return new CbcBlockCipherMac(new IdeaEngine()); @@ -194,7 +193,6 @@ namespace Org.BouncyCastle.Security { return new CfbBlockCipherMac(new IdeaEngine()); } -#endif if (mechanism == "RC2MAC") { return new CbcBlockCipherMac(new RC2Engine()); diff --git a/crypto/src/security/ParameterUtilities.cs b/crypto/src/security/ParameterUtilities.cs index bf448edff..b2d7c0dff 100644 --- a/crypto/src/security/ParameterUtilities.cs +++ b/crypto/src/security/ParameterUtilities.cs @@ -83,10 +83,8 @@ namespace Org.BouncyCastle.Security CryptoProObjectIdentifiers.GostR28147Cbc); AddAlgorithm("HC128"); AddAlgorithm("HC256"); -#if INCLUDE_IDEA AddAlgorithm("IDEA", "1.3.6.1.4.1.188.7.1.1.2"); -#endif AddAlgorithm("NOEKEON"); AddAlgorithm("RC2", PkcsObjectIdentifiers.RC2Cbc, @@ -234,12 +232,10 @@ namespace Org.BouncyCastle.Security { iv = Cast5CbcParameters.GetInstance(asn1Params).GetIV(); } -#if INCLUDE_IDEA else if (canonical == "IDEA") { iv = IdeaCbcPar.GetInstance(asn1Params).GetIV(); } -#endif else if (canonical == "RC2") { iv = RC2CbcParameter.GetInstance(asn1Params).GetIV(); @@ -288,10 +284,8 @@ namespace Org.BouncyCastle.Security if (canonical == "CAST5") return new Cast5CbcParameters(CreateIV(random, 8), 128); -#if INCLUDE_IDEA if (canonical == "IDEA") return new IdeaCbcPar(CreateIV(random, 8)); -#endif if (canonical == "RC2") return new RC2CbcParameter(CreateIV(random, 8)); -- cgit 1.5.1