コード例 #1
0
ファイル: FipsDrbg.cs プロジェクト: NDWX/BouncyCastle.FIPS
            internal override void Evaluate()
            {
                byte[] nonce = tv.nonce();
                byte[] personalisationString = tv.personalizationString();

                ISP80090Drbg d = new CtrSP800Drbg(tv.getCipher(), tv.keySizeInBits(), tv.securityStrength(), tv.entropySource(), personalisationString, nonce);

                byte[] output = new byte[tv.expectedValue(0).Length];

                d.Generate(output, tv.additionalInput(0), tv.predictionResistance());

                byte[] expected = tv.expectedValue(0);

                if (!Arrays.AreEqual(expected, output))
                {
                    Fail("Self test " + algorithm.Name + ".1 failed, expected " + Strings.FromByteArray(Hex.Encode(tv.expectedValue(0))) + " got " + Strings.FromByteArray(Hex.Encode(output)));
                }

                output = new byte[tv.expectedValue(0).Length];

                d.Generate(output, tv.additionalInput(1), tv.predictionResistance());

                expected = tv.expectedValue(1);
                if (!Arrays.AreEqual(expected, output))
                {
                    Fail("Self test " + algorithm.Name + ".2 failed, expected " + Strings.FromByteArray(Hex.Encode(tv.expectedValue(1))) + " got " + Strings.FromByteArray(Hex.Encode(output)));
                }
            }
コード例 #2
0
 internal ReseedSelfTest(Algorithm algorithm, CtrSP800Drbg parent) : base(algorithm)
 {
     this.parent = parent;
 }
コード例 #3
0
ファイル: FipsDrbg.cs プロジェクト: NDWX/BouncyCastle.FIPS
            public IDrbg Get(IEntropySource entropySource)
            {
                CtrSP800Drbg drbg = new CtrSP800Drbg(blockCipher, keySizeInBits, securityStrength, entropySource, personalizationString, nonce);

                return(new ContinuousTestingPseudoRng(drbg, primaryAdditionalInput));
            }