~paulliu/ubuntu/quantal/freerdp/fixext

« back to all changes in this revision

Viewing changes to libfreerdp-core/crypto.h

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2012-01-31 10:02:14 UTC
  • mto: This revision was merged to the branch mainline in revision 11.
  • Revision ID: package-import@ubuntu.com-20120131100214-zvig71djj2sqgq22
Tags: upstream-1.0.0
ImportĀ upstreamĀ versionĀ 1.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * FreeRDP: A Remote Desktop Protocol Client
 
3
 * Cryptographic Abstraction Layer
 
4
 *
 
5
 * Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
 
6
 *
 
7
 * Licensed under the Apache License, Version 2.0 (the "License");
 
8
 * you may not use this file except in compliance with the License.
 
9
 * You may obtain a copy of the License at
 
10
 *
 
11
 *     http://www.apache.org/licenses/LICENSE-2.0
 
12
 *
 
13
 * Unless required by applicable law or agreed to in writing, software
 
14
 * distributed under the License is distributed on an "AS IS" BASIS,
 
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
16
 * See the License for the specific language governing permissions and
 
17
 * limitations under the License.
 
18
 */
 
19
 
 
20
#ifndef __CRYPTO_H
 
21
#define __CRYPTO_H
 
22
 
 
23
#ifdef _WIN32
 
24
#include "tcp.h"
 
25
#endif
 
26
 
 
27
#include <openssl/ssl.h>
 
28
#include <openssl/err.h>
 
29
#include <openssl/rc4.h>
 
30
#include <openssl/md5.h>
 
31
#include <openssl/sha.h>
 
32
#include <openssl/hmac.h>
 
33
#include <openssl/bn.h>
 
34
#include <openssl/x509v3.h>
 
35
#include <openssl/rand.h>
 
36
 
 
37
#if defined(OPENSSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER >= 0x0090800f)
 
38
#define D2I_X509_CONST const
 
39
#else
 
40
#define D2I_X509_CONST
 
41
#endif
 
42
 
 
43
#define EXPONENT_MAX_SIZE                       4
 
44
#define MODULUS_MAX_SIZE                        256
 
45
 
 
46
#include <freerdp/freerdp.h>
 
47
#include <freerdp/utils/blob.h>
 
48
#include <freerdp/utils/memory.h>
 
49
#include <freerdp/utils/certstore.h>
 
50
 
 
51
struct crypto_sha1_struct
 
52
{
 
53
        SHA_CTX sha_ctx;
 
54
};
 
55
 
 
56
struct crypto_md5_struct
 
57
{
 
58
        MD5_CTX md5_ctx;
 
59
};
 
60
 
 
61
struct crypto_rc4_struct
 
62
{
 
63
        RC4_KEY rc4_key;
 
64
};
 
65
 
 
66
struct crypto_des3_struct
 
67
{
 
68
        EVP_CIPHER_CTX des3_ctx;
 
69
};
 
70
 
 
71
struct crypto_hmac_struct
 
72
{
 
73
        HMAC_CTX hmac_ctx;
 
74
};
 
75
 
 
76
struct crypto_cert_struct
 
77
{
 
78
        X509 * px509;
 
79
};
 
80
 
 
81
typedef struct crypto_sha1_struct* CryptoSha1;
 
82
CryptoSha1 crypto_sha1_init(void);
 
83
void crypto_sha1_update(CryptoSha1 sha1, const uint8* data, uint32 length);
 
84
void crypto_sha1_final(CryptoSha1 sha1, uint8* out_data);
 
85
 
 
86
typedef struct crypto_md5_struct* CryptoMd5;
 
87
CryptoMd5 crypto_md5_init(void);
 
88
void crypto_md5_update(CryptoMd5 md5, const uint8* data, uint32 length);
 
89
void crypto_md5_final(CryptoMd5 md5, uint8* out_data);
 
90
 
 
91
typedef struct crypto_rc4_struct* CryptoRc4;
 
92
CryptoRc4 crypto_rc4_init(const uint8* key, uint32 length);
 
93
void crypto_rc4(CryptoRc4 rc4, uint32 length, const uint8* in_data, uint8* out_data);
 
94
void crypto_rc4_free(CryptoRc4 rc4);
 
95
 
 
96
typedef struct crypto_des3_struct* CryptoDes3;
 
97
CryptoDes3 crypto_des3_encrypt_init(const uint8* key, const uint8* ivec);
 
98
CryptoDes3 crypto_des3_decrypt_init(const uint8* key, const uint8* ivec);
 
99
void crypto_des3_encrypt(CryptoDes3 des3, uint32 length, const uint8 *in_data, uint8 *out_data);
 
100
void crypto_des3_decrypt(CryptoDes3 des3, uint32 length, const uint8 *in_data, uint8* out_data);
 
101
void crypto_des3_free(CryptoDes3 des3);
 
102
 
 
103
typedef struct crypto_hmac_struct* CryptoHmac;
 
104
CryptoHmac crypto_hmac_new(void);
 
105
void crypto_hmac_sha1_init(CryptoHmac hmac, const uint8 *data, uint32 length);
 
106
void crypto_hmac_update(CryptoHmac hmac, const uint8 *data, uint32 length);
 
107
void crypto_hmac_final(CryptoHmac hmac, uint8 *out_data, uint32 length);
 
108
void crypto_hmac_free(CryptoHmac hmac);
 
109
 
 
110
typedef struct crypto_cert_struct* CryptoCert;
 
111
CryptoCert crypto_cert_read(uint8* data, uint32 length);
 
112
char* crypto_cert_fingerprint(X509* xcert);
 
113
char* crypto_cert_subject(X509* xcert);
 
114
char* crypto_cert_issuer(X509* xcert);
 
115
void crypto_cert_print_info(X509* xcert);
 
116
void crypto_cert_free(CryptoCert cert);
 
117
boolean x509_verify_cert(CryptoCert cert, rdpSettings* settings);
 
118
rdpCertData* crypto_get_cert_data(X509* xcert, char* hostname);
 
119
boolean crypto_cert_get_public_key(CryptoCert cert, rdpBlob* public_key);
 
120
 
 
121
void crypto_rsa_encrypt(const uint8* input, int length, uint32 key_length, const uint8* modulus, const uint8* exponent, uint8* output);
 
122
void crypto_reverse(uint8* data, int length);
 
123
void crypto_nonce(uint8* nonce, int size);
 
124
 
 
125
#endif /* __CRYPTO_H */