1242713Ssjg#include <sys/cdefs.h> 2242713Ssjg__FBSDID("$FreeBSD$"); 3242713Ssjg 4242713Ssjg#include <sys/types.h> 5242713Ssjg#include <crypt.h> 6242713Ssjg#include <unistd.h> 7242713Ssjg 8242713Ssjg#include <atf-c.h> 9242713Ssjg 10242713Ssjg#define LEET "0.s0.l33t" 11242713Ssjg 12242713SsjgATF_TC(md5); 13242713SsjgATF_TC_HEAD(md5, tc) 14242713Ssjg{ 15242713Ssjg 16242713Ssjg atf_tc_set_md_var(tc, "descr", "Tests the MD5 based password hash"); 17242713Ssjg} 18242713Ssjg 19242713SsjgATF_TC_BODY(md5, tc) 20242713Ssjg{ 21242713Ssjg const char want[] = "$1$deadbeef$0Huu6KHrKLVWfqa4WljDE0"; 22242713Ssjg char *pw; 23242713Ssjg 24242713Ssjg pw = crypt(LEET, want); 25242713Ssjg ATF_CHECK_STREQ(pw, want); 26242713Ssjg} 27242713Ssjg 28242713SsjgATF_TC(invalid); 29242713SsjgATF_TC_HEAD(invalid, tc) 30242713Ssjg{ 31242713Ssjg 32242713Ssjg atf_tc_set_md_var(tc, "descr", "Tests that invalid password fails"); 33242713Ssjg} 34242713Ssjg 35242713SsjgATF_TC_BODY(invalid, tc) 36242713Ssjg{ 37242713Ssjg const char want[] = "$1$cafebabe$0Huu6KHrKLVWfqa4WljDE0"; 38242713Ssjg char *pw; 39242713Ssjg 40242713Ssjg pw = crypt(LEET, want); 41242713Ssjg ATF_CHECK(strcmp(pw, want) != 0); 42242713Ssjg} 43242713Ssjg 44242713Ssjg/* 45242713Ssjg * This function must not do anything except enumerate 46256366Srpaulo * the test cases, per atf-c-api(3). 47242713Ssjg */ 48242713SsjgATF_TP_ADD_TCS(tp) 49242713Ssjg{ 50242713Ssjg 51242713Ssjg ATF_TP_ADD_TC(tp, md5); 52242713Ssjg ATF_TP_ADD_TC(tp, invalid); 53242713Ssjg return atf_no_error(); 54242713Ssjg} 55