Danger
Nothing here should be used for any security purposes.
API#
- class toy_crypto.wycheproof.Loader(path: Path) None[source]#
Tools for loading Wycheproof test vectors.
- Parameters:
path¶ (
Path)
- classmethod collect_formats(schema: JsonObject) Mapping[str, str][source]#
Collects format annotation for all string types in schema.
- Parameters:
schema¶ (
TypeAliasType) – The schema from which to collect string format annotations.- Return type:
Mapping[str,str]
Warning
If the same property name is used in different parts of the schema and have distinct formats, which format will be assigned to the single property name is undefined.
- load(path: Path | str, *, subdir: str = 'testvectors_v1', strict_validation: bool = False) TestData[source]#
Returns the file data
- Parameters:
- Raises:
Exceptions – if the expected data file can’t be found or read.
Exception – if strict_validation is True and schema validation fails.
- Return type:
- property root_dir: Path#
The absolute path of the wycheproof root directory.
- class toy_crypto.wycheproof.TestCase(test_case: Mapping[str, object]) None[source]#
- Parameters:
test_case¶ (
Mapping[str,object])
- property acceptable: bool#
If the test case is expected to be acceptable.
- property comment: str#
The comment for the case.
The comment might be the empty string.
- property flags: Set[str]#
The set of flags that are set for the case.
- has_flag(flag: str) bool[source]#
True if
flagis set for this case.- Parameters:
flag¶ (
str)- Return type:
bool
- property invalid: bool#
If the test case expected to be invalid.
- property other_data: Mapping[str, object]#
The test case data that isn’t captured by known properties.
- property result: str#
The expected result of the test
Should be one of “valid”, “invalid”, “acceptable”
- property tcId: int#
The test case ID
"tcIdof the test case
- property valid: bool#
If the test case is expected to be valid.
- class toy_crypto.wycheproof.TestGroup(group: dict[str, object], formats: Mapping[str, str]) None[source]#
Data that is common to all tests in the group.
- property other_data: Mapping[str, object]#
The data that isn’t captured by known properties.
- property type: str | None#
The test group type.
- class toy_crypto.wycheproof.TestData(data: StrDict, formats: Mapping[str, str], schema_path: Path, schema_status: str = 'valid') None[source]#
The object that results from loading a wycheproof JSON file.
- Parameters:
- property formats: Mapping[str, str]#
JSON keyword to string format annotation.
Warning
The is not completely reliable.
- property schema_file: Path#
The path where the schema file was expected.
The existence of this path does not mean that the file exists at that location.
- schema_is_loaded() bool[source]#
True iff the schema file was found and read.
That will be true even if the schema file is itself invalid.
- Return type:
bool
- schema_is_valid() bool[source]#
True iff the JSON data properly validated against a valid schema.
Note that this can be False if the schema failed to load.
- Return type:
bool
- property test_count: int | None#
The test count from the JSON “numberOfTests” value.
- class toy_crypto.wycheproof.Note(note_name: str, notes: dict[str, object]) None[source]#
Notes on flags for in TestData
- property bug_type: str#
The type of the bug tested for
- property cves: Sequence[str]#
A list of potentially related CVEs
- property description: str | None#
A description of the flag
- property effect: str | None#
The expected effect of failing the test vector
- property links: Sequence[str]#
A list of potentially related references