Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
phil777 committed Apr 7, 2010
2 parents 09954e9 + d36076b commit 7491f1c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 42 deletions.
2 changes: 1 addition & 1 deletion doc/scapy/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ Graphs (conversations)

WEP decryption

* `PyCrypto <http://www.dlitz.net/software/pycrypto/>`_: `pycrypto-2.0.1.win32-py2.5.zip <http://www.voidspace.org.uk/cgi-bin/voidspace/downman.py?file=pycrypto-2.0.1.win32-py2.5.zip>`_ `pycrypto-2.0.1.win32-py2.6.exe <http://www.voidspace.org.uk/downloads/pycrypto-2.0.1.win32-py2.6.exe>`_
* `PyCrypto <http://www.dlitz.net/software/pycrypto/>`_: `pycrypto-2.1.0.win32-py2.5.zip <http://www.voidspace.org.uk/downloads/pycrypto-2.1.0.win32-py2.5.zip>`_ `pycrypto-2.1.0.win32-py2.6.zip <http://www.voidspace.org.uk/downloads/pycrypto-2.1.0.win32-py2.6.zip>`_

Fingerprinting

Expand Down
81 changes: 40 additions & 41 deletions scapy/crypto/cert.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,12 +405,12 @@ def create_temporary_ca_path(anchor_list, folder):

class OSSLHelper:
def _apply_ossl_cmd(self, osslcmd, rawdata):
r,w=popen2.popen2(osslcmd)
w.write(rawdata)
w.close()
res = r.read()
r.close()
return res
r,w=popen2.popen2(osslcmd)
w.write(rawdata)
w.close()
res = r.read()
r.close()
return res

class _EncryptAndVerify:
### Below are encryption methods
Expand Down Expand Up @@ -1183,14 +1183,14 @@ def __init__(self, keypath):
rawkey = f.read()
f.close()
except:
raise Exception(error_msg)
raise Exception(error_msg)
else:
rawkey = keypath

if rawkey is None:
raise Exception(error_msg)
if rawkey is None:
raise Exception(error_msg)

self.rawkey = rawkey
self.rawkey = rawkey

# Let's try to get file format : PEM or DER.
fmtstr = 'openssl rsa -text -pubin -inform %s -noout '
Expand Down Expand Up @@ -1228,15 +1228,15 @@ def __init__(self, keypath):
textkey = r.read()
r.close()
res = e.read()
if res == '':
self.format = "DER"
if res == '':
self.format = "DER"
self.derkey = rawkey
self.textkey = textkey
cmd = convertstr % ("DER", "PEM")
self.pemkey = self._apply_ossl_cmd(cmd, rawkey)
cmd = convertstr % ("DER", "DER")
self.derkey = self._apply_ossl_cmd(cmd, rawkey)
else:
else:
try: # Perhaps it is a cert
c = Cert(keypath)
except:
Expand Down Expand Up @@ -1343,14 +1343,14 @@ def __init__(self, keypath):
rawkey = f.read()
f.close()
except:
raise Exception(error_msg)
raise Exception(error_msg)
else:
rawkey = keypath

if rawkey is None:
raise Exception(error_msg)
if rawkey is None:
raise Exception(error_msg)

self.rawkey = rawkey
self.rawkey = rawkey

# Let's try to get file format : PEM or DER.
fmtstr = 'openssl rsa -text -inform %s -noout '
Expand Down Expand Up @@ -1388,16 +1388,16 @@ def __init__(self, keypath):
textkey = r.read()
r.close()
res = e.read()
if res == '':
self.format = "DER"
if res == '':
self.format = "DER"
self.derkey = rawkey
self.textkey = textkey
cmd = convertstr % ("DER", "PEM")
self.pemkey = self._apply_ossl_cmd(cmd, rawkey)
cmd = convertstr % ("DER", "DER")
self.derkey = self._apply_ossl_cmd(cmd, rawkey)
else:
raise Exception(error_msg)
else:
raise Exception(error_msg)

self.osslcmdbase = 'openssl rsa -inform %s ' % self.format

Expand Down Expand Up @@ -1534,14 +1534,14 @@ def __init__(self, certpath):
rawcert = f.read()
f.close()
except:
raise Exception(error_msg)
raise Exception(error_msg)
else:
rawcert = certpath

if rawcert is None:
raise Exception(error_msg)
if rawcert is None:
raise Exception(error_msg)

self.rawcert = rawcert
self.rawcert = rawcert

# Let's try to get file format : PEM or DER.
fmtstr = 'openssl x509 -text -inform %s -noout '
Expand Down Expand Up @@ -1579,16 +1579,16 @@ def __init__(self, certpath):
textcert = r.read()
r.close()
res = e.read()
if res == '':
self.format = "DER"
if res == '':
self.format = "DER"
self.dercert = rawcert
self.textcert = textcert
cmd = convertstr % ("DER", "PEM")
self.pemcert = self._apply_ossl_cmd(cmd, rawcert)
cmd = convertstr % ("DER", "DER")
self.dercert = self._apply_ossl_cmd(cmd, rawcert)
else:
raise Exception(error_msg)
else:
raise Exception(error_msg)

self.osslcmdbase = 'openssl x509 -inform %s ' % self.format

Expand Down Expand Up @@ -1823,7 +1823,7 @@ def __init__(self, certpath):
# X509v3 Key Usage
self.keyUsage = []
v = fields_dict[" X509v3 Key Usage:"]
if v:
if v:
# man 5 x509v3_config
ku_mapping = {"Digital Signature": "digitalSignature",
"Non Repudiation": "nonRepudiation",
Expand All @@ -1848,7 +1848,7 @@ def __init__(self, certpath):
# X509v3 Extended Key Usage
self.extKeyUsage = []
v = fields_dict[" X509v3 Extended Key Usage:"]
if v:
if v:
# man 5 x509v3_config:
eku_mapping = {"TLS Web Server Authentication": "serverAuth",
"TLS Web Client Authentication": "clientAuth",
Expand Down Expand Up @@ -2016,7 +2016,7 @@ def remainingDays(self, now=None):
# return SHA-1 hash of cert embedded public key
# !! At the moment, the trailing 0 is in the hashed string if any
def keyHash(self):
m = self.modulus_hexdump
m = self.modulus_hexdump
res = []
i = 0
l = len(m)
Expand Down Expand Up @@ -2230,14 +2230,14 @@ def __init__(self, crlpath):
rawcrl = f.read()
f.close()
except:
raise Exception(error_msg)
raise Exception(error_msg)
else:
rawcrl = crlpath

if rawcrl is None:
raise Exception(error_msg)
if rawcrl is None:
raise Exception(error_msg)

self.rawcrl = rawcrl
self.rawcrl = rawcrl

# Let's try to get file format : PEM or DER.
fmtstr = 'openssl crl -text -inform %s -noout '
Expand Down Expand Up @@ -2275,16 +2275,16 @@ def __init__(self, crlpath):
textcrl = r.read()
r.close()
res = e.read()
if res == '':
self.format = "DER"
if res == '':
self.format = "DER"
self.dercrl = rawcrl
self.textcrl = textcrl
cmd = convertstr % ("DER", "PEM")
self.pemcrl = self._apply_ossl_cmd(cmd, rawcrl)
cmd = convertstr % ("DER", "DER")
self.dercrl = self._apply_ossl_cmd(cmd, rawcrl)
else:
raise Exception(error_msg)
else:
raise Exception(error_msg)

self.osslcmdbase = 'openssl crl -inform %s ' % self.format

Expand Down Expand Up @@ -2475,4 +2475,3 @@ def verify(self, anchors):




0 comments on commit 7491f1c

Please sign in to comment.