From c82f0a0d6a126e34613ac68fc3eddd91102d65bc Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Thu, 21 Apr 2016 04:08:06 -0400 Subject: Updated documentation --- misc.h | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ salsa.h | 2 +- 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/misc.h b/misc.h index 4a807473..77257bec 100644 --- a/misc.h +++ b/misc.h @@ -2002,13 +2002,35 @@ inline void PutWord(bool assumeAligned, ByteOrder order, byte *block, T value, c #endif } +//! \class GetBlock +//! \brief Access a block of memory +//! \tparam T class or type +//! \tparam B enumeration indicating endianess +//! \tparam A flag indicating alignment +//! \details GetBlock() provides alternate read access to a block of memory. The enumeration B is +//! BigEndian or LittleEndian. The flag A indicates if the memory block is aligned for class or type T. +//! Repeatedly applying \ref GetBlock::operator() "operator()" results in advancing in the block of memory. +//! \details An example of reading two word32 values from a block of memory is shown below. w1 +//! will be 0x03020100 and w1 will be 0x07060504. +//!
+//!    word32 w1, w2;
+//!    byte buffer[8] = {0,1,2,3,4,5,6,7};
+//!    GetBlock block(buffer);
+//!    block(w1)(w2);
+//! 
template class GetBlock { public: + //! \brief Construct a GetBlock + //! \param block the memory block GetBlock(const void *block) : m_block((const byte *)block) {} + //! \brief Access a block of memory + //! \tparam U class or type + //! \param x the value to read + //! \returns pointer to the remainder of the block after reading x template inline GetBlock & operator()(U &x) { @@ -2022,13 +2044,36 @@ private: const byte *m_block; }; +//! \class PutBlock +//! \brief Access a block of memory +//! \tparam T class or type +//! \tparam B enumeration indicating endianess +//! \tparam A flag indicating alignment +//! \details GetBlock() provides alternate write access to a block of memory. The enumeration B is +//! BigEndian or LittleEndian. The flag A indicates if the memory block is aligned for class or type T. +//! Repeatedly applying \ref PutBlock::operator() "operator()" results in advancing in the block of memory. +//! \details An example of reading two word32 values from a block of memory is shown below. w1 +//! will be 0x03020100 and w1 will be 0x07060504. +//!
+//!    word32 w1, w2;
+//!    byte buffer[8] = {0,1,2,3,4,5,6,7};
+//!    GetBlock block(buffer);
+//!    block(w1)(w2);
+//! 
template class PutBlock { public: + //! \brief Construct a PutBlock + //! \param block the memory block + //! \param xorBlock optional mask PutBlock(const void *xorBlock, void *block) : m_xorBlock((const byte *)xorBlock), m_block((byte *)block) {} + //! \brief Access a block of memory + //! \tparam U class or type + //! \param x the value to write + //! \returns pointer to the remainder of the block after writing x template inline PutBlock & operator()(U x) { @@ -2044,6 +2089,15 @@ private: byte *m_block; }; +//! \class BlockGetAndPut +//! \brief Access a block of memory +//! \tparam T class or type +//! \tparam B enumeration indicating endianess +//! \tparam GA flag indicating alignment for the Get operation +//! \tparam PA flag indicating alignment for the Put operation +//! \details GetBlock() provides alternate write access to a block of memory. The enumeration B is +//! BigEndian or LittleEndian. The flag A indicates if the memory block is aligned for class or type T. +//! \sa GetBlock() and PutBlock(). template struct BlockGetAndPut { diff --git a/salsa.h b/salsa.h index 37742400..54d1ec69 100644 --- a/salsa.h +++ b/salsa.h @@ -44,7 +44,7 @@ protected: //! \class Salsa20 //! \brief Salsa20 stream cipher information -//! \details XSalsa20 provides a variable number of rounds: 8, 12 or 20. The default number of rounds is 20. +//! \details Salsa20 provides a variable number of rounds: 8, 12 or 20. The default number of rounds is 20. //! \sa XSalsa20 struct Salsa20 : public Salsa20_Info, public SymmetricCipherDocumentation { -- cgit v1.2.1