diff options
author | Martin Willi <martin@strongswan.org> | 2006-04-28 07:14:48 +0000 |
---|---|---|
committer | Martin Willi <martin@strongswan.org> | 2006-04-28 07:14:48 +0000 |
commit | 997358a6c475c8886cce388ab325184a1ff733c9 (patch) | |
tree | 27a15790e030fc186d00cd710d2a3540f4defe69 /lib/libcrypto/libserpent/test_main.c | |
parent | 52923c9acb349adec3d1cc039e7a74c2e822da6e (diff) | |
download | strongswan-997358a6c475c8886cce388ab325184a1ff733c9.tar.bz2 strongswan-997358a6c475c8886cce388ab325184a1ff733c9.tar.xz |
- import of strongswan-2.7.0
- applied patch for charon
Diffstat (limited to 'lib/libcrypto/libserpent/test_main.c')
-rw-r--r-- | lib/libcrypto/libserpent/test_main.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/libcrypto/libserpent/test_main.c b/lib/libcrypto/libserpent/test_main.c new file mode 100644 index 000000000..350068e60 --- /dev/null +++ b/lib/libcrypto/libserpent/test_main.c @@ -0,0 +1,34 @@ +#include <stdio.h> +#include <string.h> +#include "serpent_cbc.h" +#define BLOCK_SIZE 16 +#define KEY_SIZE 128 /* bits */ +#define KEY "1234567890123456" +#define STR "hola guaso como estaisss ... 012" +#define STRSZ (sizeof(STR)-1) + +#define BLKLEN BLOCK_SIZE +#define CONTEXT_T serpent_context +static int pretty_print(const unsigned char *buf, int count) { + int i=0; + for (;i<count;i++) printf ("%02hhx ", buf[i]); + putchar('\n'); + return i; +} +//#define SIZE STRSZ/2 +#define SIZE STRSZ +int main() { + int ret; + char buf0[SIZE+1], buf1[SIZE+1]; + char IV[BLOCK_SIZE]; + CONTEXT_T ac; + serpent_set_key(&ac, (void *)KEY, KEY_SIZE); + memset(buf0, 0, sizeof (buf0)); + memset(buf1, 0, sizeof (buf1)); + serpent_cbc_encrypt(&ac, STR, buf0, SIZE, IV, 1); + pretty_print(buf0, SIZE); + printf("size=%d ret=%d\n%s\n", SIZE, ret, buf0); + ret=serpent_cbc_encrypt(&ac, buf0, buf1, SIZE, IV, 0); + printf("size=%d ret=%d\n%s\n", SIZE, ret, buf1); + return 0; +} |