DESECB應(yīng)用密碼學(xué)實(shí)驗(yàn)報(bào)告_第1頁(yè)
DESECB應(yīng)用密碼學(xué)實(shí)驗(yàn)報(bào)告_第2頁(yè)
DESECB應(yīng)用密碼學(xué)實(shí)驗(yàn)報(bào)告_第3頁(yè)
DESECB應(yīng)用密碼學(xué)實(shí)驗(yàn)報(bào)告_第4頁(yè)
DESECB應(yīng)用密碼學(xué)實(shí)驗(yàn)報(bào)告_第5頁(yè)
已閱讀5頁(yè),還剩6頁(yè)未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、實(shí)驗(yàn)報(bào)告題目:des算法的實(shí)現(xiàn)與應(yīng)用學(xué)號(hào):3xxxxxxxxxxx學(xué)生姓名:xx年級(jí)/專業(yè)/班:xxxx級(jí)xxx工程x班學(xué)院(直屬系):計(jì)算機(jī)與軟件工程學(xué)院指導(dǎo)教師:xx西華大學(xué)計(jì)算機(jī)系實(shí)驗(yàn)報(bào)告一、實(shí)驗(yàn)冃的清楚分組加密的5屮操作模式(該實(shí)驗(yàn)使用了ecb電子密碼本模式)o 了解并掌握對(duì)稱密 碼體制,尤其是數(shù)據(jù)加密標(biāo)準(zhǔn)(des, data encryption standard)加密解密原理。二、實(shí)驗(yàn)環(huán)境windows 7操作系統(tǒng)visual studio 2010 開發(fā)環(huán)境二、實(shí)驗(yàn)任務(wù)及要求1 分析bestial類型密碼及des的加密解密模式,并畫出流程圖。(des也采用此種模 式)2分析分組加

2、密的電子密碼本操作模式。并畫出流程圖。2編寫des實(shí)現(xiàn)所需要的函數(shù),包括初始置換,逆初始置換,輪函數(shù)f, e擴(kuò)展,s盒壓 縮,p置換,加密解密等核心函數(shù)。3. 驗(yàn)證加密解密算法能否正常工作。三、實(shí)驗(yàn)內(nèi)容1.分析festial類型密碼及des的加密解密feistel結(jié)構(gòu)的實(shí)現(xiàn)依賴于以下參數(shù)和特征(1)分組長(zhǎng)度(2)密鑰長(zhǎng)度(3)迭代輪數(shù)(4)子密鑰生成算法(5)輪函數(shù)其實(shí)現(xiàn)方法的流程圖具體實(shí)現(xiàn)如kfeistel加密解密流程圖輸入(明文)w位 w位輸入(明文)w位 w位輸入(文)w位 w位輸出(密文)w位 w位des之生成輪密鑰流程2. 分析分組加密的電子密碼本操作模式。電子密碼本是分組密碼中最簡(jiǎn)

3、單的一種操作模式。每組含有64位bitso組與組之間單獨(dú)做16輪加密,并無關(guān)聯(lián)。最后將每組密文合并組成新的完整的密文。流程圖如下:ecb模式算法邏輯如下:加密:cj=ek(pj)(j = ,2,.n)解密:p廣 q(q)c/ = i,2,.n)ecb模式的特點(diǎn)如下:(1)操作簡(jiǎn)單,不同分組可并行加密(2)明文中重復(fù)的內(nèi)容將在密文中表現(xiàn)出來(3)不具冇錯(cuò)誤傳播性質(zhì)(4)用于內(nèi)容較短的報(bào)文加密傳遞3. 函數(shù)編寫 函數(shù)定義:class des(變量泄義已省略)public:void char2bits (char *_ciparray, bool *_bi tsarray, int length)

4、; /字符轉(zhuǎn)二進(jìn)制函數(shù)且按 64 位分組 填充二進(jìn)制轉(zhuǎn)符串生成子密鑰/明文分組,合并置換后的明文加密/輸出密文/解密/輸出解密后的明文void bits2char(char *_carray, bool *_barray, int length); void produccsubkcy0;void sortandhlcrgc();void encrypteo ;void outputciphcrtext();void _deccrypte();void outputdecciphertext (): private:void tni tswap(bool tpoutput 64) :/初始置換

5、輸入的 64 位 bi ts 明文voicl extend32to48 (bool inputbi tsplaintext 32, bool outputbi tsplaintext 48);將右半部分32位的輸入擴(kuò)展為48位輸出void xor(bool a, bool b, bool c, int length);/異或運(yùn)算void sboxlocal (bool in 6, bool out 4, int box);/sbox每一個(gè)的單獨(dú)壓縮void sboxglob (bool in 48, bool out 32);/sbox 全局壓縮void poperate(bool in32,

6、 bool result32) ;/p 操作void copy ar ray (bool a, bool b, int size) ;/復(fù)制數(shù)組void cryptefunct ion (bool in32, int round, bool out 32) ;/加密函數(shù)void decryptefunction(bool in32, int round, bool out32) ; /解密函數(shù)void c i rc 1 ele f tsh i f t (boo 1 *i nputbi tsciphertext, int bits) ;/28 位長(zhǎng)度的密鑰循環(huán)左移void initreswap(

7、bool outputbitsplaintext64) ;/逆初始置換輸出的 64 位 bils 密文f加密解密核心函數(shù)/加密函數(shù)(round表示第兒輪)void des:cryptcfunction(bool in32, int round, bool out32)bool tempi48;extend32to48(in, tempi) ;/擴(kuò)展操作bool temp248;xor(tempi, (bool *) bsubkeyround, temp2, 48);/密鑰打明一文模 2jbool temp332;sboxglob (temp2, temp3) ;/s 盒壓縮poperate (

8、tomp3, out);/p 盒置換核心函數(shù)輪密鑰生成(sub0-subl5共16個(gè)輪密鑰)生成子密鑰void des:producesubkey()bool tempc28;bool tempd28;置換選擇1for (int i = 0; i< 28; i+)tempci = binikeypci - 1;tempi)i = binikeyp嘰i - 1;bool mergekey56;for(int i = 0; i< 16; i+)/循環(huán)左移circleleftshift(tempc, circleleftshifttablei);circlclcftshift(tcmpd

9、, circleleftshifttablei);/合并for(int j =0; j< 28; j+)mergekeyj = tempcfj; mergekeyj + 28 = tempdj;/置換選擇2for (int k =0 ; k< 48; k+)bsubkeyik = mergckey pkeyk - 1 ;cout « "產(chǎn)生的16輪子密鑰分別為:"« endl;for(int i 二 0; i<16; i+)/輸出了密鑰cout « "subkey" << i <<e

10、ndl;for (int j = 0; j<48; j+)cout « bsubkeyi j;)cout « endl;)4、測(cè)試程序編譯運(yùn)行后,輸入一段字符串。程序能被成功執(zhí)行。將字符串加密。調(diào)用解密流程(核心函數(shù)f不變),加密的字符串被成功解密。f:microsoft visual studioc+ + 工程文件夾cryptology_desdebugcryptology_des.exedes加密解密算法請(qǐng)輸入要加密的明文:.welcome to the nouenber 23, 2016 edition of acm tecbnewsj. providing t

11、imely infor mation for it professionals three tines a week.明文轉(zhuǎn)二迸制為:01010111011001010110110001100011011011110110110101100101001000000111010001101111 00100000011101000110100001100101001000000100111001101111011101100110010101101101 01100010011001010111001000100000001100100011001100101100001000000011001

12、000110000 00110001001101100010000001100101011001000110100101110100011010010110111101101110 00100000011011110110011000100000010000010100001101001101001000000101010001100101 01100011011010000100111001100101011101110111001100101100001000000111000001110010 01101111011101100110100101100100011010010110111

13、001100111001000000111010001101001 01101101011001010110110001111001001000000110100101101110011001100110111101110010 01101101011000010111010001101001011011110110111000100000011001100110111101110010 00100000010010010101010000100000011100000111001001101111011001100110010101110011 01110011011010010110111

14、101101110011000010110110001110011001000000111010001101000 01110010011001010110010100100000011101000110100101101101011001010111001100100000 0110000100100000011101110110010101100101011010110010111000000000請(qǐng)輸入秋置的密鑰:ronantic密鑰轉(zhuǎn)二迸制為:0101001001101111011011010110000101101110011101000110100101100011產(chǎn)生的16輪子密

15、鑰分別為:subkeo111000001011011011100110101011000100011110011000subkeyl111000001011011001110110100101110011110010100000subkey2111001001101111001110010011010000000101101110101subkey3111001101111001101110010000100111110100010011110subkes?4101011101101011101010011011001010001010110010001 subkeys011011110101

16、00110101101110001011001000000110111101010011001011111010000111100001011111100101001011010101000111111100010111010111101111111011101101110101100011000000100110110101f:microsoft visual studioc+ + 工程文件夾cryptology_desdebugcryptology_des.exe第15輪加密結(jié)果為:11100111110011011100000000101001 111000101100110010000

17、100101000110-15輪共16輪加密過后的結(jié)果:1110011111001101110000000010100111100010110011001000010010100011加密流程逆初始ip變換二0101001111000010011110000011000100000000110000111111010011111110加密流程密文二迸制為:10101111111100010110010101100001110101010110101011010110000011101011011000110101 0011010110101111101100101001110100101110

18、1001010001000100100110111000100110001100 11011101000110001100001111110010000110100011001101110110000111011100001101001111 10101110001100000110110000001101010100110011101010010111110110001010110101001110 0110000110011011000011000101101011010010101111111010101110011000000110101000111011000000011110001

19、101000101000000001010001100011011101010100010111100010101111101001011011111100111100110000111111000010001001010101110010111101001000001000100101010111101000101101110011110101001111101011011111110101001000001101101100001010010110101001011001001111010010111010110001100110111100111000100111101011110111

20、10100110010010000111010000001111001001110110001101110100011110110110000110011001010 01111001100100010001011001011111000000001011010000010101001010010111000010011010 11110110000010011110111101100010111000010000001011111110110101101101101000011110 010100111100001001111000001100010000000011000011111101

21、0011111110袞臍嬪-佩菸吐疎龜。闍m渝頑!捉2c婦 嘩一 如川.ko亞師1敏截獲的密文分組0為:1010111111110001011001010110000111010101011010101101011000001110解密流程初始ip置換:01111110010100101101010100011111第15輪解密結(jié)果為:11000101110101111011111110111011第14輪解密結(jié)果為:01110101100011000000100110110101第13輪解密結(jié)果為:11011111000010001110101111001001f:microsoft vis

22、ual studioc+ + 工程文件夾cryptology_desdebugcryptology_des.exe10010101101110101011001001000001100010011001101110100000100101110110101011010111011011001110110110011110110101011100100110010100100110001111001010001011111100011110010001110011010111110111111000000000011111110110000001100100第6輪解密結(jié)果為:1000100110

23、0110111010000010010111第5輪解密結(jié)果為:01101010110101110110110011101101第4輪解密結(jié)果為:10011110110101011100100110010100第3輪解密結(jié)果為:10011000111100101000101111110001第2輪解密結(jié)果為:11100100011100110101111101111110第1輪解密結(jié)果為:00000000011111110110000001100100第0輪解密結(jié)果為:0011110100000100010111000011110116輪解密過后的結(jié)果:001111010000010001011

24、1000011110100000000011111110110000001100100解密結(jié)果為:01010111011001010110110001100011011011110110110101100101001000000111010001101111 00100000011101000110100001100101001000000100111001101111011101100110010101101101 01100010011001010111001000100000001100100011001100101100001000000011001000110000 00110001

25、001101100010000001100101011001000110100101110100011010010110111101101110 00100000011011110110011000100000010000010100001101001101001000000101010001100101 01100011011010000100111001100101011101110111001100101100001000000111000001110010 01101111011101100110100101100100011010010110111001100111001000000111010001101001 01101101011001010110110001111001001000000110100101101110011001100110111101110010 01101101011000010111010001101001011011110110111000100000011001100110111101110010 00100000010010010101010

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論