def generate_sessioniv():
    """
    Function to generate random session iv
    """

    return crypto.SKENC_GenerateIV()
Beispiel #2
0
def generate_iv():
    """
    Function to generate random initialization vector
    """

    return crypto.SKENC_GenerateIV()
try:
    ciphertext = rpk.EncryptMessage(msg)
    plaintext = rsk.DecryptMessage(ciphertext)
except Exception as exc:
    logger.error("ERROR: Asymmetric encryption/decryption test failed: ", exc)
    sys.exit(-1)

if (bytearray(plaintext) == bytearray(msg)):
    logger.debug("Asymmetric encryption/decryption test successful!")
else:
    logger.error("ERROR: Asymmetric encryption/decryption failed.")
    exit(-1)

# TEST AES-GCM
try:
    iv = crypto.SKENC_GenerateIV()
except Exception as exc:
    logger.error("ERROR: Symmetric encryption iv generation test failed: ",
                 exc)
    sys.exit(-1)

try:
    key = crypto.SKENC_GenerateKey()
except Exception as exc:
    logger.error("ERROR: Symmetric encryption key generation test failed: ",
                 exc)
    sys.exit(-1)

try:
    crypto.SKENC_EncryptMessage(iv, None, msg)
    logger.error("ERROR: Symmetric encryption invalid key detection test " +