Speck是一類輕量級的分組密碼,最早由美國國家安全局(NSA)於2013年6月提出[2]。如今Speck碼較多應用於軟件實現,而其姊妹算法Simon英語Simon (cipher)則多用於硬件實現。

Speck
3 rounds of Speck with 2-word key schedule
概述
設計者Ray Beaulieu, Douglas Shors, Jason Smith, Stefan Treatman-Clark, Bryan Weeks, Louis Wingers NSA
首次發佈2013
相關算法Simon英語Simon (cipher)Threefish英語Threefish
密碼細節
密鑰長度64, 72, 96, 128, 144, 192 or 256 bits
分組長度32, 48, 64, 96 or 128 bits
結構ARX
重複回數22–34 (depending on block and key size)
速度2.6 cpb (5.7 without SSE) on Intel Xeon 5640 (Speck128/128)
最佳公開破解
差分密碼分析[1]

編碼描述 編輯

Speck支持多種分組密文長度。單個分組總是包含兩個單字,每個單字可以由16位、24位、32位、48位或64位比特組成。相關密文由2、3或4個詞彙組成。編碼的循環函數包含兩次反轉計算:將右單字添加到左單字,異或密文與左單字;之後異或左單字與右單字。循環的次數取決於參數的選擇如下[2]

塊大小(bits) 秘鑰大小(bits) 循環次數
2×16=32 4×16=64 22
2×24=48 3×24=72 22
4×24=96 23
2×32=64 3×32=96 26
4×32=128 27
2×48=96 2×48=96 28
3×48=144 29
2×64=128 2×64=128 32
3×64=192 33
4×64=256 34

密碼次序表與主塊密碼使用相同的循環函數。

參考代碼 編輯

以下是編碼算法實現的設計參考,使用C語言編寫,其具有128比特的分組大小與密文。

#include <stdint.h>

#define ROR(x, r) ((x >> r) | (x << (64 - r)))
#define ROL(x, r) ((x << r) | (x >> (64 - r)))
#define R(x, y, k) (x = ROR(x, 8), x += y, x ^= k, y = ROL(y, 3), y ^= x)
#define ROUNDS 32

void encrypt(uint64_t ct[2],
             uint64_t const pt[2],            
             uint64_t const K[2])
{
   uint64_t y = pt[0], x = pt[1], b = K[0], a = K[1];

   R(x, y, b);
   for (int i = 0; i < ROUNDS - 1; i++) {
      R(a, b, i);
      R(x, y, b);
   }

   ct[0] = y;
   ct[1] = x;
}

參考文獻 編輯

  1. ^ Ling, Song; Huang, Zhangjie; Yang, Qianqian. Automatic Differential Analysis of ARX Block Ciphers with Application to SPECK and LEA (PDF). 2016-06-30 [2018-05-06]. (原始內容存檔 (PDF)於2017-07-16). 
  2. ^ 2.0 2.1 Beaulieu, Ray; Shors, Douglas; Smith, Jason; Treatman-Clark, Stefan; Weeks, Bryan; Wingers, Louis. The SIMON and SPECK Families of Lightweight Block Ciphers (404). 2013 [2018-05-09]. (原始內容存檔於2013-09-03).