Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | For new Docker-generated repositories, use "auto" hash-policy as default: They might be synced with "sha1"-type repositories, this would render those repositories useless. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
9a6256cf0850e9c5a3a94da1cb6b464c |
| User & Date: | jan.nijtmans 2017-03-06 12:48:02.254 |
Context
|
2017-03-06
| ||
| 12:52 | Use "auto" hash-policy for new Docker repositories check-in: 3c9dc14831 user: jan.nijtmans tags: trunk | |
| 12:48 | For new Docker-generated repositories, use "auto" hash-policy as default: They might be synced with "sha1"-type repositories, this would render those repositories useless. check-in: 9a6256cf08 user: jan.nijtmans tags: trunk | |
| 00:08 | Add a new hyperlink to the hash policy document. check-in: 907021af51 user: drh tags: trunk | |
Changes
Changes to src/db.c.
| ︙ | ︙ | |||
1923 1924 1925 1926 1927 1928 1929 |
*/
void create_repository_cmd(void){
char *zPassword;
const char *zTemplate; /* Repository from which to copy settings */
const char *zDate; /* Date of the initial check-in */
const char *zDefaultUser; /* Optional name of the default user */
int bUseSha1 = 0; /* True to set the hash-policy to sha1 */
| | | 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 |
*/
void create_repository_cmd(void){
char *zPassword;
const char *zTemplate; /* Repository from which to copy settings */
const char *zDate; /* Date of the initial check-in */
const char *zDefaultUser; /* Optional name of the default user */
int bUseSha1 = 0; /* True to set the hash-policy to sha1 */
zTemplate = find_option("template",0,1);
zDate = find_option("date-override",0,1);
zDefaultUser = find_option("admin-user","A",1);
bUseSha1 = find_option("sha1",0,0)!=0;
/* We should be done with options.. */
verify_all_options();
|
| ︙ | ︙ | |||
1948 1949 1950 1951 1952 1953 1954 |
db_open_repository(g.argv[2]);
db_open_config(0, 0);
if( zTemplate ) db_attach(zTemplate, "settingSrc");
db_begin_transaction();
if( bUseSha1 ){
g.eHashPolicy = HPOLICY_SHA1;
db_set_int("hash-policy", HPOLICY_SHA1, 0);
| | | 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 |
db_open_repository(g.argv[2]);
db_open_config(0, 0);
if( zTemplate ) db_attach(zTemplate, "settingSrc");
db_begin_transaction();
if( bUseSha1 ){
g.eHashPolicy = HPOLICY_SHA1;
db_set_int("hash-policy", HPOLICY_SHA1, 0);
}
if( zDate==0 ) zDate = "now";
db_initial_setup(zTemplate, zDate, zDefaultUser);
db_end_transaction(0);
if( zTemplate ) db_detach("settingSrc");
fossil_print("project-id: %s\n", db_get("project-code", 0));
fossil_print("server-id: %s\n", db_get("server-code", 0));
zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin);
|
| ︙ | ︙ |
Changes to src/diffcmd.c.
| ︙ | ︙ | |||
150 151 152 153 154 155 156 | /* ** Show the difference between two files, one in memory and one on disk. ** ** The difference is the set of edits needed to transform pFile1 into ** zFile2. The content of pFile1 is in memory. zFile2 exists on disk. ** | | | 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | /* ** Show the difference between two files, one in memory and one on disk. ** ** The difference is the set of edits needed to transform pFile1 into ** zFile2. The content of pFile1 is in memory. zFile2 exists on disk. ** ** If fSwapDiff is 1, show the set of edits to transform zFile2 into pFile1 ** instead of the opposite. ** ** Use the internal diff logic if zDiffCmd is NULL. Otherwise call the ** command zDiffCmd to do the diffing. ** ** When using an external diff program, zBinGlob contains the GLOB patterns ** for file names to treat as binary. If fIncludeBinary is zero, these files |
| ︙ | ︙ |
Changes to src/encode.c.
| ︙ | ︙ | |||
359 360 361 362 363 364 365 |
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x00, 0x00,
};
| | | 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 |
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x00, 0x00,
};
c = *((*pz)++);
if( c>=0xc0 ){
c = utf8Trans1[c-0xc0];
while( (*(*pz) & 0xc0)==0x80 ){
c = (c<<6) + (0x3f & *((*pz)++));
}
if( c<0x80
|
| ︙ | ︙ |
Changes to src/hname.c.
| ︙ | ︙ | |||
160 161 162 163 164 165 166 | ** just two hashes, but HNAME_COUNT is currently fixed at 2.) ** ** Depending on the hash policy, the alternative hash may be disallowed. ** If the alterative hash is disallowed, the routine returns 0. This ** routine returns 1 if iHType>0 and the alternative hash is allowed, ** and it always returns 1 when iHType==0. ** | | | > | 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
** just two hashes, but HNAME_COUNT is currently fixed at 2.)
**
** Depending on the hash policy, the alternative hash may be disallowed.
** If the alterative hash is disallowed, the routine returns 0. This
** routine returns 1 if iHType>0 and the alternative hash is allowed,
** and it always returns 1 when iHType==0.
**
** Alternative hash is disallowed for all hash policies except auto,
** sha1 and sha3.
*/
int hname_hash(const Blob *pContent, unsigned int iHType, Blob *pHashOut){
assert( iHType==0 || iHType==1 );
if( iHType==1 ){
switch( g.eHashPolicy ){
case HPOLICY_AUTO:
case HPOLICY_SHA1:
sha3sum_blob(pContent, 256, pHashOut);
return 1;
case HPOLICY_SHA3:
sha1sum_blob(pContent, pHashOut);
return 1;
}
|
| ︙ | ︙ | |||
197 198 199 200 201 202 203 | } /* ** Return the default hash policy for repositories that do not currently ** have an assigned hash policy. ** ** Make the default HPOLICY_AUTO if there are SHA1 artficates but no SHA3 | | | | | 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
}
/*
** Return the default hash policy for repositories that do not currently
** have an assigned hash policy.
**
** Make the default HPOLICY_AUTO if there are SHA1 artficates but no SHA3
** artifacts in the repository. Make the default HPOLICY_SHA3 if there
** are one or more SHA3 artifacts or if the repository is initially empty.
*/
int hname_default_policy(void){
if( db_exists("SELECT 1 FROM blob WHERE length(uuid)>40")
|| !db_exists("SELECT 1 FROM blob WHERE length(uuid)==40")
){
return HPOLICY_SHA3;
}else{
return HPOLICY_AUTO;
}
}
/*
** Names of the hash policies.
*/
static const char *azPolicy[] = {
"sha1", "auto", "sha3", "sha3-only", "shun-sha1"
};
/* Return the name of the current hash policy.
*/
|
| ︙ | ︙ | |||
264 265 266 267 268 269 270 |
if( g.argc==2 ){
fossil_print("%s\n", azPolicy[g.eHashPolicy]);
return;
}
for(i=HPOLICY_SHA1; i<=HPOLICY_SHUN_SHA1; i++){
if( fossil_strcmp(g.argv[2],azPolicy[i])==0 ){
if( i==HPOLICY_AUTO
| | | | 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
if( g.argc==2 ){
fossil_print("%s\n", azPolicy[g.eHashPolicy]);
return;
}
for(i=HPOLICY_SHA1; i<=HPOLICY_SHUN_SHA1; i++){
if( fossil_strcmp(g.argv[2],azPolicy[i])==0 ){
if( i==HPOLICY_AUTO
&& db_exists("SELECT 1 FROM blob WHERE length(uuid)>40")
){
i = HPOLICY_SHA3;
}
g.eHashPolicy = i;
db_set_int("hash-policy", i, 0);
fossil_print("%s\n", azPolicy[i]);
return;
}
}
fossil_fatal("unknown hash policy \"%s\" - should be one of: sha1 auto"
" sha3 sha3-only shun-sha1", g.argv[2]);
}
|
Changes to src/stash.c.
| ︙ | ︙ | |||
427 428 429 430 431 432 433 | ** List all changes sets currently stashed. Show information about ** individual files in each changeset if -v or --verbose is used. ** ** fossil stash show|cat ?STASHID? ?DIFF-OPTIONS? ** fossil stash gshow|gcat ?STASHID? ?DIFF-OPTIONS? ** ** Show the contents of a stash as a diff against it's baseline. | | | 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 | ** List all changes sets currently stashed. Show information about ** individual files in each changeset if -v or --verbose is used. ** ** fossil stash show|cat ?STASHID? ?DIFF-OPTIONS? ** fossil stash gshow|gcat ?STASHID? ?DIFF-OPTIONS? ** ** Show the contents of a stash as a diff against it's baseline. ** With gshow and gcat, gdiff-command is used instead of internal ** diff logic. ** ** fossil stash pop ** fossil stash apply ?STASHID? ** ** Apply STASHID or the most recently create stash to the current ** working checkout. The "pop" command deletes that changeset from |
| ︙ | ︙ | |||
454 455 456 457 458 459 460 | ** -a|--all flag is used. Individual drops are undoable but -a|--all ** is not. ** ** fossil stash diff ?STASHID? ?DIFF-OPTIONS? ** fossil stash gdiff ?STASHID? ?DIFF-OPTIONS? ** ** Show diffs of the current working directory and what that | | | 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 | ** -a|--all flag is used. Individual drops are undoable but -a|--all ** is not. ** ** fossil stash diff ?STASHID? ?DIFF-OPTIONS? ** fossil stash gdiff ?STASHID? ?DIFF-OPTIONS? ** ** Show diffs of the current working directory and what that ** directory would be if STASHID were applied. With gdiff, ** gdiff-command is used instead of internal diff logic. ** ** SUMMARY: ** fossil stash ** fossil stash save ?-m|--comment COMMENT? ?FILES...? ** fossil stash snapshot ?-m|--comment COMMENT? ?FILES...? ** fossil stash list|ls ?-v|--verbose? ?-W|--width <num>? |
| ︙ | ︙ | |||
657 658 659 660 661 662 663 |
|| memcmp(zCmd, "gshow", nCmd)==0
|| memcmp(zCmd, "cat", nCmd)==0
|| memcmp(zCmd, "gcat", nCmd)==0
){
const char *zDiffCmd = 0;
const char *zBinGlob = 0;
int fIncludeBinary = 0;
| | | 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 |
|| memcmp(zCmd, "gshow", nCmd)==0
|| memcmp(zCmd, "cat", nCmd)==0
|| memcmp(zCmd, "gcat", nCmd)==0
){
const char *zDiffCmd = 0;
const char *zBinGlob = 0;
int fIncludeBinary = 0;
int fBaseline = 0;
u64 diffFlags;
if( strstr(zCmd,"show")!=0 || strstr(zCmd,"cat")!=0 ){
fBaseline = 1;
}
if( find_option("tk",0,0)!=0 ){
db_close(0);
|
| ︙ | ︙ |
Changes to www/hashpolicy.wiki.
1 2 3 4 5 6 7 | <title>Hash Policy</title> <h2> Executive Summary, Or How To Avoid Reading This Article </h2> There is much angst over the [http://www.shattered.io|Shattered attack] against SHA1. If you are concerned about this and its implications for Fossil, simply upgrade to Fossil 2.0 or later and the problem will go away. | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | <title>Hash Policy</title> <h2> Executive Summary, Or How To Avoid Reading This Article </h2> There is much angst over the [http://www.shattered.io|Shattered attack] against SHA1. If you are concerned about this and its implications for Fossil, simply upgrade to Fossil 2.0 or later and the problem will go away. Everything will continue to work as before. All of your legacy repositories will continue to work and all of your old check-ins will still have the same name. Your workflow will be unchanged. But if you are curious and want a deeper understanding of what is going on, read on... <h2> Introduction </h2> The first snapshot-based distributed version control system was [http://www.monotone.ca|Monotone]. Many of the ideas behind the design of Fossil were copied from Monotone, including the use of a SHA1 hash to assign names to artifacts. Git and Mercurial did the same thing. The SHA1 hash algorithm is used only to create names for artifacts in Fossil (and in Git, Mercurial, and Monotone). It is not used for security. Nevertheless, when the [http://www.shattered.io|Shattered attack] found two different PDF files with the same SHA1 hash, many users learned that "SHA1 is broken". They see that Fossil (and Git, Mercurial, and Monotone) use SHA1 and they therefore conclude that "Fossil is broken". This is not true, but it is a public relations problem. So the decision was made to migrate Fossil away from SHA1. This article describes how that migration is occurring. <h2>Use Of Hardened SHA1</h2> In Fossil version 2.0 ([/timeline?c=version-2.0|2017-03-03]), the internal SHA1 implementation was changed from a generic FIPS PUB 180-4 SHA1 implementation to a "Hardened SHA1" [[https://github.com/cr-marcstevens/sha1collisiondetection|1]] [[https://marc-stevens.nl/research/papers/C13-S.pdf|2]]. The Hardened SHA1 implement automatically detects when the artifact being hashed is specifically designed to exploit the known weaknesses |
| ︙ | ︙ | |||
59 60 61 62 63 64 65 | someone says "SHA1 is broken, and Fossil uses SHA1, therefore Fossil is broken", you can rebut the argument by pointing out that Fossil uses <em>Hardened SHA1</em> not generic SHA1 and Hardened SHA1 is <em>not</em> broken. <h2>Support For SHA3-256</h2> | | | 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | someone says "SHA1 is broken, and Fossil uses SHA1, therefore Fossil is broken", you can rebut the argument by pointing out that Fossil uses <em>Hardened SHA1</em> not generic SHA1 and Hardened SHA1 is <em>not</em> broken. <h2>Support For SHA3-256</h2> Prior to Fossil version 2.0 ([/timeline?c=version-2.0|2017-03-03]), all artifacts in all Fossil repositories were named by only a SHA1 hash. Version 2.0 extended the [./fileformat.wiki|Fossil file format] to allow artifacts to be named by either SHA1 or SHA3-256 hashes. (SHA3-256 is the only variant of SHA3 that Fossil uses for artifact naming, so for the remainder of this article it will be called simply "SHA3". Similarly, "Hardened SHA1" will |
| ︙ | ︙ | |||
135 136 137 138 139 140 141 | seen, Fossil automatically switches to "sha3" mode and thereafter generates only SHA3 hashes. When a new repository is created by cloning, the hash policy is copied from the parent. For new repositories created using the | | | | | 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | seen, Fossil automatically switches to "sha3" mode and thereafter generates only SHA3 hashes. When a new repository is created by cloning, the hash policy is copied from the parent. For new repositories created using the [/help?cmd=new|fossil new] command the default hash policy is "sha3". That means new repositories will normally hold nothing except SHA3 hashes. The hash policy for new repositories can be overridden using the "--sha1" option to the "fossil new" command. Even after upgrading to Fossil 2.1, Fossil will continue to use nothing but SHA1 hashes on legacy repositories, thus preserving complete compatibility with Fossil 1.37 and before. If you want Fossil to go ahead and start using SHA3 hashes, change the hash policy to "sha3" using a command like this: <blockquote><verbatim> fossil hash-policy sha3 </verbatim></blockquote> |
| ︙ | ︙ |