SKINNY加密算法详解(无代码,仅加密)

原作者论文请参考《The SKINNY Family of Block Ciphers and Its Low-Latency Variant MANTIS》

地址为:https://link.springer.com/chapter/10.1007/978-3-662-53008-5_5

代码及资源分析等参见:https://sites.google.com/site/skinnycipher/home

SKINNY 和 AES 类似,都是SPN结构的加密算法。

本文中截图多来自上述论文。

一、整体流程

  其中包括5个步骤,分别为字节替换、轮加常数、轮加密钥、行移位、列混淆

  SKINNY有一下几种模式:

  

  其中,n为明文长度,有64位和128位两种;对于每种明文,密钥有3种形式n/2n/3n,即64

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Skinny是一种轻量级的加密算法,它被设计用于资源受限的设备和环境中。下面是一个简单的C语言实现示例: ```c #include <stdio.h> #include <stdint.h> // 定义S盒 const uint8_t SBox[16] = { 0xC, 0x5, 0x6, 0xB, 0x9, 0x0, 0xA, 0xD, 0x3, 0xE, 0xF, 0x8, 0x4, 0x7, 0x1, 0x2 }; // 定义线性变换矩阵 const uint8_t LBox[16] = { 0x1, 0x5, 0x9, 0xD, 0x2, 0x6, 0xA, 0xE, 0x3, 0x7, 0xB, 0xF, 0x4, 0x8, 0xC, 0x0 }; // 定义密钥 const uint8_t Key[32] = { // 这里填入你的密钥值 }; // 定义轮密钥 uint8_t RoundKey[36][4]; // 字节替代函数 void SubBytes(uint8_t state[4]) { for (int i = 0; i < 4; i++) { state[i] = SBox[state[i]]; } } // 线性变换函数 void ShiftRows(uint8_t state[4]) { uint8_t temp = state[1]; state[1] = state[0]; state[0] = temp; temp = state[2]; state[2] = state[0]; state[0] = temp; temp = state[3]; state[3] = state[0]; state[0] = temp; } // 密钥扩展函数 void ExpandKey() { for (int i = 0; i < 4; i++) { RoundKey[i][0] = Key[i * 4]; RoundKey[i][1] = Key[i * 4 + 1]; RoundKey[i][2] = Key[i * 4 + 2]; RoundKey[i][3] = Key[i * 4 + 3]; } for (int i = 4; i < 36; i++) { uint8_t temp[4]; temp[0] = RoundKey[i - 1][0] ^ SBox[RoundKey[i - 1][3]] ^ (i >> 2); temp[1] = RoundKey[i - 1][1]; temp[2] = RoundKey[i - 1][2]; temp[3] = RoundKey[i - 1][3]; RoundKey[i][0] = temp[0] ^ RoundKey[i - 4][0]; RoundKey[i][1] = temp[1] ^ RoundKey[i - 4][1]; RoundKey[i][2] = temp[2] ^ RoundKey[i - 4][2]; RoundKey[i][3] = temp[3] ^ RoundKey[i - 4][3]; } } // 加密函数 void Encrypt(uint8_t plaintext[4], uint8_t ciphertext[4]) { uint8_t state[4]; for (int i = 0; i < 4; i++) { state[i] = plaintext[i] ^ RoundKey[i][0]; } for (int round = 0; round < 32; round++) { SubBytes(state); ShiftRows(state); uint8_t temp[4]; for (int i = 0; i < 4; i++) { temp[i] = LBox[state[i]]; } for (int i = 0; i < 4; i++) { state[i] = temp[i] ^ RoundKey[round + 4][i]; } } for (int i = 0; i < 4; i++) { ciphertext[i] = state[i] ^ RoundKey[35][i]; } } int main() { // 这里填入你的明文 uint8_t plaintext[4] = {0x00, 0x00, 0x00, 0x00}; uint8_t ciphertext[4]; ExpandKey(); Encrypt(plaintext, ciphertext); printf("加密结果:"); for (int i = 0; i < 4; i++) { printf("%02X ", ciphertext[i]); } printf("\n"); return 0; } ``` 这是一个简单的Skinny加密算法的C语言实现示例。你可以根据需要修改密钥和明文,然后编译运行该程序,即可得到加密结果。请注意,这只是一个简单的示例,实际使用时需要根据具体需求进行适当的修改和优化。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值