Exemplo n.º 1
0
AESParams::AESParams(GlobalContext & g, QString encryptionMode) :
		Crypto("AESParams"), _globalContext(g), _aesParams(NULL)
{
	int rc;

	if(encryptionMode == "ECB")
	{
		rc = hu_AESParamsCreate(SB_AES_ECB, SB_AES_128_BLOCK_BITS, NULL, NULL, &_aesParams, _globalContext.ctx());
	}
	else if(encryptionMode == "CBC")
	{
		rc = hu_AESParamsCreate(SB_AES_CBC, SB_AES_128_BLOCK_BITS, NULL, NULL, &_aesParams, _globalContext.ctx());
	}

	maybeLog("AESParamsCreate", rc);
}
AESParams::AESParams(AES & own, int mode, size_t blockLength, bool withRandom) :
    owner(own), params(NULL) {
    int rc = hu_AESParamsCreate(mode, blockLength,
                                withRandom ? owner.randomContext() : NULL, NULL, &params,
                                owner.context());
    if (rc != SB_SUCCESS) {
        throw errorMessage("Could not create AES params", rc);
    }
}