commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r1166310 - /commons/sandbox/runtime/trunk/src/main/native/modules/openssl/api.c
Date Wed, 07 Sep 2011 18:47:25 GMT
Author: mturk
Date: Wed Sep  7 18:47:25 2011
New Revision: 1166310

URL: http://svn.apache.org/viewvc?rev=1166310&view=rev
Log:
Fill current ssl dynamic api

Modified:
    commons/sandbox/runtime/trunk/src/main/native/modules/openssl/api.c

Modified: commons/sandbox/runtime/trunk/src/main/native/modules/openssl/api.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/modules/openssl/api.c?rev=1166310&r1=1166309&r2=1166310&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/modules/openssl/api.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/modules/openssl/api.c Wed Sep  7 18:47:25
2011
@@ -76,15 +76,90 @@ struct SSLAPIst {
     unsigned long       (*fpSSLeay)(void);
     const char*         (*fpSSLeay_version)(int);
 
+    /*** BIO      ***/
+    long                (*fpBIO_ctrl)(BIO *, int, long, void *);
+    int                 (*fpBIO_free)(BIO *);
+    BIO*                (*fpBIO_new)(BIO_METHOD *);
+    BIO*                (*fpBIO_new_file)(const char *, const char *);
+    BIO*                (*fpBIO_new_fp)(FILE *, int);
+    BIO_METHOD*         (*fpBIO_s_file)(void);
+
+    /*** BIGNUM   ***/
+    BIGNUM*             (*fpBN_bin2bn)(const unsigned char *s, int len, BIGNUM *ret);
+
+    /*** CRYPTO   ***/
+    int                 (*fpCRYPTO_num_locks)(void);
+    void                (*fpCRYPTO_set_dynlock_create_callback)(struct CRYPTO_dynlock_value
*(*)(const char *, int));
+    void                (*fpCRYPTO_set_dynlock_lock_callback)(void (*)(int, struct CRYPTO_dynlock_value
*, const char *, int));
+    void                (*fpCRYPTO_set_dynlock_destroy_callback)(void (*)(struct CRYPTO_dynlock_value
*, const char *, int));
+    void                (*fpCRYPTO_set_id_callback)(unsigned long (*)(void));
+    void                (*fpCRYPTO_set_locking_callback)(void (*)(int, int, const char *,
int));
+    int                 (*fpCRYPTO_set_mem_functions)(void *(*)(size_t),void *(*)(void *,size_t),
void (*)(void *));
+
+    /*** DH       ***/
+    DH*                 (*fpDH_new)(void);
+    void                (*fpDH_free)(DH *dh);
+
+    /*** ENGINE   ***/
+    ENGINE*             (*fpENGINE_by_id)(const char *id);
+    int                 (*fpENGINE_ctrl)(ENGINE *e, int cmd, long i, void *p, void (*f)(void));
+    int                 (*fpENGINE_ctrl_cmd)(ENGINE *e, const char *cmd_name, long i, void
*p, void (*f)(void), int cmd_optional);
+    int                 (*fpENGINE_ctrl_cmd_string)(ENGINE *e, const char *cmd_name, const
char *arg, int cmd_optional);
+    
+    int                 (*fpENGINE_free)(ENGINE *e);
+    void                (*fpENGINE_load_builtin_engines)(void);
+    int                 (*fpENGINE_register_all_complete)(void);
+    int                 (*fpENGINE_set_default)(ENGINE *e, unsigned int flags);
+
+    /*** ERR      ***/
+    void                (*fpERR_error_string_n)(unsigned long e, char *buf, size_t len);
+    unsigned long       (*fpERR_get_error)(void);
+    void                (*fpERR_load_crypto_strings)(void);
+    unsigned long       (*fpERR_peek_error)(void);
+
+    /*** MD5      ***/
+    int                 (*fpMD5_Final)(unsigned char *md, MD5_CTX *c);
+    int                 (*fpMD5_Init)(MD5_CTX *c);
+    int                 (*fpMD5_Update)(MD5_CTX *c, const void *data, size_t len);
+
+    /*** OPENSSL  ***/
+    void                (*fpOPENSSL_load_builtin_modules)(void);
+
+    /*** PEM      ***/
+    DH*                 (*fpPEM_read_bio_DHparams)(BIO *bp, DH **x, pem_password_cb *cb,
void *u);
+    X509*               (*fpPEM_read_bio_X509)(BIO *bp, X509 **x, pem_password_cb *cb, void
*u);
+
+    /*** RAND     ***/
+    int                 (*fpRAND_egd)(const char *path);
+    const char*         (*fpRAND_file_name)(char *file,size_t num);
+    int                 (*fpRAND_load_file)(const char *file,long max_bytes);
+    void                (*fpRAND_seed)(const void *buf,int num);
+    int                 (*fpRAND_status)(void);
+
+    /*** RSA      ***/
+    RSA*                (*fpRSA_generate_key)(int bits, unsigned long e,void (*callback)(int,int,void
*),void *cb_arg);
+    
+    /*** SSL_CTX  ***/
+    long                (*fpSSL_CTX_ctrl)(SSL_CTX *ctx,int cmd, long larg, void *parg); 
  
     SSL_CTX*            (*fpSSL_CTX_new)(const SSL_METHOD *);
     void                (*fpSSL_CTX_free)(SSL_CTX *);
+    
+    /*** SSL      ***/
+    void*               (*fpSSL_get_ex_data)(const SSL *ssl,int idx);
+    int                 (*fpSSL_get_ex_new_index)(long, void *, CRYPTO_EX_new *, CRYPTO_EX_dup
*, CRYPTO_EX_free *);
+    int                 (*fpSSL_library_init)(void);
+    void                (*fpSSL_load_error_strings)(void);
+    int                 (*fpSSL_set_ex_data)(SSL *ssl,int idx,void *data);
 
+    /*** X509     ***/
+    void                (*fpX509_free)(X509 *);
     void                (*fpNULL)(void);
 };
 
 struct SSLOPTst {
 #if HAVE_FIPS
     int                 (*fpFIPS_mode)(void);
+    int                 (*fpFIPS_mode_set)(int onoff);
 #endif
 #if HAVE_OCSP
 
@@ -119,9 +194,83 @@ ACR_JNI_EXPORT(jboolean, Native, ldopens
                  "OpenSSL 0.9.8 or greater is required");
         return JNI_FALSE;
     }
+
+    /*** BIO      ***/
+    CRYPTO_FPLOAD(BIO_ctrl);
+    CRYPTO_FPLOAD(BIO_free);
+    CRYPTO_FPLOAD(BIO_new);
+    CRYPTO_FPLOAD(BIO_new_file);
+    CRYPTO_FPLOAD(BIO_new_fp);
+    CRYPTO_FPLOAD(BIO_s_file);
+
+    /*** BIGNUM   ***/
+    CRYPTO_FPLOAD(BN_bin2bn);
+
+    /*** CRYPTO   ***/
+    CRYPTO_FPLOAD(CRYPTO_num_locks);
+    CRYPTO_FPLOAD(CRYPTO_set_dynlock_create_callback);
+    CRYPTO_FPLOAD(CRYPTO_set_dynlock_destroy_callback);
+    CRYPTO_FPLOAD(CRYPTO_set_dynlock_lock_callback);
+    CRYPTO_FPLOAD(CRYPTO_set_id_callback);
+    CRYPTO_FPLOAD(CRYPTO_set_locking_callback);
+    CRYPTO_FPLOAD(CRYPTO_set_mem_functions);
+
+    /*** DH       ***/
+    CRYPTO_FPLOAD(DH_new);
+    CRYPTO_FPLOAD(DH_free);
+
+    /*** ENGINE   ***/
+    CRYPTO_FPLOAD(ENGINE_by_id);
+    CRYPTO_FPLOAD(ENGINE_ctrl);
+    CRYPTO_FPLOAD(ENGINE_ctrl_cmd);
+    CRYPTO_FPLOAD(ENGINE_ctrl_cmd_string);
+    CRYPTO_FPLOAD(ENGINE_free);
+    CRYPTO_FPLOAD(ENGINE_load_builtin_engines);
+    CRYPTO_FPLOAD(ENGINE_register_all_complete);
+    CRYPTO_FPLOAD(ENGINE_set_default);
+
+    /*** ERR      ***/
+    CRYPTO_FPLOAD(ERR_error_string_n);
+    CRYPTO_FPLOAD(ERR_get_error);
+    CRYPTO_FPLOAD(ERR_load_crypto_strings);
+    CRYPTO_FPLOAD(ERR_peek_error);
+
+    /*** MD5      ***/
+    CRYPTO_FPLOAD(MD5_Final);
+    CRYPTO_FPLOAD(MD5_Init);
+    CRYPTO_FPLOAD(MD5_Update);
+
+    /*** OPENSSL  ***/
+    CRYPTO_FPLOAD(OPENSSL_load_builtin_modules);
+
+    /*** PEM      ***/
+    CRYPTO_FPLOAD(PEM_read_bio_DHparams);
+    CRYPTO_FPLOAD(PEM_read_bio_X509);
+
+    /*** RAND     ***/
+    CRYPTO_FPLOAD(RAND_egd);
+    CRYPTO_FPLOAD(RAND_file_name);
+    CRYPTO_FPLOAD(RAND_load_file);
+    CRYPTO_FPLOAD(RAND_seed);
+    CRYPTO_FPLOAD(RAND_status);
+
+    /*** RSA      ***/
+    CRYPTO_FPLOAD(RSA_generate_key);
+    
+    LIBSSL_FPLOAD(SSL_CTX_ctrl);
     LIBSSL_FPLOAD(SSL_CTX_new);
     LIBSSL_FPLOAD(SSL_CTX_free);
 
+    /*** SSL      ***/
+    LIBSSL_FPLOAD(SSL_get_ex_data);
+    LIBSSL_FPLOAD(SSL_get_ex_new_index);
+    LIBSSL_FPLOAD(SSL_library_init);
+    LIBSSL_FPLOAD(SSL_load_error_strings);
+    LIBSSL_FPLOAD(SSL_set_ex_data);
+
+    /*** X509     ***/
+    CRYPTO_FPLOAD(X509_free);
+    
 
     /* Optional functions
      * We could compile with the HAVE_FIPS, but target OpenSSL might not
@@ -129,7 +278,9 @@ ACR_JNI_EXPORT(jboolean, Native, ldopens
      */
 #if HAVE_FIPS
     LIBSSL_LDDOPT(FIPS_mode);
+    LIBSSL_LDDOPT(FIPS_mode_set);
 #endif
+
     return JNI_TRUE;
 failed:
     AcrThrowEx(env, ACR_EX_ENOENT, "Cannot find %s::%s()", dname, fname);
@@ -155,6 +306,215 @@ const char *SSLeay_version(int type)
     return SSLAPI_LINK(SSLeay_version)(type);
 }
 
+long BIO_ctrl(BIO *bp, int cmd, long larg, void *parg)
+{
+    return SSLAPI_LINK(BIO_ctrl)(bp, cmd, larg, parg);
+}
+
+BIO *BIO_new(BIO_METHOD *type)
+{
+    return SSLAPI_LINK(BIO_new)(type);
+}
+
+int  BIO_free(BIO *a)
+{
+    return SSLAPI_LINK(BIO_free)(a);
+}
+
+BIO *BIO_new_file(const char *filename, const char *mode)
+{
+    return SSLAPI_LINK(BIO_new_file)(filename, mode);
+}
+
+BIO *BIO_new_fp(FILE *stream, int close_flag)
+{
+    return SSLAPI_LINK(BIO_new_fp)(stream, close_flag);
+}
+
+BIO_METHOD *BIO_s_file(void)
+{
+    return SSLAPI_LINK(BIO_s_file)();
+}
+
+BIGNUM *BN_bin2bn(const unsigned char *s,int len,BIGNUM *ret)
+{
+    return SSLAPI_LINK(BN_bin2bn)(s, len, ret);
+}
+
+int CRYPTO_num_locks(void)
+{
+    return SSLAPI_LINK(CRYPTO_num_locks)();
+}
+
+void CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value *(*dyn_create_function)(const
char *file, int line))
+{
+    SSLAPI_LINK(CRYPTO_set_dynlock_create_callback)(dyn_create_function);
+}
+
+void CRYPTO_set_dynlock_lock_callback(void (*dyn_lock_function)(int mode, struct CRYPTO_dynlock_value
*l, const char *file, int line))
+{
+    SSLAPI_LINK(CRYPTO_set_dynlock_lock_callback)(dyn_lock_function);
+}
+
+void CRYPTO_set_dynlock_destroy_callback(void (*dyn_destroy_function)(struct CRYPTO_dynlock_value
*l, const char *file, int line))
+{
+    SSLAPI_LINK(CRYPTO_set_dynlock_destroy_callback)(dyn_destroy_function);
+}
+
+void CRYPTO_set_id_callback(unsigned long (*func)(void))
+{
+    SSLAPI_LINK(CRYPTO_set_id_callback)(func);
+}
+
+void CRYPTO_set_locking_callback(void (*func)(int mode,int type,
+                                              const char *file,int line))
+{
+    SSLAPI_LINK(CRYPTO_set_locking_callback)(func);
+}
+
+int CRYPTO_set_mem_functions(void *(*m)(size_t),void *(*r)(void *,size_t), void (*f)(void
*))
+{
+    return SSLAPI_LINK(CRYPTO_set_mem_functions)(m, r, f);
+}
+
+DH *DH_new(void)
+{
+    return SSLAPI_LINK(DH_new)();
+}
+
+void  DH_free(DH *dh)
+{
+    SSLAPI_LINK(DH_free)(dh);
+}
+
+ENGINE *ENGINE_by_id(const char *id)
+{
+    return SSLAPI_LINK(ENGINE_by_id)(id);
+}
+
+int ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void))
+{
+    return SSLAPI_LINK(ENGINE_ctrl)(e, cmd, i, p, f);
+}
+
+int ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name,
+        long i, void *p, void (*f)(void), int cmd_optional)
+{
+    return SSLAPI_LINK(ENGINE_ctrl_cmd)(e, cmd_name, i, p, f, cmd_optional);
+}
+
+int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg,
+                           int cmd_optional)
+{
+    return SSLAPI_LINK(ENGINE_ctrl_cmd_string)(e, cmd_name, arg, cmd_optional);
+}
+
+int ENGINE_free(ENGINE *e)
+{
+    return SSLAPI_LINK(ENGINE_free)(e);
+}
+
+void ENGINE_load_builtin_engines(void)
+{
+    SSLAPI_LINK(ENGINE_load_builtin_engines)();
+}
+
+int ENGINE_register_all_complete(void)
+{
+    return SSLAPI_LINK(ENGINE_register_all_complete)();
+}
+
+int ENGINE_set_default(ENGINE *e, unsigned int flags)
+{
+    return SSLAPI_LINK(ENGINE_set_default)(e, flags);
+}
+
+void ERR_error_string_n(unsigned long e, char *buf, size_t len)
+{
+    return SSLAPI_LINK(ERR_error_string_n)(e, buf, len);
+}
+
+unsigned long ERR_get_error(void)
+{
+    return SSLAPI_LINK(ERR_get_error)();
+}
+
+void ERR_load_crypto_strings(void)
+{
+    SSLAPI_LINK(ERR_load_crypto_strings)();
+}
+
+unsigned long ERR_peek_error(void)
+{
+    return SSLAPI_LINK(ERR_peek_error)();
+}
+
+int MD5_Init(MD5_CTX *c)
+{
+    return SSLAPI_LINK(MD5_Init)(c);
+}
+
+int MD5_Update(MD5_CTX *c, const void *data, size_t len)
+{
+    return SSLAPI_LINK(MD5_Update)(c, data, len);
+}
+
+int MD5_Final(unsigned char *md, MD5_CTX *c)
+{
+    return SSLAPI_LINK(MD5_Final)(md, c);
+}
+
+void OPENSSL_load_builtin_modules(void)
+{
+    SSLAPI_LINK(OPENSSL_load_builtin_modules)();
+}
+
+DH *PEM_read_bio_DHparams(BIO *bp, DH **x, pem_password_cb *cb, void *u)
+{
+    return SSLAPI_LINK(PEM_read_bio_DHparams)(bp, x, cb, u);
+}
+
+X509 *PEM_read_bio_X509(BIO *bp, X509 **x, pem_password_cb *cb, void *u)
+{
+    return SSLAPI_LINK(PEM_read_bio_X509)(bp, x, cb, u);
+}
+
+int RAND_egd(const char *path)
+{
+    return SSLAPI_LINK(RAND_egd)(path);
+}
+
+const char *RAND_file_name(char *file, size_t num)
+{
+    return SSLAPI_LINK(RAND_file_name)(file, num);
+}
+
+int RAND_load_file(const char *file, long max_bytes)
+{
+    return SSLAPI_LINK(RAND_load_file)(file, max_bytes);
+}
+
+void RAND_seed(const void *buf, int num)
+{
+    SSLAPI_LINK(RAND_seed)(buf, num);
+}
+
+int RAND_status(void)
+{
+    return SSLAPI_LINK(RAND_status)();
+}
+
+RSA *RSA_generate_key(int bits, unsigned long e,
+                      void (*callback)(int, int, void *), void *cb_arg)
+{
+    return SSLAPI_LINK(RSA_generate_key)(bits, e, callback, cb_arg);
+}
+
+long SSL_CTX_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg)
+{
+    return SSLAPI_LINK(SSL_CTX_ctrl)(ctx, cmd, larg, parg);
+}
+
 SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth)
 {
     return SSLAPI_LINK(SSL_CTX_new)(meth);
@@ -165,13 +525,50 @@ void SSL_CTX_free(SSL_CTX *ctx)
     SSLAPI_LINK(SSL_CTX_free)(ctx);
 }
 
+void *SSL_get_ex_data(const SSL *ssl, int idx)
+{
+    return SSLAPI_LINK(SSL_get_ex_data)(ssl, idx);
+}
+
+int SSL_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
+                         CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
+{
+    return SSLAPI_LINK(SSL_get_ex_new_index)(argl, argp, new_func, dup_func, free_func);
+}
+
+int SSL_library_init(void)
+{
+    return SSLAPI_LINK(SSL_library_init)();
+}
+
+void SSL_load_error_strings(void)
+{
+    SSLAPI_LINK(SSL_load_error_strings)();
+}
+
+int SSL_set_ex_data(SSL *ssl,int idx,void *data)
+{
+    return SSLAPI_LINK(SSL_set_ex_data)(ssl, idx, data);
+}
+
+void X509_free(X509 *x)
+{
+    SSLAPI_LINK(X509_free)(x);
+}
+
 #if HAVE_FIPS
-int FIPS_mode()
+int FIPS_mode(void)
 {
     if (SSLOPT_HAVE(FIPS_mode))
         return SSLOPT_LINK(FIPS_mode)();
     else
         return 0;
 }
+
+int FIPS_mode_set(int onoff)
+{
+    return SSLOPT_LINK(FIPS_mode_set)(onoff);
+}
+
 #endif /* HAVE_FIPS */
 #endif /* HAVE_OPENSSL_STATIC */



Mime
View raw message