FreeRDP/include/freerdp/crypto/crypto.h

107 lines
3.9 KiB
C
Raw Normal View History

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