Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
aes.h
Go to the documentation of this file.
1/*
2 * Copyright 2015-2018 Yubico AB
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/* aes.h
18**
19** Defines the AES crypto module for CMAC
20*/
21
22#ifndef _AESCMAC_AES_H_
23#define _AESCMAC_AES_H_
24
25#include <stdint.h>
26
27#ifdef _WIN32_BCRYPT
28#include <windows.h>
29#include <bcrypt.h>
30#else
31#include <openssl/aes.h>
32#endif
33
34#ifndef AES_BLOCK_SIZE // Defined in openssl/aes.h
35#define AES_BLOCK_SIZE 16
36#endif
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
42typedef struct {
43#ifdef _WIN32_BCRYPT
44 BCRYPT_ALG_HANDLE hAlgCBC;
45 BCRYPT_ALG_HANDLE hAlgECB;
46 BCRYPT_KEY_HANDLE hKeyCBC;
47 BCRYPT_KEY_HANDLE hKeyECB;
48 PBYTE pbKeyCBCObj;
49 PBYTE pbKeyECBObj;
50 size_t cbKeyObj;
51#else
52 AES_KEY key;
54#endif
56
57#ifndef __WIN32
58#define YH_INTERNAL __attribute__((visibility("hidden")))
59#else
60#define YH_INTERNAL
61#endif
62
64 aes_context *ctx);
66 aes_context *ctx);
67
69 const aes_context *ctx);
71 const aes_context *ctx);
72
74 uint8_t *iv, aes_context *ctx);
76 uint8_t *iv, aes_context *ctx);
77
80
82
83#ifdef __cplusplus
84}
85#endif
86
87#endif /* _AESCMAC_AES_H_ */
uint8_t YH_INTERNAL aes_set_encrypt_key(uint8_t *key, uint16_t key_len, aes_context *ctx)
Definition aes.c:172
void YH_INTERNAL aes_remove_padding(uint8_t *in, uint16_t *len)
Definition aes.c:321
uint8_t YH_INTERNAL aes_set_decrypt_key(uint8_t *key, uint16_t key_len, aes_context *ctx)
Definition aes.c:201
void YH_INTERNAL aes_add_padding(uint8_t *in, uint16_t *len)
Definition aes.c:313
#define YH_INTERNAL
Definition aes.h:58
uint8_t YH_INTERNAL aes_cbc_decrypt(uint8_t *in, uint8_t *out, uint16_t len, uint8_t *iv, aes_context *ctx)
Definition aes.c:292
uint8_t YH_INTERNAL aes_cbc_encrypt(uint8_t *in, uint8_t *out, uint16_t len, uint8_t *iv, aes_context *ctx)
Definition aes.c:271
uint8_t YH_INTERNAL aes_encrypt(uint8_t *in, uint8_t *out, const aes_context *ctx)
Definition aes.c:229
void YH_INTERNAL aes_destroy(aes_context *ctx)
Definition aes.c:330
uint8_t YH_INTERNAL aes_decrypt(uint8_t *in, uint8_t *out, const aes_context *ctx)
Definition aes.c:249
unsigned short uint16_t
Definition stdint.h:125
unsigned char uint8_t
Definition stdint.h:124
AES_KEY key
Definition aes.h:52
uint16_t key_len
Definition aes.h:53
size_t len
session operation op sign key_len