资源简介
关于C++编写的SNMP协议实现,很好的东西,扩展性好
代码片段和文件信息
/* encrypt V1.1 Fri Oct 18 04:28:03 NZDT 2002 */
/* File de/encryption using libtomcrypt */
/* Written by Daniel Richards */
/* Help from Tom St Denis with various bits */
/* This code is public domain no rights reserved. */
/* Encrypts by default -d flag enables decryption */
/* ie: ./encrypt blowfish story.txt story.ct */
/* ./encrypt -d blowfish story.ct story.pt */
#include
int errno;
int usage(char *name)
{
int x;
printf(“Usage: %s [-d](ecrypt) cipher infile outfile\nCiphers:\n“ name);
for (x = 0; cipher_descriptor[x].name != NULL; x++) {
printf(“%s\n“cipher_descriptor[x].name);
}
exit(1);
}
void register_algs(void)
{
int x;
#ifdef LTC_RIJNDAEL
register_cipher (&aes_desc);
#endif
#ifdef LTC_BLOWFISH
register_cipher (&blowfish_desc);
#endif
#ifdef LTC_XTEA
register_cipher (&xtea_desc);
#endif
#ifdef LTC_RC5
register_cipher (&rc5_desc);
#endif
#ifdef LTC_RC6
register_cipher (&rc6_desc);
#endif
#ifdef LTC_SAFERP
register_cipher (&saferp_desc);
#endif
#ifdef LTC_TWOFISH
register_cipher (&twofish_desc);
#endif
#ifdef LTC_SAFER
register_cipher (&safer_k64_desc);
register_cipher (&safer_sk64_desc);
register_cipher (&safer_k128_desc);
register_cipher (&safer_sk128_desc);
#endif
#ifdef LTC_RC2
register_cipher (&rc2_desc);
#endif
#ifdef LTC_DES
register_cipher (&des_desc);
register_cipher (&des3_desc);
#endif
#ifdef LTC_CAST5
register_cipher (&cast5_desc);
#endif
#ifdef LTC_NOEKEON
register_cipher (&noekeon_desc);
#endif
#ifdef LTC_SKIPJACK
register_cipher (&skipjack_desc);
#endif
#ifdef LTC_KHAZAD
register_cipher (&khazad_desc);
#endif
#ifdef LTC_ANUBIS
register_cipher (&anubis_desc);
#endif
if (register_hash(&sha256_desc) == -1) {
printf(“Error registering LTC_SHA256\n“);
exit(-1);
}
if (register_prng(&yarrow_desc) == -1) {
printf(“Error registering yarrow PRNG\n“);
exit(-1);
}
if (register_prng(&sprng_desc) == -1) {
printf(“Error registering sprng PRNG\n“);
exit(-1);
}
}
int main(int argc char *argv[])
{
unsigned char plaintext[512]ciphertext[512];
unsigned char tmpkey[512] key[MAXBLOCKSIZE] IV[MAXBLOCKSIZE];
unsigned char inbuf[512]; /* i/o block size */
unsigned long outlen y ivsize x decrypt;
symmetric_CTR ctr;
int cipher_idx hash_idx ks;
char *infile *outfile *cipher;
prng_state prng;
FILE *fdin *fdout;
/* register algs so they can be printed */
register_algs();
if (argc < 4) {
return usage(argv[0]);
}
if (!strcmp(argv[1] “-d“)) {
decrypt = 1;
cipher = argv[2];
infile = argv[3];
outfile = argv[4];
} else {
decrypt = 0;
cipher = argv[1];
infile = argv[2];
outfile = argv[3];
}
/* file handles setup */
fdin = fopen(infile“rb“);
if (fdin == NULL) {
perror(“Can‘t open input for reading“);
exit(-1);
}
fdout = fopen(outfile
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 902 2007-05-12 22:46 crypt\build.sh
文件 111298 2007-05-12 22:46 crypt\changes
文件 1233 2007-05-12 22:46 crypt\crypt.lof
文件 297576 2007-05-12 22:46 crypt\crypt.tex
文件 6160 2007-05-12 22:46 crypt\demos\encrypt.c
文件 2988 2007-05-12 22:46 crypt\demos\hashsum.c
文件 4333 2007-05-12 22:46 crypt\demos\multi.c
文件 334 2007-05-12 22:46 crypt\demos\small.c
文件 1794 2007-05-12 22:46 crypt\demos\test.c
文件 646 2007-05-12 22:46 crypt\demos\timing.c
文件 24417 2007-05-12 22:46 crypt\demos\tv_gen.c
文件 827358 2007-05-12 22:46 crypt\doc\crypt.pdf
文件 325 2007-05-12 22:46 crypt\doc\footer.html
文件 422 2007-05-12 22:46 crypt\doc\header.html
文件 47498 2007-05-12 22:46 crypt\Doxyfile
文件 517 2007-05-12 22:46 crypt\filter.pl
文件 218 2007-05-12 22:46 crypt\fixupind.pl
文件 681 2007-05-12 22:46 crypt\genlist.sh
文件 34650 2007-05-12 22:46 crypt\libtomcrypt.dsp
文件 82 2007-05-12 22:46 crypt\LICENSE
文件 17728 2007-05-12 22:46 crypt\makefile
文件 14754 2007-05-12 22:46 crypt\makefile.icc
文件 11445 2007-05-12 22:46 crypt\makefile.msvc
文件 14414 2007-05-12 22:46 crypt\makefile.shared
文件 13617 2009-05-27 20:07 crypt\makefile.unix
文件 122 2007-05-12 22:46 crypt\mess.sh
文件 993 2007-05-12 22:46 crypt\notes\ba
文件 14683 2007-05-12 22:46 crypt\notes\ccm_tv.txt
文件 52936 2007-05-12 22:46 crypt\notes\cipher_tv.txt
文件 23807 2007-05-12 22:46 crypt\notes\eax_tv.txt
............此处省略757个文件信息
评论
共有 条评论