2 * FreeRDP: A Remote Desktop Protocol Client
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.
20 #ifndef __CERTIFICATE_H
21 #define __CERTIFICATE_H
23 typedef struct rdp_certificate_data rdpCertificateData;
24 typedef struct rdp_certificate_store rdpCertificateStore;
30 #include <freerdp/settings.h>
31 #include <freerdp/utils/blob.h>
32 #include <freerdp/utils/stream.h>
33 #include <freerdp/utils/hexdump.h>
35 /* Certificate Version */
36 #define CERT_CHAIN_VERSION_1 0x00000001
37 #define CERT_CHAIN_VERSION_2 0x00000002
38 #define CERT_CHAIN_VERSION_MASK 0x7FFFFFFF
39 #define CERT_PERMANENTLY_ISSUED 0x00000000
40 #define CERT_TEMPORARILY_ISSUED 0x80000000
42 #define SIGNATURE_ALG_RSA 0x00000001
43 #define KEY_EXCHANGE_ALG_RSA 0x00000001
45 #define BB_RSA_KEY_BLOB 6
46 #define BB_RSA_SIGNATURE_BLOB 8
51 rdpBlob private_exponent;
55 struct rdp_certificate_data
61 struct rdp_certificate_store
66 rdpSettings* settings;
67 rdpCertificateData* certificate_data;
70 rdpCertificateData* certificate_data_new(char* hostname, char* fingerprint);
71 void certificate_data_free(rdpCertificateData* certificate_data);
72 rdpCertificateStore* certificate_store_new(rdpSettings* settings);
73 void certificate_store_free(rdpCertificateStore* certificate_store);
74 int certificate_data_match(rdpCertificateStore* certificate_store, rdpCertificateData* certificate_data);
75 void certificate_data_print(rdpCertificateStore* certificate_store, rdpCertificateData* certificate_data);
77 void certificate_read_x509_certificate(rdpCertBlob* cert, rdpCertInfo* info);
79 rdpX509CertChain* certificate_new_x509_certificate_chain(uint32 count);
80 void certificate_free_x509_certificate_chain(rdpX509CertChain* x509_cert_chain);
82 boolean certificate_read_server_proprietary_certificate(rdpCertificate* certificate, STREAM* s);
83 boolean certificate_read_server_x509_certificate_chain(rdpCertificate* certificate, STREAM* s);
84 boolean certificate_read_server_certificate(rdpCertificate* certificate, uint8* server_cert, int length);
86 rdpCertificate* certificate_new();
87 void certificate_free(rdpCertificate* certificate);
89 rdpKey* key_new(const char *keyfile);
90 void key_free(rdpKey* key);
92 #ifdef WITH_DEBUG_CERTIFICATE
93 #define DEBUG_CERTIFICATE(fmt, ...) DEBUG_CLASS(CERTIFICATE, fmt, ## __VA_ARGS__)
95 #define DEBUG_CERTIFICATE(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__)
98 #endif /* __CERTIFICATE_H */