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. |
Class Variable Summary | |
---|---|
property |
id
|
classmethod |
loadKey
|
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. |
Class Variable Details |
---|
id
|
loadKey
|
Trees | Index | Help |
---|
Generated by Epydoc 1.1 on Sun Aug 17 03:32:32 2003 | http://epydoc.sf.net |