DRBG::~DRBG() {
	if (rngCtx != NULL) {
		int rc = hu_RngDrbgDestroy(&rngCtx, context.ctx());
		maybeLog("DRBGDestroy", rc);
		rngCtx = NULL;
	}
}
int DRBG::getBytes(QByteArray & buffer) {
	if (isValid()) {
		int rc = hu_RngGetBytes(rngCtx, buffer.length(),
				(unsigned char *) buffer.data(), context.ctx());
		maybeLog("RNGGetBytes", rc);
		return rc;
	}
	return -1;
}
Exemple #3
0
AESParams::~AESParams()
{
	if (_aesParams != NULL)
	{
		int rc = hu_AESParamsDestroy(&_aesParams, _globalContext.ctx());
		maybeLog("AESParamsDestroy", rc);
		_aesParams = NULL;
	}
}
Exemple #4
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);
}
DRBG::DRBG(GlobalContext & gc) :
		Crypto("DRBG"), context(gc), rngCtx(NULL) {
	int rc = hu_RngDrbgCreate(HU_DRBG_HASH, 112, false, 0, NULL, NULL, &rngCtx,
			context.ctx());
	maybeLog("DRBGCreate", rc);
}