Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scapy
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CodeLinaro
public-release-test-restored
platform
external
scapy
Commits
86cbabb3
Commit
86cbabb3
authored
9 years ago
by
mtu
Committed by
mtu
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Avoid unnecessary list creations with keys()
parent
6882d112
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scapy/asn1fields.py
+5
-5
5 additions, 5 deletions
scapy/asn1fields.py
scapy/layers/x509.py
+7
-7
7 additions, 7 deletions
scapy/layers/x509.py
with
12 additions
and
12 deletions
scapy/asn1fields.py
+
5
−
5
View file @
86cbabb3
...
...
@@ -256,7 +256,7 @@ class ASN1F_SEQUENCE(ASN1F_field):
name
=
"
dummy_seq_name
"
default
=
[
field
.
default
for
field
in
seq
]
for
kwarg
in
[
"
context
"
,
"
implicit_tag
"
,
"
explicit_tag
"
]:
if
kwarg
in
kwargs
.
keys
()
:
if
kwarg
in
kwargs
:
setattr
(
self
,
kwarg
,
kwargs
[
kwarg
])
else
:
setattr
(
self
,
kwarg
,
None
)
...
...
@@ -401,12 +401,12 @@ class ASN1F_CHOICE(ASN1F_field):
holds_packets
=
1
ASN1_tag
=
ASN1_Class_UNIVERSAL
.
ANY
def
__init__
(
self
,
name
,
default
,
*
args
,
**
kwargs
):
if
"
implicit_tag
"
in
kwargs
.
keys
()
:
if
"
implicit_tag
"
in
kwargs
:
err_msg
=
"
ASN1F_CHOICE has been called with an implicit_tag
"
raise
ASN1_Error
(
err_msg
)
self
.
implicit_tag
=
None
for
kwarg
in
[
"
context
"
,
"
explicit_tag
"
]:
if
kwarg
in
kwargs
.
keys
()
:
if
kwarg
in
kwargs
:
setattr
(
self
,
kwarg
,
kwargs
[
kwarg
])
else
:
setattr
(
self
,
kwarg
,
None
)
...
...
@@ -419,7 +419,7 @@ class ASN1F_CHOICE(ASN1F_field):
for
p
in
args
:
if
hasattr
(
p
,
"
ASN1_root
"
):
# should be ASN1_Packet
if
hasattr
(
p
.
ASN1_root
,
"
choices
"
):
for
k
,
v
in
p
.
ASN1_root
.
choices
.
items
():
for
k
,
v
in
p
.
ASN1_root
.
choices
.
iter
items
():
self
.
choices
[
k
]
=
v
# ASN1F_CHOICE recursion
else
:
self
.
choices
[
p
.
ASN1_root
.
network_tag
]
=
p
...
...
@@ -462,7 +462,7 @@ class ASN1F_CHOICE(ASN1F_field):
s
=
""
else
:
s
=
str
(
x
)
if
hash
(
type
(
x
))
in
self
.
pktchoices
.
keys
()
:
if
hash
(
type
(
x
))
in
self
.
pktchoices
:
imp
,
exp
=
self
.
pktchoices
[
hash
(
type
(
x
))]
s
=
BER_tagging_enc
(
s
,
implicit_tag
=
imp
,
explicit_tag
=
exp
)
...
...
This diff is collapsed.
Click to expand it.
scapy/layers/x509.py
+
7
−
7
View file @
86cbabb3
...
...
@@ -622,7 +622,7 @@ class ASN1F_EXT_SEQUENCE(ASN1F_SEQUENCE):
extnID
.
set_val
(
pkt
,
oid
)
s
=
critical
.
dissect
(
pkt
,
s
)
encapsed
=
X509_ExtDefault
if
oid
.
val
in
ext_mapping
.
keys
()
:
if
oid
.
val
in
ext_mapping
:
encapsed
=
ext_mapping
[
oid
.
val
]
self
.
seq
[
2
].
cls
=
encapsed
self
.
seq
[
2
].
cls
.
ASN1_root
.
flexible_tag
=
True
...
...
@@ -788,10 +788,10 @@ class X509_TBSCertificate(ASN1_Packet):
name_str
=
""
attrsDict
=
self
.
get_issuer
()
for
attrType
,
attrSymbol
in
attrName_mapping
:
if
attrType
in
attrsDict
.
keys
()
:
if
attrType
in
attrsDict
:
name_str
+=
"
/
"
+
attrSymbol
+
"
=
"
name_str
+=
attrsDict
[
attrType
]
for
attrType
in
sorted
(
attrsDict
.
keys
()
):
for
attrType
in
sorted
(
attrsDict
):
if
attrType
not
in
attrName_specials
:
name_str
+=
"
/
"
+
attrType
+
"
=
"
name_str
+=
attrsDict
[
attrType
]
...
...
@@ -807,10 +807,10 @@ class X509_TBSCertificate(ASN1_Packet):
name_str
=
""
attrsDict
=
self
.
get_subject
()
for
attrType
,
attrSymbol
in
attrName_mapping
:
if
attrType
in
attrsDict
.
keys
()
:
if
attrType
in
attrsDict
:
name_str
+=
"
/
"
+
attrSymbol
+
"
=
"
name_str
+=
attrsDict
[
attrType
]
for
attrType
in
sorted
(
attrsDict
.
keys
()
):
for
attrType
in
sorted
(
attrsDict
):
if
attrType
not
in
attrName_specials
:
name_str
+=
"
/
"
+
attrType
+
"
=
"
name_str
+=
attrsDict
[
attrType
]
...
...
@@ -915,10 +915,10 @@ class X509_TBSCertList(ASN1_Packet):
name_str
=
""
attrsDict
=
self
.
get_issuer
()
for
attrType
,
attrSymbol
in
attrName_mapping
:
if
attrType
in
attrsDict
.
keys
()
:
if
attrType
in
attrsDict
:
name_str
+=
"
/
"
+
attrSymbol
+
"
=
"
name_str
+=
attrsDict
[
attrType
]
for
attrType
in
sorted
(
attrsDict
.
keys
()
):
for
attrType
in
sorted
(
attrsDict
):
if
attrType
not
in
attrName_specials
:
name_str
+=
"
/
"
+
attrType
+
"
=
"
name_str
+=
attrsDict
[
attrType
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment