이거 오류가 뭔지 잘 모르겟어요 -_ㅠ
움찬
이거 오류를 잘 모르겟내요...재가 아직 소스를 이해를 못하고 있어서 그런건지..ㅠㅠ혹시 이거 아는분 어떻게 고쳐야 하는지
프로그램 내용은 8문자 예security라는 값을 입력받으면 그것을 PermutedChoice함수로 넘겨줘서 마지막에 다른 문자를 출력하게 됩니다. 입력받은 문자를 몇가지 xor연산을 사용하여 16라운드 다른 문자(키값)을 생성하는 프로그램입니다.좀 도와주세용 흑...
Des의 키값생성 알고리즘
#includestdio.h
#define DWORD unsigned long
void PermutedChoice1(DWORD *Key);
void PermutedChoice2(DWORD *Key);
unsigned char PC_1[]={
57, 49, 41, 33, 25, 17, 9,
1, 58, 50, 42, 34, 26, 18,
10, 2, 59, 51, 43, 35, 27,
19, 11, 3, 60, 52, 44, 36,
63, 55, 47, 39, 31, 23, 15,
7, 62, 54, 46, 38, 30, 22,
14, 6, 61, 53, 45, 37, 29,
21, 13, 5, 28, 20, 12, 4
};
unsigned char PC_2[]={
14, 17, 11, 24, 1, 5, 3, 28,
15, 6, 21, 10, 23, 19, 12, 4,
26, 8, 16, 7, 27, 20, 13, 2,
41, 52, 31, 37, 47, 55, 30, 40,
51, 45, 33, 48, 44, 49, 39, 56,
34, 53, 46, 42, 50, 36, 29, 32
};
const unsigned char LSHIFT[]={
1,1,2,2,
2,2,2,2,
1,2,2,2,
2,2,2,1
};
void main()
{
int SHIFT=0;
char Key[8]={0};
DWORD dwKey[2]={0,0};
DWORD tmp0, tmp1;
DWORD RoundKey[2]={0,};
printf(키값을 입력하시요 : );
gets(Key);
for(int i=0; i4; i++)
{
SHIFT =((3-i)*8);
dwKey[1] ^= ((DWORD)Key[i])SHIFT;
dwKey[0] ^= ((DWORD)Key[i+4])SHIFT;
}
PermutedChoice1(Key);
for(i=0; i2; i++)
{
//Left shift
if((LSHIFT[i] == 1))
{
tmp0 = ((dwKey[0] & 0x08000000) 27);
tmp0 |= ((dwKey[0] & 0x07FFFFFF) 1);
dwKey[0] = tmp0;
tmp1 = ((dwKey[1] & 0x08000000) 27);
tmp1 |= ((dwKey[1] & 0x07FFFFFF) 1);
dwKey[1] = tmp1;
}else //2bit-shift
{
tmp0 = ((dwKey[0] & 0x0c000000) 26);
tmp0 |= ((dwKey[0] & 0x03FFFFFF) 2);
dwKey[0] = tmp0;
tmp1 = ((dwKey[1] & 0x0c000000) 26);
tmp1 |= ((dwKey[1] & 0x03FFFFFF) 2);
dwKey[1] = tmp1;
}
PermutedChoice2(Key);
RoundKey[2*i+1] = dwKey[1];
RoundKey[2*i] = dwKey[0];
dwKey[1] = tmp1;
dwKey[0] = tmp0;
printf(%d, tmp1);
}
}
void PermutedChoice1(char *Key)
{
DWORD tmpMask;
DWORD KeyMask;
DWORD NewKey[2] = {0,0};
tmpMask = 0x000000001;
for(int i=0; i28; i++)
{
KeyMask = 0x08000000 i;
if((PC_1[i] = 32) && (Key[1] & (tmpMask (32-PC_1[i])))){
NewKey[1] = NewKey[1] | KeyMask;
}
else if((PC_1[i] 32) && (Key[0] & (tmpMask (64-PC_1[i])))){
NewKey[1] = NewKey[1] | KeyMask;
}
}
for(i=28; i56; i++)
{
KeyMask = 0x08000000 (i-28);
if((PC_1[i] = 32) && (Key[1] & (tmpMask (32-PC_1[i])))){
NewKey[0] = NewKey[0] | KeyMask;
}
else if((PC_1[i] 32) && (Key[0] & (tmpMask (64-PC_1[i])))){
NewKey[0] = NewKey[0] | KeyMask;
}
}
Key[0] = NewKey[0];
Key[1] = NewKey[1];
}
void PermutedChoice2(char *Key)
{
DWORD tmpMask;
DWORD KeyMask;
DWORD NewKey[2] = {0,0};
tmpMask = 0x000000001;
for(int i=0; i28; i++)
{
KeyMask = 0x08000000 i;
if((PC_1[i] = 32) && (Key[1] & (tmpMask (32-PC_1[i])))){
NewKey[1] = NewKey[1] | KeyMask;
}
else if((PC_1[i] 32) && (Key[0] & (tmpMask (64-PC_1[i])))){
NewKey[1] = NewKey[1] | KeyMask;
}
}
for(i=28; i56; i++)
{
KeyMask = 0x08000000 (i-28);
if((PC_1[i] = 32) && (Key[1] & (tmpMask (32-PC_1[i])))){
NewKey[0] = NewKey[0] | KeyMask;
}
else if((PC_1[i] 32) && (Key[0] & (tmpMask (64-PC_1[i])))){
NewKey[0] = NewKey[0] | KeyMask;
}
}
Key[0] = NewKey[0];
Key[1] = NewKey[1];
}
-
여우비
int i선언해주고........ 함수원형 수정해주세요.......~
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2693647 | 12.620000 을요 12.620 으로 어떻게 표현해요? (2) | 파도 | 2025-05-04 |
2693619 | 타이틀 코드.. | 단순드립 | 2025-05-03 |
2693591 | 컴파일 에러에서 질문드립니다 (3) | 게자리 | 2025-05-03 |
2693463 | 동적할당 이용시 fwrite사용을 어떻게 해야하나요..? (10) | 일본어못해요 | 2025-05-02 |
2693387 | 배열문제입니다 수정오류캡쳐했습니다 (6) | 연하얀 | 2025-05-01 |
2693356 | text 입출력 내림차순 질문입니다 ㅠ | 빛글 | 2025-05-01 |
2693328 | C언어를이용해서 .txt파일 외에 다른 확장자 파일 삭제가 가능한지.. (2) | 대나무 | 2025-05-01 |
2693299 | 파일입출력 바이너리파일 | 독특한 | 2025-04-30 |
2693273 | 오류 (1) | 귀1여운렩 | 2025-04-30 |
2693080 | visual studio 2008 express edition 등록키 말인데요 | 얀별 | 2025-04-28 |
2693053 | 배열, 구조체 관련 프로그래밍 질문드립니다. | 싸리 | 2025-04-28 |
2693025 | 프로그램을 짜봤는데요 ㅠㅠ | 상처입은마음 | 2025-04-28 |
2693001 | 워닝문제, 세그멘트결함문제 (1) | 월식 | 2025-04-28 |
2692979 | 라인한줄 이랑.. 소스 설명좀 부탁드려요.. | 이루리 | 2025-04-27 |
2692947 | 이 문제좀 풀어 주세요..ㅜㅜ (1) | 소리 | 2025-04-27 |
2692889 | 함수의 구조체 인자로 받아서 그 인자로 데이터 넣기... | 한뎃집 | 2025-04-27 |
2692862 | 성적 출력 하는 프로그램인데요~!!!도움좀 주세욤.ㅠ | 두빛나래 | 2025-04-26 |
2692831 | if 문 간단해요 빨리좀 ㅠㅠ | 이플 | 2025-04-26 |
2692805 | 실행파일이 이상해요 | 푸헷 | 2025-04-26 |
2692750 | 퀵정렬 질문이요 . | 동생몬 | 2025-04-25 |