Exemplo n.º 1
0
 public static string DecryptValue(string textToDecrypt)
 {
     using (PinCollection pin = new PinCollection())
     {
         return(NativeTypes.FromNativeString(NativeCommon.FabricDecryptText(
                                                 pin.AddObject(textToDecrypt), NativeTypes.FABRIC_X509_STORE_LOCATION.FABRIC_X509_STORE_LOCATION_LOCALMACHINE)));
     }
 }
 private static SecureString DecryptTextHelper(string encryptedValue, StoreLocation storeLocation)
 {
     using (var pin = new PinCollection())
     {
         return(StringResult.FromNativeToSecureString(NativeCommon.FabricDecryptText(
                                                          pin.AddBlittable(encryptedValue),
                                                          (NativeTypes.FABRIC_X509_STORE_LOCATION)storeLocation)));
     }
 }
Exemplo n.º 3
0
 private SecureString DecryptValueHelper(string encryptedValue)
 {
     using (var pin = new PinCollection())
     {
         return(StringResult.FromNativeToSecureString(NativeCommon.FabricDecryptText(
                                                          pin.AddBlittable(encryptedValue),
                                                          NativeTypes.FABRIC_X509_STORE_LOCATION.FABRIC_X509_STORE_LOCATION_LOCALMACHINE)));
     }
 }
Exemplo n.º 4
0
 protected string DecryptText(string text, StoreLocation storeLocation)
 {
     using (var pin = new PinCollection())
     {
         // Calling native API directly because we need to return string instead of SecureString for this cmdlet,
         // and we do not want to have a public managed API that returns string instead of SecureString.
         return(StringResult.FromNative(NativeCommon.FabricDecryptText(
                                            pin.AddBlittable(text),
                                            (NativeTypes.FABRIC_X509_STORE_LOCATION)storeLocation)));
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// <para>Decrypt a text string encrypted by EncryptText methods of <see cref="System.Fabric.Security.EncryptionUtility" />.</para>
 /// </summary>
 /// <param name="textToDecrypt">
 /// <para>The encrypted text to decrypt.</para>
 /// </param>
 /// <param name="storeLocation">
 /// <para>The certificate store location to retrieve decryption certificate.</para>
 /// </param>
 /// <returns>
 /// <para>The decrypted text as <see cref="System.Security.SecureString " />.</para>
 /// </returns>
 public static SecureString DecryptText(string textToDecrypt, StoreLocation storeLocation)
 {
     using (PinCollection pin = new PinCollection())
     {
         try
         {
             return(StringResult.FromNativeToSecureString(NativeCommon.FabricDecryptText(
                                                              pin.AddObject(textToDecrypt),
                                                              (NativeTypes.FABRIC_X509_STORE_LOCATION)storeLocation)));
         }
         catch (Exception ex)
         {
             COMException comEx = Utility.TryTranslateExceptionToCOM(ex);
             if (comEx != null)
             {
                 throw comEx;
             }
             throw;
         }
     }
 }