• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

libtom / libtomcrypt / 12690005093

09 Jan 2025 12:36PM UTC coverage: 89.675% (-0.001%) from 89.676%
12690005093

push

github

web-flow
Merge pull request #319 from libtom/add/SIV

Add SIV

224 of 256 new or added lines in 2 files covered. (87.5%)

1 existing line in 1 file now uncovered.

16276 of 18150 relevant lines covered (89.67%)

2050165.82 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.3
/src/mac/omac/omac_memory_multi.c
1
/* LibTomCrypt, modular cryptographic library -- Tom St Denis */
2
/* SPDX-License-Identifier: Unlicense */
3
#include "tomcrypt_private.h"
4
#include <stdarg.h>
5

6
/**
7
  @file omac_memory_multi.c
8
  OMAC1 support, process multiple blocks of memory, Tom St Denis
9
*/
10

11
#ifdef LTC_OMAC
12

13
static LTC_INLINE int s_omac_vprocess(omac_state *omac, const unsigned char *in,  unsigned long inlen, va_list args)
14
{
15
   const unsigned char * curptr = in;
16
   unsigned long curlen = inlen;
17
   int err;
18
   for (;;) {
19
      /* process buf */
20
      if ((err = omac_process(omac, curptr, curlen)) != CRYPT_OK) {
64✔
21
         return err;
22
      }
23
      /* step to next */
24
      curptr = va_arg(args, const unsigned char*);
64✔
25
      if (curptr == NULL) {
64✔
26
         break;
27
      }
28
      curlen = va_arg(args, unsigned long);
36✔
29
   }
30
   return CRYPT_OK;
31
}
32

33
int omac_vprocess(omac_state *omac, const unsigned char *in,  unsigned long inlen, va_list args)
16✔
34
{
35
   return s_omac_vprocess(omac, in, inlen, args);
16✔
36
}
37

38
/**
39
   OMAC multiple blocks of memory
40
   @param cipher    The index of the desired cipher
41
   @param key       The secret key
42
   @param keylen    The length of the secret key (octets)
43
   @param out       [out] The destination of the authentication tag
44
   @param outlen    [in/out]  The max size and resulting size of the authentication tag (octets)
45
   @param in        The data to send through OMAC
46
   @param inlen     The length of the data to send through OMAC (octets)
47
   @param ...       tuples of (data,len) pairs to OMAC, terminated with a (NULL,x) (x=don't care)
48
   @return CRYPT_OK if successful
49
*/
50
int omac_memory_multi(int cipher,
12✔
51
                const unsigned char *key, unsigned long keylen,
52
                      unsigned char *out, unsigned long *outlen,
53
                const unsigned char *in,  unsigned long inlen, ...)
54
{
55
   int                  err;
56
   omac_state          *omac;
57
   va_list              args;
58

59
   LTC_ARGCHK(key    != NULL);
12✔
60
   LTC_ARGCHK(in     != NULL);
12✔
61
   LTC_ARGCHK(out    != NULL);
12✔
62
   LTC_ARGCHK(outlen != NULL);
12✔
63

64
   /* allocate ram for omac state */
65
   omac = XMALLOC(sizeof(omac_state));
12✔
66
   if (omac == NULL) {
12✔
67
      return CRYPT_MEM;
68
   }
69

70
   /* omac process the message */
71
   if ((err = omac_init(omac, cipher, key, keylen)) != CRYPT_OK) {
12✔
72
      goto LBL_ERR;
×
73
   }
74
   va_start(args, inlen);
12✔
75
   if ((err = s_omac_vprocess(omac, in, inlen, args)) != CRYPT_OK) {
12✔
UNCOV
76
      goto LBL_ERR;
×
77
   }
78
   err = omac_done(omac, out, outlen);
12✔
79
LBL_ERR:
12✔
80
#ifdef LTC_CLEAN_STACK
81
   zeromem(omac, sizeof(omac_state));
82
#endif
83
   XFREE(omac);
12✔
84
   va_end(args);
12✔
85
   return err;
12✔
86
}
87

88
#endif
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc