Ejemplo n.º 1
0
 internal Parameters(FipsDigestAlgorithm digestAlgorithm, PasswordConverter converter, byte[] password, int iterationCount, byte[] salt) : base(ALGORITHM_PBKDF2)
 {
     this.digestAlgorithm = digestAlgorithm;
     this.converter       = converter;
     this.password        = password;
     this.iterationCount  = iterationCount;
     this.salt            = salt;
 }
Ejemplo n.º 2
0
 internal HMacDRBGProvider(FipsDigestAlgorithm algorithm, byte[] nonce, byte[] personalizationString, int securityStrength, byte[] primaryAdditionalInput)
 {
     CryptoStatus.IsReady();
     this.hMac  = FipsShs.CreateHmac(algorithm);
     this.nonce = nonce;
     this.personalizationString  = personalizationString;
     this.securityStrength       = securityStrength;
     this.primaryAdditionalInput = primaryAdditionalInput;
 }
Ejemplo n.º 3
0
            internal Builder(FipsAlgorithm algorithm, FipsDigestAlgorithm digestAlg, Variations variation, SecureRandom random, IEntropySourceProvider entropySourceProvider)
            {
                CryptoStatus.IsReady();

                this.algorithm             = algorithm;
                this.digestAlg             = digestAlg;
                this.variation             = variation;
                this.random                = random;
                this.entropySourceProvider = entropySourceProvider;
            }
Ejemplo n.º 4
0
            /// <summary>
            /// Base constructor.
            /// </summary>
            /// <param name="version">The version of DSS the validator is for.</param>
            /// <param name="digestAlgorithm">Digest to use in prime calculations.</param>
            /// <param name="random">Source of randomness for prime number testing.</param>
            public DomainParametersValidator(Version version, FipsDigestAlgorithm digestAlgorithm, SecureRandom random)
            {
                if (Version.FipsPub186_2 == version && digestAlgorithm != FipsShs.Sha1.Algorithm)
                {
                    throw new ArgumentException("186-2 can only validate with SHA-1");
                }

                if (CryptoServicesRegistrar.IsInApprovedOnlyMode())
                {
                    Utils.ValidateRandom(random, "FIPS SecureRandom required for DSA parameter validation in approved mode.");
                }

                this.version         = version;
                this.digestAlgorithm = digestAlgorithm;
                this.random          = random;
            }
Ejemplo n.º 5
0
            /// <summary>
            /// Base constructor.
            /// </summary>
            /// <param name="parameters">domain generation parameters.</param>
            /// <param name="random">A source of randomness for the parameter generation.</param>
            internal DomainParametersGenerator(DomainGenParameters parameters, SecureRandom random)
            {
                if (CryptoServicesRegistrar.IsInApprovedOnlyMode())
                {
                    int effSizeInBits = parameters.L;

                    if (effSizeInBits != 2048 && effSizeInBits != 3072)
                    {
                        throw new CryptoUnapprovedOperationError("attempt to create parameters with unapproved key size [" + effSizeInBits + "]", Alg);
                    }

                    Utils.ValidateRandom(random, Utils.GetAsymmetricSecurityStrength(effSizeInBits), Alg, "attempt to create parameters with unapproved RNG");
                }

                this.digestAlgorithm = parameters.Digest;
                this.parameters      = parameters;
                this.random          = random;
            }
Ejemplo n.º 6
0
            internal DeriverBuilder(byte[] password, PasswordConverter converter, FipsDigestAlgorithm digestAlgorithm, byte[] salt, int iterationCount)
            {
                this.digestAlgorithm = digestAlgorithm;
                this.converter       = converter;
                this.password        = password;
                this.iterationCount  = iterationCount;
                this.salt            = salt;

                if (CryptoServicesRegistrar.IsInApprovedOnlyMode())
                {
                    if (salt.Length < 16)
                    {
                        throw new CryptoUnapprovedOperationError("salt must be at least 128 bits");
                    }
                    if (password.Length < 14)
                    {
                        throw new CryptoUnapprovedOperationError("password must be at least 112 bits");
                    }
                }
            }
Ejemplo n.º 7
0
            DomainGenParameters(FipsDigestAlgorithm digest, int L, int N, int certainty, BigInteger p, BigInteger q, byte[] seed, int usageIndex) : base(Alg)
            {
                if (CryptoServicesRegistrar.IsInApprovedOnlyMode())
                {
                    if (p == null && certainty < PrimeCertaintyCalculator.GetDefaultCertainty(L))
                    {
                        throw new CryptoUnapprovedOperationError("Prime generation certainty " + certainty + " inadequate for parameters of " + L + " bits", this.Algorithm);
                    }
                }

                if (usageIndex > 255)
                {
                    throw new ArgumentException("Usage index must be in range 0 to 255 (or -1 to ignore)");
                }

                this.mDigest     = digest;
                this.mL          = L;
                this.mN          = N;
                this.mCertainty  = certainty;
                this.mP          = p;
                this.mQ          = q;
                this.seed        = seed;
                this.mUsageIndex = usageIndex;
            }
Ejemplo n.º 8
0
 internal TlsKdfWithPrfBuilder(FipsAlgorithm algorithm, FipsDigestAlgorithm prf)
 {
     this.algorithm = algorithm;
     this.prf       = prf;
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Base constructor - for 186-4
 /// </summary>
 /// <param name="digestAlgorithm">Digest to use in prime calculations.</param>
 /// <param name="random">Source of randomness for prime number testing.</param>
 public DomainParametersValidator(FipsDigestAlgorithm digestAlgorithm, SecureRandom random) : this(Version.FipsPub186_4, digestAlgorithm, random)
 {
 }
Ejemplo n.º 10
0
 public DomainGenParameters WithDigest(FipsDigestAlgorithm digest)
 {
     return(new DomainGenParameters(digest, mL, mN, mCertainty, mP, mQ, Arrays.Clone(seed), mUsageIndex));
 }
Ejemplo n.º 11
0
 internal BuilderService(FipsAlgorithm algorithm, FipsDigestAlgorithm digestAlgorithm) : base(algorithm)
 {
     this.digestAlg = digestAlgorithm;
     this.variation = Variations.NONE;
 }
Ejemplo n.º 12
0
 public FipsDigestKmg(FipsDigestAlgorithm digestAlg)
 {
     this.digestAlg = digestAlg;
 }
Ejemplo n.º 13
0
 internal Base(BuilderService service) : base(service.Algorithm)
 {
     this.digestAlg = service.Digest;
     this.variation = service.Variation;
 }
Ejemplo n.º 14
0
 public TlsKdfWithPrfBuilder WithPrf(FipsDigestAlgorithm prf)
 {
     return(new TlsKdfWithPrfBuilder(algorithm, prf));
 }
Ejemplo n.º 15
0
 internal Parameters(FipsDigestAlgorithm algorithm, PasswordConverter converter, char[] password) : this(algorithm, converter, converter.Convert(password), 1024, new byte[20])
 {
 }
Ejemplo n.º 16
0
 internal TlsKdfWithPrfParameters(FipsAlgorithm algorithm, FipsDigestAlgorithm prf, byte[] secret, string label, byte[] seedMaterial) : base(algorithm, secret, label, seedMaterial)
 {
     this.prf = prf;
 }
Ejemplo n.º 17
0
 internal BuilderService(FipsAlgorithm algorithm, Variations variation) : base(algorithm)
 {
     this.digestAlg = null;
     this.variation = variation;
 }