CspParameters コンストラクタ (Int32)
指定したプロバイダの種類コードコードを使用して、CspParameters クラスの新しいインスタンスを初期化します。
名前空間: System.Security.Cryptography
アセンブリ: mscorlib (mscorlib.dll 内)
構文
CspParameters コンストラクタを使用し、プロバイダを表す数値を渡してプロバイダの種類を指定します。既定プロバイダの種類を表す数値は、WinCrypt.h ヘッダー ファイルで定義されます。
他のプロバイダの種類の値については、ProviderType フィールドを参照してください。既定のプロバイダの種類とそれらの動作の詳細については、MSDN ライブラリで CAPI (Microsoft Cryptography API) に関するドキュメントを参照してください。
CspParameters クラスを使用してキー コンテナを作成し、そのコンテナにキーを保存するコード例を次に示します。
Imports System Imports System.IO Imports System.Security.Cryptography Public Class StoreKey Public Shared Sub Main() ' creates the CspParameters object and sets the key container name used to store the RSA key pair Dim cp As New CspParameters() cp.KeyContainerName = "MyKeyContainerName" ' instantiates the rsa instance accessing the key container MyKeyContainerName Dim rsa As New RSACryptoServiceProvider(cp) ' add the below line to delete the key entry in MyKeyContainerName ' rsa.PersistKeyInCsp = false; 'writes out the current key pair used in the rsa instance Console.WriteLine("Key is : " & rsa.ToXmlString(True)) End Sub 'Main End Class 'StoreKey
using System; using System.IO; using System.Security.Cryptography; public class StoreKey { public static void Main() { // creates the CspParameters object and sets the key container name used to store the RSA key pair CspParameters cp = new CspParameters(); cp.KeyContainerName = "MyKeyContainerName"; // instantiates the rsa instance accessing the key container MyKeyContainerName RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(cp); // add the below line to delete the key entry in MyKeyContainerName // rsa.PersistKeyInCsp = false; //writes out the current key pair used in the rsa instance Console.WriteLine("Key is : \n" + rsa.ToXmlString(true)); } }
using namespace System; using namespace System::IO; using namespace System::Security::Cryptography; int main() { // creates the CspParameters object and sets the key container name used to store the RSA key pair CspParameters^ cp = gcnew CspParameters; cp->KeyContainerName = "MyKeyContainerName"; // instantiates the rsa instance accessing the key container MyKeyContainerName RSACryptoServiceProvider^ rsa = gcnew RSACryptoServiceProvider( cp ); // add the below line to delete the key entry in MyKeyContainerName // rsa.PersistKeyInCsp = false; //writes out the current key pair used in the rsa instance Console::WriteLine( "Key is : \n{0}", rsa->ToXmlString( true ) ); }
import System.*; import System.IO.*; import System.Security.Cryptography.*; public class StoreKey { public static void main(String[] args) { // creates the CspParameters object and sets the key container name // used to store the RSA key pair CspParameters cp = new CspParameters(); cp.KeyContainerName = "MyKeyContainerName"; // instantiates the rsa instance accessing the key container // MyKeyContainerName RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(cp); // add the below line to delete the key entry in MyKeyContainerName // rsa.PersistKeyInCsp = false; //writes out the current key pair used in the rsa instance Console.WriteLine("Key is : \n" + rsa.ToXmlString(true)); } //main } //StoreKey
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
CspParameters コンストラクタ (Int32, String)
指定したプロバイダの種類コードと名前を使用して、CspParameters クラスの新しいインスタンスを初期化します。
名前空間: System.Security.Cryptography
アセンブリ: mscorlib (mscorlib.dll 内)
構文
Dim dwTypeIn As Integer Dim strProviderNameIn As String Dim instance As New CspParameters(dwTypeIn, strProviderNameIn)
- strProviderNameIn
プロバイダ名。
CspParameters コンストラクタを使用して、プロバイダの種類と名前を指定します。
プロバイダの種類を指定するには、目的のプロバイダの種類を表す数値を渡します。既定プロバイダの種類を表す数値は、WinCrypt.h ヘッダー ファイルで定義されます。
他のプロバイダの種類の値については、ProviderType フィールドを参照してください。既定のプロバイダの種類とそれらの動作の詳細については、MSDN ライブラリで CAPI (Microsoft Cryptography API) に関するドキュメントを参照してください。
CspParameters クラスを使用してスマート カード暗号化サービス プロバイダを選択するコード例を次に示します。その後で、スマート カードを使用してデータに署名し、そのデータを検証します。
Imports System Imports System.Security.Cryptography Module SCSign Sub Main(ByVal args() As String) ' To idendify the Smart Card CryptoGraphic Providers on your ' computer, use the Microsoft Registry Editor (Regedit.exe). ' The available Smart Card CryptoGraphic Providers are listed ' in HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\Defaults\Provider. ' Create a new CspParameters object that identifies a ' Smart Card CryptoGraphic Provider. ' The 1st parameter comes from HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\Defaults\Provider Types. ' The 2nd parameter comes from HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\Defaults\Provider. Dim csp As New CspParameters(1, "Schlumberger Cryptographic Service Provider") csp.Flags = CspProviderFlags.UseDefaultKeyContainer ' Initialize an RSACryptoServiceProvider object using ' the CspParameters object. Dim rsa As New RSACryptoServiceProvider(csp) ' Create some data to sign. Dim data() As Byte = {0, 1, 2, 3, 4, 5, 6, 7} Console.WriteLine("Data : " + BitConverter.ToString(data)) ' Sign the data using the Smart Card CryptoGraphic Provider. Dim sig As Byte() = rsa.SignData(data, "SHA1") Console.WriteLine("Signature : " + BitConverter.ToString(sig)) ' Verify the data using the Smart Card CryptoGraphic Provider. Dim verified As Boolean = rsa.VerifyData(data, "SHA1", sig) Console.WriteLine("Verified") End Sub End Module
using System; using System.Security.Cryptography; namespace SmartCardSign { class SCSign { static void Main(string[] args) { // To idendify the Smart Card CryptoGraphic Providers on your // computer, use the Microsoft Registry Editor (Regedit.exe). // The available Smart Card CryptoGraphic Providers are listed // in HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\Defaults\Provider. // Create a new CspParameters object that identifies a // Smart Card CryptoGraphic Provider. // The 1st parameter comes from HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\Defaults\Provider Types. // The 2nd parameter comes from HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\Defaults\Provider. CspParameters csp = new CspParameters(1, "Schlumberger Cryptographic Service Provider"); csp.Flags = CspProviderFlags.UseDefaultKeyContainer; // Initialize an RSACryptoServiceProvider object using // the CspParameters object. RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(csp); // Create some data to sign. byte[] data = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7 }; Console.WriteLine("Data : " + BitConverter.ToString(data)); // Sign the data using the Smart Card CryptoGraphic Provider. byte[] sig = rsa.SignData(data, "SHA1"); Console.WriteLine("Signature : " + BitConverter.ToString(sig)); // Verify the data using the Smart Card CryptoGraphic Provider. bool verified = rsa.VerifyData(data, "SHA1", sig); Console.WriteLine("Verified : " + verified); } } }
using namespace System; using namespace System::Security::Cryptography; int main() { // To idendify the Smart Card CryptoGraphic Providers on your // computer, use the Microsoft Registry Editor (Regedit.exe). // The available Smart Card CryptoGraphic Providers are listed // in HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\Defaults\Provider. // Create a new CspParameters object that identifies a // Smart Card CryptoGraphic Provider. // The 1st parameter comes from HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\Defaults\Provider Types. // The 2nd parameter comes from HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\Defaults\Provider. CspParameters^ csp = gcnew CspParameters( 1,L"Schlumberger Cryptographic Service Provider" ); csp->Flags = CspProviderFlags::UseDefaultKeyContainer; // Initialize an RSACryptoServiceProvider object using // the CspParameters object. RSACryptoServiceProvider^ rsa = gcnew RSACryptoServiceProvider( csp ); // Create some data to sign. array<Byte>^data = gcnew array<Byte>{ 0,1,2,3,4,5,6,7 }; Console::WriteLine( L"Data : {0}", BitConverter::ToString( data ) ); // Sign the data using the Smart Card CryptoGraphic Provider. array<Byte>^sig = rsa->SignData( data, L"SHA1" ); Console::WriteLine( L"Signature : {0}", BitConverter::ToString( sig ) ); // Verify the data using the Smart Card CryptoGraphic Provider. bool verified = rsa->VerifyData( data, L"SHA1", sig ); Console::WriteLine( L"Verified : {0}", verified ); }
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
CspParameters コンストラクタ (Int32, String, String, CryptoKeySecurity, IntPtr)
メモ : このコンストラクタは、.NET Framework version 2.0 で新しく追加されたものです。
プロバイダの種類、プロバイダ名、コンテナ名、アクセス情報、およびアンマネージ スマート カード パスワード ダイアログを識別するハンドルを使用して、CspParameters クラスの新しいインスタンスを初期化します。
名前空間: System.Security.Cryptography
アセンブリ: mscorlib (mscorlib.dll 内)
構文
Public Sub New ( _ providerType As Integer, _ providerName As String, _ keyContainerName As String, _ cryptoKeySecurity As CryptoKeySecurity, _ parentWindowHandle As IntPtr _ )
Dim providerType As Integer Dim providerName As String Dim keyContainerName As String Dim cryptoKeySecurity As CryptoKeySecurity Dim parentWindowHandle As IntPtr Dim instance As New CspParameters(providerType, providerName, keyContainerName, cryptoKeySecurity, parentWindowHandle)
public CspParameters ( int providerType, string providerName, string keyContainerName, CryptoKeySecurity cryptoKeySecurity, IntPtr parentWindowHandle )
public: CspParameters ( int providerType, String^ providerName, String^ keyContainerName, CryptoKeySecurity^ cryptoKeySecurity, IntPtr parentWindowHandle )
public CspParameters ( int providerType, String providerName, String keyContainerName, CryptoKeySecurity cryptoKeySecurity, IntPtr parentWindowHandle )
public function CspParameters ( providerType : int, providerName : String, keyContainerName : String, cryptoKeySecurity : CryptoKeySecurity, parentWindowHandle : IntPtr )
- providerName
プロバイダ名。
- keyContainerName
コンテナ名。
コンテナ名を使用して、そのコンテナ内に格納されたキーを取得できます。
プロバイダの種類を指定するには、目的のプロバイダの種類を表す数値を渡します。既定プロバイダの種類を表す数値は、WinCrypt.h ヘッダー ファイルで定義されます。
他のプロバイダの種類の値については、ProviderType フィールドを参照してください。既定のプロバイダの種類とそれらの動作の詳細については、MSDN ライブラリで CAPI (Microsoft Cryptography API) に関するドキュメントを参照してください。
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
CspParameters コンストラクタ (Int32, String, String, CryptoKeySecurity, SecureString)
メモ : このコンストラクタは、.NET Framework version 2.0 で新しく追加されたものです。
プロバイダの種類、プロバイダ名、コンテナ名、アクセス情報、およびスマート カード キーに関連付けられたパスワードを使用して、CspParameters クラスの新しいインスタンスを初期化します。
名前空間: System.Security.Cryptography
アセンブリ: mscorlib (mscorlib.dll 内)
構文
Public Sub New ( _ providerType As Integer, _ providerName As String, _ keyContainerName As String, _ cryptoKeySecurity As CryptoKeySecurity, _ keyPassword As SecureString _ )
Dim providerType As Integer Dim providerName As String Dim keyContainerName As String Dim cryptoKeySecurity As CryptoKeySecurity Dim keyPassword As SecureString Dim instance As New CspParameters(providerType, providerName, keyContainerName, cryptoKeySecurity, keyPassword)
public CspParameters ( int providerType, string providerName, string keyContainerName, CryptoKeySecurity cryptoKeySecurity, SecureString keyPassword )
public: CspParameters ( int providerType, String^ providerName, String^ keyContainerName, CryptoKeySecurity^ cryptoKeySecurity, SecureString^ keyPassword )
public CspParameters ( int providerType, String providerName, String keyContainerName, CryptoKeySecurity cryptoKeySecurity, SecureString keyPassword )
public function CspParameters ( providerType : int, providerName : String, keyContainerName : String, cryptoKeySecurity : CryptoKeySecurity, keyPassword : SecureString )
- providerName
プロバイダ名。
- keyContainerName
コンテナ名。
コンテナ名を使用して、そのコンテナ内に格納されたキーを取得できます。
プロバイダの種類を指定するには、目的のプロバイダの種類を表す数値を渡します。既定プロバイダの種類を表す数値は、WinCrypt.h ヘッダー ファイルで定義されます。
他のプロバイダの種類の値については、ProviderType フィールドを参照してください。既定のプロバイダの種類とそれらの動作の詳細については、MSDN ライブラリで CAPI (Microsoft Cryptography API) に関するドキュメントを参照してください。
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
CspParameters コンストラクタ
CspParameters クラスの新しいインスタンスを初期化します。
オーバーロードの一覧
名前 | 説明 |
---|---|
CspParameters () | CspParameters クラスの新しいインスタンスを初期化します。 |
CspParameters (Int32) | 指定したプロバイダの種類コードコードを使用して、CspParameters クラスの新しいインスタンスを初期化します。 |
CspParameters (Int32, String) | 指定したプロバイダの種類コードと名前を使用して、CspParameters クラスの新しいインスタンスを初期化します。 |
CspParameters (Int32, String, String) | 指定したプロバイダの種類コードと名前、および指定したコンテナ名を使用して、CspParameters クラスの新しいインスタンスを初期化します。 |
CspParameters (Int32, String, String, CryptoKeySecurity, IntPtr) | プロバイダの種類、プロバイダ名、コンテナ名、アクセス情報、およびアンマネージ スマート カード パスワード ダイアログを識別するハンドルを使用して、CspParameters クラスの新しいインスタンスを初期化します。 |
CspParameters (Int32, String, String, CryptoKeySecurity, SecureString) | プロバイダの種類、プロバイダ名、コンテナ名、アクセス情報、およびスマート カード キーに関連付けられたパスワードを使用して、CspParameters クラスの新しいインスタンスを初期化します。 |
CspParameters コンストラクタ (Int32, String, String)
指定したプロバイダの種類コードと名前、および指定したコンテナ名を使用して、CspParameters クラスの新しいインスタンスを初期化します。
名前空間: System.Security.Cryptography
アセンブリ: mscorlib (mscorlib.dll 内)
構文
Public Sub New ( _ dwTypeIn As Integer, _ strProviderNameIn As String, _ strContainerNameIn As String _ )
Dim dwTypeIn As Integer Dim strProviderNameIn As String Dim strContainerNameIn As String Dim instance As New CspParameters(dwTypeIn, strProviderNameIn, strContainerNameIn)
public function CspParameters ( dwTypeIn : int, strProviderNameIn : String, strContainerNameIn : String )
- strProviderNameIn
プロバイダ名。
- strContainerNameIn
コンテナ名。
CspParameters コンストラクタを使用して、プロバイダの種類、プロバイダ名、およびコンテナ名を指定します。
コンテナ名を使用して、そのコンテナ内に格納されたキーを取得できます。
プロバイダの種類を指定するには、目的のプロバイダの種類を表す数値を渡します。既定プロバイダの種類を表す数値は、WinCrypt.h ヘッダー ファイルで定義されます。
他のプロバイダの種類の値については、ProviderType フィールドを参照してください。既定のプロバイダの種類とそれらの動作の詳細については、MSDN ライブラリで CAPI (Microsoft Cryptography API) に関するドキュメントを参照してください。
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
CspParameters コンストラクタ ()
CspParameters クラスの新しいインスタンスを初期化します。
名前空間: System.Security.Cryptography
アセンブリ: mscorlib (mscorlib.dll 内)
構文
この形式の CspParameters は、ProviderType フィールドを値 1 に初期化します。この値は、PROV_RSA_FULL プロバイダを示します。この既定のプロバイダは、RSA アルゴリズムと互換性があります。
CspParameters クラスを使用してキー コンテナを作成し、そのコンテナにキーを保存するコード例を次に示します。
Imports System Imports System.IO Imports System.Security.Cryptography Public Class StoreKey Public Shared Sub Main() ' creates the CspParameters object and sets the key container name used to store the RSA key pair Dim cp As New CspParameters() cp.KeyContainerName = "MyKeyContainerName" ' instantiates the rsa instance accessing the key container MyKeyContainerName Dim rsa As New RSACryptoServiceProvider(cp) ' add the below line to delete the key entry in MyKeyContainerName ' rsa.PersistKeyInCsp = false; 'writes out the current key pair used in the rsa instance Console.WriteLine("Key is : " & rsa.ToXmlString(True)) End Sub 'Main End Class 'StoreKey
using System; using System.IO; using System.Security.Cryptography; public class StoreKey { public static void Main() { // creates the CspParameters object and sets the key container name used to store the RSA key pair CspParameters cp = new CspParameters(); cp.KeyContainerName = "MyKeyContainerName"; // instantiates the rsa instance accessing the key container MyKeyContainerName RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(cp); // add the below line to delete the key entry in MyKeyContainerName // rsa.PersistKeyInCsp = false; //writes out the current key pair used in the rsa instance Console.WriteLine("Key is : \n" + rsa.ToXmlString(true)); } }
using namespace System; using namespace System::IO; using namespace System::Security::Cryptography; int main() { // creates the CspParameters object and sets the key container name used to store the RSA key pair CspParameters^ cp = gcnew CspParameters; cp->KeyContainerName = "MyKeyContainerName"; // instantiates the rsa instance accessing the key container MyKeyContainerName RSACryptoServiceProvider^ rsa = gcnew RSACryptoServiceProvider( cp ); // add the below line to delete the key entry in MyKeyContainerName // rsa.PersistKeyInCsp = false; //writes out the current key pair used in the rsa instance Console::WriteLine( "Key is : \n{0}", rsa->ToXmlString( true ) ); }
import System.*; import System.IO.*; import System.Security.Cryptography.*; public class StoreKey { public static void main(String[] args) { // creates the CspParameters object and sets the key container name // used to store the RSA key pair CspParameters cp = new CspParameters(); cp.KeyContainerName = "MyKeyContainerName"; // instantiates the rsa instance accessing the key container // MyKeyContainerName RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(cp); // add the below line to delete the key entry in MyKeyContainerName // rsa.PersistKeyInCsp = false; //writes out the current key pair used in the rsa instance Console.WriteLine("Key is : \n" + rsa.ToXmlString(true)); } //main } //StoreKey
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
- CspParameters コンストラクタのページへのリンク