Package keyczar :: Module keys :: Class AesKey
[hide private]
[frames] | no frames]

Class AesKey

source code

object --+        
         |        
       Key --+    
             |    
  SymmetricKey --+
                 |
                AesKey

Represents AES symmetric private keys.

Instance Methods [hide private]
 
__init__(self, key_string, hmac_key, size=128, mode=CipherMode("CBC", 0, True, lambda b, i:(i/ b+ 2)* b))
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
__str__(self)
str(x)
source code
 
_Hash(self)
Compute and return the hash id of this key.
source code
string
__Pad(self, data)
Returns the data padded using PKCS5.
source code
string
__UnPad(self, padded)
Returns the unpadded version of a data padded using PKCS5.
source code
string
Encrypt(self, data)
Return ciphertext byte string containing Header|IV|Ciph|Sig.
source code
string
Decrypt(self, input_bytes)
Decrypts the given ciphertext.
source code

Inherited from SymmetricKey (private): _GetKeyString

Inherited from Key: Header

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__

Static Methods [hide private]
AesKey
Generate(size=128)
Return a newly generated AES key.
source code
AesKey
Read(key)
Reads an AES key from a JSON string representation of it.
source code
Properties [hide private]

Inherited from Key: hash, key_bytes, key_string, size

Inherited from object: __class__

Method Details [hide private]

__init__(self, key_string, hmac_key, size=128, mode=CipherMode("CBC", 0, True, lambda b, i:(i/ b+ 2)* b))
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

_Hash(self)

source code 

Compute and return the hash id of this key. Can override default hash.

Overrides: Key._Hash
(inherited documentation)

Generate(size=128)
Static Method

source code 

Return a newly generated AES key.

Parameters:
  • size (integer) - length of key in bits to generate
Returns: AesKey
an AES key

Read(key)
Static Method

source code 

Reads an AES key from a JSON string representation of it.

Parameters:
  • key (string) - a JSON representation of an AES key
Returns: AesKey
an AES key

__Pad(self, data)

source code 

Returns the data padded using PKCS5.

For a block size B and data with N bytes in the last block, PKCS5 pads the data with B-N bytes of the value B-N.

Parameters:
  • data (string) - data to be padded
Returns: string
PKCS5 padded string

__UnPad(self, padded)

source code 

Returns the unpadded version of a data padded using PKCS5.

Parameters:
  • padded (string) - string padded with PKCS5
Returns: string
original, unpadded string

Encrypt(self, data)

source code 

Return ciphertext byte string containing Header|IV|Ciph|Sig.

Parameters:
  • data (string) - plaintext to be encrypted.
Returns: string
raw byte string ciphertext formatted to have Header|IV|Ciph|Sig.

Decrypt(self, input_bytes)

source code 

Decrypts the given ciphertext.

Parameters:
  • input_bytes (string) - raw byte string formatted as Header|IV|Ciph|Sig where Sig is the signature over the entire payload (Header|IV|Ciph).
Returns: string
plaintext message
Raises: