public int Generate(byte[] output, byte[] additionalInput, bool predictionResistant) { lock (this) { lazyInitDRBG(); if (predictionResistant) { // FSM_STATE:5.7, "DRBG RESEED HEALTH CHECK", "The module is performing DRBG Reseed Health Check self-test" // FSM_TRANS:5.7, "CONDITIONAL TEST", "DRBG RESEED HEALTH CHECKS", "Invoke DRBG Reseed Health Check" SelfTestExecutor.Validate(algorithm, drbg.CreateReseedSelfTest(algorithm)); // reseed health test // FSM_TRANS:5.8, "DRBG RESEED HEALTH CHECKS", "CONDITIONAL TEST", "DRBG Reseed Health Check successful" } // check if a reseed is required... if (drbg.Generate(output, additionalInput, predictionResistant) < 0) { // FSM_STATE:5.7, "DRBG RESEED HEALTH CHECK", "The module is performing DRBG Reseed Health Check self-test" // FSM_TRANS:5.7, "CONDITIONAL TEST", "DRBG RESEED HEALTH CHECKS", "Invoke DRBG Reseed Health Check" SelfTestExecutor.Validate(algorithm, drbg.CreateReseedSelfTest(algorithm)); // reseed health test // FSM_TRANS:5.8, "DRBG RESEED HEALTH CHECKS", "CONDITIONAL TEST", "DRBG Reseed Health Check successful" drbg.Reseed(null); return(drbg.Generate(output, additionalInput, predictionResistant)); } return(output.Length); } }
public Internal.IMac CreateEngine(EngineUsage usage) { Internal.IMac engine = SelfTestExecutor.Validate(Alg, new Internal.Macs.Poly1305(), new EngineSelfTest()); if (keyParameter != null) { engine.Init(keyParameter); } return(engine); }
public Internal.IBlockCipher CreateEngine(EngineUsage usage) { Internal.IBlockCipher engine = SelfTestExecutor.Validate(Alg, new DesEdeEngine(), new TripleDesSelfTest()); if (keyParameter != null) { engine.Init(usage == EngineUsage.ENCRYPTION, keyParameter); } return(engine); }
public Internal.IStreamCipher CreateEngine(EngineUsage usage) { Internal.IStreamCipher engine = SelfTestExecutor.Validate(Alg, new ChaChaEngine(), new EngineSelfTest()); if (keyParameter != null) { engine.Init(usage == EngineUsage.ENCRYPTION, keyParameter); } return(engine); }
private void lazyInitDRBG() { if (drbg == null) { drbg = drbgProvider.Get(entropySource); // FSM_STATE:5.6, "DRBG HEALTH CHECKS", "The module is performing DRBG Health Check self-test" // FSM_TRANS:5.5, "CONDITIONAL TEST", "DRBG HEALTH CHECKS", "Invoke DRBG Health Check" SelfTestExecutor.Validate(algorithm, drbg.CreateSelfTest(algorithm)); // instance health test // FSM_TRANS:5.6, "DRBG HEALTH CHECKS", "CONDITIONAL TEST", "DRBG Health Check successful" } }
public void Reseed(byte[] additionalInput) { lock (this) { lazyInitDRBG(); // FSM_STATE:5.7, "DRBG RESEED HEALTH CHECK", "The module is performing DRBG Reseed Health Check self-test" // FSM_TRANS:5.7, "CONDITIONAL TEST", "DRBG RESEED HEALTH CHECKS", "Invoke DRBG Reseed Health Check" SelfTestExecutor.Validate(algorithm, drbg.CreateReseedSelfTest(algorithm)); // reseed health test. // FSM_TRANS:5.8, "DRBG RESEED HEALTH CHECKS", "CONDITIONAL TEST", "DRBG Reseed Health Check successful" drbg.Reseed(additionalInput); } }
private static void validateKeyPair(FipsAlgorithm algorithm, AsymmetricCipherKeyPair kp) { switch (algorithm.Mode) { case AlgorithmMode.NONE: case AlgorithmMode.DSA: SelfTestExecutor.Validate(algorithm, kp, new DsaConsistencyTest()); break; case AlgorithmMode.CDH: SelfTestExecutor.Validate(algorithm, kp, new CdhConsistencyTest()); break; default: throw new InvalidOperationException("Unhandled EC algorithm: " + algorithm.Name); } }
public DsaSigner CreateEngine(EngineUsage usage) { // We do this using a pair-wise consistency test as per the IG 2nd March 2015, Section 9.4 return(SelfTestExecutor.Validate(Alg, new DsaSigner(), new DsaKatTest())); }
private static void CMacStartUpTest(EngineProvider provider) { SelfTestExecutor.Validate(CMac.Algorithm, provider, new CMacStartupTest()); }
private static void rsaKeyTransportTest(IEngineProvider <RsaBlindedEngine> provider) { SelfTestExecutor.Validate(WrapOaep.Algorithm, new RsaOaepKeyTransportTest(provider)); }
private static void GcmStartUpTest(EngineProvider provider) { SelfTestExecutor.Validate(Gcm.Algorithm, provider, new GcmStartupTest()); }
public override IXof CreateEngine(EngineUsage usage) { return(SelfTestExecutor.Validate(Algorithm.SHAKE256, new ShakeDigest(256), new XofKatTest(FipsKats.Values[FipsKats.Vec.Shake256]))); }
public override IDigest CreateEngine(EngineUsage usage) { return(SelfTestExecutor.Validate(Algorithm.SHA512_256, new Sha512tDigest(256), new ShaKatTest(FipsKats.Values[FipsKats.Vec.Sha512_256]))); }
private static void validateKeyPair(AsymmetricCipherKeyPair kp) { SelfTestExecutor.Validate(Alg, kp, new DsaKeyPairValidationTest()); }
private static void ecPrimitiveZTest() { SelfTestExecutor.Validate(Alg, new PrimitiveZTest()); }
public ECDHCBasicAgreement CreateEngine(EngineUsage usage) { return(SelfTestExecutor.Validate(Alg, new ECDHCBasicAgreement(), new DhcKatTest())); }
private static void DrbgStartUpTest() { SelfTestExecutor.Validate( Sha1.Algorithm, new DRBGHashSelfTest(Sha1.Algorithm, new DRBGTestVector( FipsShs.CreateDigest(FipsShs.Sha1), new KatEntropyProvider().Get(440), true, "2021222324", 128, new byte[][] { FipsKats.Values[FipsKats.Vec.DrbgSha1_A], FipsKats.Values[FipsKats.Vec.DrbgSha1_B] }) .setPersonalizationString("404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F70717273747576"))); SelfTestExecutor.Validate( Sha224.Algorithm, new DRBGHashSelfTest(Sha224.Algorithm, new DRBGTestVector( FipsShs.CreateDigest(FipsShs.Sha224), new KatEntropyProvider().Get(440), true, "2021222324", 192, new byte[][] { FipsKats.Values[FipsKats.Vec.DrbgSha224_A], FipsKats.Values[FipsKats.Vec.DrbgSha224_B] }) .setPersonalizationString("404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F70717273747576"))); SelfTestExecutor.Validate( Sha256.Algorithm, new DRBGHashSelfTest(Sha256.Algorithm, new DRBGTestVector( FipsShs.CreateDigest(FipsShs.Sha256), new KatEntropyProvider().Get(440), true, "2021222324", 256, new byte[][] { FipsKats.Values[FipsKats.Vec.DrbgSha256_A], FipsKats.Values[FipsKats.Vec.DrbgSha256_B] }) .setPersonalizationString("404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F70717273747576"))); SelfTestExecutor.Validate( Sha384.Algorithm, new DRBGHashSelfTest(Sha384.Algorithm, new DRBGTestVector( FipsShs.CreateDigest(FipsShs.Sha384), new KatEntropyProvider().Get(440), true, "2021222324", 256, new byte[][] { FipsKats.Values[FipsKats.Vec.DrbgSha384_A], FipsKats.Values[FipsKats.Vec.DrbgSha384_B] }) .setPersonalizationString("404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F70717273747576"))); SelfTestExecutor.Validate( Sha512.Algorithm, new DRBGHashSelfTest(Sha512.Algorithm, new DRBGTestVector( FipsShs.CreateDigest(FipsShs.Sha512), new KatEntropyProvider().Get(440), true, "2021222324", 256, new byte[][] { FipsKats.Values[FipsKats.Vec.DrbgSha512_A], FipsKats.Values[FipsKats.Vec.DrbgSha512_B] }) .setPersonalizationString("404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F70717273747576"))); SelfTestExecutor.Validate( Sha512_224.Algorithm, new DRBGHashSelfTest(Sha512_224.Algorithm, new DRBGTestVector( FipsShs.CreateDigest(FipsShs.Sha512_224), new KatEntropyProvider().Get(440), true, "2021222324", 192, new byte[][] { FipsKats.Values[FipsKats.Vec.DrbgSha512_224_A], FipsKats.Values[FipsKats.Vec.DrbgSha512_224_B] }) .setPersonalizationString("404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F70717273747576"))); SelfTestExecutor.Validate( Sha512_256.Algorithm, new DRBGHashSelfTest(Sha512_256.Algorithm, new DRBGTestVector( FipsShs.CreateDigest(FipsShs.Sha512_256), new KatEntropyProvider().Get(440), true, "2021222324", 256, new byte[][] { FipsKats.Values[FipsKats.Vec.DrbgSha512_256_A], FipsKats.Values[FipsKats.Vec.DrbgSha512_256_B] }) .setPersonalizationString("404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F70717273747576"))); SelfTestExecutor.Validate( Sha1HMac.Algorithm, new DRBGHMACSelfTest(Sha1HMac.Algorithm, new DRBGTestVector( FipsShs.CreateDigest(FipsShs.Sha1), new KatEntropyProvider().Get(440), true, "2021222324", 128, new byte[][] { FipsKats.Values[FipsKats.Vec.DrbgHMacSha1_A], FipsKats.Values[FipsKats.Vec.DrbgHMacSha1_B] }) .setPersonalizationString("404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F70717273747576"))); SelfTestExecutor.Validate( Sha224HMac.Algorithm, new DRBGHMACSelfTest(Sha224HMac.Algorithm, new DRBGTestVector( FipsShs.CreateDigest(FipsShs.Sha224), new KatEntropyProvider().Get(440), true, "2021222324", 192, new byte[][] { FipsKats.Values[FipsKats.Vec.DrbgHMacSha224_A], FipsKats.Values[FipsKats.Vec.DrbgHMacSha224_B] }) .setPersonalizationString("404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F70717273747576"))); SelfTestExecutor.Validate( Sha256HMac.Algorithm, new DRBGHMACSelfTest(Sha256HMac.Algorithm, new DRBGTestVector( FipsShs.CreateDigest(FipsShs.Sha256), new KatEntropyProvider().Get(440), true, "2021222324", 256, new byte[][] { FipsKats.Values[FipsKats.Vec.DrbgHMacSha256_A], FipsKats.Values[FipsKats.Vec.DrbgHMacSha256_B] }) .setPersonalizationString("404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F70717273747576"))); SelfTestExecutor.Validate( Sha384HMac.Algorithm, new DRBGHMACSelfTest(Sha384HMac.Algorithm, new DRBGTestVector( FipsShs.CreateDigest(FipsShs.Sha384), new KatEntropyProvider().Get(440), true, "2021222324", 256, new byte[][] { FipsKats.Values[FipsKats.Vec.DrbgHMacSha384_A], FipsKats.Values[FipsKats.Vec.DrbgHMacSha384_B] }) .setPersonalizationString("404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F70717273747576"))); SelfTestExecutor.Validate( Sha512HMac.Algorithm, new DRBGHMACSelfTest(Sha512HMac.Algorithm, new DRBGTestVector( FipsShs.CreateDigest(FipsShs.Sha512), new KatEntropyProvider().Get(440), true, "2021222324", 256, new byte[][] { FipsKats.Values[FipsKats.Vec.DrbgHMacSha512_A], FipsKats.Values[FipsKats.Vec.DrbgHMacSha512_B] }) .setPersonalizationString("404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F70717273747576"))); SelfTestExecutor.Validate( Sha512_224HMac.Algorithm, new DRBGHMACSelfTest(Sha512_224HMac.Algorithm, new DRBGTestVector( FipsShs.CreateDigest(FipsShs.Sha512_224), new KatEntropyProvider().Get(440), true, "2021222324", 192, new byte[][] { FipsKats.Values[FipsKats.Vec.DrbgHMacSha512_224_A], FipsKats.Values[FipsKats.Vec.DrbgHMacSha512_224_B] }) .setPersonalizationString("404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F70717273747576"))); SelfTestExecutor.Validate( Sha512_256HMac.Algorithm, new DRBGHMACSelfTest(Sha512_256HMac.Algorithm, new DRBGTestVector( FipsShs.CreateDigest(FipsShs.Sha512_256), new KatEntropyProvider().Get(440), true, "2021222324", 256, new byte[][] { FipsKats.Values[FipsKats.Vec.DrbgHMacSha512_256_A], FipsKats.Values[FipsKats.Vec.DrbgHMacSha512_256_B] }) .setPersonalizationString("404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F70717273747576"))); SelfTestExecutor.Validate( CtrTripleDes168.Algorithm, new DRBGCTRSelfTest(CtrTripleDes168.Algorithm, new DRBGTestVector( FipsTripleDes.ENGINE_PROVIDER.CreateEngine(EngineUsage.GENERAL), 168, new KatEntropyProvider().Get(440), true, "2021222324", 112, new byte[][] { FipsKats.Values[FipsKats.Vec.DrbgCtrTripleDes168_A], FipsKats.Values[FipsKats.Vec.DrbgCtrTripleDes168_B] }) .setPersonalizationString("404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F70717273747576"))); SelfTestExecutor.Validate( CtrAes128.Algorithm, new DRBGCTRSelfTest(CtrAes128.Algorithm, new DRBGTestVector( FipsAes.ENGINE_PROVIDER.CreateEngine(EngineUsage.GENERAL), 128, new KatEntropyProvider().Get(440), true, "2021222324", 128, new byte[][] { FipsKats.Values[FipsKats.Vec.DrbgCtrAes128_A], FipsKats.Values[FipsKats.Vec.DrbgCtrAes128_B] }) .setPersonalizationString("404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F70717273747576"))); SelfTestExecutor.Validate( CtrAes192.Algorithm, new DRBGCTRSelfTest(CtrAes192.Algorithm, new DRBGTestVector( FipsAes.ENGINE_PROVIDER.CreateEngine(EngineUsage.GENERAL), 192, new KatEntropyProvider().Get(440), true, "2021222324", 192, new byte[][] { FipsKats.Values[FipsKats.Vec.DrbgCtrAes192_A], FipsKats.Values[FipsKats.Vec.DrbgCtrAes192_B] }) .setPersonalizationString("404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F70717273747576"))); SelfTestExecutor.Validate( CtrAes256.Algorithm, new DRBGCTRSelfTest(CtrAes256.Algorithm, new DRBGTestVector( FipsAes.ENGINE_PROVIDER.CreateEngine(EngineUsage.GENERAL), 256, new KatEntropyProvider().Get(440), true, "2021222324", 256, new byte[][] { FipsKats.Values[FipsKats.Vec.DrbgCtrAes256_A], FipsKats.Values[FipsKats.Vec.DrbgCtrAes256_B] }) .setPersonalizationString("404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F70717273747576"))); }
public IDigest CreateEngine(EngineUsage usage) { return(SelfTestExecutor.Validate(Tls1_0.Algorithm, new MD5Digest(), new Md5KatTest())); }
private static void ValidateKeyPair(AsymmetricCipherKeyPair kp) { SelfTestExecutor.Validate(Alg, kp, new RsaKeyPairConsistencyTest()); }
public override IDigest CreateEngine(EngineUsage usage) { return(SelfTestExecutor.Validate(Algorithm.SHA3_512, new Sha3Digest(512), new ShaKatTest(FipsKats.Values[FipsKats.Vec.Sha3_512]))); }
public RsaBlindedEngine CreateEngine(EngineUsage usage) { return(SelfTestExecutor.Validate(Alg, new RsaBlindedEngine(), new RsaEngineTest())); }
public override IMac CreateEngine(EngineUsage usage) { return(SelfTestExecutor.Validate(Algorithm.SHA512_256_HMAC, new HMac(new Sha512tDigest(256)), new HMacKatTest(FipsKats.Values[FipsKats.Vec.Sha512_256HMac]))); }
private static void rsaSignTest(IEngineProvider <RsaBlindedEngine> provider) { SelfTestExecutor.Validate(Pkcs1v15.Algorithm, new RsaSignTest(provider)); }