internal string GetPublicKeyAsBase64EncodedString()
        {
            uint pdwDataLen = 0;

            this.CheckStatus(PSCryptoNativeUtils.CryptExportKey(this.hRSAKey, PSSafeCryptKey.Zero, 6U, 0U, (byte[])null, ref pdwDataLen));
            byte[] numArray = new byte[(IntPtr)pdwDataLen];
            this.CheckStatus(PSCryptoNativeUtils.CryptExportKey(this.hRSAKey, PSSafeCryptKey.Zero, 6U, 0U, numArray, ref pdwDataLen));
            return(Convert.ToBase64String(numArray, Base64FormattingOptions.None));
        }
Пример #2
0
        internal string GetPublicKeyAsBase64EncodedString()
        {
            int  pdwDataLen = 0;
            bool flag       = PSCryptoNativeUtils.CryptExportKey(this.hRSAKey, PSSafeCryptKey.Zero, 6, 0, null, ref pdwDataLen);

            this.CheckStatus(flag);
            byte[] pbData = new byte[pdwDataLen];
            flag = PSCryptoNativeUtils.CryptExportKey(this.hRSAKey, PSSafeCryptKey.Zero, 6, 0, pbData, ref pdwDataLen);
            this.CheckStatus(flag);
            return(Convert.ToBase64String(pbData, Base64FormattingOptions.None));
        }
        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));
        }
Пример #4
0
        internal string SafeExportSessionKey()
        {
            this.GenerateSessionKey();
            int  pdwDataLen = 0;
            bool flag       = PSCryptoNativeUtils.CryptExportKey(this.hSessionKey, this.hRSAKey, 1, 0, null, ref pdwDataLen);

            this.CheckStatus(flag);
            byte[] pbData = new byte[pdwDataLen];
            flag = PSCryptoNativeUtils.CryptExportKey(this.hSessionKey, this.hRSAKey, 1, 0, pbData, ref pdwDataLen);
            this.CheckStatus(flag);
            this.canEncrypt = true;
            return(Convert.ToBase64String(pbData, Base64FormattingOptions.None));
        }