internal override string GetName(NCryptKeyOrCryptProviderSafeHandle handle)
 {
     const int PP_NAME = 0x6;
     uint size = 0;
     if (!AdvApi32.CryptGetProvParam(handle, PP_NAME, IntPtr.Zero, ref size, 0u))
     {
         throw new InvalidOperationException("Failed to get property.");
     }
     var buffer = Marshal.AllocHGlobal((int)size);
     try
     {
         if (!AdvApi32.CryptGetProvParam(handle, PP_NAME, buffer, ref size, 0u))
         {
             throw new InvalidOperationException("Failed to get property.");
         }
         return Marshal.PtrToStringAnsi(buffer);
     }
     finally
     {
         Marshal.FreeHGlobal(buffer);
     }
 }
        internal override string GetName(NCryptKeyOrCryptProviderSafeHandle handle)
        {
            const int PP_NAME = 0x6;
            uint      size    = 0;

            if (!AdvApi32.CryptGetProvParam(handle, PP_NAME, IntPtr.Zero, ref size, 0u))
            {
                throw new InvalidOperationException("Failed to get property.");
            }
            var buffer = Marshal.AllocHGlobal((int)size);

            try
            {
                if (!AdvApi32.CryptGetProvParam(handle, PP_NAME, buffer, ref size, 0u))
                {
                    throw new InvalidOperationException("Failed to get property.");
                }
                return(Marshal.PtrToStringAnsi(buffer));
            }
            finally
            {
                Marshal.FreeHGlobal(buffer);
            }
        }
 internal PrivateKey(NCryptKeyOrCryptProviderSafeHandle handle, KeyProviderBase keyProvider)
 {
     _handle = handle;
     _keyProvider = keyProvider;
 }
 internal abstract string GetAlgorithmGroup(NCryptKeyOrCryptProviderSafeHandle handle);
 internal abstract string GetName(NCryptKeyOrCryptProviderSafeHandle handle);
Exemple #6
0
 internal override string GetAlgorithmGroup(NCryptKeyOrCryptProviderSafeHandle handle)
 {
     return(NCryptPropertyReader.ReadStringUni(handle, CngProperties.NCRYPT_ALGORITHM_GROUP_PROPERTY));
 }
Exemple #7
0
 internal override string GetName(NCryptKeyOrCryptProviderSafeHandle handle)
 {
     return(NCryptPropertyReader.ReadStringUni(handle, CngProperties.NCRYPT_NAME_PROPERTY));
 }
 internal override string GetAlgorithmGroup(NCryptKeyOrCryptProviderSafeHandle handle)
 {
     //Hack, but we only support RSA right now.
     return AlgorithmGroup.RSA.Name;
 }
 internal override string GetAlgorithmGroup(NCryptKeyOrCryptProviderSafeHandle handle)
 {
     //Hack, but we only support RSA right now.
     return(AlgorithmGroup.RSA.Name);
 }
Exemple #10
0
 internal PrivateKey(NCryptKeyOrCryptProviderSafeHandle handle, KeyProviderBase keyProvider, KeySpec keySpec)
 {
     _handle      = handle;
     _keyProvider = keyProvider;
     _keySpec     = keySpec;
 }
 internal override string GetAlgorithmGroup(NCryptKeyOrCryptProviderSafeHandle handle)
 {
     return NCryptPropertyReader.ReadStringUni(handle, CngProperties.NCRYPT_ALGORITHM_GROUP_PROPERTY);
 }
 internal override string GetName(NCryptKeyOrCryptProviderSafeHandle handle)
 {
     return NCryptPropertyReader.ReadStringUni(handle, CngProperties.NCRYPT_NAME_PROPERTY);
 }
 internal abstract string GetAlgorithmGroup(NCryptKeyOrCryptProviderSafeHandle handle);
 internal abstract string GetName(NCryptKeyOrCryptProviderSafeHandle handle);