1
/* -*- c-basic-offset: 8 -*-
2
FreeRDP: A Remote Desktop Protocol client.
3
Cryptographic Abstraction Layer
5
Copyright (C) Marc-Andre Moreau <marcandre.moreau@gmail.com> 2010
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2 of the License, or
10
(at your option) any later version.
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
19
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28
#define CRYPTO_OPENSSL
33
#include <openssl/ssl.h>
34
#include <openssl/err.h>
35
#include <openssl/rc4.h>
36
#include <openssl/md5.h>
37
#include <openssl/sha.h>
38
#include <openssl/bn.h>
39
#include <openssl/x509v3.h>
41
#if defined(OPENSSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER >= 0x0090800f)
42
#define D2I_X509_CONST const
44
#define D2I_X509_CONST
47
#define CRYPTO_RC4 RC4_KEY
48
#define CRYPTO_SHA1 SHA_CTX
49
#define CRYPTO_MD5 MD5_CTX
50
#define CRYPTO_CERT X509
51
#define CRYPTO_RKEY RSA
53
#else /* built-in crypto */
57
#define CRYPTO_RC4 struct rc4_state
58
#define CRYPTO_SHA1 struct sha1_context
59
#define CRYPTO_MD5 struct md5_context
60
#define CRYPTO_CERT char
61
#define CRYPTO_RKEY char
66
crypto_sha1_init(CRYPTO_SHA1 * sha1);
68
crypto_sha1_update(CRYPTO_SHA1 * sha1, uint8 * data, uint32 len);
70
crypto_sha1_final(CRYPTO_SHA1 * sha1, uint8 * out_data);
73
crypto_md5_init(CRYPTO_MD5 * md5);
75
crypto_md5_update(CRYPTO_MD5 * md5, uint8 * data, uint32 len);
77
crypto_md5_final(CRYPTO_MD5 * md5, uint8 * out_data);
80
crypto_rc4_set_key(CRYPTO_RC4 * rc4, uint8 * key, uint32 len);
82
crypto_rc4(CRYPTO_RC4 * rc4, uint32 len, uint8 * in_data, uint8 * out_data);
85
crypto_rsa_encrypt(int len, uint8 * in, uint8 * out, uint32 modulus_size, uint8 * modulus, uint8 * exponent);
88
crypto_cert_read(uint8 * data, uint32 len);
90
crypto_cert_free(CRYPTO_CERT * cert);
92
crypto_cert_to_rkey(CRYPTO_CERT * cert, uint32 * key_len);
94
crypto_cert_verify(CRYPTO_CERT * server_cert, CRYPTO_CERT * cacert);
96
crypto_cert_print_fp(FILE * fp, CRYPTO_CERT * cert);
99
crypto_rkey_free(CRYPTO_RKEY * rkey);
101
crypto_rkey_get_exp_mod(CRYPTO_RKEY * rkey, uint8 * exponent, uint32 max_exp_len, uint8 * modulus, uint32 max_mod_len);
104
crypto_sig_ok(uint8 * exponent, uint32 exp_len, uint8 * modulus, uint32 mod_len, uint8 * signature, uint32 sig_len);