~ubuntu-branches/ubuntu/raring/freerdp/raring

« back to all changes in this revision

Viewing changes to libfreerdp/crypto.h

  • Committer: Bazaar Package Importer
  • Author(s): Otavio Salvador
  • Date: 2010-06-23 21:39:09 UTC
  • Revision ID: james.westby@ubuntu.com-20100623213909-bb9pvvv03913tdv6
Tags: upstream-0.7.1
ImportĀ upstreamĀ versionĀ 0.7.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- c-basic-offset: 8 -*-
 
2
   FreeRDP: A Remote Desktop Protocol client.
 
3
   Cryptographic Abstraction Layer
 
4
 
 
5
   Copyright (C) Marc-Andre Moreau <marcandre.moreau@gmail.com> 2010
 
6
 
 
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.
 
11
 
 
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.
 
16
 
 
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.
 
20
*/
 
21
 
 
22
#ifndef __CRYPTO_H
 
23
#define __CRYPTO_H
 
24
 
 
25
#ifdef DISABLE_TLS
 
26
        #undef CRYPTO_OPENSSL
 
27
#else
 
28
        #define CRYPTO_OPENSSL
 
29
#endif
 
30
 
 
31
#ifdef CRYPTO_OPENSSL
 
32
 
 
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>
 
40
 
 
41
#if defined(OPENSSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER >= 0x0090800f)
 
42
#define D2I_X509_CONST const
 
43
#else
 
44
#define D2I_X509_CONST
 
45
#endif
 
46
 
 
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
 
52
 
 
53
#else /* built-in crypto */
 
54
 
 
55
#include "ssl.h"
 
56
 
 
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
 
62
 
 
63
#endif
 
64
 
 
65
void
 
66
crypto_sha1_init(CRYPTO_SHA1 * sha1);
 
67
void
 
68
crypto_sha1_update(CRYPTO_SHA1 * sha1, uint8 * data, uint32 len);
 
69
void
 
70
crypto_sha1_final(CRYPTO_SHA1 * sha1, uint8 * out_data);
 
71
 
 
72
void
 
73
crypto_md5_init(CRYPTO_MD5 * md5);
 
74
void
 
75
crypto_md5_update(CRYPTO_MD5 * md5, uint8 * data, uint32 len);
 
76
void
 
77
crypto_md5_final(CRYPTO_MD5 * md5, uint8 * out_data);
 
78
 
 
79
void
 
80
crypto_rc4_set_key(CRYPTO_RC4 * rc4, uint8 * key, uint32 len);
 
81
void
 
82
crypto_rc4(CRYPTO_RC4 * rc4, uint32 len, uint8 * in_data, uint8 * out_data);
 
83
 
 
84
void
 
85
crypto_rsa_encrypt(int len, uint8 * in, uint8 * out, uint32 modulus_size, uint8 * modulus, uint8 * exponent);
 
86
 
 
87
CRYPTO_CERT *
 
88
crypto_cert_read(uint8 * data, uint32 len);
 
89
void
 
90
crypto_cert_free(CRYPTO_CERT * cert);
 
91
CRYPTO_RKEY *
 
92
crypto_cert_to_rkey(CRYPTO_CERT * cert, uint32 * key_len);
 
93
RD_BOOL
 
94
crypto_cert_verify(CRYPTO_CERT * server_cert, CRYPTO_CERT * cacert);
 
95
int
 
96
crypto_cert_print_fp(FILE * fp, CRYPTO_CERT * cert);
 
97
 
 
98
void
 
99
crypto_rkey_free(CRYPTO_RKEY * rkey);
 
100
int
 
101
crypto_rkey_get_exp_mod(CRYPTO_RKEY * rkey, uint8 * exponent, uint32 max_exp_len, uint8 * modulus, uint32 max_mod_len);
 
102
 
 
103
RD_BOOL
 
104
crypto_sig_ok(uint8 * exponent, uint32 exp_len, uint8 * modulus, uint32 mod_len, uint8 * signature, uint32 sig_len);
 
105
 
 
106
#endif // __CRYPTO_H