사용자 도구

사이트 도구


사이드바

카테고리

winapi:암호화

Cryptography API

In Microsoft cryptographic technologies

  • CryptoAPI
  • Cryptographic Service Providers (CSP)
  • CryptoAPI Tools
  • CAPICOM
  • WinTrust
  • issuing and managing certificates
  • developing customizable public key infrastructures
  • Certificate and smart card enrollment
  • certificate management
  • custom module development

지원하는게 많네, 하지만 관심은 CryptoAPI에만 있으니 나머지는 패스

CryptoAPI

윈도우 어플리케이션에서 인터넷과 같은 보안 사각지대에서 문서나 데이터를 안전하게 주고 받을 수 있도록 하는 목적으로 사용된다. C나 C++을 사용할 수 있어야하고 암호화에 대한 지식이 있으면 편하겠지.

CAPICOM

32bit 컴포넌트로, VBScript나 C++ 언어로 애플리케이션 개발에 사용되는 컴포넌트.

OS가 지원하는(명시한) 런타임 환경(스펙)하에서 사용되는 것이 가능합니다.

(CAPICOM is available for use in the operating systems specified in Run-Time Requirements.)

예제 모음

Cryptography API 를 사용한 난수 생성

이런 것도 되나.. 흠

웹사이트 설명 :

  • 윈도우 환경에서 난수를 생성해야 하는 경우라면 CRT 함수 대신 Cryptography API의 하나인 CryptGenRandom() (http://msdn.microsoft.com/ko-kr/library/aa379942.aspx) 함수를 고려해 볼 수 있습니다.
  • 이 함수를 이용하면 주어진 버퍼의 크기만큼 난수를 생성할 수 있는 장점이 있습니다.
#include "stdafx.h"
#include <iostream>
#include <windows.h>
using namespace std;
#pragma comment(lib, "crypt32.lib")
#include <Wincrypt.h>
#define MY_ENCODING_TYPE  (PKCS_7_ASN_ENCODING | X509_ASN_ENCODING)
 
int main()
{
    //--------------------------------------------------------------------
    // 변수를 선언하고 초기화 합니다.
    HCRYPTPROV   hCryptProv;
    BYTE         pbData;
 
    //-------------------------------------------------------------------
    // 암호 제공자의 컨텍스트 핸들을 얻습니다.
 
    if(CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, 0)) 
    {    
        printf("CryptAcquireContext succeeded. \n");
    }
    else
    {
        printf("Error during CryptAcquireContext!\n");
    }
 
    //--------------------------------------------------------------------
    // BYTE 범위내에서 난수를 생성합니다.
 
    if(CryptGenRandom(hCryptProv, 1, &pbData)) 
    {
        printf("Random number is: %d.\n", ((int)pbData) * 100 / 255);
    }
    else
    {
        printf("Error during CryptGenRandom.\n");
        exit(1);
    }
 
    //-------------------------------------------------------------------
    // 컨텍스트 핸들을 해제합니다.
    if(hCryptProv)
    {
        if (!CryptReleaseContext(hCryptProv, 0))
        {
            printf("Failed CryptReleaseContext\n");
        }
    }
 
    return 0;
}
winapi/암호화.txt · 마지막으로 수정됨: 2013/08/28 11:41 저자 kieuns