Add the SH_TIMING_RESTRICTIONS compile flag and dependency graph implementation.
Description of the algorithm:
http://code.google.com/p/mvujovic/wiki/ShaderControlFlowAnalysis
This flag is one potential solution to timing attacks on textures containing cross-domain content
or user agent data.
This kind of analysis could be useful for both WebGL and CSS Shaders.
The SH_TIMING_RESTRICTIONS flag will reject a shader if it uses texture dependent data to affect
control flow.
Other ways of affecting shader timing such as using NaNs in basic arithmetic operations or using
built-in functions (e.g. atan) with different inputs are still under investigation.
Issue=329
Review URL: http://codereview.appspot.com/6195062/
git-svn-id: https://angleproject.googlecode.com/svn/trunk@1101 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/compiler/ShHandle.h b/src/compiler/ShHandle.h
index 91c47e7..0faaeb1 100644
--- a/src/compiler/ShHandle.h
+++ b/src/compiler/ShHandle.h
@@ -24,6 +24,7 @@
class LongNameMap;
class TCompiler;
+class TDependencyGraph;
//
// The base class used to back handles returned to the driver.
@@ -79,6 +80,17 @@
void mapLongVariableNames(TIntermNode* root);
// Translate to object code.
virtual void translate(TIntermNode* root) = 0;
+ // Returns true if the shader passes the restrictions that aim to prevent timing attacks.
+ bool enforceTimingRestrictions(TIntermNode* root,
+ const TString& restrictedSymbol,
+ bool outputGraph);
+ // Returns true if the shader does not define the restricted symbol.
+ bool enforceVertexShaderTimingRestrictions(TIntermNode* root,
+ const TString& restrictedSymbol);
+ // Returns true if the shader does not use the restricted symbol to affect control flow or in
+ // operations whose time can depend on the input values.
+ bool enforceFragmentShaderTimingRestrictions(const TDependencyGraph& graph,
+ const TString& restrictedSymbol);
// Get built-in extensions with default behavior.
const TExtensionBehavior& getExtensionBehavior() const;