]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/libcrypto/lib/aes_openssl/glue.c
update
[l4.git] / l4 / pkg / libcrypto / lib / aes_openssl / glue.c
1 /*
2  * \brief   Glue code for AES OpenSSL functions.
3  * \date    2006-09-22
4  * \author  Carsten Weinhold <weinhold@os.inf.tu-dresden.de>
5  */
6 /*
7  * Copyright (C) 2006  Carsten Weinhold <weinhold@os.inf.tu-dresden.de>
8  * Technische Universitaet Dresden, Operating Systems Research Group
9  *
10  * This file is part of the libcrypto package, which is distributed under
11  * the  terms  of the  GNU General Public Licence 2.  Please see the
12  * COPYING file for details.
13  */
14
15 /* L4-specific includes */
16 #include "aes.h"
17
18 /*
19  * Unfortunately, we need wrapper functions here ...
20  */
21
22 static int set_key(void *ctx, const unsigned char *key, unsigned int len, unsigned int flags) {
23
24     int ret;
25     
26     ret = AES_set_encrypt_key(key, len * 8, &((crypto_aes_ctx_t *) ctx)->__aes_openssl.__enc);
27     if (ret != 0)
28         return ret;
29     
30     return AES_set_decrypt_key(key, len * 8, &((crypto_aes_ctx_t *) ctx)->__aes_openssl.__dec);
31 }
32
33 static void encrypt(void *ctx, unsigned char *out, const unsigned char *in) {
34
35     AES_encrypt(in, out, &((crypto_aes_ctx_t *) ctx)->__aes_openssl.__enc);
36 }
37
38 static void decrypt(void *ctx, unsigned char *out, const unsigned char *in) {
39
40     AES_decrypt(in, out, &((crypto_aes_ctx_t *) ctx)->__aes_openssl.__dec);
41 }
42
43 crypto_cipher_set_key_fn_t aes_cipher_set_key = (crypto_cipher_set_key_fn_t) set_key;
44 crypto_cipher_encrypt_fn_t aes_cipher_encrypt = (crypto_cipher_encrypt_fn_t) encrypt;
45 crypto_cipher_decrypt_fn_t aes_cipher_decrypt = (crypto_cipher_decrypt_fn_t) decrypt;
46
47