diff options
author | akuchling <akuchling@rivest.dlitz.net> | 2003-04-03 21:36:15 -0700 |
---|---|---|
committer | akuchling <akuchling@rivest.dlitz.net> | 2003-04-03 21:36:15 -0700 |
commit | 5c1a5d079268201b65cd67b2fa7fb0b0af2fd2a1 (patch) | |
tree | 6072feaaf79b254a27418dc6e15c980a71cbc5fd | |
parent | a59d32d476b67fdd840f485289247f20f656a9da (diff) | |
download | pycrypto-5c1a5d079268201b65cd67b2fa7fb0b0af2fd2a1.tar.gz |
[project @ akuchling-20030404043615-1825725f0edaa6ca]
[project @ 2003-04-03 20:36:06 by akuchling]
Rename can* and has* to can_* and has_*
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | Doc/pycrypt.tex | 10 | ||||
-rw-r--r-- | PublicKey/DSA.py | 16 | ||||
-rw-r--r-- | PublicKey/ElGamal.py | 4 | ||||
-rw-r--r-- | PublicKey/RSA.py | 10 | ||||
-rw-r--r-- | PublicKey/pubkey.py | 16 | ||||
-rw-r--r-- | PublicKey/qNEW.py | 8 | ||||
-rw-r--r-- | test/test_publickey.py | 6 |
8 files changed, 40 insertions, 35 deletions
@@ -19,6 +19,11 @@ * Added support to RSA key objects for blinding and unblinding data. (Contributed by Joris Bontje.) + * Renamed cansign(), canencrypt(), hasprivate(), to + can_sign, can_encrypt, has_private. If people shriek about + this change very loudly, I'll add aliases for the old method + names that log a warning and call the new method. + 1.9alpha5 ========= diff --git a/Doc/pycrypt.tex b/Doc/pycrypt.tex index 4276539..658112c 100644 --- a/Doc/pycrypt.tex +++ b/Doc/pycrypt.tex @@ -702,16 +702,16 @@ Returns true if the algorithm is capable of blinding data; returns false otherwise. \end{methoddesc} -\begin{methoddesc}{canencrypt}{} +\begin{methoddesc}{can_encrypt}{} Returns true if the algorithm is capable of encrypting and decrypting data; returns false otherwise. To test if a given key object can sign -data, use \code{key.canencrypt() and key.hasprivate()}. +data, use \code{key.can_encrypt() and key.has_private()}. \end{methoddesc} -\begin{methoddesc}{cansign}{} +\begin{methoddesc}{can_sign}{} Returns true if the algorithm is capable of signing data; returns false otherwise. To test if a given key object can sign data, use -\code{key.cansign() and key.hasprivate()}. +\code{key.can_sign() and key.has_private()}. \end{methoddesc} \begin{methoddesc}{decrypt}{tuple} @@ -732,7 +732,7 @@ big-endian integer must be relatively prime to \code{self.p-1}; an exception is raised if it is not. \end{methoddesc} -\begin{methoddesc}{hasprivate}{} +\begin{methoddesc}{has_private}{} Returns true if the key object contains the private key data, which will allow decrypting data and generating signatures. Otherwise this returns false. diff --git a/PublicKey/DSA.py b/PublicKey/DSA.py index cceefe5..6cedd91 100644 --- a/PublicKey/DSA.py +++ b/PublicKey/DSA.py @@ -11,7 +11,7 @@ # or implied. Use at your own risk or not at all. # -__revision__ = "$Id: DSA.py,v 1.12 2003-04-03 18:19:03 akuchling Exp $" +__revision__ = "$Id: DSA.py,v 1.13 2003-04-03 20:36:09 akuchling Exp $" from Crypto.PublicKey.pubkey import * from Crypto.Util.number import bytes_to_long, long_to_bytes @@ -130,17 +130,17 @@ class DSAobj(pubkey): while (power<self.p): bits, power = bits+1, power<<1 return bits-1 - def hasprivate(self): + def has_private(self): """Return a Boolean denoting whether the object contains private components.""" if hasattr(self, 'x'): return 1 else: return 0 - def cansign(self): + def can_sign(self): """Return a Boolean value recording whether this algorithm can generate signatures.""" return 1 - def canencrypt(self): + def can_encrypt(self): """Return a Boolean value recording whether this algorithm can encrypt data.""" return 0 @@ -192,16 +192,16 @@ class DSAobj_c(pubkey): def size(self): return self.key.size() - def hasprivate(self): - return self.key.hasprivate() + def has_private(self): + return self.key.has_private() def publickey(self): return construct_c((self.key.y, self.key.g, self.key.p, self.key.q)) - def cansign(self): + def can_sign(self): return 1 - def canencrypt(self): + def can_encrypt(self): return 0 def generate_c(bits, randfunc, progress_func=None): diff --git a/PublicKey/ElGamal.py b/PublicKey/ElGamal.py index 1cb3c80..74c9758 100644 --- a/PublicKey/ElGamal.py +++ b/PublicKey/ElGamal.py @@ -10,7 +10,7 @@ # or implied. Use at your own risk or not at all. # -__revision__ = "$Id: ElGamal.py,v 1.6 2003-02-28 15:25:09 akuchling Exp $" +__revision__ = "$Id: ElGamal.py,v 1.7 2003-04-03 20:36:12 akuchling Exp $" from Crypto.PublicKey.pubkey import * @@ -106,7 +106,7 @@ class ElGamalobj(pubkey): while (power<self.p): bits, power = bits+1, power<<1 return bits-1 - def hasprivate(self): + def has_private(self): """Return a Boolean denoting whether the object contains private components.""" if hasattr(self, 'x'): return 1 diff --git a/PublicKey/RSA.py b/PublicKey/RSA.py index bae7b99..a9149d7 100644 --- a/PublicKey/RSA.py +++ b/PublicKey/RSA.py @@ -10,7 +10,7 @@ # or implied. Use at your own risk or not at all. # -__revision__ = "$Id: RSA.py,v 1.14 2003-04-03 20:30:00 akuchling Exp $" +__revision__ = "$Id: RSA.py,v 1.15 2003-04-03 20:36:13 akuchling Exp $" from Crypto.PublicKey import pubkey @@ -108,8 +108,8 @@ class RSAobj(pubkey.pubkey): while (power<self.n): bits, power = bits+1, power<<1 return bits-1 - def hasprivate(self): - """hasprivate() : bool + def has_private(self): + """has_private() : bool Return a Boolean denoting whether the object contains private components. """ @@ -180,8 +180,8 @@ class RSAobj_c(pubkey.pubkey): def size(self): return self.key.size() - def hasprivate(self): - return self.key.hasprivate() + def has_private(self): + return self.key.has_private() def publickey(self): return construct_c((self.key.n, self.key.e)) diff --git a/PublicKey/pubkey.py b/PublicKey/pubkey.py index 08d6193..70d07bd 100644 --- a/PublicKey/pubkey.py +++ b/PublicKey/pubkey.py @@ -10,7 +10,7 @@ # or implied. Use at your own risk or not at all. # -__revision__ = "$Id: pubkey.py,v 1.10 2003-04-03 20:30:00 akuchling Exp $" +__revision__ = "$Id: pubkey.py,v 1.11 2003-04-03 20:36:14 akuchling Exp $" import types, warnings from Crypto.Util.number import * @@ -69,7 +69,7 @@ integers, MPZ objects, or whatever.""" Return a tuple containing the signature for the message M. K is a random parameter required by some algorithms. """ - if (not self.hasprivate()): + if (not self.has_private()): raise error, 'Private key not available in this object' if isinstance(M, types.StringType): M=bytes_to_long(M) if isinstance(K, types.StringType): K=bytes_to_long(K) @@ -116,8 +116,8 @@ integers, MPZ objects, or whatever.""" # The following methods will usually be left alone, except for # signature-only algorithms. They both return Boolean values # recording whether this key's algorithm can sign and encrypt. - def cansign (self): - """cansign() : bool + def can_sign (self): + """can_sign() : bool Return a Boolean value recording whether this algorithm can generate signatures. (This does not imply that this particular key object has the private information required to @@ -125,8 +125,8 @@ integers, MPZ objects, or whatever.""" """ return 1 - def canencrypt (self): - """canencrypt() : bool + def can_encrypt (self): + """can_encrypt() : bool Return a Boolean value recording whether this algorithm can encrypt data. (This does not imply that this particular key object has the private information required to @@ -152,8 +152,8 @@ integers, MPZ objects, or whatever.""" """ return 0 - def hasprivate (self): - """hasprivate() : bool + def has_private (self): + """has_private() : bool Return a Boolean denoting whether the object contains private components. """ diff --git a/PublicKey/qNEW.py b/PublicKey/qNEW.py index 99de21b..98671c3 100644 --- a/PublicKey/qNEW.py +++ b/PublicKey/qNEW.py @@ -10,7 +10,7 @@ # or implied. Use at your own risk or not at all. # -__revision__ = "$Id: qNEW.py,v 1.6 2003-02-28 15:25:13 akuchling Exp $" +__revision__ = "$Id: qNEW.py,v 1.7 2003-04-03 20:36:14 akuchling Exp $" from Crypto.PublicKey import pubkey from Crypto.Util.number import * @@ -138,15 +138,15 @@ class qNEWobj(pubkey.pubkey): "Return the maximum number of bits that can be handled by this key." return 160 - def hasprivate(self): + def has_private(self): """Return a Boolean denoting whether the object contains private components.""" return hasattr(self, 'x') - def cansign(self): + def can_sign(self): """Return a Boolean value recording whether this algorithm can generate signatures.""" return 1 - def canencrypt(self): + def can_encrypt(self): """Return a Boolean value recording whether this algorithm can encrypt data.""" return 0 diff --git a/test/test_publickey.py b/test/test_publickey.py index 942b5be..94c0165 100644 --- a/test/test_publickey.py +++ b/test/test_publickey.py @@ -2,7 +2,7 @@ # Test script for Crypto.Util.PublicKey. # -__revision__ = "$Id: test_publickey.py,v 1.5 2003-04-03 20:30:01 akuchling Exp $" +__revision__ = "$Id: test_publickey.py,v 1.6 2003-04-03 20:36:15 akuchling Exp $" import sys, cPickle from sancho.unittest import TestScenario, parse_args, run_scenarios @@ -27,13 +27,13 @@ class PublicKeyTest (TestScenario): def testkey (self, key, randfunc, verbose=0): plaintext="Hello" - if key.canencrypt(): + if key.can_encrypt(): if verbose: print ' Encryption/decryption test' K=number.getPrime(10, randfunc) ciphertext=key.encrypt(plaintext, K) self.test_val('key.decrypt(ciphertext)', plaintext) - if key.cansign(): + if key.can_sign(): if verbose: print ' Signature test' K=number.getPrime(30, randfunc) signature=key.sign(plaintext, K) |