1 / 8

S-DES 소스

S-DES 소스. ’ 98 김동환. 기본 구성. 암호 키값 입력 암호 키값으로 서브키 생성 암호화 , 복호화 결정 암호화 또는 복호화. 키 생성 (1). 키 값에 필요한 값 P10,P8 생성 방법 P10 -> LS01 OR LS02 -> P8 -> SUB-KEY 메인에서 키를 받아 Init_key 함수로 넘김 순열 처리. for(int i=0; i<10; i++) { temp_key[i] = *(key+p10[i]); }. 키 생성 (2).

Download Presentation

S-DES 소스

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. S-DES 소스 ’98 김동환

  2. 기본 구성 • 암호 키값 입력 • 암호 키값으로 서브키 생성 • 암호화, 복호화 결정 • 암호화 또는 복호화

  3. 키 생성(1) • 키 값에 필요한 값 P10,P8 • 생성 방법 • P10 -> LS01 OR LS02 -> P8 -> SUB-KEY • 메인에서 키를 받아 Init_key함수로 넘김 • 순열 처리 for(inti=0; i<10; i++) { temp_key[i] = *(key+p10[i]); }

  4. 키 생성(2) • LS1,2 그리고 P8의 작업은 ls_p8에게 넘김 • k1 = ls_p8(temp_key, 1); • 두 번째 인수로 스프트 연산 수를 결정 • P8은 위의 P10과 같은 방법으로 연산 • 추가 작업 : 문자열값으로 8비트 서브키 생성 charsub_key=0; for(i=0; i<8; i++) { sub_key <<=1; if(temp_key[i] == 49) { sub_key |= 0x01; } }

  5. 암호화 • 두 자리를 한 자리로 변환 저장 -> tobin • 한자씩 암호화 -> encry • Encry는 ip, fk, sw, fk, reip 함수가 차례로 처리 • 다시 한자리값들을 두자리 변환 -> todig • 암호화된 값들을 복호화할 때 정확히 기입하기 위해 필요 • 출력

  6. 복호화 • 두 자리를 한 자리로 변환 저장 -> tobin • 한자씩 암호화 -> decry • decry는 ip, fk, sw, fk, reip 함수가 차례로 처리 • 다시 한자리값들을 두자리 변환 -> todig • 암호화된 값들을 복호화할 때 정확히 기입하기 위해 필요 • 출력

  7. IP • 여기서 순열을 비트열을 재조합함. charip(charbi) { intip[8] = {1,5,2,0,3,7,4,6}; chartemp=0; for(inti=0;i<8;i++) { temp <<=1; if(pow(2,7-ip[i]) == (bi & char(pow(2,7-ip[i])))) { temp |= 0x01; } } returntemp; }

  8. S-Box • 우선 s-box를 2차원 배열로 만듬 • 인덱스를 직접 비트 값을 비교하여 조합 //s0 index; if((ep_temp & 128) == 128) s_index1 |= 0x01; s_index1 <<= 1; if((ep_temp & 16) == 16) s_index1 |= 0x01; if((ep_temp & 64) == 64) s_index2 |= 0x01; s_index2 <<= 1; if((ep_temp & 32) == 32) s_index2 |= 0x01; s_temp = s0[s_index1][s_index2]; s_temp <<=2;

More Related