Пример #1
0
		public DSACryptoServiceProvider (int dwKeySize, CspParameters parameters)
		{
			LegalKeySizesValue = new KeySizes [1];
			LegalKeySizesValue [0] = new KeySizes (512, 1024, 64);

			// will throw an exception is key size isn't supported
			KeySize = dwKeySize;
			dsa = new DSAManaged (dwKeySize);
			dsa.KeyGenerated += new DSAManaged.KeyGeneratedEventHandler (OnKeyGenerated);

			persistKey = (parameters != null);
			if (parameters == null) {
				parameters = new CspParameters (PROV_DSS_DH);
				if (useMachineKeyStore)
					parameters.Flags |= CspProviderFlags.UseMachineKeyStore;
				store = new KeyPairPersistence (parameters);
				// no need to load - it cannot exists
			}
			else {
				store = new KeyPairPersistence (parameters);
				store.Load ();
				if (store.KeyValue != null) {
					persisted = true;
					this.FromXmlString (store.KeyValue);
				}
			}
		}
Пример #2
0
		void Common (int dwKeySize, bool parameters) 
		{
			LegalKeySizesValue = new KeySizes [1];
			LegalKeySizesValue [0] = new KeySizes (512, 1024, 64);

			// will throw an exception is key size isn't supported
			KeySize = dwKeySize;
			dsa = new DSAManaged (dwKeySize);
			dsa.KeyGenerated += new DSAManaged.KeyGeneratedEventHandler (OnKeyGenerated);

			persistKey = parameters;
			if (parameters)
				return;

			var p = new CspParameters (PROV_DSS_DH);
			if (useMachineKeyStore)
				p.Flags |= CspProviderFlags.UseMachineKeyStore;
			store = new KeyPairPersistence (p);
			// no need to load - it cannot exists
		}