




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、Keep Your Data Secure with the New Adva need En crypti onStan dardJames McCaffreySUMMARYThe Advaneed Encryption Standard (AES) is a National Institute of Standards and Tech no logy specificati on for the en cryptio n of electr onic data. It is expected to become the accepted means of encrypting digi
2、tal information, including financial, telecom muni catio ns, and gover nment data. This article prese nts an overview of AES and explains the algorithms it uses.After reading this article you will be able to en crypt data using AES, test AES-based software, and use AES en crypti on in your systems.N
3、ote that the code presented in this article and any other implementation based on this article is subject to applicable Federal cryptographic module export controls (see Commercial En crypti on Export Con trols for the exact regulati on s).AES is a new cryptographic algorithm that can be used to pro
4、tect electr onic data. Specifically, AES is an iterative, symmetric-key block cipher that can use keys of 128, 192, and 256 bits, and en crypts and decrypts data in blocks of 128 bits (16 bytes) Uni ike public-key ciphers, which use a pair of keys, symmetric-key ciphers use the same key to en crypt
5、and decrypt data. En crypted data returned by block ciphers have the same nu mber of bits that the in put data had. Iterative ciphers use a loop structur that repeatedly performs permutati ons and substitutio ns of the in put data. Figure 1 shows AES in action encrypting and then decrypting a 16-byt
6、e block of data using a192-bit key.Figure 1 Some DataAES is the successor to the older Data Encryption Standard (DES). DES was approved as a Federal standard in 1977 and remained viable until 1998 when a comb in ati on of adva ncesi n hardware, software, and crypta nalysis theory allowed a DES-e ncr
7、ypted message to be decrypted in 56 hours. Since that time nu merous other successful attacks on DES-encrypted data have been made and DES is now considered past its useful lifetime.In late 1999, the Rijn dael (pr onoun ced ra in doll) algorithm, created by researchers Joa n Daeme n and Vincent Rijm
8、e n, was selected by the NIST as the proposal that best met the design criteria of security, implementation efficiency, versatility, and simplicity. Although the terms AES and Rijn dael are sometimes used in tercha ngeab y, they are distinct. AES is widely expected to become the de facto standard fo
9、r encrypting all forms of electronic data including data used in commercial applications such as banking and finan cial tran sact ions, telecom muni cati ons, and private and Federal in formatio n.Overview of the AES AlgorithmThe AES algorithm is based on permutations and substitutions. Permutations
10、 are rearra ngeme nts of data, and substituti ons replace one unit of data with ano ther. AES performs permutations and substitutions using several different techniques. To illustrate these tech niq ues, lets walk through a con crete example of AES en crypti on using the data show n in Figure 1.The
11、following is the 128-bit value that you will encrypt with the indexes array:00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff 012345678910 11 12 13 14 15The 192-bit key value is:00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 012345678910 11 12 13 14 15 16 17 18 19 20 21 22 23a
12、1I3*77卄1c*TiflaIdn菲3te1c1lbFigure 2 SboxWhen the AES constructor is called, two tables that will be used by the encryption method are initialized. The first table is a substitution box named Sbox. It is a 16 16 matrix. The first five rows and colu mns of Sbox are show n in Figure 2. Behi nd the sce
13、nes, the en cryptio n rout ine takes the key array and uses it to gen erate a key schedule table n amed w, show n in Figure 3.Figure 3 Key Sched.The first Nk (6) rows of w are seededwith the original key value (0x00 through 0x17) and the remai ning rows are gen erated from the seed key. The variable
14、 Nk representsthe size of the seed key in 32-bit words. Youll see exactly how w is gen erated later whe n I exam ine the AES impleme ntati on. The point is that there are now many keys to use in stead of just one. These new keys are called the round keys to distinguish them from the original seed ke
15、y.Figure 4 StateThe AES en crypti on rout ine beg ins by copy ing the 16-byte in put array into a 44 byte matrix named State (see Figure 4). The AES encryption algorithm is named Cipher and operates on State and can be described in pseudocode (see Figure 5).The encryption algorithm performs a prelim
16、inary processing step thats called AddRoundKey in the specification. AddRoundKey performs a byte-by-byte XOR operation on the State matrix using the first four rows of the key schedule, and XORs in put Stater,c with round keys table wc,r.For example, if the first row of the State matrix holds the by
17、tes 00, 44, 88, cc , and the first column of the key schedule is 00, 04, 08, 0c , then the new value of State0,2 is the result of XORing State0,2 (0x88) with w2,0 (0x08), or 0x80:1 0 0 0 1 0 0 00 0 0 0 1 0 0 0 XOR1 0 0 0 0 0 0 0The main loop of the AES en crypti on algorithm performs four differe nt
18、 operati ons on the State matrix, called SubBytes, ShiftRows, MixColu mns, and AddRou ndKey in the specification. The AddRoundKey operation is the same as the preliminary AddRo un dKey except that each time AddRo un dKey is called, the n ext four rows of the key schedule are used. The SubBytes routi
19、 ne is a substituti on operati on that takes each byte in the State matrix and substitutes a new byte determined by the Sbox table. For example, if the value of State0,1 is 0x40 and you want to find its substitute, you take the value at State0,1 (0x40) and let x equal the left digit (4) and y equal
20、the right digit (0). Then you use x and y as indexes into the Sbox table to find the substituti on value, as show n in Figure 2.ShiftRows is a permutation operation that rotates bytes in the State matrix to the left. Figure 6 shows how ShiftRows works on State. Row 0 of State is rotated 0 positions
21、to the left, row 1 is rotated 1 position left, row 2 is rotated 2 positions left, and row 3 is rotated 3 positi ons left.t 1309cdbet19Gilfl nS3莒174cai 寸HIr*i* i1nl 14511SIr*rFigure 6 Running ShiftRows on StateThe MixColumns operation is a substitution operation that is the trickiest part of the AES
22、algorithm to understand. It replaces each byte with the result of mathematical field additions and multiplications of values in the bytes column. I will explain the details of special field addition and multiplication in the next section.Suppose the value at State0,1 is 0x09, and the other values in
23、 colu mn 1 are 0x60, 0xe1, and 0x04; then the new value for State0,1 is shown in the following: State0,1 = (State0,1 * 0x01) + (State1,1 * 0x02) +(State2,1 * 0x03) +(State3,1 * 0x01) = (0x09 * 0x01) + (0x60 * 0x02) + (0xe1 * 0x03) +(0x04 * 0x01)=0x57The addition and multiplication are special mathem
24、atical field operations, not the usual additi on and multiplicatio n on in tegers.The four operations SubBytes, ShiftRows, MixColumns, and AddRoundKey are called in side a loop that executes Nr timethe nu mber of rounds for a give n key size, less 1. The number of rounds that the encryption algorith
25、m uses is either 10, 12, or 14 and depe nds on whether the seed key size is 128, 192, or 256 bits. In this example, becauseNr equals 12, the four operations are called 11 times. After this iteration completes, the encryption algorithm finishes by calling SubBytes, ShiftRows, and AddRo un dKey before
26、 copy ing the State matrix to the output parameter.In summary, there are four operations that are at the heart of the AES encryption algorithm. AddRo un dKey substitutes groups of 4 bytes using round keys gen erated from the seed key value. SubBytes substitutes in dividual bytes using a substituti o
27、n table. ShiftRows permutes groups of 4 bytes by rotating 4-byte rows. MixColumns substitutes bytes using a comb in ati on of both field additi on and multiplicati on.Field Addition and Multiplication in GF(28)As youve see n, the AES en cryptio n algorithm uses fairly straightforward tech niq ues fo
28、r substitution and permutation, except for the MixColumns routine. The MixColumns routine uses special addition and multiplication. The addition and multiplication used by AES are based on mathematical field theory. In particular, AES is based on a field called GF(28).The GF(28) field con sists of a
29、 set of 256 values from 0x00 to 0xff, plus addition and multiplication, hence the (28). GF stands for Galois Field, named after the mathematicia n who foun ded field theory. One of the characteristics of GF(28) is that the result of an additi on or multiplicati on operati on must be in the set 0x00
30、. 0xff. Although the theory of fields is rather deep, the net result for GF(28) addition is simple: GF(28) addition is just the XOR operatio n.Multiplication in GF(28) is trickier, however. As youll see later in the C# implementation, the AES encryption and decryption routines need to know how to mu
31、ltiply by only the seven con sta nts 0x01,0x02, 0x03, 0x09, 0x0b, 0x0d, and 0x0e. So in stead of expla ining GF(28) multiplicati on theory in gen eral, I will expla in it just for these seve n specific cases.Multiplication by 0x01 in GF(28) is special; it corresponds to multiplication by 1 in no rma
32、l arithmetic and works the same waa ny value times 0x01 equals itself.Now lets look at multiplicati on by 0x02. As in the case of additi on, the theory is deep, but the net result is fairly simple. If the value being multiplied is less than 0x80, then the result of multiplication is just the value l
33、eft-shifted 1 bit position. If the value being multiplied is greater tha n or equal to 0x80, the n the result of multiplicati on is the value left-shifted 1 bit position XORed with the value 0x1b. This prevents field overflow and keeps the product of the multiplicati on in ran ge.Once youve establis
34、hed addition and multiplication by 0x02 in GF(28), you can use them to define multiplication by any constant. To multiply by 0x03 in GF(28), you can decompose 0x03 as powers of 2 and additi ons. To multiply an arbitrary byte b by0x03, observe that 0x03 = 0x02 + 0x01. Thus:b * 0x03 = b * (0x02 + 0x01
35、)=(b * 0x02) + (b * 0x01)This can be done because you know how to multiply by 0x02 and 0x01 and how to perform addition. Similarly, to multiply an arbitrary byte b by 0x0d, you do this: b * 0x0d = b * (0x08 + 0x04 + 0x01)=(b * 0x08) + (b * 0x04) + (b * 0x01)=(b * 0x02 * 0x02 * 0x02) + (b * 0x02 * 0x
36、02) + (b * 0x01)The other multiplications needed for the AES MixColumns routine in the encryption and decrypti on algorithm follow the same gen eral patter n, as show n here: b * 0x09 = b * (0x08 + 0x01)=(b * 0x02 * 0x02 * 0x02) + (b * 0x01)b * 0x0b = b * (0x08 + 0x02 + 0x01)=(b * 0x02 * 0x02 * 0x02
37、) + (b * 0x02) + (b * 0x01)b * 0x0e = b * (0x08 + 0x04 + 0x02)=(b * 0x02 * 0x02 * 0x02) + (b * 0x02 * 0x02) + (b * 0x02)To summarize, addition in GF(28) is the XOR operation. Multiplication in GF(28) reduces to additi ons and multiplicati ons by 0x02, where multiplicati on by 0x02 is a conditional 1
38、-bit left shift. The AES specification contains a lot of additional in formatio n about operati ons in GF(28).Key Expa nsionThe AES en crypti on and decrypti on algorithms use a key schedule gen erated from the seed key array of bytes. The AES specification refers to this as the KeyExpansion routi n
39、e. Gen erat ing, in esse nee, multiple keys from an in itial key in stead of using a sin gle key greatly in creases the diffusi on of bits. Although not overwhel min gly difficult, understanding KeyExpansion is one of the trickier parts of the AES algorithm. In high-level pseudocode, the KeyExpansio
40、n routine looks like the followi ng:KeyExpansion(byte key, byte4 w)copy the seed key into the first rows of wfor each remai ning row of wuse two of the previous rows to create a new rowThe use two of the previous rows to create a new row routine makes use of two subrouti nes, RotWord and SubWord, an
41、d a table of con sta nts n amed Rcon (for ro und constants). Lets look at each of these three items and then come back to the KeyExpa nsion routi ne as a whole.The RotWord routine is simple. It accepts an array of 4 bytes and rotates them 1 positi on left. Because the round schedule table w has four
42、 colu mns, RotWord rotates a row of w to the left. Notice that the RotWord function used by KeyExpansion is very similar to the ShiftRows routine used by the encryption algorithm except that it works on a sin gle row of the key schedule w in stead of the en tire en cryptio n state table State.The Su
43、bWord routi ne performs a byte-by-byte substituti on on a give n row of the key schedule table w using the substitution table Sbox. The substitutions in KeyExpa nsion operate exactly like those in the en crypti on algorithm. The in put byte to be substituted is separatedi nto an (x,y) pair which are
44、 used as in dexes into the substituti on table Sbox. For example, substituti on for 0x27 results in x = 2 and y = 7, and Sbox2,7 retur ns 0xcc.The KeyExpa nsion rout ine uses an array Rcon , called the round con sta nt table These con sta nts are 4 bytes each to match with a row of the key schedule
45、table. The AES KeyExpa nsion routi ne requires 11 round con sta nts. You can see these con sta nts listed in Figure 7.Figure 7 In itializ ing RconThe leftmost byte of each round constant is a power of 2 in the GF(28) field. Another way of looking at it is to observe that each value is the previous v
46、alue times 0x02, as described in the previous sect ion discuss ing multiplicati on in GF(28). Notice that 0x80 x 0x02 = 0x1b is 0x80 left-shifted 1 bit followed by an XOR with 0x1b, as described earlier.Now lets take a closer look at the loop in side KeyExpa nsion. In more detailed pseudocode tha n before, the loop is:for (row = Nk; row lbFigure 2 S-盒(Sbox )當(dāng)AES的構(gòu)造函數(shù)(constructor )被調(diào)用時(shí),用于加密方法的兩個(gè)表被初始化。 第一個(gè)表是代替盒稱為S-盒。它是一個(gè)16 X16的矩陣。S-
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 二零二五年度美容院美容美發(fā)服務(wù)入股協(xié)議
- 2025年度電線電纜綠色包裝與供貨合同
- 股權(quán)代持協(xié)議書標(biāo)準(zhǔn)模板:2025年度股權(quán)收購執(zhí)行范本
- 二零二五年度交通事故車輛損失保險(xiǎn)理賠協(xié)議
- 二零二五年度汽車展覽會(huì)參展商環(huán)保責(zé)任合同
- Unit 1 Going to Beijing 單元基礎(chǔ)知識(shí)復(fù)習(xí)(含答案)
- 2025年度溫室大棚承包與農(nóng)業(yè)科技成果轉(zhuǎn)化合作協(xié)議
- 二零二五年度手車過戶買賣與車輛上牌服務(wù)協(xié)議
- 兒童國畫入門課堂
- 中級(jí)消防設(shè)施操作員速記口訣
- 2025年湖南大眾傳媒職業(yè)技術(shù)學(xué)院?jiǎn)握新殬I(yè)技能測(cè)試題庫新版
- 雙均線策略(TBQ版)
- 北京房屋租賃合同電子版7篇
- 《園林機(jī)械使用與維修》課件-任務(wù)3.園林養(yǎng)護(hù)機(jī)械
- deepseek-r1論文-中文翻譯版
- 國家中醫(yī)藥管理局發(fā)布的406種中醫(yī)優(yōu)勢(shì)病種診療方案和臨床路徑目錄
- 山東省春季高考技能考試-汽車專業(yè)必刷必練題庫(600題)
- 村委會(huì)會(huì)議簽到表
- MSOP(測(cè)量標(biāo)準(zhǔn)作業(yè)規(guī)范)測(cè)量SOP
- 中央電大護(hù)理_學(xué)專業(yè)本科臨床小講課教(學(xué))案
- 制動(dòng)系統(tǒng)簡(jiǎn)介
評(píng)論
0/150
提交評(píng)論