--- gvpe/src/util.h 2008/08/10 15:04:55 1.28 +++ gvpe/src/util.h 2013/07/17 05:34:17 1.32 @@ -2,7 +2,7 @@ util.h -- process management and other utility functions Copyright (C) 1998-2002 Ivo Timmermans 2000-2002 Guus Sliepen - 2003-2008 Marc Lehmann + 2003-2013 Marc Lehmann This file is part of GVPE. @@ -44,6 +44,7 @@ #include "slog.h" #include "ev_cpp.h" #include "callback.h" +#include "global.h" typedef ev_tstamp tstamp; @@ -121,36 +122,22 @@ } }; -typedef callback run_script_cb; +typedef callback run_script_cb; // run a shell script (or actually an external program). pid_t run_script (const run_script_cb &cb, bool wait); +void hexdump (const char *header, void *data, int len); + #if ENABLE_HTTP_PROXY u8 *base64_encode (const u8 *data, unsigned int len); #endif /*****************************************************************************/ -typedef u8 rsaclear[RSA_KEYLEN - RSA_OVERHEAD]; // challenge data; -typedef u8 rsacrypt[RSA_KEYLEN]; // encrypted challenge - -static inline void -rsa_encrypt (RSA *key, const rsaclear &chg, rsacrypt &encr) -{ - if (RSA_public_encrypt (sizeof chg, - (unsigned char *)&chg, (unsigned char *)&encr, - key, RSA_PKCS1_OAEP_PADDING) < 0) - fatal ("RSA_public_encrypt error"); -} - -static inline bool -rsa_decrypt (RSA *key, const rsacrypt &encr, rsaclear &chg) -{ - return RSA_private_decrypt (sizeof encr, - (unsigned char *)&encr, (unsigned char *)&chg, - key, RSA_PKCS1_OAEP_PADDING) > 0; -} +// run work_cb in another thread, call done_cb in main thread when finished +// only one work_cb will execute at any one time. +void async (callback work_cb, callback done_cb); #endif