资源简介
Serpent加密算法
代码片段和文件信息
/*
$Id: cbc_d_m.cv 1.11 1998/06/10 20:04:10 fms Exp $
# This file is part of the C reference implementation of Serpent.
#
# Written by Frank Stajano
# Olivetti Oracle Research Laboratory and
# Cambridge University Computer Laboratory .
#
# (c) 1998 Olivetti Oracle Research Laboratory (ORL)
#
# Original (Python) Serpent reference development started on 1998 02 12.
# C implementation development started on 1998 03 04.
#
# Serpent cipher invented by Ross Anderson Eli Biham Lars Knudsen.
# Serpent is a candidate for the Advanced Encryption Standard.
*/
/* -------------------------------------------------- */
#include
#include “serpent-api.h“
#include “serpent-aux.h“
/* -------------------------------------------------- */
embed_RCS(cbc_d_m_c
“$Id: cbc_d_m.cv 1.11 1998/06/10 20:04:10 fms Exp $“)
/* The “NIST SPEC“ markers refer to the pseudo-code instructions in figure
6 (Monte Carlo Test - CBC Decryption) of the NIST document “Description
of Known Answer Tests and Monte Carlo Tests for Advanced Encryption
Standard (AES) Candidate Algorithm Submissions“ as updated on February
17 1998 */
int main(void) {
int i j k bitsPerShortKey result;
BLOCK plainText cipherText PT_9998;
KEY binaryKey;
char asciiKey[HEX_DIGITS_PER_KEY+1];
keyInstance key;
cipherInstance cipher;
/* The hack that remembers PT_9998 only works if... */
assert(BITS_PER_KEY <= 2*BITS_PER_BLOCK);
/* ...otherwise we‘d have to remember more than just PT_9998. */
printHeader(“cbc_d_m“ “Cipher Block Chaining (CBC) Mode - DECRYPTION“
“Monte Carlo Test“);
for(bitsPerShortKey=BITS_PER_SHORTEST_KEY; bitsPerShortKey<=BITS_PER_KEY;
bitsPerShortKey+=BITS_PER_KEY_STEP) {
printf(“KEYSIZE=%d\n\n“ bitsPerShortKey);
/* Construct (backwards) an ascii key of all 0s of length
bitsPerShortKey bits. */
i=bitsPerShortKey/BITS_PER_HEX_DIGIT;
asciiKey[i] = 0; /* terminating null */
for (i--; i >=0; i--) {
asciiKey[i] = ‘0‘;
}
result = makeKey(&key DIR_DECRYPT bitsPerShortKey asciiKey);
if (result != TRUE) goto error;
result = stringToWords(“00000000000000000000000000000000“ cipherText
WORDS_PER_BLOCK);
if (result != TRUE) goto error;
result = cipherInit(&cipher MODE_CBC “00000000000000000000000000000000“);
if (result != TRUE) goto error;
for(i=0; i /* NIST SPEC: if (i==0) CV_0 = IV_0 */
/* This has already been done by cipherInit outside this loop. Our CV
is held in cipher.IV. */
/* NIST SPEC: Record i KEY_i CV_0 CT_0 */
printf(“I=%d\n“ i);
render(“KEY=“ key.userKey bitsPerShortKey/BITS_PER_WORD);
render(“IV=“ (WORD*) cipher.IV WORDS_PER_BLOCK);
render(“CT=“ cip
- 上一篇:行程编码,JPEG压缩编码
- 下一篇:局域网跳棋源代码
相关资源
- Scratch源码
- E4A无障碍跨程序操作类库(带源码、
- 设备管理系统源码
- 安卓wifi直连app源码
- 我的世界源码(易语言版)
- labview编程软件滤波器以及编写程序设
- 我的界面(visual foxpro)源码
- 易语言:一键cf基址源码
- The Secret Path 3D 3D魔方迷宫[源码][scra
- scratch垃圾分类源码(最终版本).sb
- 最新版TTF16.OCX Formula One v. 6.1.6.2 控件
- 安卓QQ6.71协议源码易语言,qq协议源码
- 编译原理实验工具及参考源码(lex&
- E盾偷后台工具源码
- UNIX/LINUX编程实践教程的源码
- 十以内加减法练习 powerbuilder源码
- 农场开发项目
- OCR源码
- PLC上位机编程软件
- 用foobar2000听google音乐[更新一下]
- 学生信息管理系统源码
- 用VC 编写的仿QQ聊天室程序源代码
- 毕业论文之温度传感器DS18B20(源码
- 可自定义导航网站源码
- 栅栏填充算法源码(VC)
- msp430F149操作红外接收模块源码
- [免费]图像识别c 源码
- 周易排盘源码
- 可拖拽的甘特图控件(完整)
- RSA算法源码
评论
共有 条评论