@@ -118,13 +118,11 @@ void SpritzCipher::absorbNibble(spritz_t *ctx, const byte nibble)
118118 swap (&ctx->s [ctx->a ], &ctx->s [SPRITZ_N_HALF + nibble]);
119119 ctx->a ++;
120120}
121-
122121void SpritzCipher::absorb (spritz_t *ctx, const byte octet)
123122{
124123 absorbNibble (ctx, octet % 16 ); /* Low */
125124 absorbNibble (ctx, octet / 16 ); /* High */
126125}
127-
128126void SpritzCipher::absorbBytes (spritz_t *ctx, const byte *buf, unsigned int len)
129127{
130128 unsigned int i;
@@ -169,28 +167,40 @@ void SpritzCipher::squeeze(spritz_t *ctx, byte *out, byte len)
169167}
170168
171169
170+ /* *************************| USER FUNCTIONS |**************************/
172171
172+ /* Setup spritz state (spritz_t) */
173173void SpritzCipher::setup (spritz_t *ctx,
174174 const byte *key, unsigned int keyLen)
175175{
176176 stateInit (ctx);
177177 absorbBytes (ctx, key, keyLen);
178178}
179179
180- /* Use setupIV() after setup() to add NONCE */
180+ /* Use setupIV() * after* setup() to add NONCE (Salt) */
181181void SpritzCipher::setupIV (spritz_t *ctx,
182182 const byte *nonce, unsigned int nonceLen)
183183{
184184 absorbStop (ctx);
185185 absorbBytes (ctx, nonce, nonceLen);
186186}
187187
188+ /* Return random byte that can be used as a key */
188189byte SpritzCipher::stream (spritz_t *ctx)
189190{
190191 return drip (ctx);
191192}
192193
193194
195+ /* *
196+ * Cryptographic hash function
197+ *
198+ * - digest: Hash output.
199+ * - digestLen: Set hash output size, Value (>=) 32 is recommended.
200+ *
201+ * - data: Data to hash.
202+ * - dataLen: Data size.
203+ */
194204void SpritzCipher::hash (byte *digest, byte digestLen,
195205 const byte *data, unsigned int dataLen)
196206{
@@ -202,6 +212,18 @@ void SpritzCipher::hash(byte *digest, byte digestLen,
202212 squeeze (&ctx, digest, digestLen);
203213}
204214
215+ /* *
216+ * Message Authentication Code (MAC) function
217+ *
218+ * - digest: MAC output.
219+ * - digestLen: Set MAC output size, Value (>=) 32 is recommended.
220+ *
221+ * - msg: Message to be authenticated.
222+ * - msgLen: Message size.
223+ *
224+ * - key: The secret key.
225+ * - keyLen: The secret key size.
226+ */
205227void SpritzCipher::mac (byte *digest, byte digestLen,
206228 const byte *msg, unsigned int msgLen,
207229 const byte *key, unsigned int keyLen)
0 commit comments