Crypto API 질문
겨라
질문 제목 :crypto api 질문
쓰는방법은 알겠는데 왜 저렇게 써야하는질 모르겠음... 그냥 사용자가 입력한 암호키받고 그걸로 걍 바로 쓰면되지왜 해시값에 세션키를 처만드는지...
질문 내용 :
bool encryptfile( pchar szsource, pchar szdestination, pchar szpassword)//------------------------------------------------// 파라메터 정의// szsource : 입력으로 주어지는 파일명 원문을 담고 있다.// szdestination : 출력파일 이름. 암호화 되어 있다.// szpassword : 암호화에 사용될 키값대칭키 방식이기에 복호화에도 사용된다.
{file *hsource;file *hdestination;
hcryptprocryptprov hcryptprov;hcryptkey hkey;hcrypthash hhash;
pbyte pbbuffer;dword dwblocklen;dword dwbufferlen;dword dwcount;
// 입력 파일 열기if(hsource = fopen(szsource,rb)){ printf(the source plaintext file, %s, is open. \n, szsource);}else{ handleerror(error opening source plaintext file!);}
// 출력파일 열기if(hdestination = fopen(szdestination,wb)){printf(destination file %s is open. \n, szdestination);}else{handleerror(error opening destination ciphertext file!);}// 디폴트 csp의 핸들을 얻어온다. cryptoapi중 가장 첫번째 함수if(cryptacquirecontext(&hcryptprov,0,ms_enhanced_prov,prov_rsa_full,0 )){ printf(a cryptographic provider has been acquired. \n);}else{ handleerror(error during cryptacquirecontext!);}
//hash 오브젝트를 생성한다.if(cryptcreatehash( sp; hcryptprov, calg_md5, 0, 0, &hhash)){printf(a hash object has been created. \n);}else{handleerror(error during cryptcreatehash!\n);}
if(crypthashdata( hhash, (byte *)szpassword, strlen(szpassword), 0))//패스워드에 해쉬를 취한다.{printf(the password has been added to the hash. \n);}else{handleerror(error during crypthashdata. \n);}
if(cryptderivekey( hcryptprov, encrypt_algorithm, hhash, keylength, &hkey))// 해쉬 값을 이용하여 세션키를 생성한다.{ printf(an encryption key is derived from the password hash. \n);}else{ handleerror(error during cryptderivekey!\n);}
굵은글씨로 한부분 다 이해가안가요 ㅠㅠ
csp 핸들을 얻어오고, 해싱오브젝트를 만들어 사용자가 입력한 암호키로 해시값을 만들고만들어진 해시값으로 왜 세션키를 만들죠 ㅠㅠ?
이해가안대요 네이버에 찾아봐도 자료가 충분하지않고 소스만 덜렁있꼬 설명이 없어여 ...구글은 무능력한 영어지식에 좌절했슴미당... 수다님들 도와주세영..
쓰는방법은 알겠는데 왜 저렇게 써야하는질 모르겠음... 그냥 사용자가 입력한 암호키받고 그걸로 걍 바로 쓰면되지왜 해시값에 세션키를 처만드는지...
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2692144 | C언어와 리눅스에 대한 질문입니다. | 싴흐한세여니 | 2025-04-20 |
2692114 | 컨텍스트 스위칭하는데 걸리는 시간 측정.. | YourWay | 2025-04-19 |
2692086 | 간접참조 연산자, 증감연산자 질문이용! (2) | 블랙캣 | 2025-04-19 |
2692056 | 주석좀 달아주세요. 몇개적엇는데 몇개만달아주세요. (2) | DevilsTears | 2025-04-19 |
2691978 | 진수 쉽게 이해하는법... (3) | 지지않는 | 2025-04-18 |
2691949 | getchar() 한 문자를 입력받는 함수 질문 | 채꽃 | 2025-04-18 |
2691919 | 배열 정렬 및 합치기 질문입니다. | 사과 | 2025-04-18 |
2691845 | c언어왕초보 질문이 있습니다........ | 루나 | 2025-04-17 |
2691815 | void add(int num); 함수... (4) | 살랑살랑 | 2025-04-17 |
2691756 | 명령 프롬프트 스크롤바가 없어요 | 두메꽃 | 2025-04-16 |
2691725 | 자료구조에 관련해서 질문이 있어 글을 올립니다. | 누리알찬 | 2025-04-16 |
2691697 | if 문에서 구조체 배열에 저장되있던 문자열 검사하는 법 ? (2) | 민트맛사탕 | 2025-04-16 |
2691678 | C언어 함수 질문이요~!!! | 연보라 | 2025-04-15 |
2691650 | 반복문 | 돋가이 | 2025-04-15 |
2691618 | 링크드리스트 개념 질문이예요 (3) | 맨마루 | 2025-04-15 |
2691592 | 동적할당 이용 배열선언 질문입니다.ㅠㅠ (3) | 허리달 | 2025-04-15 |
2691542 | /=의 용도를 알려주세요 ㅠㅠ! (2) | 아라 | 2025-04-14 |
2691510 | sizeof 연산자 질문입니다 (2) | 종달 | 2025-04-14 |
2691483 | 파일 오픈시 에러 질문드립니다. (2) | 호습다 | 2025-04-14 |
2691450 | [visual c++ 툴]기초 질문 (3) | 해긴 | 2025-04-13 |