Load NIST SP 800-108 KDF Vectors
(vector_data: typing.Iterable[str])
| 826 | |
| 827 | |
| 828 | def load_nist_kbkdf_vectors(vector_data: typing.Iterable[str]) -> list[dict]: |
| 829 | """ |
| 830 | Load NIST SP 800-108 KDF Vectors |
| 831 | """ |
| 832 | vectors = [] |
| 833 | test_data: dict[str, typing.Any] = {} |
| 834 | tag: dict[str, typing.Any] = {} |
| 835 | |
| 836 | for line in vector_data: |
| 837 | line = line.strip() |
| 838 | |
| 839 | if not line or line.startswith("#"): |
| 840 | continue |
| 841 | |
| 842 | if line.startswith("[") and line.endswith("]"): |
| 843 | tag_data = line[1:-1] |
| 844 | name, value = (c.strip() for c in tag_data.split("=")) |
| 845 | if value.endswith("_BITS"): |
| 846 | tag[name.lower()] = int(value.split("_")[0]) |
| 847 | continue |
| 848 | |
| 849 | tag[name.lower()] = value.lower() |
| 850 | elif line.startswith("COUNT="): |
| 851 | test_data = {} |
| 852 | test_data.update(tag) |
| 853 | vectors.append(test_data) |
| 854 | elif line.startswith(("L", "DataBeforeCtrLen", "DataAfterCtrLen")): |
| 855 | name, value = (c.strip() for c in line.split("=")) |
| 856 | test_data[name.lower()] = int(value) |
| 857 | else: |
| 858 | name, value = (c.strip() for c in line.split("=")) |
| 859 | test_data[name.lower()] = value.encode("ascii") |
| 860 | |
| 861 | return vectors |
| 862 | |
| 863 | |
| 864 | def load_ed25519_vectors(vector_data: typing.Iterable[str]) -> list[dict]: |