New module for key material for asymmetric key types

Asymmetric keys can't just be arbitrary byte strings: the public key
has to match the private key and the private key usually has
nontrivial constraints.

In order to have deterministic test data and not to rely on
cryptographic dependencies in the Python script, hard-code some test
keys.

In this commit, copy some test keys from test_suite_psa_crypto.data.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
diff --git a/scripts/mbedtls_dev/crypto_knowledge.py b/scripts/mbedtls_dev/crypto_knowledge.py
index 2e0fa2f..65dbc34 100644
--- a/scripts/mbedtls_dev/crypto_knowledge.py
+++ b/scripts/mbedtls_dev/crypto_knowledge.py
@@ -21,6 +21,8 @@
 import re
 from typing import List, Optional, Tuple
 
+from mbedtls_dev.asymmetric_key_data import ASYMMETRIC_KEY_DATA
+
 class KeyType:
     """Knowledge about a PSA key type."""
 
@@ -101,13 +103,18 @@
         psa_export_key(id, `material`, ...);
         ```
         """
+        if self.expression in ASYMMETRIC_KEY_DATA:
+            if bits not in ASYMMETRIC_KEY_DATA[self.expression]:
+                raise ValueError('No key data for {}-bit {}'
+                                 .format(bits, self.expression))
+            return ASYMMETRIC_KEY_DATA[self.expression][bits]
         if bits % 8 != 0:
-            raise ValueError('Non-integer number of bytes: {} bits'.format(bits))
+            raise ValueError('Non-integer number of bytes: {} bits for {}'
+                             .format(bits, self.expression))
         length = bits // 8
         if self.name == 'PSA_KEY_TYPE_DES':
             # "644573206b457901644573206b457902644573206b457904"
             des3 = b'dEs kEy\001dEs kEy\002dEs kEy\004'
             return des3[:length]
-        # TODO: ECC, RSA
         return b''.join([self.DATA_BLOCK] * (length // len(self.DATA_BLOCK)) +
                         [self.DATA_BLOCK[:length % len(self.DATA_BLOCK)]])