mirror of
https://github.com/QuasarApp/Qt-AES.git
synced 2025-04-27 22:24:31 +00:00
moving to iterators
This commit is contained in:
parent
f26cbc8496
commit
310831a3f3
@ -130,18 +130,18 @@ QByteArray QAESEncryption::expandKey(const QByteArray key)
|
||||
// The round key is added to the state by an XOR function.
|
||||
void QAESEncryption::addRoundKey(quint8 round, const QByteArray expKey)
|
||||
{
|
||||
for(int i=0; i < 16; i++) {
|
||||
char value = m_state->at(i) ^ expKey.at(round * m_nb * 4 + (i/4) * m_nb + (i%4));
|
||||
m_state->replace(i, 1, &value);
|
||||
}
|
||||
QByteArray::iterator it = m_state->begin();
|
||||
for(int i=0; i < 16; i++)
|
||||
it[i] = (quint8)it[i] ^ (quint8)expKey.at(round * m_nb * 4 + (i/4) * m_nb + (i%4));
|
||||
}
|
||||
|
||||
// The SubBytes Function Substitutes the values in the
|
||||
// state matrix with values in an S-box.
|
||||
void QAESEncryption::subBytes()
|
||||
{
|
||||
QByteArray::iterator it = m_state->begin();
|
||||
for(int i = 0; i < 16; i++)
|
||||
m_state->replace(i, getSBoxValue((quint8) m_state->at(i)));
|
||||
it[i] = getSBoxValue((quint8) it[i]);
|
||||
}
|
||||
|
||||
// The ShiftRows() function shifts the rows in the state to the left.
|
||||
|
Loading…
x
Reference in New Issue
Block a user