Blame include/freerdp/crypto/crypto.h

Packit 1fb8d4
/**
Packit 1fb8d4
 * FreeRDP: A Remote Desktop Protocol Implementation
Packit 1fb8d4
 * Cryptographic Abstraction Layer
Packit 1fb8d4
 *
Packit 1fb8d4
 * Copyright 2011-2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
Packit 1fb8d4
 *
Packit 1fb8d4
 * Licensed under the Apache License, Version 2.0 (the "License");
Packit 1fb8d4
 * you may not use this file except in compliance with the License.
Packit 1fb8d4
 * You may obtain a copy of the License at
Packit 1fb8d4
 *
Packit 1fb8d4
 *     http://www.apache.org/licenses/LICENSE-2.0
Packit 1fb8d4
 *
Packit 1fb8d4
 * Unless required by applicable law or agreed to in writing, software
Packit 1fb8d4
 * distributed under the License is distributed on an "AS IS" BASIS,
Packit 1fb8d4
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Packit 1fb8d4
 * See the License for the specific language governing permissions and
Packit 1fb8d4
 * limitations under the License.
Packit 1fb8d4
 */
Packit 1fb8d4
Packit 1fb8d4
#ifndef FREERDP_CRYPTO_H
Packit 1fb8d4
#define FREERDP_CRYPTO_H
Packit 1fb8d4
Packit 1fb8d4
/* OpenSSL includes windows.h */
Packit 1fb8d4
#include <winpr/windows.h>
Packit 1fb8d4
Packit 1fb8d4
#include <openssl/ssl.h>
Packit 1fb8d4
#include <openssl/err.h>
Packit 1fb8d4
#include <openssl/bn.h>
Packit 1fb8d4
#include <openssl/x509v3.h>
Packit 1fb8d4
Packit 1fb8d4
#if OPENSSL_VERSION_NUMBER >= 0x0090800f
Packit 1fb8d4
#define D2I_X509_CONST const
Packit 1fb8d4
#else
Packit 1fb8d4
#define D2I_X509_CONST
Packit 1fb8d4
#endif
Packit 1fb8d4
Packit Service 5a9772
#define EXPONENT_MAX_SIZE 4
Packit 1fb8d4
Packit 1fb8d4
#include <freerdp/api.h>
Packit 1fb8d4
#include <freerdp/freerdp.h>
Packit 1fb8d4
#include <freerdp/crypto/certificate.h>
Packit 1fb8d4
Packit 1fb8d4
struct crypto_cert_struct
Packit 1fb8d4
{
Packit 1fb8d4
	X509* px509;
Packit Service 5a9772
	STACK_OF(X509) * px509chain;
Packit 1fb8d4
};
Packit 1fb8d4
Packit 1fb8d4
#ifdef __cplusplus
Packit Service 5a9772
extern "C"
Packit Service 5a9772
{
Packit 1fb8d4
#endif
Packit 1fb8d4
Packit Service 5a9772
	typedef struct crypto_cert_struct* CryptoCert;
Packit Service 5a9772
Packit Service 5a9772
	FREERDP_API CryptoCert crypto_cert_read(BYTE* data, UINT32 length);
Packit Service 5a9772
	FREERDP_API BYTE* crypto_cert_hash(X509* xcert, const char* hash, UINT32* length);
Packit Service 5a9772
	FREERDP_API char* crypto_cert_fingerprint_by_hash(X509* xcert, const char* hash);
Packit Service 5a9772
	FREERDP_API char* crypto_cert_fingerprint(X509* xcert);
Packit Service 5a9772
	FREERDP_API char* crypto_cert_subject(X509* xcert);
Packit Service 5a9772
	FREERDP_API char* crypto_cert_subject_common_name(X509* xcert, int* length);
Packit Service 5a9772
	FREERDP_API char** crypto_cert_get_dns_names(X509* xcert, int* count, int** lengths);
Packit Service 5a9772
	FREERDP_API char* crypto_cert_get_email(X509* x509);
Packit Service 5a9772
	FREERDP_API char* crypto_cert_get_upn(X509* x509);
Packit Service 5a9772
	FREERDP_API void crypto_cert_dns_names_free(int count, int* lengths, char** dns_names);
Packit Service 5a9772
	FREERDP_API char* crypto_cert_issuer(X509* xcert);
Packit Service 5a9772
	FREERDP_API void crypto_cert_print_info(X509* xcert);
Packit Service 5a9772
	FREERDP_API void crypto_cert_free(CryptoCert cert);
Packit Service 5a9772
Packit Service 5a9772
	/*
Packit Service 5a9772
	Deprecated function names: crypto_cert_subject_alt_name and crypto_cert_subject_alt_name_free.
Packit Service 5a9772
	Use crypto_cert_get_dns_names and crypto_cert_dns_names_free instead.
Packit Service 5a9772
	(old names kept for now for compatibility of FREERDP_API).
Packit Service 5a9772
	Note: email and upn amongst others are also alt_names,
Packit Service 5a9772
	but the old crypto_cert_get_alt_names returned only the dns_names
Packit Service 5a9772
	*/
Packit Service 5a9772
	FREERDP_API char** crypto_cert_subject_alt_name(X509* xcert, int* count, int** lengths);
Packit Service 5a9772
	FREERDP_API void crypto_cert_subject_alt_name_free(int count, int* lengths, char** alt_names);
Packit Service 5a9772
Packit Service 5a9772
	FREERDP_API BOOL x509_verify_certificate(CryptoCert cert, const char* certificate_store_path);
Packit Service 5a9772
	FREERDP_API rdpCertificateData* crypto_get_certificate_data(X509* xcert, const char* hostname,
Packit Service 5a9772
	                                                            UINT16 port);
Packit Service 5a9772
	FREERDP_API BOOL crypto_cert_get_public_key(CryptoCert cert, BYTE** PublicKey,
Packit Service 5a9772
	                                            DWORD* PublicKeyLength);
Packit Service 5a9772
Packit Service 5a9772
#define TSSK_KEY_LENGTH 64
Packit Service 5a9772
	extern const BYTE tssk_modulus[];
Packit Service 5a9772
	extern const BYTE tssk_privateExponent[];
Packit Service 5a9772
	extern const BYTE tssk_exponent[];
Packit Service 5a9772
Packit Service 5a9772
	FREERDP_API int crypto_rsa_public_encrypt(const BYTE* input, int length, UINT32 key_length,
Packit Service 5a9772
	                                          const BYTE* modulus, const BYTE* exponent,
Packit Service 5a9772
	                                          BYTE* output);
Packit Service 5a9772
	FREERDP_API int crypto_rsa_public_decrypt(const BYTE* input, int length, UINT32 key_length,
Packit Service 5a9772
	                                          const BYTE* modulus, const BYTE* exponent,
Packit Service 5a9772
	                                          BYTE* output);
Packit Service 5a9772
	FREERDP_API int crypto_rsa_private_encrypt(const BYTE* input, int length, UINT32 key_length,
Packit Service 5a9772
	                                           const BYTE* modulus, const BYTE* private_exponent,
Packit Service 5a9772
	                                           BYTE* output);
Packit Service 5a9772
	FREERDP_API int crypto_rsa_private_decrypt(const BYTE* input, int length, UINT32 key_length,
Packit Service 5a9772
	                                           const BYTE* modulus, const BYTE* private_exponent,
Packit Service 5a9772
	                                           BYTE* output);
Packit Service 5a9772
	FREERDP_API void crypto_reverse(BYTE* data, int length);
Packit Service 5a9772
Packit Service 5a9772
	FREERDP_API char* crypto_base64_encode(const BYTE* data, int length);
Packit Service 5a9772
	FREERDP_API void crypto_base64_decode(const char* enc_data, int length, BYTE** dec_data,
Packit Service 5a9772
	                                      int* res_length);
Packit 1fb8d4
Packit 1fb8d4
#ifdef __cplusplus
Packit 1fb8d4
}
Packit 1fb8d4
#endif
Packit 1fb8d4
Packit 1fb8d4
#endif /* FREERDP_CRYPTO_H */