资源简介
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压缩编码
- 下一篇:局域网跳棋源代码
相关资源
- 局域网跳棋源代码
- 行程编码,JPEG压缩编码
- 一个漂亮的打地鼠游戏源码
- 心理在线咨询系统 v2.1
- 计算机机房管理系统
- 机房管理系统(源代码)
- Exactly like the classic etch-a-sketch game yo
-
Openxm
l - 一个读取硬盘序列号与CPU序列号的D
- 易语言进销存源码
- VISIO UI控件
- 语音播报 简单(源码)
- 16进制dat数据转.bmp位图文件 源码
- 数据链路层滑动窗口协议的设计与实
- LitJson源码--cs文件
- 特征提取及分类源码
- 利用mstscax.dll开发远程登录客户端源码
- 获取视频地址源码
- 短信、拦截、转发 源码
- redupload多文件上传控件 dll
- 课程设计Joseph环源码
- 餐饮管理系统打印票据汇总(附图例
- LabWindows CVI 3D graph控件编程
- 易语言 抽奖摇号软件源码
- WIFI探针内核源码
- osgEarth35集视频教程及源码
- 89c51电子数字钟 源码和电路图
- 50HZ陷波器的C程序源码.
- HMM算法及其源码
- 冒险岛登陆器079SF源码
评论
共有 条评论