Coverage Report

Created: 2026-07-22 06:50

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wolfssl-sp-math-all-8bit/wolfcrypt/src/blake2s.c
Line
Count
Source
1
/*
2
   BLAKE2 reference source code package - reference C implementations
3
4
   Written in 2012 by Samuel Neves <sneves@dei.uc.pt>
5
6
   To the extent possible under law, the author(s) have dedicated all copyright
7
   and related and neighboring rights to this software to the public domain
8
   worldwide. This software is distributed without any warranty.
9
10
   You should have received a copy of the CC0 Public Domain Dedication along with
11
   this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
12
*/
13
/* blake2s.c
14
 *
15
 * Copyright (C) 2006-2026 wolfSSL Inc.
16
 *
17
 * This file is part of wolfSSL.
18
 *
19
 * wolfSSL is free software; you can redistribute it and/or modify
20
 * it under the terms of the GNU General Public License as published by
21
 * the Free Software Foundation; either version 3 of the License, or
22
 * (at your option) any later version.
23
 *
24
 * wolfSSL is distributed in the hope that it will be useful,
25
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27
 * GNU General Public License for more details.
28
 *
29
 * You should have received a copy of the GNU General Public License
30
 * along with this program; if not, write to the Free Software
31
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
32
 */
33
34
#include <wolfssl/wolfcrypt/libwolfssl_sources.h>
35
36
#ifdef HAVE_BLAKE2S
37
38
#include <wolfssl/wolfcrypt/blake2.h>
39
#include <wolfssl/wolfcrypt/blake2-impl.h>
40
#ifdef NO_INLINE
41
    #include <wolfssl/wolfcrypt/misc.h>
42
#else
43
    #define WOLFSSL_MISC_INCLUDED
44
    #include <wolfcrypt/src/misc.c>
45
#endif
46
47
static const word32 blake2s_IV[8] =
48
{
49
  0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
50
  0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
51
};
52
53
static const byte blake2s_sigma[10][16] =
54
{
55
  {  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15 } ,
56
  { 14, 10,  4,  8,  9, 15, 13,  6,  1, 12,  0,  2, 11,  7,  5,  3 } ,
57
  { 11,  8, 12,  0,  5,  2, 15, 13, 10, 14,  3,  6,  7,  1,  9,  4 } ,
58
  {  7,  9,  3,  1, 13, 12, 11, 14,  2,  6,  5, 10,  4,  0, 15,  8 } ,
59
  {  9,  0,  5,  7,  2,  4, 10, 15, 14,  1, 11, 12,  6,  8,  3, 13 } ,
60
  {  2, 12,  6, 10,  0, 11,  8,  3,  4, 13,  7,  5, 15, 14,  1,  9 } ,
61
  { 12,  5,  1, 15, 14, 13,  4, 10,  0,  7,  6,  3,  9,  2,  8, 11 } ,
62
  { 13, 11,  7, 14, 12,  1,  3,  9,  5,  0, 15,  4,  8,  6,  2, 10 } ,
63
  {  6, 15, 14,  9, 11,  3,  0,  8, 12,  2, 13,  7,  1,  4, 10,  5 } ,
64
  { 10,  2,  8,  4,  7,  6,  1,  5, 15, 11,  9, 14,  3, 12, 13 , 0 }
65
};
66
67
68
static WC_INLINE int blake2s_set_lastnode( blake2s_state *S )
69
0
{
70
0
  S->f[1] = ~0U;
71
0
  return 0;
72
0
}
73
74
/* Some helper functions, not necessarily useful */
75
static WC_INLINE int blake2s_set_lastblock( blake2s_state *S )
76
0
{
77
0
  if( S->last_node ) blake2s_set_lastnode( S );
78
79
0
  S->f[0] = ~0U;
80
0
  return 0;
81
0
}
82
83
static WC_INLINE int blake2s_increment_counter( blake2s_state *S, const word32
84
                                             inc )
85
0
{
86
0
  S->t[0] += inc;
87
0
  S->t[1] += ( S->t[0] < inc );
88
0
  return 0;
89
0
}
90
91
static WC_INLINE int blake2s_init0( blake2s_state *S )
92
0
{
93
0
  int i;
94
0
  XMEMSET( S, 0, sizeof( blake2s_state ) );
95
96
0
  for( i = 0; i < 8; ++i ) S->h[i] = blake2s_IV[i];
97
98
0
  return 0;
99
0
}
100
101
/* init xors IV with input parameter block */
102
int blake2s_init_param( blake2s_state *S, const blake2s_param *P )
103
0
{
104
0
  word32 i;
105
0
  const byte *p ;
106
0
  blake2s_init0( S );
107
0
  p =  ( const byte * )( P );
108
109
  /* IV XOR ParamBlock */
110
0
  for( i = 0; i < 8; ++i )
111
0
    S->h[i] ^= load32( p + sizeof( S->h[i] ) * i );
112
113
0
  return 0;
114
0
}
115
116
117
118
int blake2s_init( blake2s_state *S, const byte outlen )
119
0
{
120
0
  volatile blake2s_param P;
121
122
0
  if ( ( !outlen ) || ( outlen > BLAKE2S_OUTBYTES ) ) return BAD_FUNC_ARG;
123
124
0
  XMEMSET( (void *)(wc_ptr_t)&P, 0, sizeof( P ) );
125
0
  WC_BARRIER();
126
0
  P.digest_length = outlen;
127
0
  P.fanout        = 1;
128
0
  P.depth         = 1;
129
130
0
  return blake2s_init_param( S, (const blake2s_param *)(wc_ptr_t)&P );
131
0
}
132
133
134
int blake2s_init_key( blake2s_state *S, const byte outlen, const void *key,
135
                      const byte keylen )
136
0
{
137
0
  int ret = 0;
138
0
  volatile blake2s_param P;
139
140
0
  if ( ( !outlen ) || ( outlen > BLAKE2S_OUTBYTES ) ) return BAD_FUNC_ARG;
141
142
0
  if ( !key || !keylen || keylen > BLAKE2S_KEYBYTES ) return BAD_FUNC_ARG;
143
144
0
  XMEMSET( (void *)(wc_ptr_t)&P, 0, sizeof( P ) );
145
0
  WC_BARRIER();
146
0
  P.digest_length = outlen;
147
0
  P.key_length    = keylen;
148
0
  P.fanout        = 1;
149
0
  P.depth         = 1;
150
151
0
  ret = blake2s_init_param( S, (const blake2s_param *)(wc_ptr_t)&P );
152
0
  if (ret < 0)
153
0
      return ret;
154
155
0
  {
156
0
#ifdef WOLFSSL_SMALL_STACK
157
0
    byte* block;
158
159
0
    block = (byte*)XMALLOC(BLAKE2S_BLOCKBYTES, NULL, DYNAMIC_TYPE_TMP_BUFFER);
160
161
0
    if ( block == NULL ) return MEMORY_E;
162
#else
163
    byte block[BLAKE2S_BLOCKBYTES];
164
#endif
165
166
0
    XMEMSET( block, 0, BLAKE2S_BLOCKBYTES );
167
0
    XMEMCPY( block, key, keylen );
168
0
    ret = blake2s_update( S, block, BLAKE2S_BLOCKBYTES );
169
0
    secure_zero_memory( block, BLAKE2S_BLOCKBYTES ); /* Burn the key from */
170
                                                     /* memory */
171
172
0
    WC_FREE_VAR_EX(block, NULL, DYNAMIC_TYPE_TMP_BUFFER);
173
0
  }
174
0
  return ret;
175
0
}
176
177
static WC_INLINE int blake2s_compress(
178
    blake2s_state *S,
179
    const byte block[BLAKE2S_BLOCKBYTES],
180
    word32* m,
181
    word32* v)
182
0
{
183
0
  word32 i;
184
185
0
  for( i = 0; i < 16; ++i )
186
0
    m[i] = load32( block + i * sizeof( m[i] ) );
187
188
0
  for( i = 0; i < 8; ++i )
189
0
    v[i] = S->h[i];
190
191
0
  v[ 8] = blake2s_IV[0];
192
0
  v[ 9] = blake2s_IV[1];
193
0
  v[10] = blake2s_IV[2];
194
0
  v[11] = blake2s_IV[3];
195
0
  v[12] = S->t[0] ^ blake2s_IV[4];
196
0
  v[13] = S->t[1] ^ blake2s_IV[5];
197
0
  v[14] = S->f[0] ^ blake2s_IV[6];
198
0
  v[15] = S->f[1] ^ blake2s_IV[7];
199
0
#define G(r,i,a,b,c,d) \
200
0
  do { \
201
0
      (a) = (a) + (b) + m[blake2s_sigma[r][2*(i)+0]];   \
202
0
      (d) = rotr32((d) ^ (a), 16);                      \
203
0
      (c) = (c) + (d);                                  \
204
0
      (b) = rotr32((b) ^ (c), 12);                      \
205
0
      (a) = (a) + (b) + m[blake2s_sigma[r][2*(i)+1]];   \
206
0
      (d) = rotr32((d) ^ (a), 8);                       \
207
0
      (c) = (c) + (d);                                  \
208
0
      (b) = rotr32((b) ^ (c), 7);                       \
209
0
  } while(0)
210
0
#define ROUND(r)  \
211
0
  do { \
212
0
    G(r,0,v[ 0],v[ 4],v[ 8],v[12]); \
213
0
    G(r,1,v[ 1],v[ 5],v[ 9],v[13]); \
214
0
    G(r,2,v[ 2],v[ 6],v[10],v[14]); \
215
0
    G(r,3,v[ 3],v[ 7],v[11],v[15]); \
216
0
    G(r,4,v[ 0],v[ 5],v[10],v[15]); \
217
0
    G(r,5,v[ 1],v[ 6],v[11],v[12]); \
218
0
    G(r,6,v[ 2],v[ 7],v[ 8],v[13]); \
219
0
    G(r,7,v[ 3],v[ 4],v[ 9],v[14]); \
220
0
  } while(0)
221
0
  ROUND( 0 );
222
0
  ROUND( 1 );
223
0
  ROUND( 2 );
224
0
  ROUND( 3 );
225
0
  ROUND( 4 );
226
0
  ROUND( 5 );
227
0
  ROUND( 6 );
228
0
  ROUND( 7 );
229
0
  ROUND( 8 );
230
0
  ROUND( 9 );
231
232
0
  for( i = 0; i < 8; ++i )
233
0
    S->h[i] = S->h[i] ^ v[i] ^ v[i + 8];
234
235
0
#undef G
236
0
#undef ROUND
237
238
0
  return 0;
239
0
}
240
241
/* inlen now in bytes */
242
int blake2s_update( blake2s_state *S, const byte *in, word32 inlen )
243
0
{
244
0
  int ret = 0;
245
0
#ifdef WOLFSSL_SMALL_STACK
246
0
  word32* m;
247
0
  word32* v;
248
249
0
  m = (word32*)XMALLOC(sizeof(word32) * 32, NULL, DYNAMIC_TYPE_TMP_BUFFER);
250
251
0
  if ( m == NULL ) return MEMORY_E;
252
253
0
  v = &m[16];
254
#else
255
  word32 m[16];
256
  word32 v[16];
257
#endif
258
259
0
  while( inlen > 0 )
260
0
  {
261
0
    word32 left = S->buflen;
262
0
    word32 fill = 2 * BLAKE2S_BLOCKBYTES - left;
263
264
0
    if( inlen > fill )
265
0
    {
266
0
      XMEMCPY( S->buf + left, in, (wolfssl_word)fill ); /* Fill buffer */
267
0
      S->buflen += fill;
268
0
      blake2s_increment_counter( S, BLAKE2S_BLOCKBYTES );
269
270
0
      {
271
0
          ret= blake2s_compress( S, S->buf, m, v );
272
0
          if (ret < 0) break;
273
0
      }
274
275
0
      XMEMCPY( S->buf, S->buf + BLAKE2S_BLOCKBYTES, BLAKE2S_BLOCKBYTES );
276
              /* Shift buffer left */
277
0
      S->buflen -= BLAKE2S_BLOCKBYTES;
278
0
      in += fill;
279
0
      inlen -= fill;
280
0
    }
281
0
    else /* inlen <= fill */
282
0
    {
283
0
      XMEMCPY( S->buf + left, in, (wolfssl_word)inlen );
284
0
      S->buflen += inlen; /* Be lazy, do not compress */
285
0
      inlen = 0;
286
0
    }
287
0
  }
288
289
0
  WC_FREE_VAR_EX(m, NULL, DYNAMIC_TYPE_TMP_BUFFER);
290
291
0
  return ret;
292
0
}
293
294
/* Is this correct? */
295
int blake2s_final( blake2s_state *S, byte *out, byte outlen )
296
0
{
297
0
  int ret = 0;
298
0
  word32    i;
299
0
  byte buffer[BLAKE2S_BLOCKBYTES];
300
0
#ifdef WOLFSSL_SMALL_STACK
301
0
  word32* m;
302
0
  word32* v;
303
304
0
  m = (word32*)XMALLOC(sizeof(word32) * 32, NULL, DYNAMIC_TYPE_TMP_BUFFER);
305
306
0
  if ( m == NULL ) return MEMORY_E;
307
308
0
  v = &m[16];
309
#else
310
  word32 m[16];
311
  word32 v[16];
312
#endif
313
314
0
  if( S->buflen > BLAKE2S_BLOCKBYTES )
315
0
  {
316
0
    blake2s_increment_counter( S, BLAKE2S_BLOCKBYTES );
317
318
0
    {
319
0
        ret = blake2s_compress( S, S->buf, m, v );
320
0
        if (ret < 0) goto out;
321
0
    }
322
323
0
    S->buflen -= BLAKE2S_BLOCKBYTES;
324
0
    XMEMCPY( S->buf, S->buf + BLAKE2S_BLOCKBYTES, (wolfssl_word)S->buflen );
325
0
  }
326
327
0
  blake2s_increment_counter( S, S->buflen );
328
0
  blake2s_set_lastblock( S );
329
0
  XMEMSET( S->buf + S->buflen, 0, (wolfssl_word)(2 * BLAKE2S_BLOCKBYTES - S->buflen) );
330
         /* Padding */
331
0
  {
332
0
      ret = blake2s_compress( S, S->buf, m, v );
333
0
      if (ret < 0) goto out;
334
0
  }
335
336
0
  for( i = 0; i < 8; ++i ) /* Output full hash to temp buffer */
337
0
    store32( buffer + sizeof( S->h[i] ) * i, S->h[i] );
338
339
0
  XMEMCPY( out, buffer, outlen );
340
341
0
 out:
342
343
0
  WC_FREE_VAR_EX(m, NULL, DYNAMIC_TYPE_TMP_BUFFER);
344
345
0
  return ret;
346
0
}
347
348
/* inlen, at least, should be word32. Others can be size_t. */
349
int blake2s( byte *out, const void *in, const void *key, const byte outlen,
350
             const word32 inlen, byte keylen )
351
0
{
352
0
  blake2s_state S[1];
353
354
  /* Verify parameters */
355
0
  if ( NULL == in ) return BAD_FUNC_ARG;
356
357
0
  if ( NULL == out ) return BAD_FUNC_ARG;
358
359
0
  if( NULL == key ) keylen = 0;
360
361
0
  if( keylen > 0 )
362
0
  {
363
0
      int ret = blake2s_init_key( S, outlen, key, keylen );
364
0
      if (ret < 0) return ret;
365
0
  }
366
0
  else
367
0
  {
368
0
      int ret = blake2s_init( S, outlen );
369
0
      if (ret < 0) return ret;
370
0
  }
371
372
0
  {
373
0
      int ret = blake2s_update( S, ( const byte * )in, inlen );
374
0
      if (ret < 0) return ret;
375
0
  }
376
377
0
  return blake2s_final( S, out, outlen );
378
0
}
379
380
#if defined(BLAKE2S_SELFTEST)
381
#include <string.h>
382
#include "blake2-kat.h"
383
int main( int argc, char **argv )
384
{
385
  byte key[BLAKE2S_KEYBYTES];
386
  byte buf[KAT_LENGTH];
387
388
  for( word32 i = 0; i < BLAKE2S_KEYBYTES; ++i )
389
    key[i] = ( byte )i;
390
391
  for( word32 i = 0; i < KAT_LENGTH; ++i )
392
    buf[i] = ( byte )i;
393
394
  for( word32 i = 0; i < KAT_LENGTH; ++i )
395
  {
396
    byte hash[BLAKE2S_OUTBYTES];
397
    if ( blake2s( hash, buf, key, BLAKE2S_OUTBYTES, i, BLAKE2S_KEYBYTES ) < 0 )
398
    {
399
      puts( "error" );
400
      return -1;
401
    }
402
403
    if( 0 != XMEMCMP( hash, blake2s_keyed_kat[i], BLAKE2S_OUTBYTES ) )
404
    {
405
      puts( "error" );
406
      return -1;
407
    }
408
  }
409
410
  puts( "ok" );
411
  return 0;
412
}
413
#endif
414
415
416
/* wolfCrypt API */
417
418
/* Init Blake2s digest, track size in case final doesn't want to "remember" */
419
int wc_InitBlake2s(Blake2s* b2s, word32 digestSz)
420
0
{
421
0
    if (b2s == NULL){
422
0
        return BAD_FUNC_ARG;
423
0
    }
424
0
    if (digestSz == 0 || digestSz > BLAKE2S_OUTBYTES) {
425
0
        return BAD_FUNC_ARG;
426
0
    }
427
0
    b2s->digestSz = digestSz;
428
429
0
    return blake2s_init(b2s->S, (byte)digestSz);
430
0
}
431
432
433
/* Init Blake2s digest with key, track size in case final doesn't want to "remember" */
434
int wc_InitBlake2s_WithKey(Blake2s* b2s, word32 digestSz, const byte *key, word32 keylen)
435
0
{
436
0
    if (b2s == NULL){
437
0
        return BAD_FUNC_ARG;
438
0
    }
439
0
    if (digestSz == 0 || digestSz > BLAKE2S_OUTBYTES) {
440
0
        return BAD_FUNC_ARG;
441
0
    }
442
0
    b2s->digestSz = digestSz;
443
444
0
    if (keylen >= 256)
445
0
        return BAD_FUNC_ARG;
446
447
0
    if (key)
448
0
        return blake2s_init_key(b2s->S, (byte)digestSz, key, (byte)keylen);
449
0
    else
450
0
        return blake2s_init(b2s->S, (byte)digestSz);
451
0
}
452
453
454
/* Blake2s Update */
455
int wc_Blake2sUpdate(Blake2s* b2s, const byte* data, word32 sz)
456
0
{
457
0
    if (b2s == NULL){
458
0
        return BAD_FUNC_ARG;
459
0
    }
460
0
    if (data == NULL && sz != 0){
461
0
        return BAD_FUNC_ARG;
462
0
    }
463
0
    if (sz == 0){
464
0
        return 0;
465
0
    }
466
467
0
    return blake2s_update(b2s->S, data, sz);
468
0
}
469
470
471
/* Blake2s Final, if pass in zero size we use init digestSz */
472
int wc_Blake2sFinal(Blake2s* b2s, byte* final, word32 requestSz)
473
0
{
474
0
    word32 sz;
475
476
0
    if (b2s == NULL){
477
0
        return BAD_FUNC_ARG;
478
0
    }
479
0
    if (final == NULL){
480
0
        return BAD_FUNC_ARG;
481
0
    }
482
483
0
    sz = requestSz ? requestSz : b2s->digestSz;
484
0
    if (sz == 0 || sz > BLAKE2S_OUTBYTES) {
485
0
        return BAD_FUNC_ARG;
486
0
    }
487
488
0
    return blake2s_final(b2s->S, final, (byte)sz);
489
0
}
490
491
492
int wc_Blake2sHmacInit(Blake2s* b2s, const byte* key, size_t key_len)
493
0
{
494
0
    byte x_key[BLAKE2S_BLOCKBYTES];
495
0
    int i;
496
0
    int ret = 0;
497
498
0
    if (key == NULL)
499
0
        return BAD_FUNC_ARG;
500
501
0
    XMEMSET(x_key, 0, sizeof(x_key));
502
503
0
    if (key_len > BLAKE2S_BLOCKBYTES) {
504
0
        ret = wc_InitBlake2s(b2s, BLAKE2S_OUTBYTES);
505
0
        if (ret == 0)
506
0
            ret = wc_Blake2sUpdate(b2s, key, (word32)key_len);
507
0
        if (ret == 0)
508
0
            ret = wc_Blake2sFinal(b2s, x_key, 0);
509
0
    } else {
510
0
        XMEMCPY(x_key, key, key_len);
511
0
    }
512
513
0
    if (ret == 0) {
514
0
        for (i = 0; i < BLAKE2S_BLOCKBYTES; ++i)
515
0
            x_key[i] ^= 0x36U;
516
0
    }
517
518
0
    if (ret == 0)
519
0
        ret = wc_InitBlake2s(b2s, BLAKE2S_OUTBYTES);
520
0
    if (ret == 0)
521
0
        ret = wc_Blake2sUpdate(b2s, x_key, BLAKE2S_BLOCKBYTES);
522
523
0
    ForceZero(x_key, sizeof(x_key));
524
525
0
    return ret;
526
0
}
527
528
int wc_Blake2sHmacUpdate(Blake2s* b2s, const byte* in, size_t in_len)
529
0
{
530
0
    if (in == NULL)
531
0
        return BAD_FUNC_ARG;
532
    /* Sanity check in_len to prevent truncation when cast to word32. */
533
0
    if (in_len > WOLFSSL_MAX_32BIT)
534
0
        return BAD_FUNC_ARG;
535
536
0
    return wc_Blake2sUpdate(b2s, in, (word32)in_len);
537
0
}
538
539
int wc_Blake2sHmacFinal(Blake2s* b2s, const byte* key, size_t key_len,
540
        byte* out, size_t out_len)
541
0
{
542
0
    byte x_key[BLAKE2S_BLOCKBYTES];
543
0
    Blake2s keyHash;
544
0
    int i;
545
0
    int ret = 0;
546
547
0
    if (key == NULL)
548
0
        return BAD_FUNC_ARG;
549
550
0
    if (out_len != BLAKE2S_OUTBYTES)
551
0
        return BUFFER_E;
552
553
0
    XMEMSET(x_key, 0, sizeof(x_key));
554
555
0
    if (key_len > BLAKE2S_BLOCKBYTES) {
556
0
        ret = wc_InitBlake2s(&keyHash, BLAKE2S_OUTBYTES);
557
0
        if (ret == 0)
558
0
            ret = wc_Blake2sUpdate(&keyHash, key, (word32)key_len);
559
0
        if (ret == 0)
560
0
            ret = wc_Blake2sFinal(&keyHash, x_key, 0);
561
0
        ForceZero(&keyHash, sizeof(keyHash));
562
0
    } else {
563
0
        XMEMCPY(x_key, key, key_len);
564
0
    }
565
566
0
    if (ret == 0) {
567
0
        for (i = 0; i < BLAKE2S_BLOCKBYTES; ++i)
568
0
            x_key[i] ^= 0x5CU;
569
0
    }
570
571
0
    if (ret == 0)
572
0
        ret = wc_Blake2sFinal(b2s, out, 0);
573
574
0
    if (ret == 0)
575
0
        ret = wc_InitBlake2s(b2s, BLAKE2S_OUTBYTES);
576
0
    if (ret == 0)
577
0
        ret = wc_Blake2sUpdate(b2s, x_key, BLAKE2S_BLOCKBYTES);
578
0
    if (ret == 0)
579
0
        ret = wc_Blake2sUpdate(b2s, out, BLAKE2S_OUTBYTES);
580
0
    if (ret == 0)
581
0
        ret = wc_Blake2sFinal(b2s, out, 0);
582
583
0
    ForceZero(x_key, sizeof(x_key));
584
585
0
    return ret;
586
0
}
587
588
int wc_Blake2sHmac(const byte* in, size_t in_len,
589
        const byte* key, size_t key_len,
590
        byte* out, size_t out_len)
591
0
{
592
0
    Blake2s state;
593
0
    int ret;
594
595
0
    ret = wc_Blake2sHmacInit(&state, key, key_len);
596
0
    if (ret == 0)
597
0
        ret = wc_Blake2sHmacUpdate(&state, in, in_len);
598
0
    if (ret == 0)
599
0
        ret = wc_Blake2sHmacFinal(&state, key, key_len, out, out_len);
600
601
0
    return ret;
602
0
}
603
604
/* end wolfCrypt API */
605
606
#endif  /* HAVE_BLAKE2S */