-
Notifications
You must be signed in to change notification settings - Fork 11
/
omac.h
73 lines (56 loc) · 2.13 KB
/
omac.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
---------------------------------------------------------------------------
Copyright (c) 1998-2010, Brian Gladman, Worcester, UK. All rights reserved.
The redistribution and use of this software (with or without changes)
is allowed without the payment of fees or royalties provided that:
source code distributions include the above copyright notice, this
list of conditions and the following disclaimer;
binary distributions include the above copyright notice, this list
of conditions and the following disclaimer in their documentation.
This software is provided 'as is' with no explicit or implied warranties
in respect of its operation, including, but not limited to, correctness
and fitness for purpose.
---------------------------------------------------------------------------
Issue Date: 20/12/2007
*/
#ifndef OMAC_AES_H
#define OMAC_AES_H
/* set for OMAC version 1 or 2 */
#define OMAC_VERSION 2
#if !defined( UNIT_BITS )
# if 1
# define UNIT_BITS 64
# elif 0
# define UNIT_BITS 32
# else
# define UNIT_BITS 8
# endif
#endif
#include <string.h>
#include "aes.h"
#include "mode_hdr.h"
UNIT_TYPEDEF(buf_unit, UNIT_BITS);
BUFR_TYPEDEF(buf_type, UNIT_BITS, AES_BLOCK_SIZE);
#if defined(__cplusplus)
extern "C"
{
#endif
#define BLOCK_SIZE AES_BLOCK_SIZE
typedef struct
{
buf_type txt_cbc;
aes_encrypt_ctx aes[1]; /* AES encryption context */
uint32_t txt_cnt;
} omac_ctx;
void omac_init( const unsigned char key[], /* the encryption key */
unsigned long key_len, /* key length (bytes) */
omac_ctx ctx[1] ); /* the OMAC context */
void omac_data( unsigned char buf[], /* the data buffer */
unsigned long len, /* the length of this block (bytes) */
omac_ctx ctx[1] ); /* the OMAC context */
void omac_end( unsigned char auth_tag[], /* the encryption key */
omac_ctx ctx[1] ); /* the OMAC context */
#if defined(__cplusplus)
}
#endif
#endif