-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #242 from duo-labs/fix/237-add-new-tpm-mfg-ids
Update list of recognized TPM manufacturers
- Loading branch information
Showing
5 changed files
with
49 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from unittest import TestCase | ||
|
||
from webauthn.helpers.tpm import map_tpm_manufacturer_id | ||
|
||
|
||
class TestWebAuthnGenerateUserHandle(TestCase): | ||
def test_handles_recognized_id(self) -> None: | ||
info = map_tpm_manufacturer_id("id:4353434F") | ||
|
||
self.assertEqual(info.name, "Cisco") | ||
self.assertEqual(info.id, "CSCO") | ||
|
||
def test_raises_on_unrecognized_id(self) -> None: | ||
with self.assertRaises(KeyError): | ||
map_tpm_manufacturer_id("id:FFFFFFFF") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
from .map_tpm_manufacturer import map_tpm_manufacturer_id | ||
from .parse_cert_info import parse_cert_info | ||
from .parse_pub_area import parse_pub_area | ||
|
||
__all__ = ["parse_cert_info", "parse_pub_area"] | ||
__all__ = ["map_tpm_manufacturer_id", "parse_cert_info", "parse_pub_area"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from .structs import TPM_MANUFACTURERS, TPMManufacturerInfo | ||
|
||
|
||
def map_tpm_manufacturer_id(id: str) -> TPMManufacturerInfo: | ||
""" | ||
Map a TPM manufacturer's hex ID to a manufacturer's assigned name and ASCII identifier | ||
Args: | ||
- `id`: A TPM manufacturer ID string like `"id:FFFFFFFF"` | ||
(a.k.a. oid "2.23.133.2.1" in SubjectAlternativeName extension) | ||
Returns: | ||
An instance of `TPMManufacturerInfo` | ||
Raises: | ||
`KeyError` on unrecognized TPM manufacturer ID | ||
""" | ||
return TPM_MANUFACTURERS[id] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters