| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Bump the maximum number of iterations to recover (p,q) given (n,e,d) to
increase the chance that the algorithm succeeds. The algorithm used is a
probabilistic one with a 1/2 chance of finding the right value in each
iteration, so it's likely that only a few iterations are needed.
However, in some extreme cases this may still fail. Bumping the maximum
number allow the algorithm to correctly find the right values for these
cases. This changes bumps the number of iterations from 50 to 500 (the
value 'a' is increased by 2 in each step), and hence reduces the chance
of failure from 2**-50 to 2**-500.
Note that this change does *not* result in a performance degradation.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch strenghten the DSA signing code against
side-channel attacks.
The DSA signing formulae:
r = (g^{k} mod p) mod q
s = k^{-1} * (H(m) + r*x) mod q
becomes:
b = random in [1..q)
r = (g^{k} mod p) mod q
s = (b * k)^{-1} * (b*H(m) + r*(b*x)) mod q
In this way we avoid that the secret (x) gets multiplied
by a random factor (r) which is immediately disclosed
to an attacker (which we assume can both collect (r) and
also monitor the side-channel produced by the multiplication).
See also attack DSA_2 in:
"Minimum Requirements for Evaluating Side-Channel Attack Resistance
of RSA, DSA and Diffie-Hellman Key Exchange Implementations", BSI
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
| |
The following custom exceptions are replaced with ValueError:
* Crypto.Util.PaddingError
* Crypto.PublicKey.KeyFormatError
The custom Crypto.Util.asn1.NoDerElementError is now private to the
module.
Some white spaces have been removed.
|
| |
|
|
| |
Closes: https://bugs.launchpad.net/pycrypto/+bug/1191411
|
| |
|
|
|
|
|
|
|
|
|
|
| |
This patch adds methods importKey() to DSA module
and exportKey() to _DSAobj object.
Public and private keys can be imported/exported
in a variety of formats:
* DER vs PEM
* PKCS#8 vs OpenSSL vs OpenSSH/OpenSSL
* Encrypted vs clear
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The patch contains the following changes:
- Private RSA keys can be imported/exported in encrypted form,
protected according to PKCS#8 and:
* PBKDF2WithHMAC-SHA1AndDES-EDE3-CBC.
* PBKDF2WithHMAC-SHA1AndAES128-CBC
* PBKDF2WithHMAC-SHA1AndAES192-CBC
* PBKDF2WithHMAC-SHA1AndAES256-CBC
In addition to that, it is possible to import keys i the
following weak formats:
* pbeWithMD5AndDES-CBC
* pbeWithSHA1AndRC2-CBC
* pbeWithMD5AndRC2-CBC
* pbeWithSHA1AndDES-CBC
- The following new module (and 1 new package) are added:
* Crypto.Util.Padding for simple padding/unpadding logic
* Crypto.IO._PBES for PBE-related PKCS#5 logic
* Crypto.IO.PEM for PEM wrapping/unwrapping
* Crypto.IO.PKCS8 for PKCS#8 wrapping/unwrapping
- All Object ID (OIDs) are now in dotted form to increase
readability.
- Add AES support to PEM format (decode only).
The PEM module can decrypt messages protected with AES-CBC.
- Update RSA import test cases.
- Updated to PKCS8 test cases
|
| | |
|
| |
|
|
|
|
|
|
|
| |
These algorithm names were confusing, because there are actually
algorithms called "SHA" (a.k.a. SHA-0) and "RIPEMD" (the original
version).
This commit just renames the modules, with no backward-compatibility
support.
|
| | |
|
| |\ |
|
| | |
| |
| |
| | |
Also add a test case for it.
|
| | |
| |
| |
| | |
RSA.exportKey claims to return a byte string, so really return one.
|
| |/
|
|
|
|
|
|
|
|
|
|
|
|
| |
Constructs like
try:
...
except ValueError, IndexError:
...
don't work as expected. This only catches a ValueError and replaces the builtin
IndexError with the catches ValueError object. See [1] for details.
[1] http://docs.python.org/whatsnew/2.6.html#pep-3110-exception-handling-changes
|
| |
|
|
| |
I doubt anyone uses it anyway, and we have no test suite for it.
|
| | |
|
| | |
|
| | |
|
| |
|
|
| |
sign must really be hash.
|
| |
|
|
| |
signature verification.
|
| | |
|
| | |
|
| | |
|
| |
|
|
| |
private methods, and inherited ones are made more explicit.
|
| |\ |
|
| | | |
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The bug is at: https://bugs.launchpad.net/pycrypto/+bug/702835
When importing an DER RSA private key, u (that is, p^{-1} mod q) must be
computed manually. RSA.importKey() also raises a more descriptive exception in
case of an unknown key format.
Conflicts:
lib/Crypto/PublicKey/RSA.py
|
| | | |
|
| |\ \
| |/ |
|
| | |
| |
| |
| |
| | |
Applied patch from Debian python-crypto 2.3-3:
debian/patches/fix-RSA-generate-exception.patch
|
| | |\ |
|
| | | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
o _fastmath now builds and runs on PY3K
o Changes to setup.py to allow /usr/include for gmp.h
o Changes to setup.py to allow linking fastmath w/ static mpir
on Windows without warning messages
o Changes to test_DSA/test_RSA to throw an exception if _fastmath
is present but cannot be imported (due to an issue building
_fastmath or the shared gmp/mpir libraries not being reachable)
o number.py has the code to flag a failing _fastmath, but that
code is commented out for a better runtime experience
o Clean up the if for py21compat import - should have been == not is
o Clean up some '== None' occurences, now 'is None' instead
|
| | | | |
|
| | | |
| | |
| | |
| | | |
FIX: Certain public exponents were not correctly exported in OpenSSH keys.
|
| | | |
| | |
| | |
| | | |
import and export.
|
| | | | |
|
| | | | |
|
| |\ \ \
| | |/
| |/| |
|
| | |/
| |
| |
| |
| | |
Thanks to Geremy Condra (and others) for pointing out the timing
vulnerability.
|
| | | |
|
| | | |
|
| | |
| |
| |
| | |
it (that is, because it helps a little the inversion step that follows).
|
| | |
| |
| |
| |
| |
| |
| |
| | |
Small fix to importKey documentation (ASN.1 structure names were
incorrect for public keys).
Factors of an RSA private key are computed from private exponent d
(both slowmath and fastmath).
|
| | | |
|
| | | |
|
| |/
|
|
| |
mod q) must be computed manually. RSA.importKey() also raises a more descriptive exception in case of an unknown key format.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
tries to generate a bogus-length key.
Before this change, doing RSA.generate(128*5) would raise an exception saying:
"bits must be multiple of 128 and > 512"
This was because getStrongPrime was raising the exception when trying to
generate 320-bit primes (which is correct behaviour). Now, we raise a more
friendly error message:
"RSA modulus length must be a multiple of 256 and > 1024"
|
| |
|
|
| |
This makes _slowmath behave the same as _fastmath in this regard.
|
| |
|
|
|
|
| |
This patch add support for older python 2.1/2.2 to the previous one (DER/PEM).
Committer: Legrandin <gooksankoo@hoiptorrow.mailexpire.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Typical usage for importing an RSA key:
f = file("ssl.pem")
key = RSA.importKey(f.read())
f.close()
key.verify(hash, signature)
Typical usage for exporting an RSA public key:
key = RSA.generate(512, randfunc)
f = file("ssl.der","w")
f.write(key.publickey.exportKey('DER'))
f.close()
I confirm I am eligible for submitting code to pycrypto according
to http://www.dlitz.net/software/pycrypto/submission-requirements/
fetched on 27 December 2009.
Committer: Legrandin <gooksankoo@hoiptorrow.mailexpire.com>
|