/***********************************************************************1* *2* This software is part of the ast package *3* Copyright (c) 2003-2011 AT&T Intellectual Property *4* and is licensed under the *5* Eclipse Public License, Version 1.0 *6* by AT&T Intellectual Property *7* *8* A copy of the License is available at *9* http://www.eclipse.org/org/documents/epl-v10.html *10* (with md5 checksum b35adb5213ca9657e911e9befb180842) *11* *12* Information and Software Systems Research *13* AT&T Research *14* Florham Park NJ *15* *16* Phong Vo <[email protected]> *17* Glenn Fowler <[email protected]> *18* *19***********************************************************************/20#include "vctest.h"21#include "vccrypto.h"2223/* hold test strings */24typedef struct _pair_s25{ Vcchar_t* str;26Vcchar_t* sum;27} Pair_t;2829static Pair_t Md5[] =30{ { "0123456789", "781E5E245D69B566979B86E28D23F2C7" },31{ "abcdefghij", "A925576942E94B2EF57A066101B48876" },32{ 0, 0 }33};3435int main()36{37ssize_t k, n;38Vcchar_t *sum, hex[1024];39Vcx_t xx;4041if(vcxinit(&xx, Vcxmd5sum, 0, 0) < 0)42terror("Initializing md5 handle");43for(k = 0; Md5[k].str; ++k)44{ if((n = vcxencode(&xx, Md5[k].str, strlen((char*)Md5[k].str), &sum)) < 0 )45terror("Encoding data");46if(n != 16)47terror("Bad md5 digest length");48if(vchexcode(sum, n, hex, sizeof(hex), 1) != 32)49terror("Bad md5 hex coding length");50if(strcmp((char*)Md5[k].sum, (char*)hex) != 0)51terror("Bad md5 digest");52}53vcxstop(&xx);5455exit(0);56}575859