Ejemplo n.º 1
0
            public ISigner CreateEngine(EngineUsage usage)
            {
                ISigner sig = new PssSigner(ENGINE_PROVIDER.CreateEngine(usage), FipsShs.CreateDigest(parameters.DigestAlgorithm), parameters.SaltLength, parameters.GetSalt());

                sig.Init((usage == EngineUsage.SIGNING), sigParams);

                return(sig);
            }
Ejemplo n.º 2
0
            public bool HasTestPassed(AsymmetricCipherKeyPair kp)
            {
                byte[] data = Hex.Decode("576a1f885e3420128c8a656097ba7d8bb4c6f1b1853348cf2ba976971dbdbefc");

                DsaSigner signer = ENGINE_PROVIDER.CreateEngine(EngineUsage.GENERAL);

                signer.Init(true, new ParametersWithRandom(kp.Private, Utils.testRandom));

                BigInteger[] rv = signer.GenerateSignature(data);

                signer.Init(false, kp.Public);

                return(signer.VerifySignature(FipsKats.Values[FipsKats.Vec.DsaKeyPairConsistencyVec], rv[0], rv[1]));
            }
Ejemplo n.º 3
0
            internal RsaKeyWrapper(OaepWrapParameters algorithmDetails, IKey rsaPublicKey)
            {
                this.algorithmDetails = algorithmDetails;
                this.wrapper          = new OaepEncoding(ENGINE_PROVIDER.CreateEngine(EngineUsage.ENCRYPTION), FipsShs.CreateDigest(algorithmDetails.DigestAlgorithm), FipsShs.CreateDigest(algorithmDetails.MgfDigestAlgorithm), algorithmDetails.GetEncodingParams());

                if (CryptoServicesRegistrar.IsInApprovedOnlyMode())
                {
                    AsymmetricRsaPublicKey rsaKey = GetPublicKey(rsaPublicKey);
                    int bitLength = rsaKey.Modulus.BitLength;
                    if (bitLength != 2048 && bitLength != 3072)
                    {
                        throw new CryptoUnapprovedOperationError("Attempt to use RSA key with non-approved size: " + bitLength, rsaKey.Algorithm);
                    }
                }
                wrapper.Init(true, GetPublicParameters(rsaPublicKey, AsymmetricRsaKey.Usage.EncryptOrDecrypt));
            }
Ejemplo n.º 4
0
            public ISigner CreateEngine(EngineUsage usage)
            {
                ISigner sig;

                if (parameters.Algorithm.Mode == AlgorithmMode.PKCSv1_5)
                {
                    sig = new RsaDigestSigner(ENGINE_PROVIDER.CreateEngine(usage), FipsShs.CreateDigest(parameters.DigestAlgorithm));
                }
                else
                {
                    sig = new X931Signer(ENGINE_PROVIDER.CreateEngine(usage), FipsShs.CreateDigest(parameters.DigestAlgorithm), false);
                }

                sig.Init((usage == EngineUsage.SIGNING), sigParams);

                return(sig);
            }