tf_fuzz: add new crypto key generation model

* Add a new model of what it means for a crypto policy to be valid. This
  fixes the simulation of psa_generate_key() calls, which TF-Fuzz
  currently cannot accurately predict.

  The PSA Crypto properties modelled are whether an algorithm and key
  type are compatible, whether a key type/ algorithm are disabled, and
  what key sizes are allowed.

  Although the PSA Crypto specification has additional, more complicated
  requirements for policies and keys, this commit only implements what
  is necessary for predicting the outcome of psa_generate_key(), and not
  requirements that make a key useless but still valid or involve
  features not yet in TF-M or MbedTLS.

* Improve the way in which policies are filled in, and allow policies to
  be updated at simulation time using the value of a named policy asset.
  Information about other assets and calls is not accessible during
  parse time when the key policy is usually filled in. However, this is
  required for the improved simulation of psa_generate_key calls. This
  is because policy information for generate key calls come from a named
  policy created earlier in the test file.

* Add valid flag to set-policy calls, allowing the creation of a random
  valid policy. For example, see demo/36.test.

* Add demo/36.test. This test generates a policy with a (roughly) even
  chance of being valid or invalid and then tries to generate a key
  using it.

  Running this test a large number of times (~300) succeeds with the
  changes in this commit, showing that TF-Fuzz can now accurately
  predict the outcome of psa_generate_key calls.

Change-Id: Ia40ff893db50b8d2c579d975aa23341b7aab004d
Signed-off-by: Nik Dewally <Nik.Dewally@arm.com>
diff --git a/tf_fuzz/demo/17.test b/tf_fuzz/demo/17.test
deleted file mode 100644
index bdaeece..0000000
--- a/tf_fuzz/demo/17.test
+++ /dev/null
@@ -1,8 +0,0 @@
-purpose to try some more-complex randomization;
-set sst name neil buzz mike data *;
-2 to 5 of {
-    set sst name neil data "that's one small step for [a] man";
-    remove sst *active;
-    set sst name chris kraft data "wear the helmet";
-    remove sst name neil;
-}
diff --git a/tf_fuzz/demo/25.5.test b/tf_fuzz/demo/25.5.test
new file mode 100644
index 0000000..cea2279
--- /dev/null
+++ b/tf_fuzz/demo/25.5.test
@@ -0,0 +1,3 @@
+purpose to create a random valid policy and create a key using it (no key material specified);
+set policy name randomPolicy valid;
+set key name akey policy randomPolicy;
diff --git a/tf_fuzz/demo/28.test b/tf_fuzz/demo/28.test
index e9fd0d8..0faee18 100644
--- a/tf_fuzz/demo/28.test
+++ b/tf_fuzz/demo/28.test
@@ -1,4 +1,4 @@
 purpose to create a key, then read the key data ("material") into a variable;
-set policy name somePolicy alg sha3_224 attr noexport volatile;
+set policy name somePolicy alg cfb attr noexport volatile valid;
 set key name aKey data * policy somePolicy;
 read key name aKey var keyDataVar;
diff --git a/tf_fuzz/demo/29.test b/tf_fuzz/demo/29.test.disabled
similarity index 100%
rename from tf_fuzz/demo/29.test
rename to tf_fuzz/demo/29.test.disabled
diff --git a/tf_fuzz/demo/36.test b/tf_fuzz/demo/36.test
new file mode 100644
index 0000000..fc8e4cf
--- /dev/null
+++ b/tf_fuzz/demo/36.test
@@ -0,0 +1,12 @@
+purpose to have a more even chance of creating a valid or invalid key;
+
+/*
+ most completely random keys will be invalid so something like this helps get
+ more valid keys into the mix
+ */
+
+1 of {
+set policy name randomPolicy valid;
+set policy name randomPolicy;
+}
+set key name akey policy randomPolicy;