다음을 통해 공유


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()

Source:
CspParameters.cs
Source:
CspParameters.cs
Source:
CspParameters.cs

CspParameters 클래스의 새 인스턴스를 초기화합니다.

public:
 CspParameters();
public CspParameters ();
Public Sub New ()

예제

다음 코드 예제에서는 클래스를 사용 하 여 키 컨테이너를 CspParameters 만들고 컨테이너에 키를 저장 합니다.

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 ) );
}
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));
    }
}
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
End Class

설명

이 형식은 CspParameters 필드를 PROV_RSA_AES 공급자를 지정하는 값24으로 초기화 ProviderType 합니다. 이 기본 공급자는 알고리즘과 호환됩니다 Aes .

다른 공급자 유형에 대한 자세한 내용은 필드를 참조하세요 ProviderType .

추가 정보

적용 대상

CspParameters(Int32)

Source:
CspParameters.cs
Source:
CspParameters.cs
Source:
CspParameters.cs

지정된 공급자 유형 코드를 사용하여 CspParameters 클래스의 새 인스턴스를 초기화합니다.

public:
 CspParameters(int dwTypeIn);
public CspParameters (int dwTypeIn);
new System.Security.Cryptography.CspParameters : int -> System.Security.Cryptography.CspParameters
Public Sub New (dwTypeIn As Integer)

매개 변수

dwTypeIn
Int32

만들 공급자 종류를 지정하는 공급자 유형 코드입니다.

설명

CspParameters 생성자를 사용하여 해당 공급자를 나타내는 숫자 값을 전달하여 공급자 형식을 지정합니다. 기본 공급자 형식을 나타내는 숫자 값은 WinCrypt.h 헤더 파일에 정의되어 있습니다.

  • 알고리즘과 호환되는 공급자를 RSA 지정하려면 의 값을 1 매개 변수에 dwTypeIn 전달합니다.

  • 알고리즘과 호환되는 공급자를 DSA 지정하려면 의 값을 13 매개 변수에 dwTypeIn 전달합니다.

다른 공급자 형식 값에 대한 자세한 내용은 필드를 참조하세요 ProviderType . 기본 공급자 유형 및 해당 동작에 대한 자세한 내용은 MICROSOFT CAPI(Cryptography API) 설명서를 참조하세요.

추가 정보

적용 대상

CspParameters(Int32, String)

Source:
CspParameters.cs
Source:
CspParameters.cs
Source:
CspParameters.cs

지정된 공급자 형식 코드와 이름을 사용하여 CspParameters 클래스의 새 인스턴스를 초기화합니다.

public:
 CspParameters(int dwTypeIn, System::String ^ strProviderNameIn);
public CspParameters (int dwTypeIn, string? strProviderNameIn);
public CspParameters (int dwTypeIn, string strProviderNameIn);
new System.Security.Cryptography.CspParameters : int * string -> System.Security.Cryptography.CspParameters
Public Sub New (dwTypeIn As Integer, strProviderNameIn As String)

매개 변수

dwTypeIn
Int32

만들 공급자 종류를 지정하는 공급자 유형 코드입니다.

strProviderNameIn
String

공급자 이름입니다.

예제

다음 코드 예제에서는 클래스를 CspParameters 사용하여 스마트 카드 암호화 서비스 공급자를 선택합니다. 그런 다음 스마트 카드 사용하여 데이터에 서명하고 확인합니다.

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"SHA256" );
   Console::WriteLine( L"Signature	: {0}", BitConverter::ToString( sig ) );
   
   // Verify the data using the Smart Card CryptoGraphic Provider.
   bool verified = rsa->VerifyData( data, L"SHA256", sig );
   Console::WriteLine( L"Verified		: {0}", verified );
}
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, "SHA256");

            Console.WriteLine("Signature	: " + BitConverter.ToString(sig));

            // Verify the data using the Smart Card CryptoGraphic Provider.
            bool verified = rsa.VerifyData(data, "SHA256", sig);

            Console.WriteLine("Verified		: " + verified);
        }
    }
}
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, "SHA256")

        Console.WriteLine("Signature : " + BitConverter.ToString(sig))

        ' Verify the data using the Smart Card CryptoGraphic Provider.
        Dim verified As Boolean = rsa.VerifyData(data, "SHA256", sig)

        Console.WriteLine("Verified")

    End Sub

End Module

설명

CspParameters 생성자를 사용하여 공급자 유형 및 이름을 지정합니다.

원하는 공급자 형식을 나타내는 숫자 값을 전달하여 공급자 형식을 지정합니다. 기본 공급자 형식을 나타내는 숫자 값은 WinCrypt.h 헤더 파일에 정의되어 있습니다.

  • 알고리즘과 호환되는 공급자를 RSA 지정하려면 의 값을 1 매개 변수에 dwTypeIn 전달합니다.

  • 알고리즘과 호환되는 공급자를 DSA 지정하려면 의 값을 13 매개 변수에 dwTypeIn 전달합니다.

다른 공급자 형식 값에 대한 자세한 내용은 필드를 참조하세요 ProviderType . 기본 공급자 유형 및 해당 동작에 대한 자세한 내용은 MICROSOFT CAPI(Cryptography API) 설명서를 참조하세요.

추가 정보

적용 대상

CspParameters(Int32, String, String)

Source:
CspParameters.cs
Source:
CspParameters.cs
Source:
CspParameters.cs

지정된 공급자 형식 코드와 이름, 지정된 컨테이너 이름을 사용하여 CspParameters 클래스의 새 인스턴스를 초기화합니다.

public:
 CspParameters(int dwTypeIn, System::String ^ strProviderNameIn, System::String ^ strContainerNameIn);
public CspParameters (int dwTypeIn, string? strProviderNameIn, string? strContainerNameIn);
public CspParameters (int dwTypeIn, string strProviderNameIn, string strContainerNameIn);
new System.Security.Cryptography.CspParameters : int * string * string -> System.Security.Cryptography.CspParameters
Public Sub New (dwTypeIn As Integer, strProviderNameIn As String, strContainerNameIn As String)

매개 변수

dwTypeIn
Int32

만들 공급자 종류를 지정하는 공급자 유형 코드입니다.

strProviderNameIn
String

공급자 이름입니다.

strContainerNameIn
String

컨테이너 이름입니다.

설명

CspParameters 생성자를 사용하여 공급자 유형, 공급자 이름 및 컨테이너 이름을 지정합니다.

컨테이너 이름을 사용하여 해당 컨테이너 내에서 키를 검색할 수 있습니다.

원하는 공급자 형식을 나타내는 숫자 값을 전달하여 공급자 형식을 지정합니다. 기본 공급자 형식을 나타내는 숫자 값은 WinCrypt.h 헤더 파일에 정의되어 있습니다.

  • 알고리즘과 호환되는 공급자를 RSA 지정하려면 의 값을 1 매개 변수에 dwTypeIn 전달합니다.

  • 알고리즘과 호환되는 공급자를 DSA 지정하려면 의 값을 13 매개 변수에 dwTypeIn 전달합니다.

다른 공급자 형식 값에 대한 자세한 내용은 필드를 참조하세요 ProviderType . 기본 공급자 유형 및 해당 동작에 대한 자세한 내용은 MICROSOFT CAPI(Cryptography API) 설명서를 참조하세요.

추가 정보

적용 대상

CspParameters(Int32, String, String, CryptoKeySecurity, IntPtr)

공급자 형식, 공급자 이름, 컨테이너 이름, 액세스 정보 및 비관리 스마트 카드 암호 대화 상자에 대한 핸들을 사용하여 CspParameters 클래스의 새 인스턴스를 초기화합니다.

public:
 CspParameters(int providerType, System::String ^ providerName, System::String ^ keyContainerName, System::Security::AccessControl::CryptoKeySecurity ^ cryptoKeySecurity, IntPtr parentWindowHandle);
public CspParameters (int providerType, string providerName, string keyContainerName, System.Security.AccessControl.CryptoKeySecurity cryptoKeySecurity, IntPtr parentWindowHandle);
new System.Security.Cryptography.CspParameters : int * string * string * System.Security.AccessControl.CryptoKeySecurity * nativeint -> System.Security.Cryptography.CspParameters
Public Sub New (providerType As Integer, providerName As String, keyContainerName As String, cryptoKeySecurity As CryptoKeySecurity, parentWindowHandle As IntPtr)

매개 변수

providerType
Int32

만들 공급자 종류를 지정하는 공급자 유형 코드입니다.

providerName
String

공급자 이름입니다.

keyContainerName
String

컨테이너 이름입니다.

cryptoKeySecurity
CryptoKeySecurity

컨테이너에 대한 액세스 권한과 감사 규칙을 나타내는 개체입니다.

parentWindowHandle
IntPtr

nativeint

스마트 카드 암호 대화 상자의 부모 창에 대한 핸들입니다.

설명

컨테이너 이름을 사용하여 해당 컨테이너 내에서 키를 검색할 수 있습니다.

원하는 공급자 형식을 나타내는 숫자 값을 전달하여 공급자 형식을 지정합니다. 기본 공급자 형식을 나타내는 숫자 값은 WinCrypt.h 헤더 파일에 정의되어 있습니다.

  • 알고리즘과 호환되는 공급자를 RSA 지정하려면 의 값을 1 매개 변수에 dwTypeIn 전달합니다.

  • 알고리즘과 호환되는 공급자를 DSA 지정하려면 의 값을 13 매개 변수에 dwTypeIn 전달합니다.

다른 공급자 형식 값에 대한 자세한 내용은 필드를 참조하세요 ProviderType . 기본 공급자 유형 및 해당 동작에 대한 자세한 내용은 MICROSOFT CAPI(Cryptography API) 설명서를 참조하세요.

적용 대상

CspParameters(Int32, String, String, CryptoKeySecurity, SecureString)

공급자 형식, 공급자 이름, 컨테이너 이름, 액세스 정보 및 스마트 카드 키와 관련된 암호를 사용하여 CspParameters 클래스의 새 인스턴스를 초기화합니다.

public:
 CspParameters(int providerType, System::String ^ providerName, System::String ^ keyContainerName, System::Security::AccessControl::CryptoKeySecurity ^ cryptoKeySecurity, System::Security::SecureString ^ keyPassword);
public CspParameters (int providerType, string providerName, string keyContainerName, System.Security.AccessControl.CryptoKeySecurity cryptoKeySecurity, System.Security.SecureString keyPassword);
new System.Security.Cryptography.CspParameters : int * string * string * System.Security.AccessControl.CryptoKeySecurity * System.Security.SecureString -> System.Security.Cryptography.CspParameters
Public Sub New (providerType As Integer, providerName As String, keyContainerName As String, cryptoKeySecurity As CryptoKeySecurity, keyPassword As SecureString)

매개 변수

providerType
Int32

만들 공급자 종류를 지정하는 공급자 유형 코드입니다.

providerName
String

공급자 이름입니다.

keyContainerName
String

컨테이너 이름입니다.

cryptoKeySecurity
CryptoKeySecurity

컨테이너에 대한 액세스 권한과 감사 규칙을 나타내는 개체입니다.

keyPassword
SecureString

스마트 카드 키와 관련된 암호입니다.

설명

컨테이너 이름을 사용하여 해당 컨테이너 내에서 키를 검색할 수 있습니다.

원하는 공급자 형식을 나타내는 숫자 값을 전달하여 공급자 형식을 지정합니다. 기본 공급자 형식을 나타내는 숫자 값은 WinCrypt.h 헤더 파일에 정의되어 있습니다.

  • 알고리즘과 호환되는 공급자를 RSA 지정하려면 의 값을 1 매개 변수에 dwTypeIn 전달합니다.

  • 알고리즘과 호환되는 공급자를 DSA 지정하려면 의 값을 13 매개 변수에 dwTypeIn 전달합니다.

다른 공급자 형식 값에 대한 자세한 내용은 필드를 참조하세요 ProviderType . 기본 공급자 유형 및 해당 동작에 대한 자세한 내용은 MICROSOFT CAPI(Cryptography API) 설명서를 참조하세요.

적용 대상