summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cryptlib.cpp12
-rw-r--r--iterhash.h6
2 files changed, 10 insertions, 8 deletions
diff --git a/cryptlib.cpp b/cryptlib.cpp
index e248935a..929ed618 100644
--- a/cryptlib.cpp
+++ b/cryptlib.cpp
@@ -770,9 +770,9 @@ size_t BufferedTransformation::PeekWord16(word16 &value, ByteOrder order) const
size_t len = Peek(buf, 2);
if (order == BIG_ENDIAN_ORDER)
- value = ((word16)buf[0] << 8) | (word16)buf[1];
+ value = word16((buf[0] << 8) | buf[1]);
else
- value = ((word16)buf[1] << 8) | (word16)buf[0];
+ value = word16((buf[1] << 8) | buf[0]);
return len;
}
@@ -783,11 +783,11 @@ size_t BufferedTransformation::PeekWord32(word32 &value, ByteOrder order) const
size_t len = Peek(buf, 4);
if (order == BIG_ENDIAN_ORDER)
- value = ((word32)buf[0] << 24) | ((word32)buf[1] << 16) |
- ((word32)buf[2] << 8) | (word32)buf[3];
+ value = word32((buf[0] << 24) | (buf[1] << 16) |
+ (buf[2] << 8) | (buf[3] << 0));
else
- value = ((word32)buf[3] << 24) | ((word32)buf[2] << 16) |
- ((word32)buf[1] << 8) | (word32)buf[0];
+ value = word32((buf[3] << 24) | (buf[2] << 16) |
+ (buf[1] << 8) | (buf[0] << 0));
return len;
}
diff --git a/iterhash.h b/iterhash.h
index edaa18e2..e9204624 100644
--- a/iterhash.h
+++ b/iterhash.h
@@ -159,8 +159,9 @@ public:
}
protected:
+ enum { Blocks = T_BlockSize/sizeof(T_HashWordType) };
T_HashWordType* DataBuf() {return this->m_data;}
- FixedSizeSecBlock<T_HashWordType, T_BlockSize/sizeof(T_HashWordType)> m_data;
+ FixedSizeSecBlock<T_HashWordType, Blocks> m_data;
};
/// \brief Iterated hash with a static transformation function
@@ -191,8 +192,9 @@ protected:
void HashEndianCorrectedBlock(const T_HashWordType *data) {T_Transform::Transform(this->m_state, data);}
void Init() {T_Transform::InitState(this->m_state);}
+ enum { Blocks = T_BlockSize/sizeof(T_HashWordType) };
T_HashWordType* StateBuf() {return this->m_state;}
- FixedSizeAlignedSecBlock<T_HashWordType, T_BlockSize/sizeof(T_HashWordType), T_StateAligned> m_state;
+ FixedSizeAlignedSecBlock<T_HashWordType, Blocks, T_StateAligned> m_state;
};
#if !defined(__GNUC__) && !defined(__clang__)