1 BỘ GIÁO DỤC VÀ ĐÀO TẠO TRƯỜNG ĐẠI HỌC BÁCH KHOA HÀ NỘI ---------------------------------- ----- BÁO CÁO MÔN AN NINH MẠNG Đề tài : : Tìm hiểu và viết phần mềm truyền dữ liệu giữa hai máy sử dụng kỹ thuật mã hóa IDEA Giản viên hướng dẫn : Lê Xuân Thành
Tìm hiểu và viết phần mềm truyền dữ liệu giữa hai máy sử dụng kỹ thuật mã hóa IDEA
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
1
BỘ GIÁO DỤC VÀ ĐÀO TẠO
TRƯỜNG ĐẠI HỌC BÁCH KHOA HÀ NỘI
---------------------------------------
BÁO CÁO MÔN
AN NINH MẠNG
Đề tài : : Tìm hiểu và viết phần mềm truyền dữ liệu giữa hai máy sử dụng kỹ thuật mã hóa IDEA
Giản viên hướng dẫn : Lê Xuân Thành
Sinh viên thực hiện : Đinh Tuấn Hiệp
Phạm QuangTùng
Hà Nội 5-2015
2
Mục LụcI. Lời mở đầu...............................................................3II. Những đặc điểm chính..............................................4III. Các phép toán trong IDEA.......................................5IV. Mã hóa và giải mã trong IDEA................................74.1...................................................................Mã hóa
I. Lời mở đầuPhương pháp IDEA (International Data Encryption Algorithm) là một
phương pháp mã khối. Được phát triển bởi Lai Học Gia và James L.Massey của ETH Zurich và được công bố lần đầu tiên vào năm 1991. Phương pháp này đưa ra như là một sự thay thế cho phương pháp cũ DEA (Data Encryption Standard). Tiền thân của IDEA là phương pháp mã trước đó có tên là PES (Proposed Encryption Standard); lúc đầu IDEA còn có tên là IPES (Improved PES). Sau này IDEA đã trở thành tên thương mại. Nó sẽ hết hạn vào năm 2010-2011. IDEA đã được xác nhập sau khi phiên bản đầu tiên V1.0 được phát hiện là không còn an toàn nữa.
IDEA là hệ mã thao tác trên từng khối 64bit, mã hóa cụm rõ 64bit thành cụm mã 64bit, sử dụng 128bit làm khóa bao gồm 1 chuỗi 8 lần biến đổi liên tiếp và tiếp theo là 1 lần biến đổi đầu ra. Lần biến đổi thứ r sử dụng 6 khối khóa con 16 bit Ki(r), 1<=i<=6, để biến đổi 64bit đầu vào X thành 1 đầu ra với 4 khối 16bit và đầu ra này lại là đầu vào cho lần biến đổi tiếp theo. Đầu ra của lần biến đổi thứ 8 là đầu vào cho lần biến đổi cuối cùng là đầu ra của phương pháp này. Trong lần biến đổi này nó dùng 4 khóa con Ki(9), 1<=i<=4, để tính toán cụm mã cuối cùng Y= (Y1,Y2, Y3, Y4). Tất cả các khóa con nhận được từ K.Một khái niệm trong thiết kế mang tính đột phá của phương pháp IDEA là cách sử dụng hỗn độn các phép toán từ tập 3 phép toán đại số khác nhau của nhóm 2**n phần tử. Các phép toán nhóm thực hiện trên các phần tử biểu diễn bằng 16 bit a và b là: XOR theo từng bit: a ^ b; cộng modulo 2**n: (a+b) mod 2**n, kí hiệu: a [+] b, và nhân modulo 2**n+1, ký hiệu a (*) b.
II. Những đặc điểm chínhIDEA lµ phư¬ng ph¸p m· khèi sö dông 128 bit khãa ®Ó
*Qui t¾c t¹o ra subkey: Như trªn ®· tr×nh bµy, cÇn thiÕt ph¶i cã 52 khèi subkey 16 bit ®ưîc t¹o ra tõ 128 bit khãa. Qui t¾c t¹o như sau:- 8 subkey ®Çu tiªn, Z1...Z8, ®ưîc lÊy trùc tiÕp tõ khãa víi Z1 lµ 16 bit ®Çu (bit cã träng sè cao nhÊt), Z2 lµ 16 bit tiÕp theo vµ cø tiÕp tôc như vËy. Sau ®ã khãa ®ưîc quay
// Need to link with Ws2_32.lib, Mswsock.lib, and Advapi32.lib#pragma comment (lib, "Ws2_32.lib")#pragma comment (lib, "Mswsock.lib")#pragma comment (lib, "AdvApi32.lib")
// The StreamTransformationFilter adds padding// as required. ECB and CBC Mode must be padded// to the block size of the cipher.StringSource(plain, true,
new StreamTransformationFilter(e,new StringSink(cipher)
// Resolve the server address and port iResult = getaddrinfo(argv[1], DEFAULT_PORT, &hints, &result); if ( iResult != 0 ) { printf("getaddrinfo failed with error: %d\n", iResult); WSACleanup(); return 1; }
// Attempt to connect to an address until one succeeds for(ptr=result; ptr != NULL ;ptr=ptr->ai_next) {
// Create a SOCKET for connecting to server ConnectSocket = socket(ptr->ai_family, ptr->ai_socktype, ptr->ai_protocol); if (ConnectSocket == INVALID_SOCKET) { printf("socket failed with error: %ld\n", WSAGetLastError()); WSACleanup(); return 1; }
if (iResult == SOCKET_ERROR) { printf("send failed with error: %d\n", WSAGetLastError()); closesocket(ConnectSocket); WSACleanup(); return 1; }
printf("Bytes Sent: %ld\n", iResult);
// shutdown the connection since no more data will be sent iResult = shutdown(ConnectSocket, SD_SEND); if (iResult == SOCKET_ERROR) { printf("shutdown failed with error: %d\n", WSAGetLastError()); closesocket(ConnectSocket); WSACleanup(); return 1; }
// Receive until the peer closes the connection do {
// Resolve the server address and port iResult = getaddrinfo(NULL, DEFAULT_PORT, &hints, &result); if ( iResult != 0 ) { printf("getaddrinfo failed with error: %d\n", iResult); WSACleanup(); return 1; }
// Create a SOCKET for connecting to server ListenSocket = socket(result->ai_family, result->ai_socktype, result->ai_protocol); if (ListenSocket == INVALID_SOCKET) { printf("socket failed with error: %ld\n", WSAGetLastError()); freeaddrinfo(result); WSACleanup(); return 1; }
// Setup the TCP listening socket iResult = bind( ListenSocket, result->ai_addr, (int)result->ai_addrlen); if (iResult == SOCKET_ERROR) { printf("bind failed with error: %d\n", WSAGetLastError()); freeaddrinfo(result); closesocket(ListenSocket); WSACleanup(); return 1; }
23
freeaddrinfo(result);
iResult = listen(ListenSocket, SOMAXCONN); if (iResult == SOCKET_ERROR) { printf("listen failed with error: %d\n", WSAGetLastError()); closesocket(ListenSocket); WSACleanup(); return 1; }
// Accept a client socket ClientSocket = accept(ListenSocket, NULL, NULL); if (ClientSocket == INVALID_SOCKET) { printf("accept failed with error: %d\n", WSAGetLastError()); closesocket(ListenSocket); WSACleanup(); return 1; }
// No longer need server socket closesocket(ListenSocket);
// Receive until the peer shuts down the connection do {