1 #ifndef _wasdk_public_h
2 #define _wasdk_public_h
6 #if defined(WIN32) && !defined(_WIN64)
7 # define FUNCCALL __stdcall
13 #if defined(__cplusplus)
14 # define EXTERNC extern "C"
16 # define EXTERNC extern
20 #if defined(WIN32) && !defined(WA_SDK_STATIC)
21 # if defined(WA_SDK_EXPORTS) && defined(_USRDLL)
22 # define WA_SDK_API EXTERNC __declspec(dllexport)
24 # define WA_SDK_API EXTERNC __declspec(dllimport)
27 # define WA_SDK_API EXTERNC
35 #define WASDK_SUCCESS 0
37 #define MAX_SYMM_KEY_SIZE 32
38 #define MAX_SYMM_BLOCK_SIZE 16
39 #define MAX_ASYMM_KEY_SIZE 512
40 #define MAX_HASH_SIZE 64
43 #define WASDK_SAFE_FREE(_PTR_) do { if (_PTR_) { free(_PTR_); (_PTR_) = NULL; } } while (0)
46 typedef enum enum_ESymmetricOperationMode {
64 typedef enum enum_ESymmetricAlgorithm {
82 typedef enum enum_EAsymmetricAlgorithm {
95 typedef enum enum_EHashAlgorithm {
110 typedef enum enum_ERsaEncryptionScheme {
120 typedef enum enum_EEncodingFormat {
132 typedef enum enum_ECompareResult {
254 const unsigned char *data,
279 unsigned char *random,
289 unsigned char *publicKey,
291 int publicKeyBufSize,
292 unsigned char *privateKey,
294 int privateKeyBufSize,
308 const unsigned char *publicKey,
310 const unsigned char *privateKey,
329 unsigned char *publicKey,
331 int publicKeyBufSize,
332 unsigned char *privateKey,
334 int privateKeyBufSize,
336 const char *curveName
348 const unsigned char *publicKey,
350 const unsigned char *privateKey,
353 const char *curveName
368 const unsigned char *ivSeed,
383 unsigned char *hashValue,
385 int hashValueBufSize,
386 const unsigned char *plaintext,
400 unsigned char *hmacValue,
402 int hmacValueBufSize,
403 const unsigned char *plaintext,
405 const unsigned char *key,
420 unsigned char *encrypted,
422 int encryptedBufSize,
423 const unsigned char *plaintext,
425 const unsigned char *key,
427 const unsigned char *iv,
443 unsigned char *encrypted,
445 int encryptedBufSize,
446 const unsigned char *plaintext,
448 const unsigned char *key,
450 const unsigned char *iv,
454 unsigned char padFlag
468 unsigned char *decrypted,
470 int decryptedBufSize,
471 const unsigned char *encrypted,
473 const unsigned char *key,
475 const unsigned char *iv,
492 unsigned char *decrypted,
494 int decryptedBufSize,
495 const unsigned char *encrypted,
497 const unsigned char *key,
499 const unsigned char *iv,
503 unsigned char padFlag
515 unsigned char *encrypted,
517 int encryptedBufSize,
518 const unsigned char *plaintext,
520 const unsigned char *publicKey,
535 unsigned char *decrypted,
537 int decryptedBufSize,
538 const unsigned char *encrypted,
540 const unsigned char *privateKey,
556 unsigned char *encrypted,
558 int encryptedBufSize,
559 const unsigned char *plaintext,
561 const unsigned char *cert,
573 unsigned char *decrypted,
575 int decryptedBufSize,
576 const unsigned char *encrypted,
578 const unsigned char *privateKey,
593 unsigned char *decrypted,
595 int decryptedBufSize,
596 const unsigned char *encrypted,
598 void *privateKeyInfoPtr,
613 unsigned char *encrypted,
615 int encryptedBufSize,
616 const unsigned char *plaintext,
618 const unsigned char *customSessionKey,
623 const unsigned char *publicKey,
640 unsigned char *decrypted,
642 int decryptedBufSize,
643 unsigned char *sessionKey,
645 int sessionKeyBufSize,
646 const unsigned char *encrypted,
651 const unsigned char *privateKey,
668 unsigned char *encrypted,
670 int encryptedBufSize,
671 const unsigned char *plaintext,
673 const unsigned char *customSessionKey,
678 const unsigned char *certificate,
695 unsigned char *encrypted,
697 int encryptedBufSize,
698 const unsigned char *plaintext,
700 const unsigned char *customSessionKey,
702 const unsigned char *customIvSeed,
707 const unsigned char *publicKey,
725 unsigned char *decrypted,
727 int decryptedBufSize,
728 unsigned char *sessionKey,
730 int sessionKeyBufSize,
732 const unsigned char *encrypted,
737 const unsigned char *privateKey,
751 unsigned char *decrypted,
753 int decryptedBufSize,
754 const unsigned char *encrypted,
756 const unsigned char *sessionKey,
EErrorCode
새롭게 구현된 내부 API 에서 사용되는 에러코드들
Definition: wasdk_errorcode.h:13
WA_SDK_API EErrorCode FUNCCALL wasdk_hybrid_decrypt_by_sessionkey(unsigned char *decrypted, int *decryptedSize, int decryptedBufSize, const unsigned char *encrypted, int encryptedSize, const unsigned char *sessionKey, int sessionKeySize, ESymmetricAlgorithm symmAlg, ESymmetricOperationMode opMode)
주어진 세션키로 하이브리드 데이터의 암호문 부분을 복호화한다.
WA_SDK_API EErrorCode FUNCCALL wasdk_hash_encrypt(unsigned char *hashValue, int *hashValueSize, int hashValueBufSize, const unsigned char *plaintext, int plaintextSize, EHashAlgorithm hashAlg)
해시 암호화를 실행한다.
WA_SDK_API EErrorCode FUNCCALL wasdk_generate_keypair_ec(unsigned char *publicKey, int *publicKeySize, int publicKeyBufSize, unsigned char *privateKey, int *privateKeySize, int privateKeyBufSize, EAsymmetricAlgorithm asymmAlg, const char *curveName)
Elliptic Curve 키쌍을 생성한다. (ECDSA, ECKCDSA)
WA_SDK_API EErrorCode FUNCCALL wasdk_init_with_ini(const char *ini, int ini_len)
INI 설정을 이용하여 모듈 초기화를 실행한다.
WA_SDK_API EErrorCode FUNCCALL wasdk_rsa_decrypt_by_pkcs8(unsigned char *decrypted, int *decryptedSize, int decryptedBufSize, const unsigned char *encrypted, int encryptedSize, const unsigned char *privateKey, int privateKeySize, EHashAlgorithm hashAlg)
RSA 복호화를 실행한다. (PKCS8 형식의 개인키 사용)
WA_SDK_API EErrorCode FUNCCALL wasdk_init_with_ini_file(const char *ini_path)
INI 설정 파일을 이용하여 모듈 초기화를 실행한다.
WA_SDK_API int FUNCCALL wasdk_current_state(void)
모듈의 현재상태를 가져온다. (디버깅 용 정보)
WA_SDK_API EErrorCode FUNCCALL wasdk_rsa_encrypt_by_cert(unsigned char *encrypted, int *encryptedSize, int encryptedBufSize, const unsigned char *plaintext, int plaintextSize, const unsigned char *cert, int certSize, EHashAlgorithm hashAlg)
RSA 암호화를 실행한다. (인증서의 공개키 사용)
WA_SDK_API EErrorCode FUNCCALL wasdk_generate_random(unsigned char *random, int randomSize)
RNG(Random Number Generator)를 사용하여 랜덤값을 생성한다.
ESymmetricAlgorithm
대칭키 암호화 알고리즘
Definition: wasdk_public.h:64
WA_SDK_API const char *FUNCCALL wasdk_product_info(void)
모듈의 정보를 가져온다.
WA_SDK_API EErrorCode FUNCCALL wasdk_generate_iv_from_seed(unsigned char *iv, int *ivSize, int ivBufSize, const unsigned char *ivSeed, int ivSeedSize, ESymmetricAlgorithm symmAlg, EHashAlgorithm hashAlg)
IV SEED를 입력받아 IV를 생성한다.
WA_SDK_API EErrorCode FUNCCALL wasdk_hybrid_encrypt_by_cert(unsigned char *encrypted, int *encryptedSize, int encryptedBufSize, const unsigned char *plaintext, int plaintextSize, const unsigned char *customSessionKey, int sessionKeySize, ESymmetricAlgorithm symmAlg, ESymmetricOperationMode opMode, EHashAlgorithm hashAlg, const unsigned char *certificate, int certificateSize)
하이브리드 암호화를 실행한다.
WA_SDK_API const char *FUNCCALL wasdk_error_message(EErrorCode errorCode)
에러코드에 해당하는 에러 메시지를 가져온다.
WA_SDK_API EErrorCode FUNCCALL wasdk_hybrid_decrypt_ivseed(unsigned char *decrypted, int *decryptedSize, int decryptedBufSize, unsigned char *sessionKey, int *sessionKeySize, int sessionKeyBufSize, int ivSeedSize, const unsigned char *encrypted, int encryptedSize, ESymmetricAlgorithm symmAlg, ESymmetricOperationMode opMode, EHashAlgorithm hashAlg, const unsigned char *privateKey, int privateKeySize, ERsaEncryptionScheme rsaEncryptionScheme)
하이브리드 복호화를 실행한다. (IV SEED 포함)
WA_SDK_API EErrorCode FUNCCALL wasdk_generate_keypair(unsigned char *publicKey, int *publicKeySize, int publicKeyBufSize, unsigned char *privateKey, int *privateKeySize, int privateKeyBufSize, EAsymmetricAlgorithm asymmAlg, int keySizeInBit)
키쌍을 생성한다.
WA_SDK_API EErrorCode FUNCCALL wasdk_set_verified_service(void)
암호모듈 유한상태모델(FSM)의 현재 상태를 검증 서비스 상태로 변경한다.
WA_SDK_API EErrorCode FUNCCALL wasdk_rsa_decrypt(unsigned char *decrypted, int *decryptedSize, int decryptedBufSize, const unsigned char *encrypted, int encryptedSize, const unsigned char *privateKey, int privateKeySize, EHashAlgorithm hashAlg, ERsaEncryptionScheme rsaEncryptionScheme)
RSA 복호화를 실행한다.
WA_SDK_API EErrorCode FUNCCALL wasdk_hybrid_decrypt(unsigned char *decrypted, int *decryptedSize, int decryptedBufSize, unsigned char *sessionKey, int *sessionKeySize, int sessionKeyBufSize, const unsigned char *encrypted, int encryptedSize, ESymmetricAlgorithm symmAlg, ESymmetricOperationMode opMode, EHashAlgorithm hashAlg, const unsigned char *privateKey, int privateKeySize, ERsaEncryptionScheme rsaEncryptionScheme)
하이브리드 복호화를 실행한다.
WA_SDK_API EErrorCode FUNCCALL wasdk_check_keypair_ec(const unsigned char *publicKey, int publicKeySize, const unsigned char *privateKey, int privateKeySize, EAsymmetricAlgorithm asymmAlg, const char *curveName)
Elliptic Curve 키쌍을 검증한다.
WA_SDK_API EErrorCode FUNCCALL wasdk_init(void)
모듈 초기화를 실행한다.
WA_SDK_API EErrorCode FUNCCALL wasdk_hmac_encrypt(unsigned char *hmacValue, int *hmacValueSize, int hmacValueBufSize, const unsigned char *plaintext, int plaintextSize, const unsigned char *key, int keySize, EHashAlgorithm hashAlg)
HMAC (Hashed MAC) 암호화를 실행한다.
WA_SDK_API EErrorCode FUNCCALL wasdk_init_without_license(void)
라이선스 확인 없이 모듈 초기화만 실행한다.
WA_SDK_API int FUNCCALL wasdk_get_detail_errorcode(void)
상세한 에러코드를 리턴한다.
ECompareResult
비교 결과
Definition: wasdk_public.h:132
WA_SDK_API EErrorCode FUNCCALL wasdk_rsa_encrypt(unsigned char *encrypted, int *encryptedSize, int encryptedBufSize, const unsigned char *plaintext, int plaintextSize, const unsigned char *publicKey, int publicKeySize, EHashAlgorithm hashAlg, ERsaEncryptionScheme rsaEncryptionScheme)
RSA 암호화를 실행한다.
WA_SDK_API EErrorCode FUNCCALL wasdk_symmetric_decrypt_ex(unsigned char *decrypted, int *decryptedSize, int decryptedBufSize, const unsigned char *encrypted, int encryptedSize, const unsigned char *key, int keySize, const unsigned char *iv, int ivSize, ESymmetricAlgorithm symmAlg, ESymmetricOperationMode opMode, unsigned char padFlag)
비밀키 복호화를 실행한다.
EAsymmetricAlgorithm
비대칭키 알고리즘 (전자서명, 암호화)
Definition: wasdk_public.h:82
WA_SDK_API void FUNCCALL wasdk_free(void *ptr)
WA-SDK 에서 생성된 메모리를 해제한다. (다른 메모리 영역)
WA_SDK_API EErrorCode FUNCCALL wasdk_finalize(void)
모듈을 종료한다.
WA_SDK_API EErrorCode FUNCCALL wasdk_set_not_verified_service(void)
암호모듈 유한상태모델(FSM)의 현재 상태를 비검증 서비스 상태로 변경한다.
WA_SDK_API EErrorCode FUNCCALL wasdk_hybrid_encrypt_ivseed(unsigned char *encrypted, int *encryptedSize, int encryptedBufSize, const unsigned char *plaintext, int plaintextSize, const unsigned char *customSessionKey, int sessionKeySize, const unsigned char *customIvSeed, int ivSeedSize, ESymmetricAlgorithm symmAlg, ESymmetricOperationMode opMode, EHashAlgorithm hashAlg, const unsigned char *publicKey, int publicKeySize, ERsaEncryptionScheme rsaEncryptionScheme)
하이브리드 암호화를 실행한다. (IV SEED 포함)
WA_SDK_API EErrorCode FUNCCALL wasdk_symmetric_encrypt(unsigned char *encrypted, int *encryptedSize, int encryptedBufSize, const unsigned char *plaintext, int plaintextSize, const unsigned char *key, int keySize, const unsigned char *iv, int ivSize, ESymmetricAlgorithm symmAlg, ESymmetricOperationMode opMode)
비밀키 암호화를 실행한다.
EHashAlgorithm
해시 알고리즘
Definition: wasdk_public.h:95
ESymmetricOperationMode
비밀키 암호화 운영모드
Definition: wasdk_public.h:46
WA_SDK_API const char *FUNCCALL wasdk_version(void)
모듈의 버전을 가져온다.
WA_SDK_API EErrorCode FUNCCALL wasdk_check_keypair(const unsigned char *publicKey, int publicKeySize, const unsigned char *privateKey, int privateKeySize, EAsymmetricAlgorithm asymmAlg)
RSA 키쌍을 검증한다.
WA_SDK_API EErrorCode FUNCCALL wasdk_rsa_decrypt_by_pkcs8_ptr(unsigned char *decrypted, int *decryptedSize, int decryptedBufSize, const unsigned char *encrypted, int encryptedSize, void *privateKeyInfoPtr, EHashAlgorithm hashAlg)
RSA 복호화를 실행한다. (외부에서 생성된 CIS PKCS8 형식의 개인키 포인터 사용)
WA_SDK_API EErrorCode FUNCCALL wasdk_symmetric_encrypt_ex(unsigned char *encrypted, int *encryptedSize, int encryptedBufSize, const unsigned char *plaintext, int plaintextSize, const unsigned char *key, int keySize, const unsigned char *iv, int ivSize, ESymmetricAlgorithm symmAlg, ESymmetricOperationMode opMode, unsigned char padFlag)
비밀키 암호화를 실행한다.
WA_SDK_API EErrorCode FUNCCALL wasdk_symmetric_decrypt(unsigned char *decrypted, int *decryptedSize, int decryptedBufSize, const unsigned char *encrypted, int encryptedSize, const unsigned char *key, int keySize, const unsigned char *iv, int ivSize, ESymmetricAlgorithm symmAlg, ESymmetricOperationMode opMode)
비밀키 복호화를 실행한다.
WA_SDK_API EErrorCode FUNCCALL wasdk_base64_decoding(unsigned char *data, int *dataSize, int dataBufSize, const char *b64)
Base64 디코딩
WA_SDK_API EErrorCode FUNCCALL wasdk_hybrid_encrypt(unsigned char *encrypted, int *encryptedSize, int encryptedBufSize, const unsigned char *plaintext, int plaintextSize, const unsigned char *customSessionKey, int sessionKeySize, ESymmetricAlgorithm symmAlg, ESymmetricOperationMode opMode, EHashAlgorithm hashAlg, const unsigned char *publicKey, int publicKeySize, ERsaEncryptionScheme rsaEncryptionScheme)
하이브리드 암호화를 실행한다.
ERsaEncryptionScheme
PKCS1 RSA 암호화에 사용되는 Encryption Scheme
Definition: wasdk_public.h:110
WA_SDK_API EErrorCode FUNCCALL wasdk_base64_encoding(char *b64, int b64BufSize, const unsigned char *data, int dataSize)
Base64 인코딩
EEncodingFormat
데이터 인코딩 형식
Definition: wasdk_public.h:120
WA_SDK_API EErrorCode FUNCCALL wasdk_get_license_info(char *outstring)
라이선스 정보를 가져온다.
@ ESA_ARIA192
ARIA192
Definition: wasdk_public.h:70
@ ESA_AES256
AES256
Definition: wasdk_public.h:68
@ ESA_LEA128
LEA128
Definition: wasdk_public.h:75
@ ESA_TDES
TDES
Definition: wasdk_public.h:73
@ ESA_SEED
SEED
Definition: wasdk_public.h:66
@ ESA_ARIA256
ARIA256
Definition: wasdk_public.h:71
@ ESA_LEA256
LEA256
Definition: wasdk_public.h:77
@ ESA_UNDEFINED
Definition: wasdk_public.h:65
@ ESA_DES
DES
Definition: wasdk_public.h:72
@ ESA_ARIA
ARIA
Definition: wasdk_public.h:69
@ ESA_IDEA
IDEA
Definition: wasdk_public.h:74
@ ESA_LEA192
LEA192
Definition: wasdk_public.h:76
@ ESymmetricAlgorithm_COUNT
Definition: wasdk_public.h:78
@ ESA_AES128
AES128
Definition: wasdk_public.h:67
@ ECR_LessThan
왼쪽이 작다
Definition: wasdk_public.h:134
@ ECR_Equal
같다
Definition: wasdk_public.h:135
@ ECR_GreaterThan
왼쪽이 크다
Definition: wasdk_public.h:136
@ ECR_Unknown
모르겠다
Definition: wasdk_public.h:133
@ EAA_UNDEFINED
Definition: wasdk_public.h:83
@ EAA_RSA21
RSA v2.1
Definition: wasdk_public.h:85
@ EAA_KCDSA1
KCDSA1 (Korean Certificate based - Digital Signature Algorithm)
Definition: wasdk_public.h:87
@ EAA_ECDSA
ECDSA (Elliptic Curve Digital Signature Algorithm)
Definition: wasdk_public.h:88
@ EAA_ECKCDSA
ECKCDSA (Korean Certificate based - Elliptic Curve Digital Signature Algorithm)
Definition: wasdk_public.h:89
@ EAA_KCDSA0
KCDSA (Korean Certificate based - Digital Signature Algorithm)
Definition: wasdk_public.h:86
@ EAA_RSA
RSA
Definition: wasdk_public.h:84
@ EAsymmetricAlgorithm_COUNT
Definition: wasdk_public.h:91
@ EAA_DSA
DSA (Digital Signature Algorithm)
Definition: wasdk_public.h:90
@ EHashAlgorithm_COUNT
Definition: wasdk_public.h:106
@ EHA_HAS160
HAS160
Definition: wasdk_public.h:103
@ EHA_UNDEFINED
Definition: wasdk_public.h:96
@ EHA_SHA224
SHA224
Definition: wasdk_public.h:99
@ EHA_MD2
MD2
Definition: wasdk_public.h:104
@ EHA_SHA256
SHA256
Definition: wasdk_public.h:100
@ EHA_MD5
MD5
Definition: wasdk_public.h:105
@ EHA_SHA512
SHA512
Definition: wasdk_public.h:102
@ EHA_SHA384
SHA384
Definition: wasdk_public.h:101
@ EHA_SHA1_OLD
SHA1_OLD (예전 ROTL 문제가 있었던 알고리즘)
Definition: wasdk_public.h:97
@ EHA_SHA1
SHA1
Definition: wasdk_public.h:98
@ ESOM_CFB1
CFB1
Definition: wasdk_public.h:55
@ ESOM_GCM
GCM (Galois/Counter Mode of Operation) (unsupported)
Definition: wasdk_public.h:58
@ ESymmetricOperationMode_COUNT
Definition: wasdk_public.h:60
@ ESOM_OFB
OFB (Output Feedback)
Definition: wasdk_public.h:52
@ ESOM_CTR
CTR (Counter Mode)
Definition: wasdk_public.h:56
@ ESOM_CFB_BYTE
CFB BYTE
Definition: wasdk_public.h:51
@ ESOM_ECB
ECB (Electronic Codebook)
Definition: wasdk_public.h:48
@ ESOM_MCFB
MCFB
Definition: wasdk_public.h:57
@ ESOM_CCM
CCM (Counter Mode with CBC-MAC) (unsupported)
Definition: wasdk_public.h:59
@ ESOM_OFB_BYTE
OFB BYTE
Definition: wasdk_public.h:53
@ ESOM_CTS
CTS
Definition: wasdk_public.h:54
@ ESOM_CBC
CBC (Cipher Block Chaining)
Definition: wasdk_public.h:49
@ ESOM_CFB
CFB (Cipher Feedback)
Definition: wasdk_public.h:50
@ ESOM_UNDEFINED
Definition: wasdk_public.h:47
@ ERES_OAEP_OLD
OAEP 예전 방식
Definition: wasdk_public.h:112
@ ERES_OAEP_V20
v2.0 OAEP 방식
Definition: wasdk_public.h:114
@ ERES_PKCS1_V15
v1.5 방식
Definition: wasdk_public.h:113
@ ERES_OAEP_V21
v2.1 OAEP 방식
Definition: wasdk_public.h:115
@ ERES_UNDEFINED
Definition: wasdk_public.h:111
@ ERsaEncryptionScheme_COUNT
Definition: wasdk_public.h:116
@ EEncodingFormat_COUNT
Definition: wasdk_public.h:128
@ EEF_UNKNOWN
Definition: wasdk_public.h:121
@ EEF_Base64Url
Base64 URL 인코딩
Definition: wasdk_public.h:124
@ EEF_Base64UrlWithPadding
Base64 URL 인코딩 (패딩포함)
Definition: wasdk_public.h:125
@ EEF_HexLower
Hex 인코딩 (소문자)
Definition: wasdk_public.h:127
@ EEF_Base64
Base64 인코딩
Definition: wasdk_public.h:123
@ EEF_Binary
이진 데이터 형식 (인코딩 안함)
Definition: wasdk_public.h:122
@ EEF_HexUpper
Hex 인코딩 (대문자)
Definition: wasdk_public.h:126
#define FUNCCALL
Definition: wasdk_public.h:9
#define WA_SDK_API
Definition: wasdk_public.h:27