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

Add identifiers for Hash algorithms #12154

Merged
merged 1 commit into from
Dec 16, 2024
Merged

Conversation

DarkaMaul
Copy link
Contributor

This is a QoL PR to improve how ObjectIdentifier are displayed.

The following script shows the difference:

from cryptography.x509.oid import ObjectIdentifier
SHA256_OID = ObjectIdentifier("2.16.840.1.101.3.4.2.1")
print(SHA256_OID)
  • With PR: <ObjectIdentifier(oid=2.16.840.1.101.3.4.2.1, name=sha256)>
  • Without: <ObjectIdentifier(oid=2.16.840.1.101.3.4.2.1, name=Unknown OID)>

The hash list is extracted from

// Hashes
pub const SHA1_OID: asn1::ObjectIdentifier = asn1::oid!(1, 3, 14, 3, 2, 26);
pub const SHA224_OID: asn1::ObjectIdentifier = asn1::oid!(2, 16, 840, 1, 101, 3, 4, 2, 4);
pub const SHA256_OID: asn1::ObjectIdentifier = asn1::oid!(2, 16, 840, 1, 101, 3, 4, 2, 1);
pub const SHA384_OID: asn1::ObjectIdentifier = asn1::oid!(2, 16, 840, 1, 101, 3, 4, 2, 2);
pub const SHA512_OID: asn1::ObjectIdentifier = asn1::oid!(2, 16, 840, 1, 101, 3, 4, 2, 3);
pub const SHA3_224_OID: asn1::ObjectIdentifier =
asn1::oid!(1, 3, 6, 1, 4, 1, 37476, 3, 2, 1, 99, 7, 224);
pub const SHA3_256_OID: asn1::ObjectIdentifier =
asn1::oid!(1, 3, 6, 1, 4, 1, 37476, 3, 2, 1, 99, 7, 256);
pub const SHA3_384_OID: asn1::ObjectIdentifier =
asn1::oid!(1, 3, 6, 1, 4, 1, 37476, 3, 2, 1, 99, 7, 384);
pub const SHA3_512_OID: asn1::ObjectIdentifier =
asn1::oid!(1, 3, 6, 1, 4, 1, 37476, 3, 2, 1, 99, 7, 512);

@alex alex merged commit 065a98d into pyca:main Dec 16, 2024
63 checks passed
@woodruffw woodruffw deleted the dm/add-hashes branch December 16, 2024 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants