西华大学计算机系上机实践报告
课程:级::名称:上机实践日期:2009-11-10上机实践编号:组:
目的
内容与
根据对置换密码算法的介绍,自己创建明文信息,并选择一个密钥,编写替代密码算法的实现程序,实现加密和解密操作。
根据上述密码算法最后的实现程序提供加密和解密两个接口:int encrypt( ) 和int decrypt(). 当加密和解密成功时返回CRYPT_OK, 失败时返回CRYPT_ERROR.。
三、用环境
Windows 或Linux 操作系统的PC机,具有GCC(Linux)、VC(Windows) 等C语言编译环境。
四#include "mycrypt.h"
#ifdef YARROW
const struct _prng_descriptor yarrow_desc =
{
"yarrow",
&yarrow_start,
&yarrow_add_entropy,
&yarrow_ready,
&yarrow_read
};
int yarrow_start(prng_state *prng)
{
int err;
_ARGCHK(prng != NULL);
/* these are the default hash/cipher combo used */
#ifdef RIJNDAEL
#if YARROW_AES==0
prng->yarrow.cipher = register_cipher(&rijndael_enc_desc);
#elif YARROW_AES==1
prng->yarrow.cipher = register_cipher(&aes_enc_desc);
#elif YARROW_AES==2
prng->yarrow.cipher = register_cipher(&rijndael_desc);
#elif YARROW_AES==3
prng->yarrow.cipher = register_cipher(&aes_desc);
#endif
#elif defined(BLOWFISH)
prng->yarrow.cipher = register_cipher(&blowfish_desc);
#elif defined(TWOFISH)
prng->yarrow.cipher = register_cipher(&twofish_desc);
#elif defined(RC6)
prng->yarrow.cipher = register_cipher(&rc6_desc);
#elif defined(RC5)
prng->yarrow.cipher = register_cipher(&rc5_desc);
#elif defined(SAFERP)
prng->yarrow.cipher = register_cipher(&saferp_desc);
#elif defined(RC2)
prng->yarrow.cipher = register_cipher(&rc2_desc);
#elif defined(NOEKEON)
prng->yarrow.cipher = register_cipher(&noekeon_desc);
#elif defined(CAST5)
prng->yarrow.cipher = register_cipher(&cast5_desc);
#elif defined(XTEA)
prng->yarrow.cipher = register_cipher(&xtea_desc);
#elif defined(SAFER)
prng->yarrow.cipher = register_cipher(&safer_sk128_desc);
#elif defined(DES)
prng->yarrow.cipher = register_cipher(&des3_desc);
#elif
#error YARROW needs at least one CIPHER
#endif
if ((err = cipher_is_valid(prng->yarrow.cipher)) != CRYPT_OK) {
return err;
}
#ifdef SHA256
prng->yarrow.hash = register_hash(&sha256_desc);
#elif defined(