예제 #1
0
def generate_encrypted_session_key(session_iv, worker_encryption_key):
    """
    Function to generate session key for the client
    Parameters:
    - worker_encryption_key is a one-time encryption key generated by the participant submitting the work order.
    - session_iv is an initialization vector if required by the data encryption algorithm (encryptedSessionKey). The default is all zeros.
    """

    session_key = crypto.SKENC_GenerateKey()
    return encrypt_data(worker_encryption_key.encode(), session_key,
                        session_iv)
예제 #2
0
def generate_key():
    """
    Function to generate symmetric key
    """
    return crypto.SKENC_GenerateKey()
예제 #3
0
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 " +
                 "failed: not detected.")
    sys.exit(-1)
except Exception as exc:
    if (type(exc) == ValueError):
        logger.debug(
            "Symmetric encryption invalid key detection test successful!")
    else: