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
Prev Previous commit
Next Next commit
address review comments
  • Loading branch information
shubhamdp committed Jun 17, 2024
commit 63e3d9d72e916ed0efccee76f6c28d4ffe48a283
12 changes: 7 additions & 5 deletions credentials/generate-revocation-set.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from click_option_group import RequiredMutuallyExclusiveOptionGroup, optgroup
from cryptography import x509
from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.x509.oid import NameOID

# Supported log levels, mapping string values required for argument
# parsing into logging constants
Expand Down Expand Up @@ -64,13 +65,14 @@ def extract_single_integer_attribute(subject, oid):
return None


def extract_single_attribute_from_cn(cn, marker):
def extract_fallback_tag_from_common_name(cn, marker):
val_len = 4
start_idx = cn.find(marker)

if start_idx != -1:
val_start_idx = start_idx + len(marker)
return int(cn[val_start_idx:val_start_idx + val_len], 16)
val = cn[val_start_idx:val_start_idx + val_len]
return int(val, 16) if len(val) == 4 else None

return None

Expand All @@ -82,9 +84,9 @@ def parse_vid_pid_from_distinguished_name(distinguished_name):

# 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
vid = extract_single_attribute_from_cn(cn, 'Mvid:')
pid = extract_single_attribute_from_cn(cn, 'Mpid:')
cn = distinguished_name.get_attributes_for_oid(x509.ObjectIdentifier(NameOID.COMMON_NAME))[0].value
vid = extract_fallback_tag_from_common_name(cn, 'Mvid:')
pid = extract_fallback_tag_from_common_name(cn, 'Mpid:')

return vid, pid

Expand Down