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 핸들을 얻어오고, 해싱오브젝트를 만들어 사용자가 입력한 암호키로 해시값을 만들고만들어진 해시값으로 왜 세션키를 만들죠 ㅠㅠ?
이해가안대요 네이버에 찾아봐도 자료가 충분하지않고 소스만 덜렁있꼬 설명이 없어여 ...구글은 무능력한 영어지식에 좌절했슴미당... 수다님들 도와주세영..
쓰는방법은 알겠는데 왜 저렇게 써야하는질 모르겠음... 그냥 사용자가 입력한 암호키받고 그걸로 걍 바로 쓰면되지왜 해시값에 세션키를 처만드는지...
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2700668 | c언어 질문입니다. 도와주세요~ (3) | 가자 | 2025-07-07 |
2700639 | 한글입력받아서 ㄱㄴㄷ순서대로출력하는법좀 | 두빛나래 | 2025-07-06 |
2700610 | 정말 기초적인 더하기,여백 문제 help | 무슬 | 2025-07-06 |
2700562 | 함수포인터에서요 (7) | 소심한여자 | 2025-07-06 |
2700530 | 전처리문 질문입니다. (1) | 아놀드 | 2025-07-05 |
2700510 | c언어를 어케하면 잘할수 있을까요.. | 연연두 | 2025-07-05 |
2700484 | 두 개가 차이가 뭔지 알려주세요...(소수 찾는 프로그램) (2) | 날위해 | 2025-07-05 |
2700426 | 인터넷 창 띄우는 질문이요 (1) | 정훈 | 2025-07-04 |
2700400 | 원넓이를 계산이요 ㅜㅜ | 천칭자리 | 2025-07-04 |
2700368 | if에 관해서 질문이요... | Orange | 2025-07-04 |
2700339 | 이거 결과값이 왜이런건지.. (4) | 그댸와나 | 2025-07-04 |
2700313 | 파일 읽어서 저장하는데 빈파일일 경우 문재가 발생하네요.. (2) | 크나 | 2025-07-03 |
2700287 | 구조체 동적할당 연습을 하는데 오류가 뜹니다...(해결) (3) | 아련나래 | 2025-07-03 |
2700264 | 문자와 숫자 동시에 입력??? | 글고운 | 2025-07-03 |
2700236 | txt파일로만 쓰고 읽게 하려면 어떻게 해야 하나요..?? (8) | 미국녀 | 2025-07-03 |
2700211 | 전위 연산자 (2) | 어른처럼 | 2025-07-02 |
2700183 | C에서 파일이름을 받고, 그 파일의 사이즈를 출력해줘야하는데 내용이 출력이 안되네요 ;ㅅ; | 피스케스 | 2025-07-02 |
2700150 | 꼭좀 도와주세요ㅠㅠㅠ | 호습다 | 2025-07-02 |
2700095 | 연산문제...질문... | 오빤테앵겨 | 2025-07-01 |
2700070 | while문 , 3의배수 출력하는 프로그램좀 짜주세욤. | 횃불 | 2025-07-01 |