C# Class MoreInternals.Compiler.Tasks.CacheBreak

Finds all references to external resources and adds automagic cache breakers to them. The rules are essentially: - if we can *find* the resource, hash it and use that - if we can't find it, generate a reference that won't collide
Show file Open project: kevin-montrose/More

Public Methods

Method Description
Task ( List blocks ) : List

Private Methods

Method Description
AddCacheBreaker ( Value val ) : Value
CacheBreakBlock ( SelectorAndBlock block ) : SelectorAndBlock
CacheBreakProperty ( NameValueProperty prop ) : NameValueProperty
CacheBreakValue ( Value val ) : Value
Encode ( byte arr ) : string
GenerateCacheBreaker ( string path ) : string
GetRandom ( int n ) : byte[]
HashAndTruncate ( Stream input, HashAlgorithm hash ) : byte[]

OK, this is going overboard but you got to have some fun sometime. Truncating a hash isn't a safe operation, while an ideal hash would have equal entropy in each "half" there's no proof that any extant hash algorithm behaves that way. A construction proposed by Kelsey in 2005 is: - pick a fixed IV for length N * every potentional length has a different IV * we're going to truncate to 8 bytes always, so there's only one IV but in principle... - let H(IV ^ 0xCCC...CCC, N) be IV_H - let H(IV_H, message) be HASH - truncate HASH to N bits This is not (to my knowledge) a battle tested construction, but since we're only using it for cache breaking there's not much attack surface. It's also almost certainly better than anything I can cook up or naive truncation.

Method Details

Task() public static method

public static Task ( List blocks ) : List
blocks List
return List