コード例 #1
0
        public SchemeEccEphemeralUnified(
            IDsaEcc dsa,
            IEccCurveFactory eccCurveFactory,
            IKdfOneStepFactory kdfFactory,
            IKeyConfirmationFactory keyConfirmationFactory,
            INoKeyConfirmationFactory noKeyConfirmationFactory,
            IOtherInfoFactory otherInfoFactory,
            IEntropyProvider entropyProvider,
            SchemeParametersBase <KasDsaAlgoAttributesEcc> schemeParameters,
            KdfParameters kdfParameters,
            MacParameters macParameters,
            IDiffieHellman <EccDomainParameters, EccKeyPair> diffieHellman
            )
            : base(
                dsa,
                eccCurveFactory,
                kdfFactory,
                keyConfirmationFactory,
                noKeyConfirmationFactory,
                otherInfoFactory,
                entropyProvider,
                schemeParameters,
                kdfParameters,
                macParameters
                )
        {
            _diffieHellman = diffieHellman;

            if (SchemeParameters.KasAlgoAttributes.Scheme != EccScheme.EphemeralUnified)
            {
                throw new ArgumentException(nameof(SchemeParameters.KasAlgoAttributes.Scheme));
            }

            if (SchemeParameters.KasMode == KasMode.KdfKc)
            {
                throw new ArgumentException($"{SchemeParameters.KasMode} not possible with {SchemeParameters.KasAlgoAttributes.Scheme}");
            }
        }
コード例 #2
0
 public SchemeBuilderEcc(
     IDsaEccFactory dsaEccFactory,
     IEccCurveFactory eccCurveFactory,
     IKdfOneStepFactory kdfFactory,
     IKeyConfirmationFactory keyConfirmationFactory,
     INoKeyConfirmationFactory noKeyConfirmationFactory,
     IOtherInfoFactory otherInfoFactory,
     IEntropyProvider entropyProvider,
     IDiffieHellman <EccDomainParameters, EccKeyPair> diffieHellmanEcc,
     IMqv <EccDomainParameters, EccKeyPair> mqv)
     : base(
         kdfFactory,
         keyConfirmationFactory,
         noKeyConfirmationFactory,
         otherInfoFactory,
         entropyProvider,
         diffieHellmanEcc,
         mqv
         )
 {
     _dsaEccFactory   = dsaEccFactory;
     _eccCurveFactory = eccCurveFactory;
 }
コード例 #3
0
 protected SchemeBaseFfc(
     IDsaFfc dsa,
     IKdfOneStepFactory kdfFactory,
     IKeyConfirmationFactory keyConfirmationFactory,
     INoKeyConfirmationFactory noKeyConfirmationFactory,
     IOtherInfoFactory otherInfoFactory,
     IEntropyProvider entropyProvider,
     SchemeParametersBase <KasDsaAlgoAttributesFfc> schemeParameters,
     KdfParameters kdfParameters,
     MacParameters macParameters
     )
     : base(
         kdfFactory,
         keyConfirmationFactory,
         noKeyConfirmationFactory,
         otherInfoFactory,
         entropyProvider,
         schemeParameters,
         kdfParameters,
         macParameters
         )
 {
     Dsa = dsa;
 }
コード例 #4
0
 public SchemeKts(
     IEntropyProvider entropyProvider,
     SchemeParametersIfc schemeParameters,
     IFixedInfoFactory fixedInfoFactory,
     FixedInfoParameter fixedInfoParameter,
     IIfcSecretKeyingMaterialBuilder thisPartyKeyingMaterialBuilder,
     IKeyConfirmationFactory keyConfirmationFactory,
     MacParameters macParameters,
     IKtsFactory ktsFactory,
     KtsParameter ktsParameter
     )
     : base
     (
         entropyProvider,
         schemeParameters,
         fixedInfoFactory,
         fixedInfoParameter,
         thisPartyKeyingMaterialBuilder,
         keyConfirmationFactory,
         macParameters)
 {
     _ktsFactory   = ktsFactory;
     _ktsParameter = ktsParameter;
 }
コード例 #5
0
 public SchemeBaseKasOneKeyPair(
     IEntropyProvider entropyProvider,
     SchemeParametersIfc schemeParameters,
     IFixedInfoFactory fixedInfoFactory,
     FixedInfoParameter fixedInfoParameter,
     IIfcSecretKeyingMaterialBuilder thisPartyKeyingMaterialBuilder,
     IKeyConfirmationFactory keyConfirmationFactory,
     MacParameters macParameters,
     IKdfVisitor kdfVisitor,
     IKdfParameter kdfParameter,
     IRsaSve rsaSve)
     : base(
         entropyProvider,
         schemeParameters,
         fixedInfoFactory,
         fixedInfoParameter,
         thisPartyKeyingMaterialBuilder,
         keyConfirmationFactory,
         macParameters,
         kdfVisitor,
         kdfParameter,
         rsaSve)
 {
 }
コード例 #6
0
        /// <summary>
        /// Takes in a hash function, and nonce provider, and optional entropy provider (only used for 'random' nonce)
        /// </summary>
        /// <param name="hashFunction"></param>
        /// <param name="nonceProviderTypes"></param>
        /// <param name="entropyProvider"></param>
        /// <returns></returns>
        public IDsaEcc GetInstanceForSignatures(HashFunction hashFunction, NonceProviderTypes nonceProviderTypes, IEntropyProvider entropyProvider = null)
        {
            var sha           = _shaFactory.GetShaInstance(hashFunction);
            var hmac          = _hmacFactory.GetHmacInstance(hashFunction);
            var nonceProvider = _nonceProviderFactory.GetNonceProvider(nonceProviderTypes, hmac, entropyProvider);

            return(new EccDsa(sha, nonceProvider));
        }
コード例 #7
0
 /// <summary>
 /// Takes in completed entropy provider and returns an ECDSA Key Generator
 /// </summary>
 /// <param name="keyEntropy">Completed entropy provider (BigInteger)</param>
 /// <returns></returns>
 public IDsaEcc GetInstanceForKeys(IEntropyProvider keyEntropy)
 {
     return(new EccDsa(keyEntropy));
 }
コード例 #8
0
 public KdfMultiExpansionParameterVisitor(IEntropyProvider entropyProvider, IRandom800_90 random)
 {
     _entropyProvider = entropyProvider;
     _random          = random;
 }
コード例 #9
0
 public PssPadderWithModifiedSignature(ISha sha, IMaskFunction mask, IEntropyProvider entropy, int saltLength) : base(sha, mask, entropy, saltLength)
 {
 }
コード例 #10
0
 /// <summary>
 /// KAS constructor
 /// </summary>
 /// <param name="sha">The SHA instance.</param>
 /// <param name="entropyProvider">An entropy provider.</param>
 public EccDsa(ISha sha, IEntropyProvider entropyProvider)
 {
     Sha = sha;
     _entropyProvider = entropyProvider;
 }
コード例 #11
0
 public FakeDrbgCounterAes(IEntropyProvider entropyProvider, IBlockCipherEngineFactory engineFactory, IModeBlockCipherFactory cipherFactory, DrbgParameters drbgParameters)
     : base(entropyProvider, engineFactory, cipherFactory, drbgParameters)
 {
 }
コード例 #12
0
 public IRsaSveBuilder WithEntropyProvider(IEntropyProvider value)
 {
     _entropProvider = value;
     return(this);
 }
コード例 #13
0
 public PreSigVerMessageRandomizer(IEntropyProvider entropyProvider)
 {
     _entropyProvider = entropyProvider;
 }
コード例 #14
0
 public IFips186_2PrimeGenerator GetFips186_2PrimeGenerator(IEntropyProvider entropyProvider, PrimeTestModes primeTest)
 {
     return(new RandomProbablePrimeGenerator(entropyProvider, primeTest));
 }
コード例 #15
0
        private static IPrimeGenerator GetPrimeGenerator(PrimeGenModes primeGen, ISha sha, IEntropyProvider entropyProvider, PrimeTestModes primeTest)
        {
            switch (primeGen)
            {
            case PrimeGenModes.RandomProvablePrimes:
                return(new RandomProvablePrimeGenerator(sha));

            case PrimeGenModes.RandomProbablePrimes:
                return(new RandomProbablePrimeGenerator(entropyProvider, primeTest));

            case PrimeGenModes.RandomProvablePrimesWithAuxiliaryProvablePrimes:
                return(new AllProvablePrimesWithConditionsGenerator(sha));

            case PrimeGenModes.RandomProbablePrimesWithAuxiliaryProvablePrimes:
                return(new ProvableProbablePrimesWithConditionsGenerator(sha, entropyProvider, primeTest));

            case PrimeGenModes.RandomProbablePrimesWithAuxiliaryProbablePrimes:
                return(new AllProbablePrimesWithConditionsGenerator(entropyProvider, primeTest));

            default:
                throw new ArgumentException("Invalid prime gen mode");
            }
        }
コード例 #16
0
 public IFips186_4PrimeGenerator GetFips186_4PrimeGenerator(PrimeGenModes primeGen, ISha sha, IEntropyProvider entropyProvider, PrimeTestModes primeTest)
 {
     return(GetPrimeGenerator(primeGen, sha, entropyProvider, primeTest) as IFips186_4PrimeGenerator);
 }
コード例 #17
0
 public ProvablePQGeneratorValidator(ISha sha, EntropyProviderTypes entropyType = EntropyProviderTypes.Random)
 {
     _sha     = sha;
     _entropy = _entropyFactory.GetEntropyProvider(entropyType);
 }
コード例 #18
0
     > WithEntropyProvider(IEntropyProvider entropyProvider)
 {
     _withEntropyProvider = entropyProvider;
     return(this);
 }
コード例 #19
0
 // Used for both signatures and keys
 public EccDsa(ISha sha, IEccNonceProvider nonceProvider, EntropyProviderTypes entropyType)
 {
     Sha              = sha;
     _nonceProvider   = nonceProvider;
     _entropyProvider = _entropyFactory.GetEntropyProvider(entropyType);
 }
コード例 #20
0
 public DrbgHash(IEntropyProvider entropyProvider, ISha sha, DrbgParameters drbgParameters) : base(entropyProvider, drbgParameters)
 {
     _sha           = sha;
     HashAttributes = DrbgAttributesHelper.GetHashDrbgAttributes(drbgParameters.Mode);
 }
コード例 #21
0
 // Used for ONLY keys
 public EccDsa(IEntropyProvider entropyProvider)
 {
     _entropyProvider = entropyProvider;
 }
コード例 #22
0
 public RandomNonceProvider(IEntropyProvider entropyProvider)
 {
     _entropyProvider = entropyProvider;
 }
コード例 #23
0
 public AllProbablePrimesWithConditionsGenerator(IEntropyProvider entropyProvider, PrimeTestModes primeTestMode)
 {
     _entropyProvider = entropyProvider;
     _primeTestMode   = primeTestMode;
 }
コード例 #24
0
        /// Always correct
        public IPaddingScheme GetPaddingScheme(SignatureSchemes sigMode, ISha sha, PssMaskTypes maskType = PssMaskTypes.None, IEntropyProvider entropyProvider = null, int saltLength = 0)
        {
            switch (sigMode)
            {
            case SignatureSchemes.Ansx931:
                return(new AnsxPadder(sha));

            case SignatureSchemes.Pkcs1v15:
                return(new PkcsPadder(sha));

            case SignatureSchemes.Pss:
                var mask = _maskFactory.GetMaskInstance(maskType, sha.HashFunction);
                return(new PssPadder(sha, mask, entropyProvider, saltLength));

            default:
                throw new ArgumentException("Invalid signature scheme");
            }
        }
コード例 #25
0
 public ISchemeIfcBuilder WithEntropyProvider(IEntropyProvider value)
 {
     _entropyProvider = value;
     return(this);
 }
コード例 #26
0
 public DrbgCounterAes(IEntropyProvider entropyProvider, IBlockCipherEngineFactory engineFactory, IModeBlockCipherFactory cipherFactory, DrbgParameters drbgParameters)
     : base(entropyProvider, drbgParameters)
 {
     Cipher = cipherFactory.GetStandardCipher(
         engineFactory.GetSymmetricCipherPrimitive(BlockCipherEngines.Aes), BlockCipherModesOfOperation.Ecb);
 }
コード例 #27
0
 public ProvableProbablePrimesWithConditionsGenerator(ISha sha, IEntropyProvider entropyProvider, PrimeTestModes primeTest)
 {
     _sha             = sha;
     _entropyProvider = entropyProvider;
     _primeTest       = primeTest;
 }
コード例 #28
0
 public DrbgHmac(IEntropyProvider entropyProvider, IHmac hmac, DrbgParameters drbgParameters) : base(entropyProvider, drbgParameters)
 {
     _hmac          = hmac;
     HashAttributes = DrbgAttributesHelper.GetHashDrbgAttributes(drbgParameters.Mode);
 }
コード例 #29
0
ファイル: FfcDsa.cs プロジェクト: usnistgov/ACVP-Server
 public FfcDsa(ISha sha, EntropyProviderTypes entropyType = EntropyProviderTypes.Random)
 {
     Sha = sha;
     _entropyProvider = _entropyFactory.GetEntropyProvider(entropyType);
 }
コード例 #30
0
        /// Could introduce errors
        public IPaddingScheme GetSigningPaddingScheme(SignatureSchemes sigMode, ISha sha, SignatureModifications errors, PssMaskTypes maskType = PssMaskTypes.None, IEntropyProvider entropyProvider = null, int saltLength = 0)
        {
            if (sigMode == SignatureSchemes.Ansx931)
            {
                switch (errors)
                {
                case SignatureModifications.None:
                    return(new AnsxPadder(sha));

                case SignatureModifications.E:
                    return(new AnsxPadderWithModifiedPublicExponent(sha));

                case SignatureModifications.Message:
                    return(new AnsxPadderWithModifiedMessage(sha));

                case SignatureModifications.ModifyTrailer:
                    return(new AnsxPadderWithModifiedTrailer(sha));

                case SignatureModifications.MoveIr:
                    return(new AnsxPadderWithMovedIr(sha));

                case SignatureModifications.Signature:
                    return(new AnsxPadderWithModifiedSignature(sha));

                default:
                    throw new ArgumentException("Signature modification does not exist for selected scheme");
                }
            }
            else if (sigMode == SignatureSchemes.Pkcs1v15)
            {
                switch (errors)
                {
                case SignatureModifications.None:
                    return(new PkcsPadder(sha));

                case SignatureModifications.E:
                    return(new PkcsPadderWithModifiedPublicExponent(sha));

                case SignatureModifications.Message:
                    return(new PkcsPadderWithModifiedMessage(sha));

                case SignatureModifications.ModifyTrailer:
                    return(new PkcsPadderWithModifiedTrailer(sha));

                case SignatureModifications.MoveIr:
                    return(new PkcsPadderWithMovedIr(sha));

                case SignatureModifications.Signature:
                    return(new PkcsPadderWithModifiedSignature(sha));

                default:
                    throw new ArgumentException("Signature modification does not exist for selected scheme");
                }
            }
            else if (sigMode == SignatureSchemes.Pss)
            {
                var mask = _maskFactory.GetMaskInstance(maskType, sha.HashFunction);

                switch (errors)
                {
                case SignatureModifications.None:
                    return(new PssPadder(sha, mask, entropyProvider, saltLength));

                case SignatureModifications.E:
                    return(new PssPadderWithModifiedPublicExponent(sha, mask, entropyProvider, saltLength));

                case SignatureModifications.Message:
                    return(new PssPadderWithModifiedMessage(sha, mask, entropyProvider, saltLength));

                case SignatureModifications.ModifyTrailer:
                    return(new PssPadderWithModifiedTrailer(sha, mask, entropyProvider, saltLength));

                case SignatureModifications.MoveIr:
                    return(new PssPadderWithMovedIr(sha, mask, entropyProvider, saltLength));

                case SignatureModifications.Signature:
                    return(new PssPadderWithModifiedSignature(sha, mask, entropyProvider, saltLength));

                default:
                    throw new ArgumentException("Signature modification does not exist for selected scheme");
                }
            }

            throw new ArgumentException("Invalid signature scheme");
        }