Exemplo n.º 1
0
            internal override void Evaluate()
            {
                byte[] nonce = tv.nonce();
                byte[] personalisationString = tv.personalizationString();

                ISP80090Drbg d = new HMacSP800Drbg(new HMac(tv.getDigest()), 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)));
                }
            }
Exemplo n.º 2
0
            public IDrbg Get(IEntropySource entropySource)
            {
                HMacSP800Drbg drbg = new HMacSP800Drbg(hMac, securityStrength, entropySource, personalizationString, nonce);

                return(new ContinuousTestingPseudoRng(drbg, primaryAdditionalInput));
            }
Exemplo n.º 3
0
 internal ReseedSelfTest(Algorithm algorithm, HMacSP800Drbg parent) : base(algorithm)
 {
     this.parent = parent;
 }