Changeset 481 for trunk/src/sh_utils.c
- Timestamp:
- Jul 18, 2015, 5:06:52 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_utils.c
r473 r481 309 309 } 310 310 } 311 out[rem] = ','; ++rem; 312 while (p[1] == '\n') ++p; /* scan over consecutive newlines */311 out[rem] = ','; ++rem; /* <-- ensures (rem > 0) is true */ 312 while (p[1] == '\n') ++p; /* scan over consecutive newlines */ 313 313 state = 0; 314 314 if (p[1] == '\0') { 315 if (rem > 0) out[rem-1] = '\0';315 out[rem-1] = '\0'; /* rem > 0 because of 4 lines above */ 316 316 break; 317 317 } … … 782 782 char hashbuf[KEYBUF_SIZE]; 783 783 784 784 int result; 785 785 size_t i; 786 786 787 787 SL_ENTER(_("sh_util_hmac_tiger")); 788 ASSERT((KEY_BLOCK <= (KEY_LEN/2)), _("KEY_BLOCK <= (KEY_LEN/2)")) 789 790 if (KEY_BLOCK > (KEY_LEN/2)) 791 { 792 (void) sh_tiger_hash (NULL, TIGER_DATA, 0, hashbuf, sizeof(hashbuf)); 793 sl_strlcpy(res, hashbuf, len); 794 SL_RETURN(res, _("sh_util_hmac_tiger")); 795 } 788 789 ASSERT((KEY_BLOCK <= (KEY_LEN/2)), _("KEY_BLOCK <= (KEY_LEN/2)")); 796 790 797 791 memcpy (K, zap, KEY_BLOCK); 798 792 799 if (sh_util_hextobinary (K, hexkey, KEY_LEN) < 0) 800 { 801 (void) sh_tiger_hash (NULL, TIGER_DATA, 0, hashbuf, sizeof(hashbuf)); 802 sl_strlcpy(res, hashbuf, len); 803 SL_RETURN(res, _("sh_util_hmac_tiger")); 804 } 805 806 if (sl_ok_adds(textlen, KEY_BLOCK)) 793 result = sh_util_hextobinary (K, hexkey, KEY_LEN); 794 795 ASSERT((result >= 0), _("result >= 0")); 796 797 if ((result >= 0) && sl_ok_adds(textlen, KEY_BLOCK)) 807 798 { 808 799 inner = (char *) SH_ALLOC (textlen + KEY_BLOCK); … … 830 821 /* now compute the hash 831 822 */ 832 h1 = sh_tiger_hash_uint32 ( outer, 833 TIGER_DATA, 834 KEY_BLOCK, 823 h1 = sh_tiger_hash_uint32 ( outer, TIGER_DATA, KEY_BLOCK, 835 824 kbuf, KEY_BYT/sizeof(UINT32)); 836 825 for (i = 0; i < (KEY_LEN/8); ++i) 837 { 838 /* cc[i] = h1[i]; */ 839 copy_four ( (unsigned char *) &(cc[i]), h1[i]); 840 } 841 842 h2 = sh_tiger_hash_uint32 ( inner, 843 TIGER_DATA, 826 copy_four ( (unsigned char *) &(cc[i]), h1[i]); 827 828 h2 = sh_tiger_hash_uint32 ( inner, TIGER_DATA, 844 829 (unsigned long) KEY_BLOCK+textlen, 845 830 kbuf, KEY_BYT/sizeof(UINT32)); 846 831 for (i = KEY_LEN/8; i < (KEY_LEN/4); ++i) 847 { 848 copy_four ( (unsigned char *) &(cc[i]), h2[i - (KEY_LEN/8)]); 849 /* cc[i] = h2[i - (KEY_LEN/8)]; */ 850 } 832 copy_four ( (unsigned char *) &(cc[i]), h2[i - (KEY_LEN/8)]); 833 851 834 SH_FREE(inner); 852 835 … … 1033 1016 1034 1017 1035 /* interval [0, 429496729 6]1018 /* interval [0, 4294967295] 1036 1019 */ 1037 1020 static UINT32 taus_get_long (void *vstate) … … 1160 1143 char bufx[9 * sizeof(UINT32) + 1]; 1161 1144 int status; 1162 static unsigned long seed_time = 0; 1145 static unsigned long seed_time = 0; 1146 static unsigned long seed_counter = 3000; 1163 1147 unsigned long gtime; 1164 1148 … … 1167 1151 if (skey->rngI == GOOD) 1168 1152 { 1169 if ( (sh_unix_longtime () - seed_time) < 7200) 1153 ++seed_counter; 1154 1155 if ( ((sh_unix_longtime () - seed_time) < 1800) && 1156 ( seed_counter < 3000)) 1170 1157 SL_RETURN( (0), _("taus_seed")); 1171 1158 } 1172 1159 1173 seed_time = sh_unix_longtime (); 1160 seed_time = sh_unix_longtime (); 1161 seed_counter = 0; 1174 1162 1175 1163 status = sh_entropy (24, bufx); … … 1834 1822 int sh_util_obscurename (ShErrLevel level, const char * name_orig, int flag) 1835 1823 { 1836 const unsigned char * name = ( unsigned char *) name_orig;1824 const unsigned char * name = (const unsigned char *) name_orig; 1837 1825 char * safe; 1838 1826 unsigned int i; … … 2308 2296 unsigned char b; 2309 2297 size_t lout = 0; 2310 intw = 0;2298 unsigned int w = 0; 2311 2299 2312 2300 if (out && in)
Note:
See TracChangeset
for help on using the changeset viewer.