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 OIDs for GOST 2001-2012 #284

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
16 changes: 16 additions & 0 deletions asn1crypto/algos.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,10 @@ class SignedDigestAlgorithmId(ObjectIdentifier):
'0.4.0.127.0.7.1.1.4.1.9': 'sha3_256_ecdsa_plain',
'0.4.0.127.0.7.1.1.4.1.10': 'sha3_384_ecdsa_plain',
'0.4.0.127.0.7.1.1.4.1.11': 'sha3_512_ecdsa_plain',
# GOST
'1.2.643.2.2.3': 'gost2001',
'1.2.643.7.1.1.3.2': 'gost2012_256',
'1.2.643.7.1.1.3.3': 'gost2012_512',
}

_reverse_map = {
Expand Down Expand Up @@ -333,6 +337,10 @@ class SignedDigestAlgorithmId(ObjectIdentifier):
'sha3_256_ecdsa_plain': '0.4.0.127.0.7.1.1.4.1.9',
'sha3_384_ecdsa_plain': '0.4.0.127.0.7.1.1.4.1.10',
'sha3_512_ecdsa_plain': '0.4.0.127.0.7.1.1.4.1.11',
# GOST
'gost2001': '1.2.643.2.2.3',
'gost2012_256': '1.2.643.7.1.1.3.2',
'gost2012_512': '1.2.643.7.1.1.3.3',
}


Expand Down Expand Up @@ -386,6 +394,10 @@ class SignedDigestAlgorithm(_ForceNullParameters, Sequence):
'sha3_256_rsa': 'sha3_256',
'sha3_384_rsa': 'sha3_384',
'sha3_512_rsa': 'sha3_512',
# GOST
'gost2001': 'ГОСТ Р 34.11-94 256 бит',
'gost2012_256': 'ГОСТ Р 34.11-2012 256 бит',
'gost2012_512': 'ГОСТ Р 34.11-2012 512 бит',
}

@property
Expand Down Expand Up @@ -443,6 +455,10 @@ def signature_algo(self):
'ecdsa': 'ecdsa',
'ed25519': 'ed25519',
'ed448': 'ed448',
# GOST
'gost2001': 'ГОСТ Р 34.11-94/34.10-2001 256 бит',
'gost2012_256': 'ГОСТ Р 34.11-2012/34.10-2012 256 бит',
'gost2012_512': 'ГОСТ Р 34.11-2012/34.10-2012 512 бит',
}
if algorithm in algo_map:
return algo_map[algorithm]
Expand Down
6 changes: 6 additions & 0 deletions asn1crypto/keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,9 @@ class PublicKeyAlgorithmId(ObjectIdentifier):
'1.3.101.111': 'x448',
'1.3.101.112': 'ed25519',
'1.3.101.113': 'ed448',
'1.2.643.2.2.19': 'gost2001',
'1.2.643.7.1.1.1.1': 'gost2012_256',
'1.2.643.7.1.1.1.2': 'gost2012_512',
}


Expand Down Expand Up @@ -1085,6 +1088,9 @@ def _public_key_spec(self):
'x448': (OctetBitString, None),
'ed25519': (OctetBitString, None),
'ed448': (OctetBitString, None),
'gost2001': (OctetBitString, None),
'gost2012_256': (OctetBitString, None),
'gost2012_512': (OctetBitString, None),
}[algorithm]

_spec_callbacks = {
Expand Down
23 changes: 23 additions & 0 deletions asn1crypto/x509.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,12 @@ class NameType(ObjectIdentifier):
'0.9.2342.19200300.100.1.25': 'domain_component',
# http://www.alvestrand.no/objectid/0.2.262.1.10.7.20.html
'0.2.262.1.10.7.20': 'name_distinguisher',
# GOST
'1.2.643.100.1': 'ogrn',
'1.2.643.100.3': 'snils',
'1.2.643.100.4': 'innle',
'1.2.643.100.5': 'ogrnip',
'1.2.643.3.131.1.1': 'inn',
}

# This order is largely based on observed order seen in EV certs from
Expand Down Expand Up @@ -582,6 +588,11 @@ class NameType(ObjectIdentifier):
'platform_manufacturer',
'platform_model',
'platform_version',
'ogrn',
'ogrnip',
'inn',
'innle',
'snils',
]

@classmethod
Expand Down Expand Up @@ -646,6 +657,12 @@ def human_friendly(self):
'platform_model': 'Platform Model',
'platform_version': 'Platform Version',
'user_id': 'User ID',
# GOST
'ogrn': 'ОГРН',
'ogrnip': 'ОГРНИП',
'inn': 'ИНН',
'innle': 'ИНН ЮЛ',
'snils': 'СНИЛС',
}.get(self.native, self.native)


Expand Down Expand Up @@ -693,6 +710,12 @@ class NameTypeAndValue(Sequence):
'platform_model': UTF8String,
'platform_version': UTF8String,
'user_id': DirectoryString,
# GOST
'ogrn': NumericString,
'ogrnip': NumericString,
'inn': NumericString,
'innle': NumericString,
'snils': NumericString,
}

_prepped = None
Expand Down