1 /*
2 *			GPAC - Multimedia Framework C SDK
3 *
4 *			Authors: Jean Le Feuvre
5 *			Copyright (c) Telecom ParisTech 2000-2012
6 *					All rights reserved
7 *
8 *  This file is part of GPAC / Crypto Tools sub-project
9 *
10 *  GPAC is free software; you can redistribute it and/or modify
11 *  it under the terms of the GNU Lesser General Public License as published by
12 *  the Free Software Foundation; either version 2, or (at your option)
13 *  any later version.
14 *
15 *  GPAC is distributed in the hope that it will be useful,
16 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 *  GNU Lesser General Public License for more details.
19 *
20 *  You should have received a copy of the GNU Lesser General Public
21 *  License along with this library; see the file COPYING.  If not, write to
22 *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 */
25 
26 #ifndef _GF_CRYPT_DEV_H_
27 #define _GF_CRYPT_DEV_H_
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 #include <gpac/crypt.h>
34 
35 /*private - do not use*/
36 struct _gf_crypt_context
37 {
38 	GF_CRYPTO_ALGO algo; //single value for now
39 	GF_CRYPTO_MODE mode; //CBC or CTR
40 
41 	/* Internal context for openSSL or tiny AES*/
42 	void *context;
43 
44 	//ptr to encryption function
45 	GF_Err(*_init_crypt) (GF_Crypt *ctx, void*, const void*);
46 	void(*_deinit_crypt) (GF_Crypt *ctx);
47 	void(*_end_crypt) (GF_Crypt *ctx);
48 	void(*_set_key)(GF_Crypt *ctx, void*);
49 	GF_Err(*_crypt) (GF_Crypt *ctx, u8 *buffer, u32 size);
50 	GF_Err(*_decrypt) (GF_Crypt*, u8 *buffer, u32 size);
51 	GF_Err(*_set_state) (GF_Crypt*, const u8 *IV, u32 IV_size);
52 	GF_Err(*_get_state) (GF_Crypt*, u8 *IV, u32 *IV_size);
53 };
54 
55 #ifdef GPAC_HAS_SSL
56 GF_Err gf_crypt_open_open_openssl(GF_Crypt* td, GF_CRYPTO_MODE mode);
57 #else
58 GF_Err gf_crypt_open_open_tinyaes(GF_Crypt* td, GF_CRYPTO_MODE mode);
59 #endif
60 
61 
62 #ifdef __cplusplus
63 }
64 #endif
65 
66 #endif	/*_GF_CRYPT_DEV_H_*/
67