22 #ifndef __KOPENSSLPROXY_H
23 #define __KOPENSSLPROXY_H
25 #define KOSSL KOpenSSLProxy
26 class KOpenSSLProxyPrivate;
30 #include <ksslconfig.h>
33 #define crypt _openssl_crypt
34 #include <openssl/ssl.h>
35 #include <openssl/x509.h>
36 #include <openssl/x509v3.h>
37 #include <openssl/pem.h>
38 #include <openssl/bio.h>
39 #include <openssl/rand.h>
40 #include <openssl/asn1.h>
41 #include <openssl/pkcs7.h>
42 #include <openssl/pkcs12.h>
43 #include <openssl/evp.h>
44 #include <openssl/stack.h>
45 #include <openssl/bn.h>
47 #if OPENSSL_VERSION_NUMBER >= 0x10000000L
49 #define OSSL_SKVALUE_RTYPE void
50 #define OSSL_MORECONST const
52 #define OSSL_SKVALUE_RTYPE char
53 #define OSSL_MORECONST
96 int SSL_connect(SSL *ssl);
101 int SSL_accept(SSL *ssl);
106 int SSL_get_error(SSL *ssl,
int rc);
111 int SSL_read(SSL *ssl,
void *buf,
int num);
116 int SSL_write(SSL *ssl,
const void *buf,
int num);
121 SSL *SSL_new(SSL_CTX *ctx);
126 void SSL_free(SSL *ssl);
131 int SSL_shutdown(SSL *ssl);
136 SSL_CTX *SSL_CTX_new(SSL_METHOD *method);
141 void SSL_CTX_free(SSL_CTX *ctx);
146 int SSL_set_fd(SSL *ssl,
int fd);
151 int SSL_pending(SSL *ssl);
156 int SSL_peek(SSL *ssl,
void *buf,
int num);
161 int SSL_CTX_set_cipher_list(SSL_CTX *ctx,
const char *str);
166 void SSL_CTX_set_verify(SSL_CTX *ctx,
int mode,
167 int (*verify_callback)(
int, X509_STORE_CTX *));
172 int SSL_use_certificate(SSL *ssl, X509 *x);
177 SSL_CIPHER *SSL_get_current_cipher(SSL *ssl);
189 long SSL_ctrl(SSL *ssl,
int cmd,
long larg,
char *parg);
194 int RAND_egd(
const char *path);
200 const char *RAND_file_name(
char *buf,
size_t num);
206 int RAND_load_file(
const char *filename,
long max_bytes);
212 int RAND_write_file(
const char *filename);
218 SSL_METHOD *TLSv1_client_method();
224 SSL_METHOD *SSLv23_client_method();
230 X509 *SSL_get_peer_certificate(SSL *s);
236 STACK_OF(X509) *SSL_get_peer_cert_chain(SSL *s);
241 int SSL_CIPHER_get_bits(SSL_CIPHER *c,
int *alg_bits);
247 char *SSL_CIPHER_get_version(SSL_CIPHER *c);
253 const char *SSL_CIPHER_get_name(SSL_CIPHER *c);
259 char *SSL_CIPHER_description(SSL_CIPHER *,
char *buf,
int size);
266 int SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey);
272 int SSL_CTX_use_certificate(SSL_CTX *ctx, X509 *x);
278 X509 * d2i_X509(X509 **a,
unsigned char **pp,
long length);
284 int i2d_X509(X509 *a,
unsigned char **pp);
290 int X509_cmp(X509 *a, X509 *b);
296 X509 *X509_dup(X509 *x509);
302 X509_STORE_CTX *X509_STORE_CTX_new(
void);
308 void X509_STORE_CTX_free(X509_STORE_CTX *v);
314 void X509_STORE_CTX_set_chain(X509_STORE_CTX *v,
STACK_OF(X509)* x);
319 void X509_STORE_CTX_set_purpose(X509_STORE_CTX *v,
int purpose);
324 int X509_verify_cert(X509_STORE_CTX *v);
330 X509_STORE *X509_STORE_new(
void);
336 void X509_STORE_free(X509_STORE *v);
342 void X509_free(X509 *v);
348 char *X509_NAME_oneline(X509_NAME *a,
char *buf,
int size);
354 X509_NAME *X509_get_subject_name(X509 *a);
360 X509_NAME *X509_get_issuer_name(X509 *a);
366 X509_LOOKUP *X509_STORE_add_lookup(X509_STORE *v, X509_LOOKUP_METHOD *m);
372 X509_LOOKUP_METHOD *X509_LOOKUP_file(
void);
378 void X509_LOOKUP_free(X509_LOOKUP *x);
384 int X509_LOOKUP_ctrl(X509_LOOKUP *ctx,
int cmd,
const char *argc,
long argl,
char **ret);
390 void X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, X509 *x509,
STACK_OF(X509) *chain);
396 void CRYPTO_free(
void *x);
401 BIO *BIO_new(BIO_METHOD *type);
406 BIO_METHOD *BIO_s_mem(
void);
411 BIO *BIO_new_fp(FILE *stream,
int close_flag);
416 BIO *BIO_new_mem_buf(
void *buf,
int len);
421 int BIO_free(BIO *a);
426 long BIO_ctrl(BIO *bp,
int cmd,
long larg,
void *parg);
431 int BIO_write(BIO *b,
const void *data,
int len);
436 int PEM_write_bio_X509(BIO *bp, X509 *x);
441 int ASN1_item_i2d_fp(FILE *out,
unsigned char *x);
447 X509 *X509_d2i_fp(FILE *out, X509** buf);
453 int X509_print(FILE *
fp, X509 *x);
459 PKCS12 *d2i_PKCS12_fp(FILE *fp, PKCS12 **p12);
465 int PKCS12_newpass(PKCS12 *p12,
char *oldpass,
char *newpass);
471 int i2d_PKCS12(PKCS12 *p12,
unsigned char **p);
477 int i2d_PKCS12_fp(FILE *fp, PKCS12 *p12);
483 PKCS12 *PKCS12_new(
void);
489 void PKCS12_free(PKCS12 *a);
495 int PKCS12_parse(PKCS12 *p12,
const char *pass, EVP_PKEY **pkey,
502 void EVP_PKEY_free(EVP_PKEY *x);
508 char *sk_pop(STACK *s);
516 #if OPENSSL_VERSION_NUMBER >= 0x10000000L
517 void sk_free(
void *s) {
return sk_free(reinterpret_cast<STACK*>(s)); }
531 #if OPENSSL_VERSION_NUMBER >= 0x10000000L
532 char *
sk_value(
void *s,
int n) {
return sk_value(reinterpret_cast<STACK*>(s), n); }
538 STACK *
sk_new(
int (*cmp)());
544 int sk_push(STACK *s,
char *d);
546 #if OPENSSL_VERSION_NUMBER >= 0x10000000L
547 int sk_push(
void *s,
void *d) {
return sk_push(reinterpret_cast<STACK*>(s), reinterpret_cast<char*>(d)); }
560 char *i2s_ASN1_INTEGER(X509V3_EXT_METHOD *meth, ASN1_INTEGER *aint);
566 ASN1_INTEGER *X509_get_serialNumber(X509 *x);
572 EVP_PKEY *X509_get_pubkey(X509 *x);
578 int i2d_PublicKey(EVP_PKEY *a,
unsigned char **pp);
584 int X509_check_private_key(X509 *x, EVP_PKEY *p);
590 char *BN_bn2hex(
const BIGNUM *a);
596 int X509_digest(
const X509 *x,
const EVP_MD *t,
unsigned char *md,
unsigned int *len);
608 void ASN1_INTEGER_free(ASN1_INTEGER *x);
614 unsigned char *ASN1_STRING_data(ASN1_STRING *x);
619 int ASN1_STRING_length(ASN1_STRING *x);
624 int OBJ_obj2nid(ASN1_OBJECT *o);
629 const char * OBJ_nid2ln(
int n);
634 int X509_get_ext_count(X509 *x);
639 int X509_get_ext_by_NID(X509 *x,
int nid,
int lastpos);
644 int X509_get_ext_by_OBJ(X509 *x,ASN1_OBJECT *obj,
int lastpos);
649 X509_EXTENSION *X509_get_ext(X509 *x,
int loc);
654 X509_EXTENSION *X509_delete_ext(X509 *x,
int loc);
659 int X509_add_ext(X509 *x, X509_EXTENSION *ex,
int loc);
664 void *X509_get_ext_d2i(X509 *x,
int nid,
int *crit,
int *idx);
669 char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, ASN1_OCTET_STRING *ia5);
674 int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a,
int n);
679 PKCS7 *PKCS7_new(
void);
684 void PKCS7_free(PKCS7 *a);
689 void PKCS7_content_free(PKCS7 *a);
694 int i2d_PKCS7(PKCS7 *a,
unsigned char **pp);
699 PKCS7 *d2i_PKCS7(PKCS7 **a,
unsigned char **pp,
long length);
704 int i2d_PKCS7_fp(FILE *fp,PKCS7 *p7);
709 PKCS7 *d2i_PKCS7_fp(FILE *fp,PKCS7 **p7);
714 int i2d_PKCS7_bio(BIO *bp,PKCS7 *p7);
719 PKCS7 *d2i_PKCS7_bio(BIO *bp,PKCS7 **p7);
724 PKCS7 *PKCS7_dup(PKCS7 *p7);
729 PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey,
STACK_OF(X509) *certs,
730 BIO *data,
int flags);
735 int PKCS7_verify(PKCS7 *p7,
STACK_OF(X509) *certs, X509_STORE *store,
736 BIO *indata, BIO *out,
int flags);
741 STACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7,
STACK_OF(X509) *certs,
int flags);
746 PKCS7 *PKCS7_encrypt(
STACK_OF(X509) *certs, BIO *in, EVP_CIPHER *cipher,
752 int PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data,
int flags);
758 STACK_OF(X509_NAME) *SSL_load_client_CA_file(
const char *file);
764 pem_password_cb *cb,
void *u);
769 int X509_PURPOSE_get_count();
775 int X509_PURPOSE_get_id(X509_PURPOSE *);
781 int X509_check_purpose(X509 *x,
int id,
int ca);
787 X509_PURPOSE * X509_PURPOSE_get0(
int idx);
793 EVP_PKEY* EVP_PKEY_new();
799 int EVP_PKEY_assign(EVP_PKEY *pkey,
int type,
char *key);
805 RSA *RSA_generate_key(
int bits,
unsigned long e,
void
806 (*callback)(
int,
int,
void *),
void *cb_arg);
812 X509_REQ *X509_REQ_new();
813 void X509_REQ_free(X509_REQ *a);
819 int X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey);
822 int i2d_X509_REQ_fp(FILE *fp, X509_REQ *x);
825 STACK *X509_get1_email(X509 *x);
826 void X509_email_free(STACK *sk);
829 EVP_CIPHER *EVP_des_ede3_cbc();
830 EVP_CIPHER *EVP_des_cbc();
831 EVP_CIPHER *EVP_rc2_cbc();
832 EVP_CIPHER *EVP_rc2_64_cbc();
833 EVP_CIPHER *EVP_rc2_40_cbc();
836 void ERR_clear_error();
839 unsigned long ERR_get_error();
842 void ERR_print_errors_fp(FILE *fp);
845 SSL_SESSION *SSL_get1_session(SSL *ssl);
848 void SSL_SESSION_free(SSL_SESSION *session);
851 int SSL_set_session(SSL *ssl, SSL_SESSION *session);
854 SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a,
unsigned char **pp,
long length);
856 int i2d_SSL_SESSION(SSL_SESSION *in,
unsigned char **pp);
859 int i2d_PrivateKey_fp(FILE*, EVP_PKEY*);
862 int i2d_PKCS8PrivateKey_fp(FILE*, EVP_PKEY*,
const EVP_CIPHER*,
char*,
int, pem_password_cb*,
void*);
868 EVP_CIPHER *EVP_bf_cbc();
871 int X509_REQ_sign(X509_REQ*, EVP_PKEY*,
const EVP_MD*);
874 int X509_NAME_add_entry_by_txt(X509_NAME*,
char*,
int,
unsigned char*,
int,
int,
int);
877 X509_NAME *X509_NAME_new();
880 int X509_REQ_set_subject_name(X509_REQ*,X509_NAME*);
883 STACK_OF(SSL_CIPHER) *SSL_get_ciphers(
const SSL* ssl);
bool hasLibCrypto() const
Return true of libcrypto was found and loaded.
Dynamically load and wrap OpenSSL.
friend class KOpenSSLProxyPrivate
bool hasLibSSL() const
Return true of libssl was found and loaded.
void destroy()
Destroy the class and start over - don't use this unless you know what you are doing.