File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change 1
1
GSSAPI= " BASE" # This ensures that a full module is generated by Cython
2
2
3
+ import six
4
+
3
5
from libc.string cimport memcmp, memcpy
4
6
from libc.stdlib cimport free, malloc
5
7
@@ -51,6 +53,27 @@ cdef class OID:
51
53
memcpy(self .raw_oid.elements, byte_str, self .raw_oid.length)
52
54
return 0
53
55
56
+ @classmethod
57
+ def from_int_seq (cls , integer_sequence ):
58
+ elements= cls ._encode_asn1ber(integer_sequence)
59
+ return cls (elements = elements)
60
+
61
+ @staticmethod
62
+ def _encode_asn1ber (oid_seq ):
63
+ if isinstance (oid_seq, six.string_types):
64
+ oid_seq = oid_seq.split(' .' )
65
+ oid_seq = [int (x) for x in oid_seq]
66
+ if len (oid_seq) < 2 :
67
+ raise ValueError (" Sequence must be 2 or more elements long." )
68
+ byte_seq = bytearray([oid_seq[0 ] * 40 + oid_seq[1 ]])
69
+ for element in oid_seq[2 :]:
70
+ element_seq = [element & 0x7f ]
71
+ while element > 127 :
72
+ element >>= 7
73
+ element_seq.insert(0 , (element & 0x7f ) | 0x80 )
74
+ byte_seq.extend(element_seq)
75
+ return bytes(byte_seq)
76
+
54
77
def __dealloc__ (self ):
55
78
# NB(directxman12): MIT Kerberos has gss_release_oid
56
79
# for this purpose, but it's not in the RFC
Original file line number Diff line number Diff line change @@ -187,7 +187,8 @@ def gssapi_modules(lst):
187
187
keywords = ['gssapi' , 'security' ],
188
188
install_requires = [
189
189
'enum34' ,
190
- 'decorator'
190
+ 'decorator' ,
191
+ 'six'
191
192
],
192
193
tests_require = [
193
194
'tox'
You can’t perform that action at this time.
0 commit comments