Package yawPyCrypto :: Module AdvKey
[show private | hide private]
[frames | no frames]

Module yawPyCrypto.AdvKey

AdvKey.py
=========

AsciiKey
--------

Key class which wraps key data and encryption/signature packets in base64
encoding. This class offers exactly the same functionality that the
underlying Key class offers, and is a drop-in replacement. The packets it
generates have a similar look and feel as GPG ascii-armored packets, with
a header and a footer (which is configurable through several class
members). If you wish to convert any key object to an AsciiKey, call the
toAsciiKey function.

SecureKey
---------

Key class which wraps private key data in an encryption packet with the
block cipher algorithm Blowfish. This class offers exactly the same
functionality that the underlying Key class offers, and is a drop-in
replacement. The returned packets are byte strings, just as the key class.
If you wish to convert any key object to a SecureKey, call the toSecureKey
function.

SecureAsciiKey
--------------

Key class which combines wrapping key data and encryption/signature
packets in base64 encoding, while encrypting private key data first
with the block cipher Blowfish. This class offers exactly the same
functionality that the underlying Key class offers, and is a drop-in
replacement. The packets it generates have a similar look and feel as
GPG ascii-armored packets, with a header and a footer (which is
configurable through several class members). If you wish to convert any
key object to a SecureAsciiKey, call the toSecureAsciiKey function.

Writing your own Key extension classes
--------------------------------------

It is quite simple to write your own key extension classes, which do
data wrapping in a user-specified format. The first thing to do is to
define two functions, which have reverse effects, one to wrap data in
your personal format, one to unwrap the data from this format.

The functions should be defined similar to the following:
    
    def _wrap(selfcls,data,datatype,*args,**kwargs):
        <wrap data>
        return <wrapped data>
        
    def _unwrap(selfcls,data,datatype,*args,**kwargs):
        <unwrap data>
        return <unwrapped data>

The parameters these functions take are:
    
    1. selfcls, the Key class on which the method which does
    wrapping/unwrapping is called. Thus, if you declare the
    functions as class members, they have to be classmethods.
    
    2. data, the data which is to be wrapped or unwrapped. This is a
    string. The function should change this string to a more suitable
    format, and return the changed data.
    
    3. datatype, one of the PRIVKEYDATA, PUBKEYDATA, ENCDATA, SIGNDATA
    constants defined in the Key module, which specify the type of data
    that is being wrapped. This can be used to add specific headers to
    the data (as demonstrated in the _asciiWrap() and _asciiUnwrap()
    functions). You can also use this to only wrap specific packets.
    Sidenote: On unwrapping key data, PRIVKEYDATA is always used when
    unwrapping keys, as it is not known whether the key is only a public
    key when the unwrapping is being done. On wrapping key data, one of
    PRIVKEYDATA and PUBKEYDATA is passed in depending on whether
    storeKey() or storePublicKey() is called and whether the key contains
    a public key.
    
    4. *args, **kwargs, all extra arguments that are passed to the
    function which calls the wrapper/unwrapper. These can be used at free
    will by the function. An example is the SecureKey class, which expects
    to be passed a password which is used to protect the key as a keyword
    argument called password.
    
The class also needs to define two class members called _wrappers and
_unwrappers, which are lists of tuples. These lists specify the wrapping
functions to be called, and the order in which they are called. The tuples
have to be in the format: (<priority>,<function to call>). <Priority> is a
number, where functions with a lower priority are called earlier, while
<function to call> is simply a reference to the function which is to be
called.

Further questions on writing Key extension classes?
---------------------------------------------------

Read the source, luke. The source should be self-documentary enough to get
you started quickly.

Copyright
=========

yawPyCrypto is copyright (C) 2002-3 by Heiko Wundram
<heiko@asta.uni-saarland.de>.

This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or (at
your option) any later version.

This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this library in the file "COPYLEFT"; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307  USA

Classes
AsciiKey AsciiKey is a Key derived class which offers functionality to wrap Key data in base64 encoded packets.
SecureAsciiKey SecureAsciiKey is a Key derived class which offers both ascii-armoring and also encryption of private key data in a single key class.
SecureKey SecureKey is a Key derived class which offers encryption of private key data using the Blowfish cipher, with a specified password.

Function Summary
  toAsciiKey(key)
Changes the passed in key so that it now is an instance of AsciiKey.
  toSecureAsciiKey(key)
Changes the passed in key so that it now is an instance of SecureAsciiKey.
  toSecureKey(key)
Changes the passed in key so that it now is an instance of SecureKey.

Variable Summary
str __date__
str __version__
int CIPHER_AES
int CIPHER_ARC2
int CIPHER_ARC4
int CIPHER_BLOWFISH
int CIPHER_CAST
int CIPHER_DES3
int CIPHERALGO
int ENCDATA
int HASH_MD2
int HASH_MD4
int HASH_MD5
int HASH_NONE
int HASH_SHA
int HASHALGO
bool HAVE_AES
bool HAVE_ARC2
bool HAVE_ARC4
bool HAVE_BLOWFISH
bool HAVE_CAST
bool HAVE_DES3
bool HAVE_DSA
bool HAVE_ELGAMAL
bool HAVE_IDEA
bool HAVE_MD2
bool HAVE_MD4
bool HAVE_MD5
bool HAVE_QNEW
bool HAVE_RC5
bool HAVE_RIPEMD
bool HAVE_RSA
bool HAVE_SHA
int LOAD_INSECURE_CIPHER_ALGOS
int MODE_CBC
int MODE_CFB
int MODE_CTR
int MODE_ECB
int MODE_NONE
int MODE_OFB
int MODE_PGP
int PRIVKEYDATA
int PUBKEYDATA
int PUBLICKEY_DSA
int PUBLICKEY_ELGAMAL
int PUBLICKEY_QNEW
int PUBLICKEY_RSA
int SIGNDATA

Function Details

toAsciiKey(key)

Changes the passed in key so that it now is an instance of AsciiKey. This can be transparently done with any key instance. Returned values will now be ascii wrapped if this key is used.

toSecureAsciiKey(key)

Changes the passed in key so that it now is an instance of SecureAsciiKey. This can be transparently done with any key instance. Returned values will now be ascii wrapped, and private key data is encrypted with a password.

toSecureKey(key)

Changes the passed in key so that it now is an instance of SecureKey. This can be transparently done with any key instance. Returned private key data will now be encrypted with a specified password.

Variable Details

__date__

Type:
str
Value:
'2003/08/16'                                                           

__version__

Type:
str
Value:
'0.1p18'                                                               

CIPHER_AES

Type:
int
Value:
0                                                                      

CIPHER_ARC2

Type:
int
Value:
1                                                                      

CIPHER_ARC4

Type:
int
Value:
2                                                                      

CIPHER_BLOWFISH

Type:
int
Value:
3                                                                      

CIPHER_CAST

Type:
int
Value:
4                                                                      

CIPHER_DES3

Type:
int
Value:
6                                                                      

CIPHERALGO

Type:
int
Value:
3                                                                      

ENCDATA

Type:
int
Value:
2                                                                      

HASH_MD2

Type:
int
Value:
1                                                                      

HASH_MD4

Type:
int
Value:
2                                                                      

HASH_MD5

Type:
int
Value:
3                                                                      

HASH_NONE

Type:
int
Value:
0                                                                      

HASH_SHA

Type:
int
Value:
5                                                                      

HASHALGO

Type:
int
Value:
5                                                                      

HAVE_AES

Type:
bool
Value:
True                                                                   

HAVE_ARC2

Type:
bool
Value:
True                                                                   

HAVE_ARC4

Type:
bool
Value:
True                                                                   

HAVE_BLOWFISH

Type:
bool
Value:
True                                                                   

HAVE_CAST

Type:
bool
Value:
True                                                                   

HAVE_DES3

Type:
bool
Value:
True                                                                   

HAVE_DSA

Type:
bool
Value:
True                                                                   

HAVE_ELGAMAL

Type:
bool
Value:
True                                                                   

HAVE_IDEA

Type:
bool
Value:
False                                                                  

HAVE_MD2

Type:
bool
Value:
True                                                                   

HAVE_MD4

Type:
bool
Value:
True                                                                   

HAVE_MD5

Type:
bool
Value:
True                                                                   

HAVE_QNEW

Type:
bool
Value:
True                                                                   

HAVE_RC5

Type:
bool
Value:
False                                                                  

HAVE_RIPEMD

Type:
bool
Value:
False                                                                  

HAVE_RSA

Type:
bool
Value:
True                                                                   

HAVE_SHA

Type:
bool
Value:
True                                                                   

LOAD_INSECURE_CIPHER_ALGOS

Type:
int
Value:
0                                                                      

MODE_CBC

Type:
int
Value:
1                                                                      

MODE_CFB

Type:
int
Value:
2                                                                      

MODE_CTR

Type:
int
Value:
3                                                                      

MODE_ECB

Type:
int
Value:
4                                                                      

MODE_NONE

Type:
int
Value:
0                                                                      

MODE_OFB

Type:
int
Value:
5                                                                      

MODE_PGP

Type:
int
Value:
6                                                                      

PRIVKEYDATA

Type:
int
Value:
0                                                                      

PUBKEYDATA

Type:
int
Value:
1                                                                      

PUBLICKEY_DSA

Type:
int
Value:
0                                                                      

PUBLICKEY_ELGAMAL

Type:
int
Value:
1                                                                      

PUBLICKEY_QNEW

Type:
int
Value:
2                                                                      

PUBLICKEY_RSA

Type:
int
Value:
3                                                                      

SIGNDATA

Type:
int
Value:
3                                                                      

Generated by Epydoc 1.1 on Sun Aug 17 03:32:31 2003 http://epydoc.sf.net