Fossil SCM
Merge latest trunk.
Commit
02ee688a4d15bf2e5059e034229d007d901ab952
Parent
3115774ffe6e82d…
7 files changed
+1
-1
+19
-9
+49
-34
+49
-34
+4
+10
-1
-1
+1
-1
| --- src/configure.c | ||
| +++ src/configure.c | ||
| @@ -726,11 +726,11 @@ | ||
| 726 | 726 | |
| 727 | 727 | |
| 728 | 728 | /* |
| 729 | 729 | ** COMMAND: configuration |
| 730 | 730 | ** |
| 731 | -** Usage: %fossil configure METHOD ... ?-R|--repository REPOSITORY? | |
| 731 | +** Usage: %fossil configuration METHOD ... ?-R|--repository REPOSITORY? | |
| 732 | 732 | ** |
| 733 | 733 | ** Where METHOD is one of: export import merge pull push reset. All methods |
| 734 | 734 | ** accept the -R or --repository option to specific a repository. |
| 735 | 735 | ** |
| 736 | 736 | ** %fossil configuration export AREA FILENAME |
| 737 | 737 |
| --- src/configure.c | |
| +++ src/configure.c | |
| @@ -726,11 +726,11 @@ | |
| 726 | |
| 727 | |
| 728 | /* |
| 729 | ** COMMAND: configuration |
| 730 | ** |
| 731 | ** Usage: %fossil configure METHOD ... ?-R|--repository REPOSITORY? |
| 732 | ** |
| 733 | ** Where METHOD is one of: export import merge pull push reset. All methods |
| 734 | ** accept the -R or --repository option to specific a repository. |
| 735 | ** |
| 736 | ** %fossil configuration export AREA FILENAME |
| 737 |
| --- src/configure.c | |
| +++ src/configure.c | |
| @@ -726,11 +726,11 @@ | |
| 726 | |
| 727 | |
| 728 | /* |
| 729 | ** COMMAND: configuration |
| 730 | ** |
| 731 | ** Usage: %fossil configuration METHOD ... ?-R|--repository REPOSITORY? |
| 732 | ** |
| 733 | ** Where METHOD is one of: export import merge pull push reset. All methods |
| 734 | ** accept the -R or --repository option to specific a repository. |
| 735 | ** |
| 736 | ** %fossil configuration export AREA FILENAME |
| 737 |
+19
-9
| --- src/report.c | ||
| +++ src/report.c | ||
| @@ -198,10 +198,21 @@ | ||
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | 200 | return rc; |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | +/* | |
| 204 | +** Activate the query authorizer | |
| 205 | +*/ | |
| 206 | +static void report_restrict_sql(char **pzErr){ | |
| 207 | + (void)fossil_localtime(0); | |
| 208 | + sqlite3_set_authorizer(g.db, report_query_authorizer, (void*)pzErr); | |
| 209 | +} | |
| 210 | +static void report_unrestrict_sql(void){ | |
| 211 | + sqlite3_set_authorizer(g.db, 0, 0); | |
| 212 | +} | |
| 213 | + | |
| 203 | 214 | |
| 204 | 215 | /* |
| 205 | 216 | ** Check the given SQL to see if is a valid query that does not |
| 206 | 217 | ** attempt to do anything dangerous. Return 0 on success and a |
| 207 | 218 | ** pointer to an error message string (obtained from malloc) if |
| @@ -237,11 +248,11 @@ | ||
| 237 | 248 | } |
| 238 | 249 | } |
| 239 | 250 | } |
| 240 | 251 | |
| 241 | 252 | /* Compile the statement and check for illegal accesses or syntax errors. */ |
| 242 | - sqlite3_set_authorizer(g.db, report_query_authorizer, (void*)&zErr); | |
| 253 | + report_restrict_sql(&zErr); | |
| 243 | 254 | rc = sqlite3_prepare(g.db, zSql, -1, &pStmt, &zTail); |
| 244 | 255 | if( rc!=SQLITE_OK ){ |
| 245 | 256 | zErr = mprintf("Syntax error: %s", sqlite3_errmsg(g.db)); |
| 246 | 257 | } |
| 247 | 258 | if( !sqlite3_stmt_readonly(pStmt) ){ |
| @@ -248,11 +259,11 @@ | ||
| 248 | 259 | zErr = mprintf("SQL must not modify the database"); |
| 249 | 260 | } |
| 250 | 261 | if( pStmt ){ |
| 251 | 262 | sqlite3_finalize(pStmt); |
| 252 | 263 | } |
| 253 | - sqlite3_set_authorizer(g.db, 0, 0); | |
| 264 | + report_unrestrict_sql(); | |
| 254 | 265 | return zErr; |
| 255 | 266 | } |
| 256 | 267 | |
| 257 | 268 | /* |
| 258 | 269 | ** WEBPAGE: /rptsql |
| @@ -963,25 +974,24 @@ | ||
| 963 | 974 | output_color_key(zClrKey, 1, |
| 964 | 975 | "border=\"0\" cellpadding=\"3\" cellspacing=\"0\" class=\"report\""); |
| 965 | 976 | @ <table border="1" cellpadding="2" cellspacing="0" class="report"> |
| 966 | 977 | sState.rn = rn; |
| 967 | 978 | sState.nCount = 0; |
| 968 | - (void)fossil_localtime(0); /* initialize the g.fTimeFormat variable */ | |
| 969 | - sqlite3_set_authorizer(g.db, report_query_authorizer, (void*)&zErr1); | |
| 979 | + report_restrict_sql(&zErr1); | |
| 970 | 980 | sqlite3_exec_readonly(g.db, zSql, generate_html, &sState, &zErr2); |
| 971 | - sqlite3_set_authorizer(g.db, 0, 0); | |
| 981 | + report_unrestrict_sql(); | |
| 972 | 982 | @ </table> |
| 973 | 983 | if( zErr1 ){ |
| 974 | 984 | @ <p class="reportError">Error: %h(zErr1)</p> |
| 975 | 985 | }else if( zErr2 ){ |
| 976 | 986 | @ <p class="reportError">Error: %h(zErr2)</p> |
| 977 | 987 | } |
| 978 | 988 | style_footer(); |
| 979 | 989 | }else{ |
| 980 | - sqlite3_set_authorizer(g.db, report_query_authorizer, (void*)&zErr1); | |
| 990 | + report_restrict_sql(&zErr1); | |
| 981 | 991 | sqlite3_exec_readonly(g.db, zSql, output_tab_separated, &count, &zErr2); |
| 982 | - sqlite3_set_authorizer(g.db, 0, 0); | |
| 992 | + report_unrestrict_sql(); | |
| 983 | 993 | cgi_set_content_type("text/plain"); |
| 984 | 994 | } |
| 985 | 995 | } |
| 986 | 996 | |
| 987 | 997 | /* |
| @@ -1137,12 +1147,12 @@ | ||
| 1137 | 1147 | zSql = mprintf("SELECT * FROM (%s) WHERE %s",zSql,zFilter); |
| 1138 | 1148 | } |
| 1139 | 1149 | count = 0; |
| 1140 | 1150 | tktEncode = enc; |
| 1141 | 1151 | zSep = zSepIn; |
| 1142 | - sqlite3_set_authorizer(g.db, report_query_authorizer, (void*)&zErr1); | |
| 1152 | + report_restrict_sql(&zErr1); | |
| 1143 | 1153 | sqlite3_exec_readonly(g.db, zSql, output_separated_file, &count, &zErr2); |
| 1144 | - sqlite3_set_authorizer(g.db, 0, 0); | |
| 1154 | + report_unrestrict_sql(); | |
| 1145 | 1155 | if( zFilter ){ |
| 1146 | 1156 | free(zSql); |
| 1147 | 1157 | } |
| 1148 | 1158 | } |
| 1149 | 1159 |
| --- src/report.c | |
| +++ src/report.c | |
| @@ -198,10 +198,21 @@ | |
| 198 | } |
| 199 | } |
| 200 | return rc; |
| 201 | } |
| 202 | |
| 203 | |
| 204 | /* |
| 205 | ** Check the given SQL to see if is a valid query that does not |
| 206 | ** attempt to do anything dangerous. Return 0 on success and a |
| 207 | ** pointer to an error message string (obtained from malloc) if |
| @@ -237,11 +248,11 @@ | |
| 237 | } |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | /* Compile the statement and check for illegal accesses or syntax errors. */ |
| 242 | sqlite3_set_authorizer(g.db, report_query_authorizer, (void*)&zErr); |
| 243 | rc = sqlite3_prepare(g.db, zSql, -1, &pStmt, &zTail); |
| 244 | if( rc!=SQLITE_OK ){ |
| 245 | zErr = mprintf("Syntax error: %s", sqlite3_errmsg(g.db)); |
| 246 | } |
| 247 | if( !sqlite3_stmt_readonly(pStmt) ){ |
| @@ -248,11 +259,11 @@ | |
| 248 | zErr = mprintf("SQL must not modify the database"); |
| 249 | } |
| 250 | if( pStmt ){ |
| 251 | sqlite3_finalize(pStmt); |
| 252 | } |
| 253 | sqlite3_set_authorizer(g.db, 0, 0); |
| 254 | return zErr; |
| 255 | } |
| 256 | |
| 257 | /* |
| 258 | ** WEBPAGE: /rptsql |
| @@ -963,25 +974,24 @@ | |
| 963 | output_color_key(zClrKey, 1, |
| 964 | "border=\"0\" cellpadding=\"3\" cellspacing=\"0\" class=\"report\""); |
| 965 | @ <table border="1" cellpadding="2" cellspacing="0" class="report"> |
| 966 | sState.rn = rn; |
| 967 | sState.nCount = 0; |
| 968 | (void)fossil_localtime(0); /* initialize the g.fTimeFormat variable */ |
| 969 | sqlite3_set_authorizer(g.db, report_query_authorizer, (void*)&zErr1); |
| 970 | sqlite3_exec_readonly(g.db, zSql, generate_html, &sState, &zErr2); |
| 971 | sqlite3_set_authorizer(g.db, 0, 0); |
| 972 | @ </table> |
| 973 | if( zErr1 ){ |
| 974 | @ <p class="reportError">Error: %h(zErr1)</p> |
| 975 | }else if( zErr2 ){ |
| 976 | @ <p class="reportError">Error: %h(zErr2)</p> |
| 977 | } |
| 978 | style_footer(); |
| 979 | }else{ |
| 980 | sqlite3_set_authorizer(g.db, report_query_authorizer, (void*)&zErr1); |
| 981 | sqlite3_exec_readonly(g.db, zSql, output_tab_separated, &count, &zErr2); |
| 982 | sqlite3_set_authorizer(g.db, 0, 0); |
| 983 | cgi_set_content_type("text/plain"); |
| 984 | } |
| 985 | } |
| 986 | |
| 987 | /* |
| @@ -1137,12 +1147,12 @@ | |
| 1137 | zSql = mprintf("SELECT * FROM (%s) WHERE %s",zSql,zFilter); |
| 1138 | } |
| 1139 | count = 0; |
| 1140 | tktEncode = enc; |
| 1141 | zSep = zSepIn; |
| 1142 | sqlite3_set_authorizer(g.db, report_query_authorizer, (void*)&zErr1); |
| 1143 | sqlite3_exec_readonly(g.db, zSql, output_separated_file, &count, &zErr2); |
| 1144 | sqlite3_set_authorizer(g.db, 0, 0); |
| 1145 | if( zFilter ){ |
| 1146 | free(zSql); |
| 1147 | } |
| 1148 | } |
| 1149 |
| --- src/report.c | |
| +++ src/report.c | |
| @@ -198,10 +198,21 @@ | |
| 198 | } |
| 199 | } |
| 200 | return rc; |
| 201 | } |
| 202 | |
| 203 | /* |
| 204 | ** Activate the query authorizer |
| 205 | */ |
| 206 | static void report_restrict_sql(char **pzErr){ |
| 207 | (void)fossil_localtime(0); |
| 208 | sqlite3_set_authorizer(g.db, report_query_authorizer, (void*)pzErr); |
| 209 | } |
| 210 | static void report_unrestrict_sql(void){ |
| 211 | sqlite3_set_authorizer(g.db, 0, 0); |
| 212 | } |
| 213 | |
| 214 | |
| 215 | /* |
| 216 | ** Check the given SQL to see if is a valid query that does not |
| 217 | ** attempt to do anything dangerous. Return 0 on success and a |
| 218 | ** pointer to an error message string (obtained from malloc) if |
| @@ -237,11 +248,11 @@ | |
| 248 | } |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | /* Compile the statement and check for illegal accesses or syntax errors. */ |
| 253 | report_restrict_sql(&zErr); |
| 254 | rc = sqlite3_prepare(g.db, zSql, -1, &pStmt, &zTail); |
| 255 | if( rc!=SQLITE_OK ){ |
| 256 | zErr = mprintf("Syntax error: %s", sqlite3_errmsg(g.db)); |
| 257 | } |
| 258 | if( !sqlite3_stmt_readonly(pStmt) ){ |
| @@ -248,11 +259,11 @@ | |
| 259 | zErr = mprintf("SQL must not modify the database"); |
| 260 | } |
| 261 | if( pStmt ){ |
| 262 | sqlite3_finalize(pStmt); |
| 263 | } |
| 264 | report_unrestrict_sql(); |
| 265 | return zErr; |
| 266 | } |
| 267 | |
| 268 | /* |
| 269 | ** WEBPAGE: /rptsql |
| @@ -963,25 +974,24 @@ | |
| 974 | output_color_key(zClrKey, 1, |
| 975 | "border=\"0\" cellpadding=\"3\" cellspacing=\"0\" class=\"report\""); |
| 976 | @ <table border="1" cellpadding="2" cellspacing="0" class="report"> |
| 977 | sState.rn = rn; |
| 978 | sState.nCount = 0; |
| 979 | report_restrict_sql(&zErr1); |
| 980 | sqlite3_exec_readonly(g.db, zSql, generate_html, &sState, &zErr2); |
| 981 | report_unrestrict_sql(); |
| 982 | @ </table> |
| 983 | if( zErr1 ){ |
| 984 | @ <p class="reportError">Error: %h(zErr1)</p> |
| 985 | }else if( zErr2 ){ |
| 986 | @ <p class="reportError">Error: %h(zErr2)</p> |
| 987 | } |
| 988 | style_footer(); |
| 989 | }else{ |
| 990 | report_restrict_sql(&zErr1); |
| 991 | sqlite3_exec_readonly(g.db, zSql, output_tab_separated, &count, &zErr2); |
| 992 | report_unrestrict_sql(); |
| 993 | cgi_set_content_type("text/plain"); |
| 994 | } |
| 995 | } |
| 996 | |
| 997 | /* |
| @@ -1137,12 +1147,12 @@ | |
| 1147 | zSql = mprintf("SELECT * FROM (%s) WHERE %s",zSql,zFilter); |
| 1148 | } |
| 1149 | count = 0; |
| 1150 | tktEncode = enc; |
| 1151 | zSep = zSepIn; |
| 1152 | report_restrict_sql(&zErr1); |
| 1153 | sqlite3_exec_readonly(g.db, zSql, output_separated_file, &count, &zErr2); |
| 1154 | report_unrestrict_sql(); |
| 1155 | if( zFilter ){ |
| 1156 | free(zSql); |
| 1157 | } |
| 1158 | } |
| 1159 |
+49
-34
| --- src/sha1.c | ||
| +++ src/sha1.c | ||
| @@ -27,60 +27,79 @@ | ||
| 27 | 27 | * blk0() and blk() perform the initial expand. |
| 28 | 28 | * I got the idea of expanding during the round function from SSLeay |
| 29 | 29 | * |
| 30 | 30 | * blk0le() for little-endian and blk0be() for big-endian. |
| 31 | 31 | */ |
| 32 | -#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits)))) | |
| 33 | -#define blk0le(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \ | |
| 34 | - |(rol(block->l[i],8)&0x00FF00FF)) | |
| 35 | -#define blk0be(i) block->l[i] | |
| 36 | -#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \ | |
| 37 | - ^block->l[(i+2)&15]^block->l[i&15],1)) | |
| 32 | +#if __GNUC__ && (defined(__i386__) || defined(__x86_64__)) | |
| 33 | +/* | |
| 34 | + * GCC by itself only generates left rotates. Use right rotates if | |
| 35 | + * possible to be kinder to dinky implementations with iterative rotate | |
| 36 | + * instructions. | |
| 37 | + */ | |
| 38 | +#define SHA_ROT(op, x, k) \ | |
| 39 | + ({ unsigned int y; asm(op " %1,%0" : "=r" (y) : "I" (k), "0" (x)); y; }) | |
| 40 | +#define rol(x,k) SHA_ROT("roll", x, k) | |
| 41 | +#define ror(x,k) SHA_ROT("rorl", x, k) | |
| 42 | + | |
| 43 | +#else | |
| 44 | +/* Generic C equivalent */ | |
| 45 | +#define SHA_ROT(x,l,r) ((x) << (l) | (x) >> (r)) | |
| 46 | +#define rol(x,k) SHA_ROT(x,k,32-(k)) | |
| 47 | +#define ror(x,k) SHA_ROT(x,32-(k),k) | |
| 48 | +#endif | |
| 49 | + | |
| 50 | + | |
| 51 | +#define blk0le(i) (block[i] = (ror(block[i],8)&0xFF00FF00) \ | |
| 52 | + |(rol(block[i],8)&0x00FF00FF)) | |
| 53 | +#define blk0be(i) block[i] | |
| 54 | +#define blk(i) (block[i&15] = rol(block[(i+13)&15]^block[(i+8)&15] \ | |
| 55 | + ^block[(i+2)&15]^block[i&15],1)) | |
| 38 | 56 | |
| 39 | 57 | /* |
| 40 | 58 | * (R0+R1), R2, R3, R4 are the different operations (rounds) used in SHA1 |
| 41 | 59 | * |
| 42 | 60 | * Rl0() for little-endian and Rb0() for big-endian. Endianness is |
| 43 | 61 | * determined at run-time. |
| 44 | 62 | */ |
| 45 | 63 | #define Rl0(v,w,x,y,z,i) \ |
| 46 | - z+=((w&(x^y))^y)+blk0le(i)+0x5A827999+rol(v,5);w=rol(w,30); | |
| 64 | + z+=((w&(x^y))^y)+blk0le(i)+0x5A827999+rol(v,5);w=ror(w,2); | |
| 47 | 65 | #define Rb0(v,w,x,y,z,i) \ |
| 48 | - z+=((w&(x^y))^y)+blk0be(i)+0x5A827999+rol(v,5);w=rol(w,30); | |
| 66 | + z+=((w&(x^y))^y)+blk0be(i)+0x5A827999+rol(v,5);w=ror(w,2); | |
| 49 | 67 | #define R1(v,w,x,y,z,i) \ |
| 50 | - z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30); | |
| 68 | + z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=ror(w,2); | |
| 51 | 69 | #define R2(v,w,x,y,z,i) \ |
| 52 | - z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30); | |
| 70 | + z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=ror(w,2); | |
| 53 | 71 | #define R3(v,w,x,y,z,i) \ |
| 54 | - z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30); | |
| 72 | + z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=ror(w,2); | |
| 55 | 73 | #define R4(v,w,x,y,z,i) \ |
| 56 | - z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30); | |
| 57 | - | |
| 58 | -typedef union { | |
| 59 | - unsigned char c[64]; | |
| 60 | - unsigned int l[16]; | |
| 61 | -} CHAR64LONG16; | |
| 74 | + z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=ror(w,2); | |
| 62 | 75 | |
| 63 | 76 | /* |
| 64 | 77 | * Hash a single 512-bit block. This is the core of the algorithm. |
| 65 | 78 | */ |
| 79 | +#define a qq[0] | |
| 80 | +#define b qq[1] | |
| 81 | +#define c qq[2] | |
| 82 | +#define d qq[3] | |
| 83 | +#define e qq[4] | |
| 84 | + | |
| 66 | 85 | void SHA1Transform(unsigned int state[5], const unsigned char buffer[64]) |
| 67 | 86 | { |
| 68 | - unsigned int a, b, c, d, e; | |
| 69 | - CHAR64LONG16 *block; | |
| 87 | + unsigned int qq[5]; // a, b, c, d, e; | |
| 70 | 88 | static int one = 1; |
| 71 | - CHAR64LONG16 workspace; | |
| 72 | - | |
| 73 | - block = &workspace; | |
| 74 | - (void)memcpy(block, buffer, 64); | |
| 89 | + unsigned int block[16]; | |
| 90 | + memcpy(block, buffer, 64); | |
| 91 | + memcpy(qq,state,5*sizeof(unsigned int)); | |
| 75 | 92 | |
| 76 | 93 | /* Copy context->state[] to working vars */ |
| 94 | + /* | |
| 77 | 95 | a = state[0]; |
| 78 | 96 | b = state[1]; |
| 79 | 97 | c = state[2]; |
| 80 | 98 | d = state[3]; |
| 81 | 99 | e = state[4]; |
| 100 | + */ | |
| 82 | 101 | |
| 83 | 102 | /* 4 rounds of 20 operations each. Loop unrolled. */ |
| 84 | 103 | if( 1 == *(unsigned char*)&one ){ |
| 85 | 104 | Rl0(a,b,c,d,e, 0); Rl0(e,a,b,c,d, 1); Rl0(d,e,a,b,c, 2); Rl0(c,d,e,a,b, 3); |
| 86 | 105 | Rl0(b,c,d,e,a, 4); Rl0(a,b,c,d,e, 5); Rl0(e,a,b,c,d, 6); Rl0(d,e,a,b,c, 7); |
| @@ -113,13 +132,10 @@ | ||
| 113 | 132 | state[0] += a; |
| 114 | 133 | state[1] += b; |
| 115 | 134 | state[2] += c; |
| 116 | 135 | state[3] += d; |
| 117 | 136 | state[4] += e; |
| 118 | - | |
| 119 | - /* Wipe variables */ | |
| 120 | - a = b = c = d = e = 0; | |
| 121 | 137 | } |
| 122 | 138 | |
| 123 | 139 | |
| 124 | 140 | /* |
| 125 | 141 | * SHA1Init - Initialize new context |
| @@ -192,18 +208,17 @@ | ||
| 192 | 208 | ** digest is stored in the first 20 bytes. zBuf should |
| 193 | 209 | ** be "char zBuf[41]". |
| 194 | 210 | */ |
| 195 | 211 | static void DigestToBase16(unsigned char *digest, char *zBuf){ |
| 196 | 212 | static char const zEncode[] = "0123456789abcdef"; |
| 197 | - int i, j; | |
| 198 | - | |
| 199 | - for(j=i=0; i<20; i++){ | |
| 200 | - int a = digest[i]; | |
| 201 | - zBuf[j++] = zEncode[(a>>4)&0xf]; | |
| 202 | - zBuf[j++] = zEncode[a & 0xf]; | |
| 203 | - } | |
| 204 | - zBuf[j] = 0; | |
| 213 | + int ix; | |
| 214 | + | |
| 215 | + for(ix=0; ix<20; ix++){ | |
| 216 | + *zBuf++ = zEncode[(*digest>>4)&0xf]; | |
| 217 | + *zBuf++ = zEncode[*digest++ & 0xf]; | |
| 218 | + } | |
| 219 | + *zBuf = '\0'; | |
| 205 | 220 | } |
| 206 | 221 | |
| 207 | 222 | /* |
| 208 | 223 | ** The state of a incremental SHA1 checksum computation. Only one |
| 209 | 224 | ** such computation can be underway at a time, of course. |
| 210 | 225 |
| --- src/sha1.c | |
| +++ src/sha1.c | |
| @@ -27,60 +27,79 @@ | |
| 27 | * blk0() and blk() perform the initial expand. |
| 28 | * I got the idea of expanding during the round function from SSLeay |
| 29 | * |
| 30 | * blk0le() for little-endian and blk0be() for big-endian. |
| 31 | */ |
| 32 | #define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits)))) |
| 33 | #define blk0le(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \ |
| 34 | |(rol(block->l[i],8)&0x00FF00FF)) |
| 35 | #define blk0be(i) block->l[i] |
| 36 | #define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \ |
| 37 | ^block->l[(i+2)&15]^block->l[i&15],1)) |
| 38 | |
| 39 | /* |
| 40 | * (R0+R1), R2, R3, R4 are the different operations (rounds) used in SHA1 |
| 41 | * |
| 42 | * Rl0() for little-endian and Rb0() for big-endian. Endianness is |
| 43 | * determined at run-time. |
| 44 | */ |
| 45 | #define Rl0(v,w,x,y,z,i) \ |
| 46 | z+=((w&(x^y))^y)+blk0le(i)+0x5A827999+rol(v,5);w=rol(w,30); |
| 47 | #define Rb0(v,w,x,y,z,i) \ |
| 48 | z+=((w&(x^y))^y)+blk0be(i)+0x5A827999+rol(v,5);w=rol(w,30); |
| 49 | #define R1(v,w,x,y,z,i) \ |
| 50 | z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30); |
| 51 | #define R2(v,w,x,y,z,i) \ |
| 52 | z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30); |
| 53 | #define R3(v,w,x,y,z,i) \ |
| 54 | z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30); |
| 55 | #define R4(v,w,x,y,z,i) \ |
| 56 | z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30); |
| 57 | |
| 58 | typedef union { |
| 59 | unsigned char c[64]; |
| 60 | unsigned int l[16]; |
| 61 | } CHAR64LONG16; |
| 62 | |
| 63 | /* |
| 64 | * Hash a single 512-bit block. This is the core of the algorithm. |
| 65 | */ |
| 66 | void SHA1Transform(unsigned int state[5], const unsigned char buffer[64]) |
| 67 | { |
| 68 | unsigned int a, b, c, d, e; |
| 69 | CHAR64LONG16 *block; |
| 70 | static int one = 1; |
| 71 | CHAR64LONG16 workspace; |
| 72 | |
| 73 | block = &workspace; |
| 74 | (void)memcpy(block, buffer, 64); |
| 75 | |
| 76 | /* Copy context->state[] to working vars */ |
| 77 | a = state[0]; |
| 78 | b = state[1]; |
| 79 | c = state[2]; |
| 80 | d = state[3]; |
| 81 | e = state[4]; |
| 82 | |
| 83 | /* 4 rounds of 20 operations each. Loop unrolled. */ |
| 84 | if( 1 == *(unsigned char*)&one ){ |
| 85 | Rl0(a,b,c,d,e, 0); Rl0(e,a,b,c,d, 1); Rl0(d,e,a,b,c, 2); Rl0(c,d,e,a,b, 3); |
| 86 | Rl0(b,c,d,e,a, 4); Rl0(a,b,c,d,e, 5); Rl0(e,a,b,c,d, 6); Rl0(d,e,a,b,c, 7); |
| @@ -113,13 +132,10 @@ | |
| 113 | state[0] += a; |
| 114 | state[1] += b; |
| 115 | state[2] += c; |
| 116 | state[3] += d; |
| 117 | state[4] += e; |
| 118 | |
| 119 | /* Wipe variables */ |
| 120 | a = b = c = d = e = 0; |
| 121 | } |
| 122 | |
| 123 | |
| 124 | /* |
| 125 | * SHA1Init - Initialize new context |
| @@ -192,18 +208,17 @@ | |
| 192 | ** digest is stored in the first 20 bytes. zBuf should |
| 193 | ** be "char zBuf[41]". |
| 194 | */ |
| 195 | static void DigestToBase16(unsigned char *digest, char *zBuf){ |
| 196 | static char const zEncode[] = "0123456789abcdef"; |
| 197 | int i, j; |
| 198 | |
| 199 | for(j=i=0; i<20; i++){ |
| 200 | int a = digest[i]; |
| 201 | zBuf[j++] = zEncode[(a>>4)&0xf]; |
| 202 | zBuf[j++] = zEncode[a & 0xf]; |
| 203 | } |
| 204 | zBuf[j] = 0; |
| 205 | } |
| 206 | |
| 207 | /* |
| 208 | ** The state of a incremental SHA1 checksum computation. Only one |
| 209 | ** such computation can be underway at a time, of course. |
| 210 |
| --- src/sha1.c | |
| +++ src/sha1.c | |
| @@ -27,60 +27,79 @@ | |
| 27 | * blk0() and blk() perform the initial expand. |
| 28 | * I got the idea of expanding during the round function from SSLeay |
| 29 | * |
| 30 | * blk0le() for little-endian and blk0be() for big-endian. |
| 31 | */ |
| 32 | #if __GNUC__ && (defined(__i386__) || defined(__x86_64__)) |
| 33 | /* |
| 34 | * GCC by itself only generates left rotates. Use right rotates if |
| 35 | * possible to be kinder to dinky implementations with iterative rotate |
| 36 | * instructions. |
| 37 | */ |
| 38 | #define SHA_ROT(op, x, k) \ |
| 39 | ({ unsigned int y; asm(op " %1,%0" : "=r" (y) : "I" (k), "0" (x)); y; }) |
| 40 | #define rol(x,k) SHA_ROT("roll", x, k) |
| 41 | #define ror(x,k) SHA_ROT("rorl", x, k) |
| 42 | |
| 43 | #else |
| 44 | /* Generic C equivalent */ |
| 45 | #define SHA_ROT(x,l,r) ((x) << (l) | (x) >> (r)) |
| 46 | #define rol(x,k) SHA_ROT(x,k,32-(k)) |
| 47 | #define ror(x,k) SHA_ROT(x,32-(k),k) |
| 48 | #endif |
| 49 | |
| 50 | |
| 51 | #define blk0le(i) (block[i] = (ror(block[i],8)&0xFF00FF00) \ |
| 52 | |(rol(block[i],8)&0x00FF00FF)) |
| 53 | #define blk0be(i) block[i] |
| 54 | #define blk(i) (block[i&15] = rol(block[(i+13)&15]^block[(i+8)&15] \ |
| 55 | ^block[(i+2)&15]^block[i&15],1)) |
| 56 | |
| 57 | /* |
| 58 | * (R0+R1), R2, R3, R4 are the different operations (rounds) used in SHA1 |
| 59 | * |
| 60 | * Rl0() for little-endian and Rb0() for big-endian. Endianness is |
| 61 | * determined at run-time. |
| 62 | */ |
| 63 | #define Rl0(v,w,x,y,z,i) \ |
| 64 | z+=((w&(x^y))^y)+blk0le(i)+0x5A827999+rol(v,5);w=ror(w,2); |
| 65 | #define Rb0(v,w,x,y,z,i) \ |
| 66 | z+=((w&(x^y))^y)+blk0be(i)+0x5A827999+rol(v,5);w=ror(w,2); |
| 67 | #define R1(v,w,x,y,z,i) \ |
| 68 | z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=ror(w,2); |
| 69 | #define R2(v,w,x,y,z,i) \ |
| 70 | z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=ror(w,2); |
| 71 | #define R3(v,w,x,y,z,i) \ |
| 72 | z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=ror(w,2); |
| 73 | #define R4(v,w,x,y,z,i) \ |
| 74 | z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=ror(w,2); |
| 75 | |
| 76 | /* |
| 77 | * Hash a single 512-bit block. This is the core of the algorithm. |
| 78 | */ |
| 79 | #define a qq[0] |
| 80 | #define b qq[1] |
| 81 | #define c qq[2] |
| 82 | #define d qq[3] |
| 83 | #define e qq[4] |
| 84 | |
| 85 | void SHA1Transform(unsigned int state[5], const unsigned char buffer[64]) |
| 86 | { |
| 87 | unsigned int qq[5]; // a, b, c, d, e; |
| 88 | static int one = 1; |
| 89 | unsigned int block[16]; |
| 90 | memcpy(block, buffer, 64); |
| 91 | memcpy(qq,state,5*sizeof(unsigned int)); |
| 92 | |
| 93 | /* Copy context->state[] to working vars */ |
| 94 | /* |
| 95 | a = state[0]; |
| 96 | b = state[1]; |
| 97 | c = state[2]; |
| 98 | d = state[3]; |
| 99 | e = state[4]; |
| 100 | */ |
| 101 | |
| 102 | /* 4 rounds of 20 operations each. Loop unrolled. */ |
| 103 | if( 1 == *(unsigned char*)&one ){ |
| 104 | Rl0(a,b,c,d,e, 0); Rl0(e,a,b,c,d, 1); Rl0(d,e,a,b,c, 2); Rl0(c,d,e,a,b, 3); |
| 105 | Rl0(b,c,d,e,a, 4); Rl0(a,b,c,d,e, 5); Rl0(e,a,b,c,d, 6); Rl0(d,e,a,b,c, 7); |
| @@ -113,13 +132,10 @@ | |
| 132 | state[0] += a; |
| 133 | state[1] += b; |
| 134 | state[2] += c; |
| 135 | state[3] += d; |
| 136 | state[4] += e; |
| 137 | } |
| 138 | |
| 139 | |
| 140 | /* |
| 141 | * SHA1Init - Initialize new context |
| @@ -192,18 +208,17 @@ | |
| 208 | ** digest is stored in the first 20 bytes. zBuf should |
| 209 | ** be "char zBuf[41]". |
| 210 | */ |
| 211 | static void DigestToBase16(unsigned char *digest, char *zBuf){ |
| 212 | static char const zEncode[] = "0123456789abcdef"; |
| 213 | int ix; |
| 214 | |
| 215 | for(ix=0; ix<20; ix++){ |
| 216 | *zBuf++ = zEncode[(*digest>>4)&0xf]; |
| 217 | *zBuf++ = zEncode[*digest++ & 0xf]; |
| 218 | } |
| 219 | *zBuf = '\0'; |
| 220 | } |
| 221 | |
| 222 | /* |
| 223 | ** The state of a incremental SHA1 checksum computation. Only one |
| 224 | ** such computation can be underway at a time, of course. |
| 225 |
+49
-34
| --- src/sha1.c | ||
| +++ src/sha1.c | ||
| @@ -27,60 +27,79 @@ | ||
| 27 | 27 | * blk0() and blk() perform the initial expand. |
| 28 | 28 | * I got the idea of expanding during the round function from SSLeay |
| 29 | 29 | * |
| 30 | 30 | * blk0le() for little-endian and blk0be() for big-endian. |
| 31 | 31 | */ |
| 32 | -#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits)))) | |
| 33 | -#define blk0le(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \ | |
| 34 | - |(rol(block->l[i],8)&0x00FF00FF)) | |
| 35 | -#define blk0be(i) block->l[i] | |
| 36 | -#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \ | |
| 37 | - ^block->l[(i+2)&15]^block->l[i&15],1)) | |
| 32 | +#if __GNUC__ && (defined(__i386__) || defined(__x86_64__)) | |
| 33 | +/* | |
| 34 | + * GCC by itself only generates left rotates. Use right rotates if | |
| 35 | + * possible to be kinder to dinky implementations with iterative rotate | |
| 36 | + * instructions. | |
| 37 | + */ | |
| 38 | +#define SHA_ROT(op, x, k) \ | |
| 39 | + ({ unsigned int y; asm(op " %1,%0" : "=r" (y) : "I" (k), "0" (x)); y; }) | |
| 40 | +#define rol(x,k) SHA_ROT("roll", x, k) | |
| 41 | +#define ror(x,k) SHA_ROT("rorl", x, k) | |
| 42 | + | |
| 43 | +#else | |
| 44 | +/* Generic C equivalent */ | |
| 45 | +#define SHA_ROT(x,l,r) ((x) << (l) | (x) >> (r)) | |
| 46 | +#define rol(x,k) SHA_ROT(x,k,32-(k)) | |
| 47 | +#define ror(x,k) SHA_ROT(x,32-(k),k) | |
| 48 | +#endif | |
| 49 | + | |
| 50 | + | |
| 51 | +#define blk0le(i) (block[i] = (ror(block[i],8)&0xFF00FF00) \ | |
| 52 | + |(rol(block[i],8)&0x00FF00FF)) | |
| 53 | +#define blk0be(i) block[i] | |
| 54 | +#define blk(i) (block[i&15] = rol(block[(i+13)&15]^block[(i+8)&15] \ | |
| 55 | + ^block[(i+2)&15]^block[i&15],1)) | |
| 38 | 56 | |
| 39 | 57 | /* |
| 40 | 58 | * (R0+R1), R2, R3, R4 are the different operations (rounds) used in SHA1 |
| 41 | 59 | * |
| 42 | 60 | * Rl0() for little-endian and Rb0() for big-endian. Endianness is |
| 43 | 61 | * determined at run-time. |
| 44 | 62 | */ |
| 45 | 63 | #define Rl0(v,w,x,y,z,i) \ |
| 46 | - z+=((w&(x^y))^y)+blk0le(i)+0x5A827999+rol(v,5);w=rol(w,30); | |
| 64 | + z+=((w&(x^y))^y)+blk0le(i)+0x5A827999+rol(v,5);w=ror(w,2); | |
| 47 | 65 | #define Rb0(v,w,x,y,z,i) \ |
| 48 | - z+=((w&(x^y))^y)+blk0be(i)+0x5A827999+rol(v,5);w=rol(w,30); | |
| 66 | + z+=((w&(x^y))^y)+blk0be(i)+0x5A827999+rol(v,5);w=ror(w,2); | |
| 49 | 67 | #define R1(v,w,x,y,z,i) \ |
| 50 | - z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30); | |
| 68 | + z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=ror(w,2); | |
| 51 | 69 | #define R2(v,w,x,y,z,i) \ |
| 52 | - z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30); | |
| 70 | + z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=ror(w,2); | |
| 53 | 71 | #define R3(v,w,x,y,z,i) \ |
| 54 | - z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30); | |
| 72 | + z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=ror(w,2); | |
| 55 | 73 | #define R4(v,w,x,y,z,i) \ |
| 56 | - z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30); | |
| 57 | - | |
| 58 | -typedef union { | |
| 59 | - unsigned char c[64]; | |
| 60 | - unsigned int l[16]; | |
| 61 | -} CHAR64LONG16; | |
| 74 | + z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=ror(w,2); | |
| 62 | 75 | |
| 63 | 76 | /* |
| 64 | 77 | * Hash a single 512-bit block. This is the core of the algorithm. |
| 65 | 78 | */ |
| 79 | +#define a qq[0] | |
| 80 | +#define b qq[1] | |
| 81 | +#define c qq[2] | |
| 82 | +#define d qq[3] | |
| 83 | +#define e qq[4] | |
| 84 | + | |
| 66 | 85 | void SHA1Transform(unsigned int state[5], const unsigned char buffer[64]) |
| 67 | 86 | { |
| 68 | - unsigned int a, b, c, d, e; | |
| 69 | - CHAR64LONG16 *block; | |
| 87 | + unsigned int qq[5]; // a, b, c, d, e; | |
| 70 | 88 | static int one = 1; |
| 71 | - CHAR64LONG16 workspace; | |
| 72 | - | |
| 73 | - block = &workspace; | |
| 74 | - (void)memcpy(block, buffer, 64); | |
| 89 | + unsigned int block[16]; | |
| 90 | + memcpy(block, buffer, 64); | |
| 91 | + memcpy(qq,state,5*sizeof(unsigned int)); | |
| 75 | 92 | |
| 76 | 93 | /* Copy context->state[] to working vars */ |
| 94 | + /* | |
| 77 | 95 | a = state[0]; |
| 78 | 96 | b = state[1]; |
| 79 | 97 | c = state[2]; |
| 80 | 98 | d = state[3]; |
| 81 | 99 | e = state[4]; |
| 100 | + */ | |
| 82 | 101 | |
| 83 | 102 | /* 4 rounds of 20 operations each. Loop unrolled. */ |
| 84 | 103 | if( 1 == *(unsigned char*)&one ){ |
| 85 | 104 | Rl0(a,b,c,d,e, 0); Rl0(e,a,b,c,d, 1); Rl0(d,e,a,b,c, 2); Rl0(c,d,e,a,b, 3); |
| 86 | 105 | Rl0(b,c,d,e,a, 4); Rl0(a,b,c,d,e, 5); Rl0(e,a,b,c,d, 6); Rl0(d,e,a,b,c, 7); |
| @@ -113,13 +132,10 @@ | ||
| 113 | 132 | state[0] += a; |
| 114 | 133 | state[1] += b; |
| 115 | 134 | state[2] += c; |
| 116 | 135 | state[3] += d; |
| 117 | 136 | state[4] += e; |
| 118 | - | |
| 119 | - /* Wipe variables */ | |
| 120 | - a = b = c = d = e = 0; | |
| 121 | 137 | } |
| 122 | 138 | |
| 123 | 139 | |
| 124 | 140 | /* |
| 125 | 141 | * SHA1Init - Initialize new context |
| @@ -192,18 +208,17 @@ | ||
| 192 | 208 | ** digest is stored in the first 20 bytes. zBuf should |
| 193 | 209 | ** be "char zBuf[41]". |
| 194 | 210 | */ |
| 195 | 211 | static void DigestToBase16(unsigned char *digest, char *zBuf){ |
| 196 | 212 | static char const zEncode[] = "0123456789abcdef"; |
| 197 | - int i, j; | |
| 198 | - | |
| 199 | - for(j=i=0; i<20; i++){ | |
| 200 | - int a = digest[i]; | |
| 201 | - zBuf[j++] = zEncode[(a>>4)&0xf]; | |
| 202 | - zBuf[j++] = zEncode[a & 0xf]; | |
| 203 | - } | |
| 204 | - zBuf[j] = 0; | |
| 213 | + int ix; | |
| 214 | + | |
| 215 | + for(ix=0; ix<20; ix++){ | |
| 216 | + *zBuf++ = zEncode[(*digest>>4)&0xf]; | |
| 217 | + *zBuf++ = zEncode[*digest++ & 0xf]; | |
| 218 | + } | |
| 219 | + *zBuf = '\0'; | |
| 205 | 220 | } |
| 206 | 221 | |
| 207 | 222 | /* |
| 208 | 223 | ** The state of a incremental SHA1 checksum computation. Only one |
| 209 | 224 | ** such computation can be underway at a time, of course. |
| 210 | 225 |
| --- src/sha1.c | |
| +++ src/sha1.c | |
| @@ -27,60 +27,79 @@ | |
| 27 | * blk0() and blk() perform the initial expand. |
| 28 | * I got the idea of expanding during the round function from SSLeay |
| 29 | * |
| 30 | * blk0le() for little-endian and blk0be() for big-endian. |
| 31 | */ |
| 32 | #define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits)))) |
| 33 | #define blk0le(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \ |
| 34 | |(rol(block->l[i],8)&0x00FF00FF)) |
| 35 | #define blk0be(i) block->l[i] |
| 36 | #define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \ |
| 37 | ^block->l[(i+2)&15]^block->l[i&15],1)) |
| 38 | |
| 39 | /* |
| 40 | * (R0+R1), R2, R3, R4 are the different operations (rounds) used in SHA1 |
| 41 | * |
| 42 | * Rl0() for little-endian and Rb0() for big-endian. Endianness is |
| 43 | * determined at run-time. |
| 44 | */ |
| 45 | #define Rl0(v,w,x,y,z,i) \ |
| 46 | z+=((w&(x^y))^y)+blk0le(i)+0x5A827999+rol(v,5);w=rol(w,30); |
| 47 | #define Rb0(v,w,x,y,z,i) \ |
| 48 | z+=((w&(x^y))^y)+blk0be(i)+0x5A827999+rol(v,5);w=rol(w,30); |
| 49 | #define R1(v,w,x,y,z,i) \ |
| 50 | z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30); |
| 51 | #define R2(v,w,x,y,z,i) \ |
| 52 | z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30); |
| 53 | #define R3(v,w,x,y,z,i) \ |
| 54 | z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30); |
| 55 | #define R4(v,w,x,y,z,i) \ |
| 56 | z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30); |
| 57 | |
| 58 | typedef union { |
| 59 | unsigned char c[64]; |
| 60 | unsigned int l[16]; |
| 61 | } CHAR64LONG16; |
| 62 | |
| 63 | /* |
| 64 | * Hash a single 512-bit block. This is the core of the algorithm. |
| 65 | */ |
| 66 | void SHA1Transform(unsigned int state[5], const unsigned char buffer[64]) |
| 67 | { |
| 68 | unsigned int a, b, c, d, e; |
| 69 | CHAR64LONG16 *block; |
| 70 | static int one = 1; |
| 71 | CHAR64LONG16 workspace; |
| 72 | |
| 73 | block = &workspace; |
| 74 | (void)memcpy(block, buffer, 64); |
| 75 | |
| 76 | /* Copy context->state[] to working vars */ |
| 77 | a = state[0]; |
| 78 | b = state[1]; |
| 79 | c = state[2]; |
| 80 | d = state[3]; |
| 81 | e = state[4]; |
| 82 | |
| 83 | /* 4 rounds of 20 operations each. Loop unrolled. */ |
| 84 | if( 1 == *(unsigned char*)&one ){ |
| 85 | Rl0(a,b,c,d,e, 0); Rl0(e,a,b,c,d, 1); Rl0(d,e,a,b,c, 2); Rl0(c,d,e,a,b, 3); |
| 86 | Rl0(b,c,d,e,a, 4); Rl0(a,b,c,d,e, 5); Rl0(e,a,b,c,d, 6); Rl0(d,e,a,b,c, 7); |
| @@ -113,13 +132,10 @@ | |
| 113 | state[0] += a; |
| 114 | state[1] += b; |
| 115 | state[2] += c; |
| 116 | state[3] += d; |
| 117 | state[4] += e; |
| 118 | |
| 119 | /* Wipe variables */ |
| 120 | a = b = c = d = e = 0; |
| 121 | } |
| 122 | |
| 123 | |
| 124 | /* |
| 125 | * SHA1Init - Initialize new context |
| @@ -192,18 +208,17 @@ | |
| 192 | ** digest is stored in the first 20 bytes. zBuf should |
| 193 | ** be "char zBuf[41]". |
| 194 | */ |
| 195 | static void DigestToBase16(unsigned char *digest, char *zBuf){ |
| 196 | static char const zEncode[] = "0123456789abcdef"; |
| 197 | int i, j; |
| 198 | |
| 199 | for(j=i=0; i<20; i++){ |
| 200 | int a = digest[i]; |
| 201 | zBuf[j++] = zEncode[(a>>4)&0xf]; |
| 202 | zBuf[j++] = zEncode[a & 0xf]; |
| 203 | } |
| 204 | zBuf[j] = 0; |
| 205 | } |
| 206 | |
| 207 | /* |
| 208 | ** The state of a incremental SHA1 checksum computation. Only one |
| 209 | ** such computation can be underway at a time, of course. |
| 210 |
| --- src/sha1.c | |
| +++ src/sha1.c | |
| @@ -27,60 +27,79 @@ | |
| 27 | * blk0() and blk() perform the initial expand. |
| 28 | * I got the idea of expanding during the round function from SSLeay |
| 29 | * |
| 30 | * blk0le() for little-endian and blk0be() for big-endian. |
| 31 | */ |
| 32 | #if __GNUC__ && (defined(__i386__) || defined(__x86_64__)) |
| 33 | /* |
| 34 | * GCC by itself only generates left rotates. Use right rotates if |
| 35 | * possible to be kinder to dinky implementations with iterative rotate |
| 36 | * instructions. |
| 37 | */ |
| 38 | #define SHA_ROT(op, x, k) \ |
| 39 | ({ unsigned int y; asm(op " %1,%0" : "=r" (y) : "I" (k), "0" (x)); y; }) |
| 40 | #define rol(x,k) SHA_ROT("roll", x, k) |
| 41 | #define ror(x,k) SHA_ROT("rorl", x, k) |
| 42 | |
| 43 | #else |
| 44 | /* Generic C equivalent */ |
| 45 | #define SHA_ROT(x,l,r) ((x) << (l) | (x) >> (r)) |
| 46 | #define rol(x,k) SHA_ROT(x,k,32-(k)) |
| 47 | #define ror(x,k) SHA_ROT(x,32-(k),k) |
| 48 | #endif |
| 49 | |
| 50 | |
| 51 | #define blk0le(i) (block[i] = (ror(block[i],8)&0xFF00FF00) \ |
| 52 | |(rol(block[i],8)&0x00FF00FF)) |
| 53 | #define blk0be(i) block[i] |
| 54 | #define blk(i) (block[i&15] = rol(block[(i+13)&15]^block[(i+8)&15] \ |
| 55 | ^block[(i+2)&15]^block[i&15],1)) |
| 56 | |
| 57 | /* |
| 58 | * (R0+R1), R2, R3, R4 are the different operations (rounds) used in SHA1 |
| 59 | * |
| 60 | * Rl0() for little-endian and Rb0() for big-endian. Endianness is |
| 61 | * determined at run-time. |
| 62 | */ |
| 63 | #define Rl0(v,w,x,y,z,i) \ |
| 64 | z+=((w&(x^y))^y)+blk0le(i)+0x5A827999+rol(v,5);w=ror(w,2); |
| 65 | #define Rb0(v,w,x,y,z,i) \ |
| 66 | z+=((w&(x^y))^y)+blk0be(i)+0x5A827999+rol(v,5);w=ror(w,2); |
| 67 | #define R1(v,w,x,y,z,i) \ |
| 68 | z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=ror(w,2); |
| 69 | #define R2(v,w,x,y,z,i) \ |
| 70 | z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=ror(w,2); |
| 71 | #define R3(v,w,x,y,z,i) \ |
| 72 | z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=ror(w,2); |
| 73 | #define R4(v,w,x,y,z,i) \ |
| 74 | z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=ror(w,2); |
| 75 | |
| 76 | /* |
| 77 | * Hash a single 512-bit block. This is the core of the algorithm. |
| 78 | */ |
| 79 | #define a qq[0] |
| 80 | #define b qq[1] |
| 81 | #define c qq[2] |
| 82 | #define d qq[3] |
| 83 | #define e qq[4] |
| 84 | |
| 85 | void SHA1Transform(unsigned int state[5], const unsigned char buffer[64]) |
| 86 | { |
| 87 | unsigned int qq[5]; // a, b, c, d, e; |
| 88 | static int one = 1; |
| 89 | unsigned int block[16]; |
| 90 | memcpy(block, buffer, 64); |
| 91 | memcpy(qq,state,5*sizeof(unsigned int)); |
| 92 | |
| 93 | /* Copy context->state[] to working vars */ |
| 94 | /* |
| 95 | a = state[0]; |
| 96 | b = state[1]; |
| 97 | c = state[2]; |
| 98 | d = state[3]; |
| 99 | e = state[4]; |
| 100 | */ |
| 101 | |
| 102 | /* 4 rounds of 20 operations each. Loop unrolled. */ |
| 103 | if( 1 == *(unsigned char*)&one ){ |
| 104 | Rl0(a,b,c,d,e, 0); Rl0(e,a,b,c,d, 1); Rl0(d,e,a,b,c, 2); Rl0(c,d,e,a,b, 3); |
| 105 | Rl0(b,c,d,e,a, 4); Rl0(a,b,c,d,e, 5); Rl0(e,a,b,c,d, 6); Rl0(d,e,a,b,c, 7); |
| @@ -113,13 +132,10 @@ | |
| 132 | state[0] += a; |
| 133 | state[1] += b; |
| 134 | state[2] += c; |
| 135 | state[3] += d; |
| 136 | state[4] += e; |
| 137 | } |
| 138 | |
| 139 | |
| 140 | /* |
| 141 | * SHA1Init - Initialize new context |
| @@ -192,18 +208,17 @@ | |
| 208 | ** digest is stored in the first 20 bytes. zBuf should |
| 209 | ** be "char zBuf[41]". |
| 210 | */ |
| 211 | static void DigestToBase16(unsigned char *digest, char *zBuf){ |
| 212 | static char const zEncode[] = "0123456789abcdef"; |
| 213 | int ix; |
| 214 | |
| 215 | for(ix=0; ix<20; ix++){ |
| 216 | *zBuf++ = zEncode[(*digest>>4)&0xf]; |
| 217 | *zBuf++ = zEncode[*digest++ & 0xf]; |
| 218 | } |
| 219 | *zBuf = '\0'; |
| 220 | } |
| 221 | |
| 222 | /* |
| 223 | ** The state of a incremental SHA1 checksum computation. Only one |
| 224 | ** such computation can be underway at a time, of course. |
| 225 |
+4
| --- src/timeline.c | ||
| +++ src/timeline.c | ||
| @@ -551,11 +551,13 @@ | ||
| 551 | 551 | cgi_printf("]}%s", pRow->pNext ? ",\n" : "];\n"); |
| 552 | 552 | } |
| 553 | 553 | cgi_printf("var nrail = %d\n", pGraph->mxRail+1); |
| 554 | 554 | graph_free(pGraph); |
| 555 | 555 | @ var canvasDiv = document.getElementById("canvas"); |
| 556 | +#if 0 | |
| 556 | 557 | @ var realCanvas = null; |
| 558 | +#endif | |
| 557 | 559 | @ function drawBox(color,x0,y0,x1,y1){ |
| 558 | 560 | @ var n = document.createElement("div"); |
| 559 | 561 | @ if( x0>x1 ){ var t=x0; x0=x1; x1=t; } |
| 560 | 562 | @ if( y0>y1 ){ var t=y0; y0=y1; y1=t; } |
| 561 | 563 | @ var w = x1-x0+1; |
| @@ -680,10 +682,11 @@ | ||
| 680 | 682 | @ for(var i in rowinfo){ |
| 681 | 683 | @ rowinfo[i].y = absoluteY("m"+rowinfo[i].id) + 10 - canvasY; |
| 682 | 684 | @ rowinfo[i].x = left + rowinfo[i].r*20; |
| 683 | 685 | @ } |
| 684 | 686 | @ var btm = absoluteY("grbtm") + 10 - canvasY; |
| 687 | +#if 0 | |
| 685 | 688 | @ if( btm<32768 ){ |
| 686 | 689 | @ canvasDiv.innerHTML = '<canvas id="timeline-canvas" '+ |
| 687 | 690 | @ 'style="position:absolute;left:'+(left-5)+'px;"' + |
| 688 | 691 | @ ' width="'+width+'" height="'+btm+'"><'+'/canvas>'; |
| 689 | 692 | @ realCanvas = document.getElementById('timeline-canvas'); |
| @@ -700,10 +703,11 @@ | ||
| 700 | 703 | @ if(isNaN(x0) || isNaN(y0) || isNaN(x1) || isNaN(y1)) return; |
| 701 | 704 | @ context.fillStyle = color; |
| 702 | 705 | @ context.fillRect(x0-left+5,y0,x1-x0+1,y1-y0+1); |
| 703 | 706 | @ }; |
| 704 | 707 | @ } |
| 708 | +#endif | |
| 705 | 709 | @ for(var i in rowinfo){ |
| 706 | 710 | @ drawNode(rowinfo[i], left, btm); |
| 707 | 711 | @ } |
| 708 | 712 | @ } |
| 709 | 713 | @ var lastId = "m"+rowinfo[rowinfo.length-1].id; |
| 710 | 714 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -551,11 +551,13 @@ | |
| 551 | cgi_printf("]}%s", pRow->pNext ? ",\n" : "];\n"); |
| 552 | } |
| 553 | cgi_printf("var nrail = %d\n", pGraph->mxRail+1); |
| 554 | graph_free(pGraph); |
| 555 | @ var canvasDiv = document.getElementById("canvas"); |
| 556 | @ var realCanvas = null; |
| 557 | @ function drawBox(color,x0,y0,x1,y1){ |
| 558 | @ var n = document.createElement("div"); |
| 559 | @ if( x0>x1 ){ var t=x0; x0=x1; x1=t; } |
| 560 | @ if( y0>y1 ){ var t=y0; y0=y1; y1=t; } |
| 561 | @ var w = x1-x0+1; |
| @@ -680,10 +682,11 @@ | |
| 680 | @ for(var i in rowinfo){ |
| 681 | @ rowinfo[i].y = absoluteY("m"+rowinfo[i].id) + 10 - canvasY; |
| 682 | @ rowinfo[i].x = left + rowinfo[i].r*20; |
| 683 | @ } |
| 684 | @ var btm = absoluteY("grbtm") + 10 - canvasY; |
| 685 | @ if( btm<32768 ){ |
| 686 | @ canvasDiv.innerHTML = '<canvas id="timeline-canvas" '+ |
| 687 | @ 'style="position:absolute;left:'+(left-5)+'px;"' + |
| 688 | @ ' width="'+width+'" height="'+btm+'"><'+'/canvas>'; |
| 689 | @ realCanvas = document.getElementById('timeline-canvas'); |
| @@ -700,10 +703,11 @@ | |
| 700 | @ if(isNaN(x0) || isNaN(y0) || isNaN(x1) || isNaN(y1)) return; |
| 701 | @ context.fillStyle = color; |
| 702 | @ context.fillRect(x0-left+5,y0,x1-x0+1,y1-y0+1); |
| 703 | @ }; |
| 704 | @ } |
| 705 | @ for(var i in rowinfo){ |
| 706 | @ drawNode(rowinfo[i], left, btm); |
| 707 | @ } |
| 708 | @ } |
| 709 | @ var lastId = "m"+rowinfo[rowinfo.length-1].id; |
| 710 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -551,11 +551,13 @@ | |
| 551 | cgi_printf("]}%s", pRow->pNext ? ",\n" : "];\n"); |
| 552 | } |
| 553 | cgi_printf("var nrail = %d\n", pGraph->mxRail+1); |
| 554 | graph_free(pGraph); |
| 555 | @ var canvasDiv = document.getElementById("canvas"); |
| 556 | #if 0 |
| 557 | @ var realCanvas = null; |
| 558 | #endif |
| 559 | @ function drawBox(color,x0,y0,x1,y1){ |
| 560 | @ var n = document.createElement("div"); |
| 561 | @ if( x0>x1 ){ var t=x0; x0=x1; x1=t; } |
| 562 | @ if( y0>y1 ){ var t=y0; y0=y1; y1=t; } |
| 563 | @ var w = x1-x0+1; |
| @@ -680,10 +682,11 @@ | |
| 682 | @ for(var i in rowinfo){ |
| 683 | @ rowinfo[i].y = absoluteY("m"+rowinfo[i].id) + 10 - canvasY; |
| 684 | @ rowinfo[i].x = left + rowinfo[i].r*20; |
| 685 | @ } |
| 686 | @ var btm = absoluteY("grbtm") + 10 - canvasY; |
| 687 | #if 0 |
| 688 | @ if( btm<32768 ){ |
| 689 | @ canvasDiv.innerHTML = '<canvas id="timeline-canvas" '+ |
| 690 | @ 'style="position:absolute;left:'+(left-5)+'px;"' + |
| 691 | @ ' width="'+width+'" height="'+btm+'"><'+'/canvas>'; |
| 692 | @ realCanvas = document.getElementById('timeline-canvas'); |
| @@ -700,10 +703,11 @@ | |
| 703 | @ if(isNaN(x0) || isNaN(y0) || isNaN(x1) || isNaN(y1)) return; |
| 704 | @ context.fillStyle = color; |
| 705 | @ context.fillRect(x0-left+5,y0,x1-x0+1,y1-y0+1); |
| 706 | @ }; |
| 707 | @ } |
| 708 | #endif |
| 709 | @ for(var i in rowinfo){ |
| 710 | @ drawNode(rowinfo[i], left, btm); |
| 711 | @ } |
| 712 | @ } |
| 713 | @ var lastId = "m"+rowinfo[rowinfo.length-1].id; |
| 714 |
+10
-1
| --- www/changes.wiki | ||
| +++ www/changes.wiki | ||
| @@ -1,15 +1,17 @@ | ||
| 1 | 1 | <title>Change Log</title> |
| 2 | 2 | |
| 3 | -<h2>Changes For Version 1.19 (pending)</h2> | |
| 3 | +<h2>Changes For Version 1.19 (2011-09-02)</h2> | |
| 4 | 4 | |
| 5 | 5 | * Added a ./configure script based on autosetup. |
| 6 | 6 | * Added the "[/help/winsrv | fossil winsrv]" command |
| 7 | 7 | for creating a Fossil service on windows systems. |
| 8 | 8 | * Added "versionable settings" where settings that affect |
| 9 | 9 | the local tree can be stored in versioned files in the |
| 10 | 10 | .fossil-settings directory. |
| 11 | + * Background colors for branches are choosen automatically if no | |
| 12 | + color is specified by the user. | |
| 11 | 13 | * The status, changes and extras commands now show |
| 12 | 14 | pathnames relative to the current working directory, |
| 13 | 15 | unless overridden by command line options or the |
| 14 | 16 | "relative-paths" setting.<br><b>WARNING:</b> This |
| 15 | 17 | change will break scripts which rely on the current |
| @@ -18,10 +20,17 @@ | ||
| 18 | 20 | * Added "empty-dirs" versionable setting. |
| 19 | 21 | * Added support for client-side SSL certificates with "ssl-identity" |
| 20 | 22 | setting and --ssl-identity option. |
| 21 | 23 | * Added "ssl-ca-location" setting to specify trusted root |
| 22 | 24 | SSL certificates. |
| 25 | + * Added the --case-sensitive BOOLEAN command-line option to many commands. | |
| 26 | + Default to true for unix and false for windows. | |
| 27 | + * Added the "Color-Test" submenu button on the branch list web page. | |
| 28 | + * Compatibility improvements to the git-export feature. | |
| 29 | + * Performance improvements on SHA1 checksums | |
| 30 | + * Update to the latest SQLite version 3.7.8 alpha. | |
| 31 | + * Fix the tarball generator to work with very log pathnames | |
| 23 | 32 | |
| 24 | 33 | <h2>Changes For Version 1.18 (2011-07-14)</h2> |
| 25 | 34 | |
| 26 | 35 | * Added this Change Log |
| 27 | 36 | * Added sequential version numbering |
| 28 | 37 |
| --- www/changes.wiki | |
| +++ www/changes.wiki | |
| @@ -1,15 +1,17 @@ | |
| 1 | <title>Change Log</title> |
| 2 | |
| 3 | <h2>Changes For Version 1.19 (pending)</h2> |
| 4 | |
| 5 | * Added a ./configure script based on autosetup. |
| 6 | * Added the "[/help/winsrv | fossil winsrv]" command |
| 7 | for creating a Fossil service on windows systems. |
| 8 | * Added "versionable settings" where settings that affect |
| 9 | the local tree can be stored in versioned files in the |
| 10 | .fossil-settings directory. |
| 11 | * The status, changes and extras commands now show |
| 12 | pathnames relative to the current working directory, |
| 13 | unless overridden by command line options or the |
| 14 | "relative-paths" setting.<br><b>WARNING:</b> This |
| 15 | change will break scripts which rely on the current |
| @@ -18,10 +20,17 @@ | |
| 18 | * Added "empty-dirs" versionable setting. |
| 19 | * Added support for client-side SSL certificates with "ssl-identity" |
| 20 | setting and --ssl-identity option. |
| 21 | * Added "ssl-ca-location" setting to specify trusted root |
| 22 | SSL certificates. |
| 23 | |
| 24 | <h2>Changes For Version 1.18 (2011-07-14)</h2> |
| 25 | |
| 26 | * Added this Change Log |
| 27 | * Added sequential version numbering |
| 28 |
| --- www/changes.wiki | |
| +++ www/changes.wiki | |
| @@ -1,15 +1,17 @@ | |
| 1 | <title>Change Log</title> |
| 2 | |
| 3 | <h2>Changes For Version 1.19 (2011-09-02)</h2> |
| 4 | |
| 5 | * Added a ./configure script based on autosetup. |
| 6 | * Added the "[/help/winsrv | fossil winsrv]" command |
| 7 | for creating a Fossil service on windows systems. |
| 8 | * Added "versionable settings" where settings that affect |
| 9 | the local tree can be stored in versioned files in the |
| 10 | .fossil-settings directory. |
| 11 | * Background colors for branches are choosen automatically if no |
| 12 | color is specified by the user. |
| 13 | * The status, changes and extras commands now show |
| 14 | pathnames relative to the current working directory, |
| 15 | unless overridden by command line options or the |
| 16 | "relative-paths" setting.<br><b>WARNING:</b> This |
| 17 | change will break scripts which rely on the current |
| @@ -18,10 +20,17 @@ | |
| 20 | * Added "empty-dirs" versionable setting. |
| 21 | * Added support for client-side SSL certificates with "ssl-identity" |
| 22 | setting and --ssl-identity option. |
| 23 | * Added "ssl-ca-location" setting to specify trusted root |
| 24 | SSL certificates. |
| 25 | * Added the --case-sensitive BOOLEAN command-line option to many commands. |
| 26 | Default to true for unix and false for windows. |
| 27 | * Added the "Color-Test" submenu button on the branch list web page. |
| 28 | * Compatibility improvements to the git-export feature. |
| 29 | * Performance improvements on SHA1 checksums |
| 30 | * Update to the latest SQLite version 3.7.8 alpha. |
| 31 | * Fix the tarball generator to work with very log pathnames |
| 32 | |
| 33 | <h2>Changes For Version 1.18 (2011-07-14)</h2> |
| 34 | |
| 35 | * Added this Change Log |
| 36 | * Added sequential version numbering |
| 37 |
-1
| --- www/mkdownload.tcl | ||
| +++ www/mkdownload.tcl | ||
| @@ -60,11 +60,10 @@ | ||
| 60 | 60 | puts $out "<center><b><a href=\"$hr\">$dt</a></b></center>" |
| 61 | 61 | puts $out "</td></tr>" |
| 62 | 62 | |
| 63 | 63 | foreach {prefix suffix img desc} { |
| 64 | 64 | fossil-linux-x86 zip linux.gif {Linux x86} |
| 65 | - fossil-linux-amd64 zip linux64.gif {Linux x86_64} | |
| 66 | 65 | fossil-macosx-x86 zip mac.gif {Mac 10.5 x86} |
| 67 | 66 | fossil-openbsd-x86 zip openbsd.gif {OpenBSD 4.7 x86} |
| 68 | 67 | fossil-w32 zip win32.gif {Windows} |
| 69 | 68 | fossil-src tar.gz src.gif {Source Tarball} |
| 70 | 69 | } { |
| 71 | 70 |
| --- www/mkdownload.tcl | |
| +++ www/mkdownload.tcl | |
| @@ -60,11 +60,10 @@ | |
| 60 | puts $out "<center><b><a href=\"$hr\">$dt</a></b></center>" |
| 61 | puts $out "</td></tr>" |
| 62 | |
| 63 | foreach {prefix suffix img desc} { |
| 64 | fossil-linux-x86 zip linux.gif {Linux x86} |
| 65 | fossil-linux-amd64 zip linux64.gif {Linux x86_64} |
| 66 | fossil-macosx-x86 zip mac.gif {Mac 10.5 x86} |
| 67 | fossil-openbsd-x86 zip openbsd.gif {OpenBSD 4.7 x86} |
| 68 | fossil-w32 zip win32.gif {Windows} |
| 69 | fossil-src tar.gz src.gif {Source Tarball} |
| 70 | } { |
| 71 |
| --- www/mkdownload.tcl | |
| +++ www/mkdownload.tcl | |
| @@ -60,11 +60,10 @@ | |
| 60 | puts $out "<center><b><a href=\"$hr\">$dt</a></b></center>" |
| 61 | puts $out "</td></tr>" |
| 62 | |
| 63 | foreach {prefix suffix img desc} { |
| 64 | fossil-linux-x86 zip linux.gif {Linux x86} |
| 65 | fossil-macosx-x86 zip mac.gif {Mac 10.5 x86} |
| 66 | fossil-openbsd-x86 zip openbsd.gif {OpenBSD 4.7 x86} |
| 67 | fossil-w32 zip win32.gif {Windows} |
| 68 | fossil-src tar.gz src.gif {Source Tarball} |
| 69 | } { |
| 70 |