Trees | Index | Help |
---|
Package yawPyCrypto ::
Module Key ::
Class Key |
|
object
--+ |IFlatten
--+ |object
--+ | | |AlgoDefinitions
--+ | Key
SecureKey
,
SecureAsciiKey
,
AsciiKey
Method Summary | |
---|---|
Create a new key. | |
Compares two keys. | |
Deletes the specified key argument from this key. | |
Loads the key attribute name from the current key object, and unserializes it. | |
Returns a hash value of a key instance. | |
Return an iterator over all names of key arguments. | |
a new object with type S, a subtype of T |
|
Sets the passed in keyword argument called name to the value that is passed in along. | |
Returns a boolean whether this key can decrypt data. | |
Returns a boolean whether this key can encrypt data. | |
Returns a boolean whether this key can sign data. | |
Returns a boolean whether this key can verify signed data. | |
Returns the maximum string length of data which can be encrypted or signed. | |
Decrypt string data as passed in using data. | |
Encrypt string data as passed in using data. | |
Checks whether this key has a private key part. | |
Checks whether this key has a public key part. | |
Returns the key's keysize in bits. | |
Returns a new key object which contains only the public key associated with the current key, and only public key arguments. | |
Create a new signature for the data that is passed in. | |
Stores a key to a string of bytes. | |
Stores only the public key of this key to a string of bytes. | |
Dictionary style updating for a Key instance. | |
Verify the signature of the passed in string. | |
_IFlatten__serialize(self,
*args,
**kwargs)
(inherited from IFlatten )
| |
_IFlatten__unserialize(self,
*args,
**kwargs)
(inherited from IFlatten )
| |
Function which is called to check whether the current key argument should be treated as a private key argument (and as such is stored only on a call to storeKey()). | |
Function used to create a new key for this Key object. | |
Decrypt the passed in PyCrypto output of encryption, and return the decrypted string. | |
Encrypt data as passed in, and return the PyCrypto output of the encrypted data. | |
Function used to get an encryption prime as required by the El Gamal public key encryption algorithm. | |
Returns the yawPyCrypto ID of the current key object. | |
Function called by the Flatten serialization library to serialize a key instance. | |
Function that returns a PyCrypto signature for the data that is passed in. | |
Function called by the Flatten serialization library to unserialize a key instance from the dictionary passed in as serstate. | |
Function that verifies a PyCrypto signature for the data that is passed in. |
Class Variable Summary | |
---|---|
property |
id
|
classmethod |
loadKey
|
dict |
_Key__typeMap
|
classmethod |
_Key__unwrap
|
classmethod |
_Key__wrap
|
list |
_unwrappers
|
list |
_wrappers
|
Method Details |
---|
__init__(self,
keysize=1024,
algo_pub=3,
**kwargs)
|
__cmp__(self,
other)
Compares two keys. Two keys are equal if and only if their IDs match.
This means that two keys can compare equal, although their key
arguments are not equal.
|
__delitem__(self,
name)
Deletes the specified key argument from this key. In case it is not
present, a KeyError is raised.
|
__getitem__(self,
name)
Loads the key attribute name from the current key object, and
unserializes it. Loading a key attribute checks for validity of the
data by comparing the stored string representation against a signature
which was stored on setting the attribute (in case the key contained a
private key). In case no signature is found, the object is (by default)
returned in an Untrusted() wrapping object. In case the signature found
is bad, an exception is raised. This behaviour is configurable through
the Config.py option WARN_ABOUT_UNTRUSTED_KEY_ARGUMENTS.
|
__hash__(self)
Returns a hash value of a key instance. The hash value is computed by
computing the Python hash of the key's ID.
|
__iter__(self)Return an iterator over all names of key arguments. |
__new__(S, ...)
|
__setitem__(self,
name,
value)
Sets the passed in keyword argument called name to the value that is
passed in along. The value is stored using the serialize function from
the Flatten module, and in case the current key has the possibility to
sign values, a signature is stored along with the key-data.
|
canDecrypt(self)Returns a boolean whether this key can decrypt data. |
canEncrypt(self)Returns a boolean whether this key can encrypt data. |
canSign(self)Returns a boolean whether this key can sign data. |
canVerify(self)Returns a boolean whether this key can verify signed data. |
cryptSize(self)Returns the maximum string length of data which can be encrypted or signed. This is equivalent to doing keySize() // 8. |
decrypt(self, encdata, wrap=True, *args, **kwargs)Decrypt string data as passed in using data. The string must have been created by the encrypt() method of this class for decryption to succeed. The parameters passed in have the following meaning: data - String data to be decrypted. wrap - Defaults to True. In case you use a Key derived class such as AsciiKey, specifies whether the decrypted data should be unwrapped before decrypting it. *args, **kwargs - All extra arguments are passed to the unwrapping functions declared by the current Key(-derived) class. |
encrypt(self, data, wrap=True, *args, **kwargs)Encrypt string data as passed in using data. The string data may not be longer than self.cryptSize() for encryption to succeed. The parameters passed in have the following meaning: data - String data to be encrypted. wrap - Defaults to True. In case you use a Key derived class such as AsciiKey, specifies whether the encrypted data should be wrapped after storing it. *args, **kwargs - All extra arguments are passed to the wrapping functions declared by the current Key(-derived) class. |
hasPrivate(self)Checks whether this key has a private key part. |
hasPublic(self)Checks whether this key has a public key part. Always returns true at the moment. |
keySize(self)Returns the key's keysize in bits. |
publicKey(self)Returns a new key object which contains only the public key associated with the current key, and only public key arguments. This is done by serializing the class, and then loading it again, so the two copies are disjoint. |
sign(self, data, hash_algo=5, wrap=True, *args, **kwargs)Create a new signature for the data that is passed in. The signature is a string, which is returned. The parameters passed in have the following meaning: data - String data to be signed. hash_algo - Hash algorithm to use to hash the data before signing it. Special value HASH_NONE for hash_algo means that no hashing of the data is done before signing it. wrap - Defaults to True. In case you use a Key derived class such as AsciiKey, specifies whether the signature data should be wrapped on return. *args, **kwargs - All extra arguments are passed to the wrapping functions declared by the current Key(-derived) class. |
storeKey(self, wrap=True, *args, **kwargs)Stores a key to a string of bytes. The arguments passed to this function have the following meaning: wrap - Defaults to True. In case you use a Key derived class such as SecureKey or AsciiKey, specifies whether the keydata should be wrapped after storing it. *args, **kwargs - All extra arguments are passed to the wrapping functions declared by the current Key(-derived) class. This function stores all key arguments to the key stream, even when the key only contains a public key. In case the key contains only a public key, the data is stored as PUBKEYDATA nevertheless (even though private key arguments are stored to the stream), so that e.g. SecureKey doesn't do encryption on the key. This means that by using this function, you may leak private key arguments that have been set on a public key (these are Untrusted anyway). |
storePublicKey(self, wrap=True, *args, **kwargs)Stores only the public key of this key to a string of bytes. The arguments passed to this function have the following meaning: wrap - Defaults to True. In case you use a Key derived class such as SecureKey or AsciiKey, specifies whether the keydata should be wrapped after storing it. *args, **kwargs - All extra arguments are passed to the wrapping functions declared by the current Key(-derived) class. This function only stores public key arguments to the output stream. |
update(self, args)Dictionary style updating for a Key instance. It allows you to set key arguments based on another Key instance, or based on any object supporting dictionary style interation and access. |
verify(self, data, signature, wrap=True, *args, **kwargs)Verify the signature of the passed in string. The signature must have been created by the sign() method. data - String data to be verified. signature - Signature of the string data which was returned by the sign() function. wrap - Defaults to True. In case you use a Key derived class such as AsciiKey, specifies whether the signature data should be unwrapped before trying to verify it. *args, **kwargs - All extra arguments are passed to the unwrapping functions declared by the current Key(-derived) class. |
_isPrivate(self, key)Function which is called to check whether the current key argument should be treated as a private key argument (and as such is stored only on a call to storeKey()). The default implementation checks whether the key argument name is a string, and in case it is, whether it starts with an underscore. In this case it returns True, in all other cases False. In case you need different behaviour, override this method in a Key-derived class. |
_Key__createKey(self, keysize)Function used to create a new key for this Key object. |
_Key__decrypt(self, data)Decrypt the passed in PyCrypto output of encryption, and return the decrypted string. |
_Key__encrypt(self, data)Encrypt data as passed in, and return the PyCrypto output of the encrypted data. |
_Key__getEncPrime(self)Function used to get an encryption prime as required by the El Gamal public key encryption algorithm. It returns a random prime in big-endian string representation. |
_Key__getID(self)Returns the yawPyCrypto ID of the current key object. This is a string, which basically is a hash of all key numbers the public key contains, represented in big-endian byte-order. The key ID is used to compute a hash value of a key, and also to compare two keys. |
_Key__serialize(self, private=True, network=False, *args, **kwargs)Function called by the Flatten serialization library to serialize a key instance. The parameters passed in are the same as passed to the serialize() function. The serialization implementation stores the key to a dictionary. In case the keyword argument private is True and network is False, the private key (in case it is there) is stored, along with all private key arguments; in all other cases only the public key with the public key arguments is stored. |
_Key__sign(self, data)Function that returns a PyCrypto signature for the data that is passed in. |
_Key__unserialize(self, serstate, *args, **kwargs)Function called by the Flatten serialization library to unserialize a key instance from the dictionary passed in as serstate. This function checks whether the key is in a valid format, and loads the data from the key and all key arguments into this instances private variables. |
_Key__verify(self, data, signature)Function that verifies a PyCrypto signature for the data that is passed in. |
Class Variable Details |
---|
id
|
loadKey
|
_Key__typeMap
|
_Key__unwrap
|
_Key__wrap
|
_unwrappers
|
_wrappers
|
Trees | Index | Help |
---|
Generated by Epydoc 1.1 on Sun Aug 17 03:32:34 2003 | http://epydoc.sf.net |