2 * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
10 #include <openssl/aes.h>
11 #include <openssl/modes.h>
13 typedef struct prov_aes_cipher_st PROV_AES_CIPHER;
15 typedef struct prov_aes_key_st {
26 /* The cipher functions we are going to use */
27 const PROV_AES_CIPHER *ciph;
29 /* The mode that we are using */
32 /* Set to 1 if we are encrypting or 0 otherwise */
35 unsigned char iv[AES_BLOCK_SIZE];
38 * num contains the number of bytes of |iv| which are valid for modes that
39 * manage partial blocks themselves.
43 /* Buffer of partial blocks processed via update calls */
44 unsigned char buf[AES_BLOCK_SIZE];
46 /* Number of bytes in buf */
53 /* Whether padding should be used or not */
57 struct prov_aes_cipher_st {
58 int (*init)(PROV_AES_KEY *dat, const uint8_t *key, size_t keylen);
59 int (*cipher)(PROV_AES_KEY *dat, uint8_t *out, const uint8_t *in,
63 const PROV_AES_CIPHER *PROV_AES_CIPHER_ecb(void);
64 const PROV_AES_CIPHER *PROV_AES_CIPHER_cbc(void);
65 const PROV_AES_CIPHER *PROV_AES_CIPHER_ofb(void);
66 const PROV_AES_CIPHER *PROV_AES_CIPHER_cfb(void);
67 const PROV_AES_CIPHER *PROV_AES_CIPHER_cfb1(void);
68 const PROV_AES_CIPHER *PROV_AES_CIPHER_cfb8(void);
69 const PROV_AES_CIPHER *PROV_AES_CIPHER_ctr(void);
71 size_t fillblock(unsigned char *buf, size_t *buflen, size_t blocksize,
72 const unsigned char **in, size_t *inlen);
73 int trailingdata(unsigned char *buf, size_t *buflen, size_t blocksize,
74 const unsigned char **in, size_t *inlen);
75 void padblock(unsigned char *buf, size_t *buflen, size_t blocksize);
76 int unpadblock(unsigned char *buf, size_t *buflen, size_t blocksize);