Blame include/freerdp/crypto/crypto.h

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