applied cryptography - protocols, algorithms, and source code in c

5560 15 lm adleman on breaking generalized knapsack

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ec(“KEY = ”,k); printvec(“PLAIN = ”,a); encrypt(&ampgc,a); printvec(“CIPHER = ”,a); /* Test vector 3. */ k[2]=0xbcdef012;k[1]=0x456789ab;k[0]=0xdef01234; a[2]=0×01234567;a[1]=0x9abcdef0;a[0]=0x23456789; twy_key(&ampgc,k); printf(“**********\n”); printvec(“KEY = ”,k); printvec(“PLAIN = ”,a); encrypt(&ampgc,a); printvec(“CIPHER = ”,a); /* Test vector 4. */ k[2]=0xcab920cd;k[1]=0xd6144138;k[0]=0xd2f05b5e; a[2]=0xad21ecf7;a[1]=0x83ae9dc4;a[0]=0x4059c76e; twy_key(&ampgc,k); printf(“**********\n”); printvec(“KEY = ”,k); printvec(“PLAIN = ”,a); encrypt(&ampgc,a); printvec(“CIPHER = ”,a); /* TEST VALUES key : 00000000 00000000 00000000 plaintext : 00000001 00000001 00000001 ciphertext : ad21ecf7 83ae9dc4 4059c76e key : 00000004 00000005 00000006 plaintext : 00000001 00000002 00000003 ciphertext : cab920cd d6144138 d2f05b5e key : bcdef012 456789ab def01234 plaintext : 01234567 9abcdef0 23456789 ciphertext : 7cdb76b2 9cdddb6d 0aa55dbb key : cab920cd d6144138 d2f05b5e plaintext : ad21ecf7 83ae9dc4 4059c76e ciphertext : 15b155ed 6b13f17c 478ea871 */ /* Enc/dec test: */ for(i=0;i<9;i++) a[i]=i; twy_enc(&ampgc,a,3); for(i=0;i<9;i+=3) printf(“Block %01d encrypts to %08lx %08lx %08lx\n”, i/3,a[i],a[i+1],a[i+2]); twy_dec(&ampgc,a,2); twy_dec(&ampgc,a+6,1); for(i=0;i<9;i+=3) printf(“Block %01d decrypts to %08lx %08lx %08lx\n”, i/3,a[i],a[i+1],a[i+2]); } RC5 #include <stdio.h> /* An RC5 context needs to know how many rounds it has, and its subkeys. */ typedef struct { u4 *xk; int nr; } rc5_ctx; /* Where possible, these should be replaced with actual rotate instructions. For Turbo C++, this is done with _lrotl and _lrotr. */ #define ROTL32(X,C) (((X)<<(C))|((X)>>(32–(C)))) #define ROTR32(X,C) (((X)>>(C))|((X)<<(32–(C)))) /* Function prototypes for dealing with RC5 basic operations. */ void rc5_init(rc5_ctx *, int); void rc5_destroy(rc5_ctx *); void rc5_key(rc5_ctx *, u1 *, int); void rc5_encrypt(rc5_c...
View Full Document

This note was uploaded on 10/18/2010 for the course MATH CS 301 taught by Professor Aliulger during the Fall '10 term at Koç University.

Ask a homework question - tutors are online