1 / 24

AES 函式庫

AES 函式庫. Speaker : Chungyi Wang Advisor: Quincy Wu. outline. 加密的目的 加密法簡介 對稱式加密演算法 非對稱式加密演算法 (RSA) DES 簡介 AES 簡介 AES 函式庫 Demo Reference. 加密的目的. 純紙 本的時代 戰爭時傳遞訊息 電子資訊的時代 個人隱私資訊 特定接收者的保護 考量的因素 安全度 速度 鑰匙 (Key) 的型態. 對稱式加密演算法 (1/2). 鑰匙僅有一把 用此鑰匙對文件進行 加密 ,且用此鑰匙對加密過後的文件 解密

randi
Download Presentation

AES 函式庫

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. AES 函式庫 Speaker : Chungyi Wang Advisor: Quincy Wu

  2. outline • 加密的目的 • 加密法簡介 • 對稱式加密演算法 • 非對稱式加密演算法 (RSA) • DES 簡介 • AES 簡介 • AES 函式庫 • Demo • Reference

  3. 加密的目的 • 純紙本的時代 • 戰爭時傳遞訊息 • 電子資訊的時代 • 個人隱私資訊 • 特定接收者的保護 • 考量的因素 • 安全度 • 速度 • 鑰匙(Key)的型態

  4. 對稱式加密演算法 (1/2) • 鑰匙僅有一把 • 用此鑰匙對文件進行加密,且用此鑰匙對加密過後的文件解密 • 凱薩加密法、DES、AES…等 • 凱薩加密法 • 從字母(a~z)挑選一個當作起頭,接著後面的進而取代之

  5. 對稱式加密演算法 (2/2)凱薩加密法 明文:t e s tf o r t h i s 密文:n y m nz i l n b c m 。雙方事先溝通,或者是僅需知道字母g即可解密 。但是可能的排列只有26種,很容易被暴力法破解

  6. 非對稱式加密演算法 (RSA) (1/2) • 鑰匙共有兩把 • Public key (可公佈) • Private key (私人擁有) • 非對稱 • 發送者用收件者的Public key進行加密 • 收件者則用自己的Private key進行解密 • 沒有該Private key則難以解開 • 運用兩個大的質數為原理作加密 • http://zh.wikipedia.org/w/index.php?title=RSA&variant=zh-tw

  7. 加密 Receiver’s Private-key 解密 非對稱式加密演算法 (RSA) (2/2)

  8. DES 簡介 • 1976年被美國聯邦政府的聯邦信息處理標準選中,其短密鑰長度(56bits)安全性備受外界質疑 • DES目前已經被視為一種不安全的加密方式 • 目前已經由AES取代之 • 相關資訊 • http://zh.wikipedia.org/w/index.php?title=DES&variant=zh-tw

  9. AES 簡介 (1/2) • Advanced Encryption Standard (AES) • 亦稱 Rijndael 加密法 • 採用密鑰長度16、24 or 32 bytes • 由美國國家標準與技術研究院 (NIST)於2001年11月26日發佈,並在2002年5月26日成為有效的標準 • 目前為夠安全的加密方法 • 沒有一個加密方法絕對安全,或者是永遠安全

  10. AES 簡介 (2/2) • 相較於DES • 密鑰長度較長,且AES可以選擇三種不同長度的加密(本報告選取的函式庫也支援20、28bytes的長度) • AES設計易於實作,且記憶體需求較小 • 縱然Triple-DES安全但速度比AES慢 • 詳細AES過程請於內容請參考 • http://zh.wikipedia.org/w/index.php?title=AES&variant=zh-tw

  11. AES 函式庫 (1/12) • 採用 之AES函式庫 • http://fp.gladman.plus.com/cryptography_technology/rijndael/index.htm • source code:http://fp.gladman.plus.com/cryptography_technology/rijndael/aessrc.zip • 此函式庫之優點: • 程式獨立 • 檔案較小

  12. Init Fill rand 一次讀取16bytes 一次加密一個區塊 Read file enc Write file AES 函式庫 (2/12) • 加密流程 From source To encrypted

  13. AES 函式庫 (3/12) • init • aes_init • 輸入key的型態為char且用16進位表示,於此步驟會檢查key是否符合正確型態,並且取得key的長度 • aes_enc_key • 所建立的的key會正確存入ctx結構當中,並且紀錄回合以及加解密的所在區塊 • 關於加密或解密都是使用aes_init以及aes_enc_key來進行初始動作

  14. AES 函式庫 (4/12) • encrypt • CBC mode from:http://upload.wikimedia.org/wikipedia/en/d/d3/Cbc_encryption.png

  15. AES 函式庫 (5/12) • EBC mode http://upload.wikimedia.org/wikipedia/en/c/c4/Ecb_encryption.png

  16. AES 函式庫 (6/12) • aes_encode(…) • do CBC chaining prior to encryption • encrypt the block • write data(dbuf by BLOCK_LEN) into file

  17. AES 函式庫 (7/12) • decrypt • CBC(Cipher Block Chaining) chaining • for(i = 0; i < BLOCK_LEN; ++i) buf[i] ^= dbuf[i]; • aes_enc_blk • 對於已經設置好的區塊進行加密 • write 16 buf 16 ⊕ buf 16 16 dbuf

  18. AES 函式庫 (8/12) dbuf : 加密用的陣列 buf : 明文陣列 buf dbuf ctx dbuf write

  19. Init First read 一次讀取16bytes 一次解密一個區塊 Read file dec Write file AES 函式庫 (9/12) • 解密流程 From encrypted To decrypted

  20. AES 函式庫 (10/12) dbuf : 解密用的陣列 b2 : 密文陣列 b1 : 暫存陣列 b1 b2 ctx dbuf b2->b1 http://upload.wikimedia.org/wikipedia/en/6/66/Cbc_decryption.png

  21. AES 函式庫 (11/12) • init • 與加密一樣也採用aes_init和aes_dec_key初始 • aes_decode(…) • decrypt input buffer • unchain CBC using the last ciphertext block • write data

  22. AES 函式庫 (12/12) • decrypt • aes_dec_blk(…); • unchain CBC using the last ciphertext block • for(i = 0; i < BLOCK_LEN; ++i) dbuf[i] ^= b1[i]; • write

  23. Demo • 執行結果 • ./encode • ./decode • 程式說明 • encrypt.c decrypt.c • aesmatt.h • Makefile • 必須加入必須的obj

  24. Reference • 凱薩加密法 • http://en.wikipedia.org/wiki/Caesar_Cipher • RSA • http://zh.wikipedia.org/w/index.php?title=RSA&variant=zh-tw • DES • http://en.wikipedia.org/wiki/Des • AES • http://en.wikipedia.org/wiki/Aes • AES 函式庫 • http://fp.gladman.plus.com/cryptography_technology/rijndael/index.htm • 投影片範例: • http://ms11.voip.edu.tw/~chungyi/ncnu-research/aes/aesdemo.zip

More Related