HSL 2.0 framework
Description of the framework
|
Class for data encryption using AES. More..
Public Member Functions | |
def | __init__ (self) |
Constructor. More... | |
def | init (self, key, iv=None) |
Initialize. More... | |
def | use_ecb (self) |
Uses the ECB (Electronic Code Book) mode for encryption More... | |
def | use_cbc (self) |
Uses the CBC (Cipher Block Chaining) mode for encryption | |
def | use_cfb (self) |
Uses the CFB (Cipher FeedBack) mode for encryption | |
def | use_ofb (self) |
Uses the OFB (Output FeedBack) mode for encryption | |
def | use_ctr (self) |
Uses the CTR (Counter Mode) for encryption | |
def | encrypt (self, data) |
Encrypts the transmitted data block. More... | |
def | decrypt (self, data) |
Decrypts the transferred data block. More... | |
Static Public Member Functions | |
def | generate_init_vector () |
Generates a 16 characters long string. More... | |
Class for encrypting data using AES
Part of the packet for encryption.
The methods encrypt (encrypt) and decrypt (decrypt) are used to process whole strings. By default CBC (Cipher-Block Chaining) is used
If a telegram is received at input PIN_I_DO_CRYPTO, the data block data is encrypted with the static vector vector (aes_1) and stored in the variable encrypted.
The encrypted data block encrypted is then decrypted again with the same vector (aes_2) and stored in the variable decrypted.
In both cases the method CBC is used.
def hsl20_4_crypto.hsl20_4_crypto.AESCipher.__init__ | ( | self | ) |
Constructor
def hsl20_4_crypto.hsl20_4_crypto.AESCipher.decrypt | ( | self, | |
data | |||
) |
Decrypts the transferred data block
data | string Data block |
AttributeError |
|
ValueError |
|
def hsl20_4_crypto.hsl20_4_crypto.AESCipher.encrypt | ( | self, | |
data | |||
) |
Encrypts the transferred data block
The entire packet to be encrypted must be transferred
data | string Data block |
AttributesError |
|
ValueError |
|
|
static |
Generates a 16 character long string
This can be used as an init vector
def hsl20_4_crypto.hsl20_4_crypto.AESCipher.init | ( | self, | |
key, | |||
iv = None |
|||
) |
Initialize
key | string Key. Must be 16, 24 or 32 in length |
iv | string Optional. Init vector, must be 16 characters long |
def hsl20_4_crypto.hsl20_4_crypto.AESCipher.use_ecb | ( | self | ) |
Uses the ECB (Electronic Code Book) mode for encryption