Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
shrapnel
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
shrapnel
Commits
24144b0f
Commit
24144b0f
authored
Mar 19, 2015
by
Sam Rushing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more careful segregation of UNIVERSAL/STRUCTURED.
parent
1cbbf5df
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
21 deletions
+16
-21
coro/asn1/ber.pyx
coro/asn1/ber.pyx
+16
-21
No files found.
coro/asn1/ber.pyx
View file @
24144b0f
...
@@ -626,8 +626,6 @@ cdef object _decode (unsigned char * s, long * pos, long eos, bint just_tlv):
...
@@ -626,8 +626,6 @@ cdef object _decode (unsigned char * s, long * pos, long eos, bint just_tlv):
# 1) get tag
# 1) get tag
tag
=
_decode_tag
(
s
,
pos
,
eos
,
&
flags
)
tag
=
_decode_tag
(
s
,
pos
,
eos
,
&
flags
)
# 2) get length
# 2) get length
print
'tag'
,
tag
print
'flags'
,
flags
check_pos
(
pos
,
eos
)
check_pos
(
pos
,
eos
)
if
s
[
pos
[
0
]]
<
0x80
:
if
s
[
pos
[
0
]]
<
0x80
:
# one-byte length
# one-byte length
...
@@ -656,7 +654,6 @@ cdef object _decode (unsigned char * s, long * pos, long eos, bint just_tlv):
...
@@ -656,7 +654,6 @@ cdef object _decode (unsigned char * s, long * pos, long eos, bint just_tlv):
elif
just_tlv
:
elif
just_tlv
:
return
(
tag
,
flags
,
length
)
return
(
tag
,
flags
,
length
)
elif
flags
==
FLAGS_UNIVERSAL
:
elif
flags
==
FLAGS_UNIVERSAL
:
# these are builtin types
if
tag
==
TAGS_OCTET_STRING
:
if
tag
==
TAGS_OCTET_STRING
:
return
decode_string
(
s
,
pos
,
length
)
return
decode_string
(
s
,
pos
,
length
)
elif
tag
==
TAGS_UTF8STRING
:
elif
tag
==
TAGS_UTF8STRING
:
...
@@ -668,10 +665,6 @@ cdef object _decode (unsigned char * s, long * pos, long eos, bint just_tlv):
...
@@ -668,10 +665,6 @@ cdef object _decode (unsigned char * s, long * pos, long eos, bint just_tlv):
return
decode_integer
(
s
,
pos
,
length
)
return
decode_integer
(
s
,
pos
,
length
)
elif
tag
==
TAGS_BOOLEAN
:
elif
tag
==
TAGS_BOOLEAN
:
return
decode_boolean
(
s
,
pos
,
length
)
return
decode_boolean
(
s
,
pos
,
length
)
elif
tag
==
TAGS_SEQUENCE
:
return
decode_structured
(
s
,
pos
,
length
)
elif
tag
==
TAGS_SET
:
return
decode_structured
(
s
,
pos
,
length
)
elif
tag
==
TAGS_ENUMERATED
:
elif
tag
==
TAGS_ENUMERATED
:
return
decode_integer
(
s
,
pos
,
length
)
return
decode_integer
(
s
,
pos
,
length
)
elif
tag
==
TAGS_OBJID
:
elif
tag
==
TAGS_OBJID
:
...
@@ -680,24 +673,26 @@ cdef object _decode (unsigned char * s, long * pos, long eos, bint just_tlv):
...
@@ -680,24 +673,26 @@ cdef object _decode (unsigned char * s, long * pos, long eos, bint just_tlv):
return
(
kind_bitstring
,
decode_bitstring
(
s
,
pos
,
length
))
return
(
kind_bitstring
,
decode_bitstring
(
s
,
pos
,
length
))
elif
tag
==
TAGS_NULL
:
elif
tag
==
TAGS_NULL
:
return
None
return
None
elif
TAG_TABLE
.
has_key
(
tag
):
return
(
TAG_TABLE
[
tag
],
tag
,
decode_raw
(
s
,
pos
,
length
))
else
:
else
:
return
(
kind_unknown
,
tag
,
decode_raw
(
s
,
pos
,
length
))
return
(
kind_unknown
,
tag
,
decode_raw
(
s
,
pos
,
length
))
else
:
else
:
if
flags
&
FLAGS_CONTEXT
:
if
tag
==
TAGS_SEQUENCE
and
flags
==
FLAGS_STRUCTURED
:
# union discriminator
return
decode_structured
(
s
,
pos
,
length
)
kind
=
kind_context
elif
tag
==
TAGS_SET
and
flags
==
FLAGS_STRUCTURED
:
elif
flags
&
FLAGS_APPLICATION
:
return
decode_structured
(
s
,
pos
,
length
)
# user type tags
kind
=
kind_application
elif
TAG_TABLE
.
has_key
(
tag
):
# unsupported
kind
=
TAG_TABLE
[
tag
]
else
:
kind
=
kind_unknown
if
flags
&
FLAGS_STRUCTURED
:
return
(
kind
,
tag
,
decode_structured
(
s
,
pos
,
length
))
else
:
else
:
return
(
kind
,
tag
,
decode_raw
(
s
,
pos
,
length
))
if
flags
&
FLAGS_CONTEXT
:
kind
=
kind_context
elif
flags
&
FLAGS_APPLICATION
:
kind
=
kind_application
else
:
kind
=
kind_unknown
if
flags
&
FLAGS_STRUCTURED
:
return
(
kind
,
tag
,
decode_structured
(
s
,
pos
,
length
))
else
:
return
(
kind
,
tag
,
decode_raw
(
s
,
pos
,
length
))
def
decode
(
bytes
s
,
long
pos
=
0
,
just_tlv
=
0
):
def
decode
(
bytes
s
,
long
pos
=
0
,
just_tlv
=
0
):
return
_decode
(
return
_decode
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment