internal override void Evaluate() { byte[] oaepOut = Hex.Decode( "4458cce0f94ebd79d275a134d224f95ef4126034e5d979359703b466096fcc15b71b78df4d4a68033112dfcfad7611cc" + "0458475ab4a66b815f87fcb16a8aa1133441b9d61ed846c4856c5d42059fab7505bd8ffa5281a2bb187c6c853f298c98" + "d5752a40be905f85e5ccb27d59415f09ac12a1788d654c675d98f412e6481e6f1159f1736dd96b29c99b411b4e5420b5" + "6b07be2885dbc397fa091f66877c41e502cb4afeba460a2ebcdec7d09d933e630b98a4510ad6f32ca7ffc1bdb43e46ff" + "f709819d3a69d9b62b774cb12c9dc176a6911bf370ab5029719dc1b4c13e23e57e46a7cd8ba5ee54c954ed460835ddab" + "0086fa36ac110a5790e82c929bc7ca86"); IAsymmetricBlockCipher cipher = new OaepEncoding(provider.CreateEngine(EngineUsage.GENERAL), new Sha1Digest(), new Sha1Digest(), null); cipher.Init(true, new ParametersWithRandom(testPubKey, new TestRandomData("18b776ea21069d69776a33e96bad48e1dda0a5ef"))); byte[] output; output = cipher.ProcessBlock(msg, 0, msg.Length); if (!Arrays.AreEqual(FipsKats.Values[FipsKats.Vec.RsaStartupOaepEnc], output)) { Fail("self test OAEP transport encrypt failed."); } cipher.Init(false, new ParametersWithRandom(testPrivKey, Utils.testRandom)); output = cipher.ProcessBlock(oaepOut, 0, oaepOut.Length); if (!Arrays.AreEqual(FipsKats.Values[FipsKats.Vec.RsaStartupOaepDec], output)) { Fail("self test OAEP transport decrypt failed."); } }
public IMac CreateEngine(EngineUsage usage) { IMac mac = new AeadCipherMac(new CcmBlockCipher(baseProvider.CreateEngine(EngineUsage.ENCRYPTION)), parameters.MacSizeInBits); mac.Init(new Internal.Parameters.ParametersWithIV(null, parameters.GetIV())); return(mac); }
public IMac CreateEngine(EngineUsage usage) { IMac mac = new CMac(baseProvider.CreateEngine(EngineUsage.ENCRYPTION), macSizeInBits); mac.Init(null); return(mac); }
public ICipherBuilder <Parameters> doCreateCipherBuilder(bool forEncryption, Parameters parameters) { IBufferedCipher cipher = new BufferedStreamCipher(engineProvider.CreateEngine(forEncryption ? EngineUsage.ENCRYPTION : EngineUsage.DECRYPTION)); cipher.Init(forEncryption, null); return(new CipherBuilderImpl <Parameters> (parameters, cipher)); }
public ICipherBuilder <Parameters> DoCreateCipherBuilder(bool forEncryption, Parameters parameters) { IBufferedCipher cipher = new BufferedStreamCipher(engineProvider.CreateEngine(forEncryption ? EngineUsage.ENCRYPTION : EngineUsage.DECRYPTION)); cipher.Init(forEncryption, new ParametersWithRounds(new Internal.Parameters.ParametersWithIV(null, parameters.GetIV()), parameters.Rounds)); return(new CipherBuilderImpl <Parameters> (parameters, cipher)); }
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)); }
public byte [] ProduceImage(ScreenshotJob task) { using (var workerEngine = _engineProvider.CreateEngine(task)) { foreach (var cookie in task.Cookies) { workerEngine.Cookies.Add(cookie); } workerEngine.AcceptLanguages = task.AcceptLanguages; workerEngine.UserAgent = task.UserAgent; return(workerEngine.CaptureRawUrl(task.FinalUri, task.Timeout)); } }
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); } }
internal static IWrapper CreateWrapper(string name, AlgorithmMode algorithmMode, bool useInverse, bool forWrapping, IEngineProvider <Internal.IBlockCipher> baseCipherProvider) { Internal.IBlockCipher baseCipher = baseCipherProvider.CreateEngine(GetWrapUsage(useInverse, forWrapping)); IWrapper cipher; switch (algorithmMode) { case AlgorithmMode.WRAP: cipher = new SP80038FWrapEngine(baseCipher, useInverse); break; case AlgorithmMode.WRAPPAD: cipher = new SP80038FWrapWithPaddingEngine(baseCipher, useInverse); break; default: throw new ArgumentException("Unknown wrapper algorithm passed to " + name + ".Provider: " + algorithmMode); } cipher.Init(forWrapping, null); return(cipher); }
internal override void Evaluate() { RsaDigestSigner signer = new RsaDigestSigner(provider.CreateEngine(EngineUsage.GENERAL), FipsShs.CreateDigest(FipsShs.Sha256)); signer.Init(false, new RsaKeyParameters(false, katM, katE)); signer.BlockUpdate(msg, 0, msg.Length); if (!signer.VerifySignature(FipsKats.Values[FipsKats.Vec.RsaStartupVerifySig])) { Fail("self test signature verify failed."); } signer.Init(true, new ParametersWithRandom(testPrivKey, Utils.testRandom)); signer.BlockUpdate(msg, 0, msg.Length); byte[] sig = signer.GenerateSignature(); if (!Arrays.AreEqual(FipsKats.Values[FipsKats.Vec.RsaStartupResultSig], sig)) { Fail("self test signature generate failed."); } }
/// <summary> /// Create a stream calculator for the XOF associated with this factory. The stream /// calculator is used for the actual operation of entering the data to be processed /// and producing the XOF output. /// </summary> /// <returns>A calculator producing an StreamResult which can be used to read the output from the XOF.</returns> public IVariableStreamCalculator <IBlockResult> CreateCalculator() { CryptoServicesRegistrar.ApprovedModeCheck(approvedOnlyMode, "XofFactory"); return(new XofCalculator(xofProvider.CreateEngine(EngineUsage.GENERAL))); }
/// <summary> /// Create a stream calculator for the digest algorithm associated with this factory. The stream /// calculator is used for the actual operation of entering the data to be digested /// and producing the digest block. /// </summary> /// <returns>A calculator producing an IBlockResult with the final digest in it.</returns> public IStreamCalculator <IBlockResult> CreateCalculator() { CryptoServicesRegistrar.ApprovedModeCheck(approvedOnlyMode, "DigestFactory"); return(new DigestCalculator(digestProvider.CreateEngine(EngineUsage.GENERAL))); }
private IBlockCipherBuilder <Parameters> DoCreateBlockCipherBuilder(bool forEncryption, Parameters parameters) { EngineUsage engineUsage = forEncryption ? EngineUsage.ENCRYPTION : EngineUsage.DECRYPTION; IBufferedCipher cipher = ProviderUtils.CreateBufferedCipher("FipsTripleDES", parameters.Algorithm.Mode, parameters, desEdeEngineProvider.CreateEngine(engineUsage)); cipher.Init(forEncryption, null); return(new BlockCipherBuilderImpl <Parameters>(forEncryption, parameters, cipher)); }
/// <summary> /// Create a stream calculator for the signature algorithm associated with this factory. The stream /// calculator is used for the actual operation of entering the data to be signed /// and producing the signature block. /// </summary> /// <returns>A calculator producing an IBlockResult with the final signature in it.</returns> public IStreamCalculator <IBlockResult> CreateCalculator() { return(new SignatureCalculator(signerProvider.CreateEngine(EngineUsage.SIGNING))); }
/// <summary> /// Create a stream calculator for the digest algorithm associated with this factory. The stream /// calculator is used for the actual operation of entering the data to be digested /// and producing the digest block. /// </summary> /// <returns>A calculator producing an IBlockResult with the final digest in it.</returns> public IStreamCalculator <IBlockResult> CreateCalculator() { return(new MacCalculator(macProvider.CreateEngine(EngineUsage.GENERAL))); }
public IBlockCipherBuilder <TParam> CreateBlockDecryptorBuilder(TParam parameters) { if (CryptoServicesRegistrar.IsInApprovedOnlyMode()) { throw new CryptoUnapprovedOperationError("Attempt to create unapproved BlockCipherBuilder in approved only mode"); } IBufferedCipher cipher = ProviderUtils.CreateBufferedCipher(name, parameters.Algorithm.Mode, parameters, engineProvider.CreateEngine(EngineUsage.DECRYPTION)); cipher.Init(false, null); return(new BlockCipherBuilderImpl <TParam>(false, parameters, cipher)); }
/// <summary> /// Create a stream calculator for the signature algorithm associated with this factory. The stream /// calculator is used for the actual operation of entering the data to be signed /// and producing the signature block. /// </summary> /// <returns>A calculator producing an IBlockResult with the final signature in it.</returns> public IStreamCalculator <IVerifier> CreateCalculator() { return(new VerifierCalculator(signerProvider.CreateEngine(EngineUsage.VERIFICATION))); }