Second step for enabling pipelined AES

This commit is contained in:
Michael Zohner 2016-01-28 15:28:21 +01:00
parent ac4d534b02
commit 8f59edce71
4 changed files with 28 additions and 4 deletions

View File

@ -660,7 +660,7 @@ void InitOTReceiver(uint8_t* keyMtx, CSocket sock, crypto* crypt)
uint8_t* pBuf = (uint8_t*) malloc(crypt->get_hash_bytes() * numbaseOTs * 2); uint8_t* pBuf = (uint8_t*) malloc(crypt->get_hash_bytes() * numbaseOTs * 2);
bot->Sender(2, numbaseOTs, sock, pBuf); bot->Sender(2, numbaseOTs, sock, pBuf);
#ifdef AES256_HASH2 #ifdef AES256_HASH
//Key expansion //Key expansion
uint8_t* pBufIdx = pBuf; uint8_t* pBufIdx = pBuf;
for(uint32_t i=0; i<numbaseOTs; i++ ) for(uint32_t i=0; i<numbaseOTs; i++ )

View File

@ -205,12 +205,21 @@ void OTExtension1ooNECCReceiver::GenerateChoiceCodes(CBitVector& choicecodes, CB
void OTExtension1ooNECCReceiver::BuildMatrices(CBitVector& T, CBitVector& SndBuf, uint32_t numblocks, uint32_t ctr, uint8_t* ctr_buf) void OTExtension1ooNECCReceiver::BuildMatrices(CBitVector& T, CBitVector& SndBuf, uint32_t numblocks, uint32_t ctr, uint8_t* ctr_buf)
{ {
uint32_t* counter = (uint32_t*) ctr_buf; uint64_t* counter = (uint64_t*) ctr_buf;
uint32_t tempctr = (*counter); uint64_t tempctr = (*counter);
uint8_t* Tptr = T.GetArr(); uint8_t* Tptr = T.GetArr();
uint8_t* sndbufptr = SndBuf.GetArr(); uint8_t* sndbufptr = SndBuf.GetArr();
#ifdef AES256_HASH
//first prg output written to tptr
intrin_sequential_gen_rnd8(ctr_buf, tempctr, Tptr, (int) 2*numblocks, (int) m_nCodeWordBits, m_vKeySeedMtx);
//second prg output written to snd buffer
intrin_sequential_gen_rnd8(ctr_buf, tempctr, sndbufptr, (int) 2*numblocks, (int) m_nCodeWordBits, m_vKeySeedMtx+m_nCodeWordBits);
#else
//cout << "Numblocks = " << numblocks << endl; //cout << "Numblocks = " << numblocks << endl;
for(uint32_t k = 0; k < m_nCodeWordBits; k++) for(uint32_t k = 0; k < m_nCodeWordBits; k++)
{ {
@ -240,6 +249,7 @@ void OTExtension1ooNECCReceiver::BuildMatrices(CBitVector& T, CBitVector& SndBuf
cout << endl; cout << endl;
#endif #endif
} }
#endif
SndBuf.XORBytes(T.GetArr(), (uint32_t) 0, m_nCodeWordBytes*numblocks*m_nCodeWordBits); SndBuf.XORBytes(T.GetArr(), (uint32_t) 0, m_nCodeWordBytes*numblocks*m_nCodeWordBits);
} }

View File

@ -196,6 +196,10 @@ void OTExtensionReceiver::BuildMatrices(CBitVector& T, CBitVector& SndBuf, uint3
uint8_t* Tptr = T.GetArr(); uint8_t* Tptr = T.GetArr();
uint8_t* sndbufptr = SndBuf.GetArr(); uint8_t* sndbufptr = SndBuf.GetArr();
uint32_t ctrbyte = ctr/8; uint32_t ctrbyte = ctr/8;
#ifdef AES256_HASH
cerr << "Not supported with AES256 HASH enabled. Exiting." << endl;
exit(0);
#else
for(uint32_t k = 0; k < m_nSymSecParam; k++) for(uint32_t k = 0; k < m_nSymSecParam; k++)
{ {
(*counter) = tempctr; (*counter) = tempctr;
@ -211,6 +215,7 @@ void OTExtensionReceiver::BuildMatrices(CBitVector& T, CBitVector& SndBuf, uint3
} }
SndBuf.XORBytesReverse(m_nChoices.GetArr()+ctrbyte, k*OTEXT_BLOCK_SIZE_BYTES * numblocks, OTEXT_BLOCK_SIZE_BYTES * numblocks); SndBuf.XORBytesReverse(m_nChoices.GetArr()+ctrbyte, k*OTEXT_BLOCK_SIZE_BYTES * numblocks, OTEXT_BLOCK_SIZE_BYTES * numblocks);
} }
#endif
SndBuf.XORBytes(T.GetArr(), (uint32_t) 0, OTEXT_BLOCK_SIZE_BYTES*numblocks*m_nSymSecParam); SndBuf.XORBytes(T.GetArr(), (uint32_t) 0, OTEXT_BLOCK_SIZE_BYTES*numblocks*m_nSymSecParam);
} }
@ -575,7 +580,7 @@ void OTExtensionSender::BuildQMatrix(CBitVector& T, CBitVector& RcvBuf, uint32_t
uint32_t* counter = (uint32_t*) ctr_buf; uint32_t* counter = (uint32_t*) ctr_buf;
uint32_t tempctr = *counter; uint32_t tempctr = *counter;
#ifdef AES256_HASH #ifdef AES256_HASH
cerr << "Not supported atm. Exiting." << endl; cerr << "Not supported with AES256 HASH enabled. Exiting." << endl;
exit(0); exit(0);
#else #else
for (uint32_t k = 0; k < m_nSymSecParam; k++, rcvbufptr += (OTEXT_BLOCK_SIZE_BYTES * numblocks)) for (uint32_t k = 0; k < m_nSymSecParam; k++, rcvbufptr += (OTEXT_BLOCK_SIZE_BYTES * numblocks))

View File

@ -210,8 +210,13 @@ class OTExtensionReceiver {
m_nCounter = 0; m_nCounter = 0;
#ifdef AES256_HASH
m_vKeySeedMtx = (ROUND_KEYS*) malloc(sizeof(ROUND_KEYS) * nbaseOTs * nSndVals);
intrin_sequential_ks4(m_vKeySeedMtx, keybytes, (int) nbaseOTs * nSndVals);
#else
m_vKeySeedMtx = (AES_KEY_CTX*) malloc(sizeof(AES_KEY_CTX) * nbaseOTs * nSndVals); m_vKeySeedMtx = (AES_KEY_CTX*) malloc(sizeof(AES_KEY_CTX) * nbaseOTs * nSndVals);
InitAESKey(m_vKeySeedMtx, keybytes, nbaseOTs * nSndVals); InitAESKey(m_vKeySeedMtx, keybytes, nbaseOTs * nSndVals);
#endif
m_nSeed = (uint8_t*) malloc(sizeof(AES_BYTES)); // m_nSeed = (uint8_t*) malloc(sizeof(AES_BYTES)); //
m_cCrypto->gen_rnd(m_nSeed, AES_BYTES);//seed; m_cCrypto->gen_rnd(m_nSeed, AES_BYTES);//seed;
@ -252,7 +257,11 @@ class OTExtensionReceiver {
CBitVector m_vTempOTMasks; CBitVector m_vTempOTMasks;
uint8_t* m_nSeed; uint8_t* m_nSeed;
MaskingFunction* m_fMaskFct; MaskingFunction* m_fMaskFct;
#ifdef AES256_HASH
ROUND_KEYS* m_vKeySeedMtx;
#else
AES_KEY_CTX* m_vKeySeedMtx; AES_KEY_CTX* m_vKeySeedMtx;
#endif
crypto* m_cCrypto; crypto* m_cCrypto;
CLock* m_lRcvLock; CLock* m_lRcvLock;
#ifdef FIXED_KEY_AES_HASHING #ifdef FIXED_KEY_AES_HASHING