Changeset 225 for trunk/src/sh_srp.c
- Timestamp:
- Mar 4, 2009, 11:39:50 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_srp.c
r138 r225 388 388 if (res != BIG_OK) val = (-1); 389 389 else if (0 != big_zerop(&AB) ) val = (-1); /* 0 != (sign == 0) */ 390 else if (0 != big_zerop(&r) ) val = (-1); /* 0 != (sign == 0) */ 390 391 else val = 0; 391 392 … … 711 712 712 713 713 714 714 #ifdef SH_CUTEST 715 #include "CuTest.h" 716 717 void Test_srp (CuTest *tc) 718 { 719 #if defined(USE_SRP_PROTOCOL) && (defined (SH_WITH_CLIENT) || defined (SH_WITH_SERVER)) 720 721 int result; 722 char modulus[80*4]; 723 bignum a, b, c; 724 bigerr_t res; 725 char *str = NULL; 726 727 res = sh_srp_init(); 728 CuAssertTrue(tc, res == 0); 729 730 (void) sl_strlcpy(modulus, SRP_MODULUS_1024_1, sizeof(modulus)); 731 (void) sl_strlcat(modulus, SRP_MODULUS_1024_2, sizeof(modulus)); 732 (void) sl_strlcat(modulus, SRP_MODULUS_1024_3, sizeof(modulus)); 733 (void) sl_strlcat(modulus, SRP_MODULUS_1024_4, sizeof(modulus)); 734 735 res = big_create(&a); 736 CuAssertTrue(tc, res == BIG_OK); 737 738 /* Check plain zero 739 */ 740 result = sh_srp_check_zero ("0"); 741 CuAssertTrue(tc, result != 0); 742 743 res = big_set_string ("0", 16, &a); 744 CuAssertTrue(tc, res == BIG_OK); 745 746 result = sh_srp_check_zero (big_string(&a, 16)); 747 CuAssertTrue(tc, result != 0); 748 749 /* Check modulus (equals 0 % M) 750 */ 751 result = sh_srp_check_zero (modulus); 752 CuAssertTrue(tc, result != 0); 753 754 res = big_set_string (modulus, 16, &a); 755 CuAssertTrue(tc, res == BIG_OK); 756 757 result = sh_srp_check_zero (big_string(&a, 16)); 758 CuAssertTrue(tc, result != 0); 759 760 /* Check non-zero 761 */ 762 modulus[0] = 'a'; 763 764 result = sh_srp_check_zero (modulus); 765 CuAssertTrue(tc, result == 0); 766 767 res = big_set_string (modulus, 16, &a); 768 CuAssertTrue(tc, res == BIG_OK); 769 770 result = sh_srp_check_zero (big_string(&a, 16)); 771 CuAssertTrue(tc, result == 0); 772 773 modulus[0] = 'f'; 774 775 /* Check multiple of modulus 776 */ 777 res = big_set_string (modulus, 16, &a); 778 CuAssertTrue(tc, res == BIG_OK); 779 780 res = big_create(&b); 781 CuAssertTrue(tc, res == BIG_OK); 782 783 res = big_create(&c); 784 CuAssertTrue(tc, res == BIG_OK); 785 786 res = big_set_string ("deadbeef", 16, &b); 787 CuAssertTrue(tc, res == BIG_OK); 788 789 res = big_mul (&a, &b, &c); 790 CuAssertTrue(tc, res == BIG_OK); 791 792 str = strdup(big_string (&c, 16)); 793 CuAssertPtrNotNull(tc, str); 794 795 result = sh_srp_check_zero (str); 796 CuAssertTrue(tc, result != 0); 797 798 #else 799 (void) tc; /* fix compiler warning */ 800 #endif 801 return; 802 } 803 #endif 804 805 806
Note:
See TracChangeset
for help on using the changeset viewer.