吳宗恩
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # AES對稱加密演算法 ## 簡介 是一種對稱加密演算法,它被廣泛應用於保護資料的安全性。AES 實作指的是如何利用 AES 演算法來加密和解密資料。由於 AES 使用相同的金鑰進行加密和解密,因此它屬於對稱加密的一種。 ## AES數學推導 ### 有限域**GF(2^8)運算** AES主要基於**有限域GF(2^8)**,即256個元素組成的代數結構,這裡的加法和乘法都是**模2**運算 (1) **加法(XOR運算)** 加法定義為**逐位XOR**: $$a+b= a \oplus b$$ 範例: $$(1101\ 0110)_2 \oplus (1011\ 0011)_2 =(0110\ 0101)_2$$ 實作程式碼: ```cpp= uint8_t AESadd(uint8_t a,uint8_t b){ return a^b; } ``` (2) **乘法(有限域GF(2^8)下的乘法)** 乘法需要一個不可約多項式$P(x)=x^8+x^4+x^3+x+1$來進行模運算 範例: $$(0x57 \times 0x83) \mod P(x)$$ 計算方式 1.轉換成多項式相乘 2.以$P(x)$為模,對結果進行模運算 這個運算是AES**S-Box、MixColumns**變換的基礎 實作程式碼: ```cpp= uint8_t GF_mul(uint8_t a,uint8_t b){ uint8_t p=0; uint8_t mod=0x1b; // x^8+x^4+x^3+x+1 for(int i=0; i<8; i++){ if (b&1) p^=a; bool high_bit=(a&0x80); a<<=1; if(high_bit) a^=mod; b>>=1; } return p; } ``` ## AES算法 有四種操作,分別是金鑰加密(Add Round Key)、位元組代換(SubByte)、行位移(Shift Rows)、列混淆(Mix Column) 明文和金鑰都是128位的(密鑰也可以192位256位,下面都已128為主),16個字節由上到下由左到右排成4*4 總共進行10輪處理,只有最後一輪少了一次MixColumn ### 流程圖 ![upload_84e1696561086efce1e9898187a664aa](https://hackmd.io/_uploads/rkMdkA4TJl.png) ### **SubBytes(S-Box變換)** 這步驟使用**GF(2^8)** 的逆元和**仿射變換**,來增加 AES 的非線性度,防禦線性攻擊。 (1)**計算GF(2^8)逆元** 如果輸入字節$\alpha$,則找出: $$\alpha^{-1} \mod P(x)$$ 例如: $$0X53^{-1}=0xCA\quad \text(在GF(2^8)中)$$ (2)仿設變換 將逆元的位元$x$進行以下變換: $$y_i = x_i \oplus x_{(i+4) \mod 8} \oplus x_{(i+5) \mod 8} \oplus x_{(i+6) \mod 8} \oplus x_{(i+7) \mod 8} \oplus c_i$$ 其中$c_i$是固定的二進制向量。 S_box ![HkFiriLpp](https://hackmd.io/_uploads/Hym-RaEa1x.png) 來源Wiki:https://en.wikipedia.org/wiki/Rijndael_S-box INV_S_box ![Hk5bIiIp6](https://hackmd.io/_uploads/S1MBCaVakg.png) 來源Wiki:https://en.wikipedia.org/wiki/Rijndael_S-box 程式碼實作: ```cpp= #define State vector<vector<uint8_t>> uint8_t char s_box[256] = { 0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5, 0x30, 0x01, 0x67, 0x2B, 0xFE, 0xD7, 0xAB, 0x76, 0xCA, 0x82, 0xC9, 0x7D, 0xFA, 0x59, 0x47, 0xF0, 0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0, 0xB7, 0xFD, 0x93, 0x26, 0x36, 0x3F, 0xF7, 0xCC, 0x34, 0xA5, 0xE5,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, 0x35, 0x85, 0xE2, 0xF9, 0x37, 0xE8, 0x1C, 0x75, 0xDF, 0x6E, 0x47, 0xF1, 0x1A, 0x71, 0x1D, 0x29, 0xC5, 0x89, 0x6F, 0xB7, 0x62, 0x0E, 0xAA, 0x18, 0xBE, 0x1B, 0xFC, 0x56, 0x3E, 0x4B, 0xC6, 0xD2, 0x79, 0x20, 0x9A, 0xDB, 0xC0, 0xFE, 0x78, 0xCD, 0x5A, 0xF4, 0x1F, 0xDD, 0xA8, 0x33, 0x88, 0x07, 0xC7, 0x31, 0xB1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xEC, 0x5F, 0x60, 0x51, 0x7F, 0xA9, 0x19, 0xB5, 0x4A, 0x0D, 0x2D, 0xE5, 0x7A, 0x9F, 0x93, 0xC9, 0x9C, 0xEF, 0xA0, 0xE0, 0x3B, 0x4D, 0xAE, 0x2A, 0xF5, 0xB0, 0xC8, 0xEB, 0xBB, 0x3C, 0x83, 0x53, 0x99, 0x61, 0x17, 0x2B, 0x04, 0x7E, 0xBA, 0x77, 0xD6, 0x26, 0xE1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0C, 0x7D }; State sub_bytes(const State &state){ State new_state=state; for(int i=0; i<4; i++){ for(int j=0; j<4; j++){ new_state[i][j]= s_box[state[i][j]]; } } return new_state; } State Inv_sub_bytes(const State &state){ State new_state=state; for(int i=0; i<4; i++){ for(int j=0; j<4; j++){ new_state[i][j]= inv_s_box[state[i][j]]; } } return new_state; } ``` ### ShiftRows(行位移) 在 AES 中,ShiftRows 是對明文狀態矩陣進行處理的一個步驟。狀態矩陣的大小為 4x4,每一行進行不同的位移。假設我們的狀態矩陣為: $$ \text{state} = \begin{bmatrix} s_{00} & s_{01} & s_{02} & s_{03} \\ s_{10} & s_{11} & s_{12} & s_{13} \\ s_{20} & s_{21} & s_{22} & s_{23} \\ s_{30} & s_{31} & s_{32} & s_{33} \\ \end{bmatrix} $$ 在AES中,對於**ShiftRows**操作,會依照如下規則對行進行位移: * 第一行(Row 0)不變 * 第二行(Row 1)左移一位 * 第三行(Row 2)左移兩位 * 第四行(Row 3)左移三位 這個過程的數學表達如下: $$ \text{After ShifhtRows} = \begin{bmatrix} s_{00} & s_{01} & s_{02} & s_{03} \\ s_{11} & s_{12} & s_{13} & s_{10} \\ s_{22} & s_{23} & s_{20} & s_{21} \\ s_{33} & s_{30} & s_{31} & s_{32} \\ \end{bmatrix} $$ InvShiftRows就是移回去(還原) 程式實作碼: ```cpp= #define State vector<vector<uint8_t>> State ShiftRows(const State &state){ State new_state=state; for(int i=1; i<=3; i++){ vector<uint8_t> row(4); for(int j=0; j<4; j++){ row[j] = state[i][j]; } for(int j=0; j<4; j++){ new_state[i][(j-i+4)%4]=row[j]; } } return new_state; } State Inv_ShiftRows(const State &state){ State new_state=state; for(int i=1; i<=3; i++){ vector<uint8_t> row(4); for(int j=0; j<4; j++){ row[j]=state[i][j]; } for(int j=0; j<4; j++){ new_state[i][(i+j)%4]=row[j]; } } return new_state; } ``` ### MixClumns(列混合) 這步驟透過**GF(2^8)矩陣乘法**來提供擴散性,矩陣為 \ \begin{bmatrix} 2 & 1 & 1 & 3 \\ 3 & 2 & 1 & 1 \\ 1 & 3 & 2 & 1 \\ 1 & 1 & 3 & 2 \end{bmatrix} \ 行向量**s**變換後為: $$s'=M \cdot s$$ 其中的乘法是**GF(2^8)乘法**,如: $$2 \times x = x \ll 1 \mod P(x)$$ 這確保小的輸入變化會擴散到整個區塊。 程式碼實作 ```cpp= #define State uint8_t State MixColumns(const State &state){ State tmp(4,vector<uint8_t>(4)); for(int i=0; i<4; i++){ for (int j=0; j<4; j++){ tmp[i][j]=state[i][j]; } } for(int i=0; i<4; i++){ for(int j=0; j<4; j++){ //乘換成擴展域的乘法,加換成擴展域的加法(XOR) state[i][j]=G_Multi(tmp[0][j], Mix[i][0])^G_Multi(tmp[1][j], Mix[i][1])^G_Multi(tmp[2][j], Mix[i][2])^G_Multi(tmp[3][j], Mix[i][3]); } } return state; } State InvMixColumns(const State &state) { State tmp(4,vector<uint8_t>(4)); for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { tmp[i][j] = state[i][j]; } } for (int i=0; i<4; i++) { for (int j=0; j<4; j++) { //乘換成擴展域的乘法加,換成擴展域的加法(XOR) state[i][j]=G_Multi(tmp[0][j], InvMix[i][0])^G_Multi(tmp[1][j], InvMix[i][1])^G_Multi(tmp[2][j], InvMix[i][2])^G_Multi(tmp[3][j], InvMix[i][3]); } } return state; } uint8_t G_Multi(uint8_t a, uint8_t b) { uint8_t result = 0; for (int i=0; i<8; i++) { if (b&1) { result^=a; } bool Highbit = a&0x80; a<<=1;//模擬乘上x(因為下次和a的高一次方運算) if(Highbit) { a^=0x1B;//模擬除以(x^8 + x^4 + x^3 + x^1 + 1),剛剛左移丟失的高位也剛好被除掉 } b>>=1;//將高一次方移到第一位 } return result; } ``` ### **密鑰擴展** 使用**輪常數Rcon**,並透過XOR產生新的子密鑰: $$w[i] = w[i-4] \oplus T(w[i-1])$$ 其中$T(x)$包含**S-Box變換+Rcon** ### AddRoundKey(輪密鑰加) AddRoundKey 步驟是將當前的狀態矩陣與 輪密鑰(Round Key)進行 XOR 操作。每一輪的密鑰是通過密鑰擴展從原始密鑰生成的,密鑰大小也是 128 位(16 字節)。假設我們有以下狀態矩陣: $$ \text{state} = \begin{bmatrix} s_{00} & s_{01} & s_{02} & s_{03} \\ s_{10} & s_{11} & s_{12} & s_{13} \\ s_{20} & s_{21} & s_{22} & s_{23} \\ s_{30} & s_{31} & s_{32} & s_{33} \\ \end{bmatrix} $$ 而輪密鑰(Round Key)也有相同大小: $$ \text{Round Key} = \begin{bmatrix} k_{00} & k_{01} & k_{02} & k_{03} \\ k_{10} & k_{11} & k_{12} & k_{13} \\ k_{20} & k_{21} & k_{22} & k_{23} \\ k_{30} & k_{31} & k_{32} & k_{33} \\ \end{bmatrix} $$ **AddRoundKey**的操作是對每個位置進行**XOR**操作,即: $$ State_{new} = State \oplus Round Key$$ 這會對每一個元素進行**XOR**。舉例如下: $$ \text{State}_{\text{new}} = \begin{bmatrix} s_{00} \oplus k_{00} & s_{01} \oplus k_{01} & s_{02} \oplus k_{02} & s_{03} \oplus k_{03} \\ s_{10} \oplus k_{10} & s_{11} \oplus k_{11} & s_{12} \oplus k_{12} & s_{13} \oplus k_{13} \\ s_{20} \oplus k_{20} & s_{21} \oplus k_{21} & s_{22} \oplus k_{22} & s_{23} \oplus k_{23} \\ s_{30} \oplus k_{30} & s_{31} \oplus k_{31} & s_{32} \oplus k_{32} & s_{33} \oplus k_{33} \\ \end{bmatrix} $$ 程式碼實作: ```cpp= #define State vector<vector<uint8_t>> State AddRoundKey(const State &state, const State &round_key){ State new_state = state; for(int i=0; i<4; i++){ for(int j=0; j<4; j++){ new_state[i][j]^=round_key[i][j]; } return new_state; } } ``` ### 密鑰生成 ![Sk_kQUHAp](https://hackmd.io/_uploads/H1DB2CVakl.png) 來源:https://www.slideserve.com/keegan/chapter-5#google_vignette $其中W_0=K_0和K_1和K_2和K_3連起來(是四分之一長的密鑰,而W_0和W_1和W_2和W_3$是原始的密鑰),g函式是實作中的KeyScheduleCore 實作程式碼: ```cpp= uint8_t RCON[11] = { 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36 }; void KeyExpansion(const uint8_tr* key, uint8_t* ExpandKey) { int KeyLength = 16; int ExpandKeyLength = 176; int Pre = 16;//to previous round key //int m = 0; //this four value is depanding on the size of the key. Now it is 128bit for(int i=0; i<16; i++){ ExpandKey[i] = key[i]; } for (int i=KeyLength, rconIt=1; i<ExpandKeyLength; rconIt++) { uint8_t tmp[4]; memcpy(tmp, ExpandKey+i-4, 4); uint8_t g[4]; KeyScheduleCore(rconIt, tmp, g); memcpy(tmp, ExpandKey+i-Pre, 4); for(int j=0; j<4; j++){ tmp[j] ^= g[j]; } memcpy(ExpandKey+i, tmp, 4); i += 4; for(int j=0; j<3; j++){ memcpy(tmp, ExpandKey+i-4, 4); for(int k = 0; k < 4; k++){ ExpandKey[i+k] = tmp[k]^ExpandKey[i-Pre+k]; } i += 4; } //如要支援其他大小的密鑰,還有其他東西要寫 } } ``` ### ECB 在加密時,明文的長度通常會超過 128 位(AES 區塊的大小)。而 ECB模式 是處理這個問題最簡單的一種方式。除了 ECB,還有其他模式如 CBC、CTR、CFB 和 OFB,也可以解決長明文的加密問題,但它們在處理方式和安全性上有所不同。 ECB 模式的工作原理非常簡單,它將明文每 128 位切分成一個區塊,並對每個區塊單獨進行加密。這樣處理的最大問題是:相同的明文區塊會被加密為相同的密文區塊,這樣會暴露出明文的某些模式或結構,從而削弱了加密的安全性。 ### pkcs7_padding 在加密時,明文大小通常不會是加密演算法所需區塊大小的整數倍。例如,AES 的區塊大小是 16 字節,所以如果明文的大小不是 16 的倍數,就需要進行填充。而 PKCS7 padding 的填充方式很簡單,假設現在差一個字節就能成為 16 的倍數,那就填充 0x01,如果差兩個字節,就填充兩個 0x02,以此類推。當差 15 個字節時,就填充 15 個 0x0f。比較特別的是,如果明文的長度本來就已經是 16 的倍數,則需要填充 16 個 0x10。 這樣的填充方式是必要的,因為在去除填充時,需要依據最後一個字節的數值來判定需要刪除多少個填充字節。例如,如果最後一個字節是 0x04,那麼可以知道倒數 4 個字節都是填充字節,應該將其刪除。因此,填充 0x10 也是必要的,這樣才能在去除填充時正確地恢復原來的數據。 程式碼實作 ```cpp= string pkcs7_padding(const string& str, int BlockSize) { int PaddingSize = BlockSize-(str.size()%BlockSize); uint8_t PaddingChar = (uint8_t)PaddingSize; for(int i=0; i<PaddingSize; i++){ str.push_back(PaddingChar); } return str; } string pkcs7_unpadding(const string& str) { int PaddingSize = (int)((unsigned char)str[str.size()-1]); str.resize(str.size()-PaddingSize); return str; } ``` 完整實作 實際實作上還有很多細節,(包括ECB的處理、Base64的使用等) 可以到github詳細觀看

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully