changeset 235:b84406fbb267

bad_calls: it is now an error to put a secret arg in the wrong place
author Sigurd Meldgaard <stm@daimi.au.dk>
date Mon, 04 Jan 2010 14:08:57 +0100
parents b229f5b732c9
children e1442a016352
files pysmcl/bad_calls.py
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/pysmcl/bad_calls.py	Mon Jan 04 14:08:08 2010 +0100
+++ b/pysmcl/bad_calls.py	Mon Jan 04 14:08:57 2010 +0100
@@ -1,6 +1,7 @@
 import pysmcl.ast_wrapper as ast
 import util
 from secret_annotator import expr_secret, non_compromising_functions
+from secret_annotator import annotated_functions
 
 
 def bad_calls(function_def):
@@ -13,7 +14,15 @@
                     util.error("Call of non-fixed function "
                                "with secret argument", node)
             elif(node.func.id in non_compromising_functions):
-                return
+                if node.func.id not in annotated_functions:
+                    continue
+                else:
+                    function = annotated_functions[node.func.id]
+                    for arg, secret in zip(node.args, function.args_secret):
+                        if not secret and expr_secret(arg):
+                            util.error("Call of secure function "
+                                       "with secret argument"
+                                       " where a non-secret was expected", node)
             elif(any([expr_secret(i, e) for i in node.args])):
                 util.error("Call of non-secret "
                            "function with secret argument", node)