internal static IBufferedCipher CreateBufferedCipher(string name, AlgorithmMode algorithmMode, IParametersWithIV <IParameters <Algorithm>, Algorithm> parameters, bool forEncryption, IEngineProvider <Internal.IBlockCipher> cipherProvider) { Internal.IBlockCipher baseCipher = cipherProvider.CreateEngine(GetUsage(forEncryption, algorithmMode)); Internal.IBlockCipher cipher; switch (algorithmMode) { case AlgorithmMode.CBC: cipher = new CbcBlockCipher(baseCipher); break; case AlgorithmMode.CS1: return(new NistCtsBlockCipher(NistCtsBlockCipher.CS1, baseCipher)); case AlgorithmMode.CS2: return(new NistCtsBlockCipher(NistCtsBlockCipher.CS2, baseCipher)); case AlgorithmMode.CS3: return(new NistCtsBlockCipher(NistCtsBlockCipher.CS3, baseCipher)); case AlgorithmMode.CFB8: cipher = new CfbBlockCipher(baseCipher, 8); break; case AlgorithmMode.CFB64: cipher = new CfbBlockCipher(baseCipher, 64); break; case AlgorithmMode.CFB128: cipher = new CfbBlockCipher(baseCipher, 128); break; case AlgorithmMode.OpenPGPCFB: cipher = new OpenPgpCfbBlockCipher(baseCipher); break; case AlgorithmMode.OFB64: cipher = new OfbBlockCipher(baseCipher, 64); break; case AlgorithmMode.OFB128: cipher = new OfbBlockCipher(baseCipher, 128); break; case AlgorithmMode.CTR: cipher = new SicBlockCipher(baseCipher); break; default: throw new ArgumentException("Unknown algorithm mode passed to " + name + ".Provider: " + algorithmMode); } return(new BufferedBlockCipher(cipher)); }
internal static IAeadBlockCipher CreateAeadCipher(string name, AlgorithmMode algorithmMode, IParametersWithIV <IParameters <Algorithm>, Algorithm> parameters, bool forEncryption, IEngineProvider <Internal.IBlockCipher> cipherProvider) { Internal.IBlockCipher baseCipher = cipherProvider.CreateEngine(GetUsage(forEncryption, algorithmMode)); switch (algorithmMode) { case AlgorithmMode.CCM: return(new CcmBlockCipher(baseCipher)); case AlgorithmMode.GCM: return(new GcmBlockCipher(baseCipher)); default: throw new ArgumentException("Unknown algorithm mode passed to " + name + ".Provider: " + algorithmMode); } }