2
* FreeRDP: A Remote Desktop Protocol Client
3
* Cryptographic Abstraction Layer
5
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
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
11
* http://www.apache.org/licenses/LICENSE-2.0
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.
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>
37
#if defined(OPENSSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER >= 0x0090800f)
38
#define D2I_X509_CONST const
40
#define D2I_X509_CONST
43
#define EXPONENT_MAX_SIZE 4
44
#define MODULUS_MAX_SIZE 256
46
#include <freerdp/freerdp.h>
47
#include <freerdp/utils/blob.h>
48
#include <freerdp/utils/memory.h>
49
#include <freerdp/utils/certstore.h>
51
struct crypto_sha1_struct
56
struct crypto_md5_struct
61
struct crypto_rc4_struct
66
struct crypto_des3_struct
68
EVP_CIPHER_CTX des3_ctx;
71
struct crypto_hmac_struct
76
struct crypto_cert_struct
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);
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);
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);
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);
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);
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);
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);
125
#endif /* __CRYPTO_H */