internal string GenerateSessionKeyAndSafeExport()
        {
            this.CheckStatus(PSCryptoNativeUtils.CryptGenKey(this.hProv, 26128U, 16777221U, ref this.hSessionKey));
            uint pdwDataLen = 0;

            this.CheckStatus(PSCryptoNativeUtils.CryptExportKey(this.hSessionKey, this.hRSAKey, 1U, 0U, (byte[])null, ref pdwDataLen));
            byte[] numArray = new byte[(IntPtr)pdwDataLen];
            this.CheckStatus(PSCryptoNativeUtils.CryptExportKey(this.hSessionKey, this.hRSAKey, 1U, 0U, numArray, ref pdwDataLen));
            this.canEncrypt = true;
            return(Convert.ToBase64String(numArray, Base64FormattingOptions.None));
        }
예제 #2
0
 internal void GenerateSessionKey()
 {
     if (!this.sessionKeyGenerated)
     {
         lock (syncObject)
         {
             if (!this.sessionKeyGenerated)
             {
                 bool flag = PSCryptoNativeUtils.CryptGenKey(this.hProv, 0x6610, 0x1000005, ref this.hSessionKey);
                 this.CheckStatus(flag);
                 this.sessionKeyGenerated = true;
                 this.canEncrypt          = true;
             }
         }
     }
 }
 internal void GenerateKeyPair()
 {
     if (!PSRSACryptoServiceProvider.keyGenerated)
     {
         lock (PSRSACryptoServiceProvider.syncObject)
         {
             if (!PSRSACryptoServiceProvider.keyGenerated)
             {
                 PSRSACryptoServiceProvider._hStaticProv = new PSSafeCryptProvHandle();
                 this.CheckStatus(PSCryptoNativeUtils.CryptAcquireContext(ref PSRSACryptoServiceProvider._hStaticProv, (string)null, (string)null, 24U, 4026531840U));
                 PSRSACryptoServiceProvider._hStaticRSAKey = new PSSafeCryptKey();
                 this.CheckStatus(PSCryptoNativeUtils.CryptGenKey(PSRSACryptoServiceProvider._hStaticProv, 1U, 134217729U, ref PSRSACryptoServiceProvider._hStaticRSAKey));
                 PSRSACryptoServiceProvider.keyGenerated = true;
             }
         }
     }
     this.hProv   = PSRSACryptoServiceProvider._hStaticProv;
     this.hRSAKey = PSRSACryptoServiceProvider._hStaticRSAKey;
 }
예제 #4
0
 internal void GenerateKeyPair()
 {
     if (!keyPairGenerated)
     {
         lock (syncObject)
         {
             if (!keyPairGenerated)
             {
                 _hStaticProv = new PSSafeCryptProvHandle();
                 bool flag = PSCryptoNativeUtils.CryptAcquireContext(ref _hStaticProv, null, null, 0x18, (0xf0000000).ToInt32());
                 this.CheckStatus(flag);
                 _hStaticRSAKey = new PSSafeCryptKey();
                 flag           = PSCryptoNativeUtils.CryptGenKey(_hStaticProv, 1, 0x8000001, ref _hStaticRSAKey);
                 this.CheckStatus(flag);
                 keyPairGenerated = true;
             }
         }
     }
     this.hProv   = _hStaticProv;
     this.hRSAKey = _hStaticRSAKey;
 }