Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dac revocation: Fallback method to parse VID/PID from crl signer #33605

Merged
merged 5 commits into from
Jun 17, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
dac revocation: Fallback method to parse VID/PID from crl signer
  • Loading branch information
shubhamdp committed Jun 17, 2024
commit d95ce24f7c57b421db6ce68fa0cdf576ca876be2
25 changes: 21 additions & 4 deletions credentials/generate-revocation-set.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,26 @@ def extract_single_integer_attribute(subject, oid):
return None


def parse_vid_pid_from_distinguished_name(distinguished_name):
# VID/PID encoded using Matter specific RDNs
vid = extract_single_integer_attribute(distinguished_name, OID_VENDOR_ID)
pid = extract_single_integer_attribute(distinguished_name, OID_PRODUCT_ID)

# Fallback method to get the VID/PID, encoded in CN as "Mvid:FFFF Mpid:1234"
if vid is None and pid is None:
cn = distinguished_name.get_attributes_for_oid(x509.ObjectIdentifier("2.5.4.3"))[0].value
tcarmelveilleux marked this conversation as resolved.
Show resolved Hide resolved

vid_start = cn.find('Mvid:')
if vid_start != -1:
vid = int(cn[vid_start + 5:vid_start + 9], 16)

pid_start = cn.find('Mpid:')
if pid_start != -1:
pid = int(cn[pid_start + 5:pid_start + 9], 16)

return vid, pid


class DCLDClient:
'''
A client for interacting with DCLD using either the REST API or command line interface (CLI).
Expand Down Expand Up @@ -248,14 +268,11 @@ def main(use_main_net_dcld: str, use_test_net_dcld: str, use_main_net_http: bool
is_paa = revocation_point["isPAA"]

# 3. && 4. Validate VID/PID
# TODO: Need to support alternate representation of VID/PID (see spec "6.2.2.2. Encoding of Vendor ID and Product ID in subject and issuer fields")
crl_vid = extract_single_integer_attribute(crl_signer_certificate.subject, OID_VENDOR_ID)
crl_pid = extract_single_integer_attribute(crl_signer_certificate.subject, OID_PRODUCT_ID)
crl_vid, crl_pid = parse_vid_pid_from_distinguished_name(crl_signer_certificate.subject)

if is_paa:
if crl_vid is not None:
if vid != crl_vid:
# TODO: Need to log all situations where a continue is called
logging.warning("VID is not CRL VID, continue...")
continue
else:
Expand Down