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 support for RFC 3114, RFC 5755, RFC 5913, and RFC 5917 #103

Merged
merged 4 commits into from
Nov 10, 2019
Merged

Add support for RFC 3114, RFC 5755, RFC 5913, and RFC 5917 #103

merged 4 commits into from
Nov 10, 2019

Conversation

russhousley
Copy link
Contributor

Add modules and tests for RFC 3114, RFC 5755, RFC 5913, and RFC 5917.

@etingof
Copy link
Owner

etingof commented Nov 9, 2019

CI fails on Py3 jobs:

======================================================================
FAIL: testOpenTypes (tests.test_rfc5755.AttributeCertificateTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/etingof/pyasn1-modules/tests/test_rfc5755.py", line 85, in testOpenTypes
    assert attr['values'][0]['authInfo'] == 'password'
AssertionError

May be this has something to do with str vs bytes in "password"?

@russhousley
Copy link
Contributor Author

I am also seeing this when I run under python3:

.../pyasn1/type/univ.py:711: DeprecationWarning: int returned non-int (type SizedInteger). The ability to return an instance of a strict subclass of int is deprecated, and may be removed in a future version of Python.
return SizedInteger(value).setBitLength(len(value))

Add str() so the test works in python2 and python3
@codecov-io
Copy link

codecov-io commented Nov 10, 2019

Codecov Report

Merging #103 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #103      +/-   ##
==========================================
+ Coverage   99.36%   99.37%   +0.01%     
==========================================
  Files          91       95       +4     
  Lines        5801     5941     +140     
==========================================
+ Hits         5764     5904     +140     
  Misses         37       37
Impacted Files Coverage Δ
pyasn1_modules/rfc5913.py 100% <100%> (ø)
pyasn1_modules/rfc5755.py 100% <100%> (ø)
pyasn1_modules/rfc5917.py 100% <100%> (ø)
pyasn1_modules/rfc3114.py 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 745eed0...9a848c8. Read the comment docs.

@russhousley
Copy link
Contributor Author

I added str() so that it works under python2 and python3.

@etingof
Copy link
Owner

etingof commented Nov 10, 2019

I added str() so that it works under python2 and python3.

I changed it to str2octs so that we ensure the result is in bytes on Py3.


id_tsp_TEST_Amoco = id_tsp + (1, )

class Amoco_SecurityClassification(univ.Integer):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: it so happened that we primarily use CamelCase (no underscore), so it probably makes sense to stick with it if possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to align with the ASN.1 definition with hyphen changed to underscore:

Amoco-SecurityClassification ::= INTEGER {
amoco-general (6),
amoco-confidential (7),
amoco-highly-confidential (8) }

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that hyphen does not occur often in ASN.1 definitions. This is probably the first time when it caught my eye.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It happens all the time, especially with OIDs. asn1ate does the substitution from hypen to underscore automatically. The following examples are at the top of the ASN.1 module in RFC 5280...

-- PKIX specific OIDs

id-pkix OBJECT IDENTIFIER ::=
{ iso(1) identified-organization(3) dod(6) internet(1)
security(5) mechanisms(5) pkix(7) }

-- PKIX arcs

id-pe OBJECT IDENTIFIER ::= { id-pkix 1 }
-- arc for private certificate extensions
id-qt OBJECT IDENTIFIER ::= { id-pkix 2 }
-- arc for policy qualifier types
id-kp OBJECT IDENTIFIER ::= { id-pkix 3 }
-- arc for extended key purpose OIDS
id-ad OBJECT IDENTIFIER ::= { id-pkix 48 }
-- arc for access descriptors

-- policyQualifierIds for Internet policy qualifiers

id-qt-cps OBJECT IDENTIFIER ::= { id-qt 1 }
-- OID for CPS qualifier
id-qt-unotice OBJECT IDENTIFIER ::= { id-qt 2 }
-- OID for user notice qualifier

-- access descriptor definitions

id-ad-ocsp OBJECT IDENTIFIER ::= { id-ad 1 }
id-ad-caIssuers OBJECT IDENTIFIER ::= { id-ad 2 }
id-ad-timeStamping OBJECT IDENTIFIER ::= { id-ad 3 }
id-ad-caRepository OBJECT IDENTIFIER ::= { id-ad 5 }

@etingof etingof merged commit 5032fad into etingof:master Nov 10, 2019
@etingof
Copy link
Owner

etingof commented Nov 10, 2019

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants