zxid
view release on metacpan or search on metacpan
smimeutil.h view on Meta::CPAN
const char* end_date,
long serial,
const char* basic_constraints,
const char* cert_type,
const char* key_usage,
const char* comment);
#endif
/* ======================= U T I L I T I E S ======================= */
extern char randomfile[256];
/* initializes EVP algorithm tables and injects randomness into
* system. If random file existed it is read as well and 0 (for
* success) is returned. If random file did not exist, it will be
* created (if permissions allow) and -1 is returned. On that occasion
* it is advisable to arrange some real randomness (such as movements of
* mouse, times between key presses, /dev/random, etc.) and call
* init again. */
DSEXPORT int smime_init(const char* random_file, const char* randomness, int randlen);
/* encp=0 base64->binary, enc=1 binary->base64 */
DSEXPORT int smime_base64(int encp, const char* data, int len, char** b64);
/* stores smime library level error. The buffer only has meaningful
* values if an error has happened. You must detect the error from
* return value of a function (NULL or -1) before looking here or
* calling smime_get_errors(). */
extern char smime_error_buf[256];
DSEXPORT char* smime_get_errors();
DSEXPORT char* smime_hex(const char* data, int len);
DSEXPORT char* smime_dotted_hex(const char* data, int len);
/* ================= I N T E R N A L U T I L I T I E S ================ */
#ifdef SMIME_INTERNALS
/* Hard coded mime separators. Hope the content will never have these. */
#define SEP "42_is_the_answer" /* MIME multipart boundary separator */
#define SIG "42_is_the_question" /* MIME multipart/signed boundary sep */
/* To guard agains any macintosh brain damage where \n == \015 */
#define CR "\015"
#define LF "\012"
#define CRLF "\015\012"
/* Initialize a memory BIO to have certain content */
DSEXPORT BIO* set_read_BIO_from_buf(const char* buf, int len);
DSEXPORT int get_written_BIO_data(BIO* wbio, char** data);
/* Get private key from buffer full of encrypted stuff */
DSEXPORT EVP_PKEY* open_private_key(const char* privatekey_pem, const char* password);
DSEXPORT int write_private_key(EVP_PKEY* pkey, const char* passwd, char** priv);
/* Extract a certificate from pem encoding */
DSEXPORT X509* extract_certificate(const char* cert);
DSEXPORT int /* returns length of the PEM encoding */
write_certificate(X509* x509, char** x509_cert_pem);
DSEXPORT X509_REQ* extract_request(const char* req);
DSEXPORT int write_request(X509_REQ* x509_req, char** x509_req_pem);
DSEXPORT PKCS12* load_PKCS12(const char* pkcs12, int pkcs12_len);
DSEXPORT int save_PKCS12(PKCS12* p12, char** pkcs12_out);
DSEXPORT int password_callback(char* buf, int buf_size, int x /*not used*/, void* password);
DSEXPORT char* concat(char* b, const char* s);
DSEXPORT char* concatmem(char* b, const char* s, int len);
/* WARNING: returned value can not be freed */
DSEXPORT char* /* returns pointer to within buf. Buf is modified. */
cut_pem_markers_off(char* buf, int len, char* algo_name);
DSEXPORT char* /* returns new buf */
wrap_in_pem_markers(const char* buf, char* algo_name);
/* Adds some of the most commonly wanted extensions
*
* Examples:
* basic_constraints: CA:TRUE,pathlen:3
* cert_type: client,server,email,objsign,sslCA,emailCA,objCA
* key_usage: digitalSignature,nonRepudiation,keyEncipherment,dataEncipherment,keyAgreement,keyCertSign,cRLSign
* comment: dont trust me ;-)
*/
DSEXPORT int
add_some_X509v3_extensions(X509* cert,
const char* basic_constraints,
const char* cert_type,
const char* key_usage,
const char* comment);
/* Macro to make error reporting more friendly while still easy. */
#if 1
# define GOTO_ERR(x) do{ snprintf(smime_error_buf, sizeof(smime_error_buf), \
"%s (%s:%d)\n", (x), __FILE__, __LINE__); \
smime_error_buf[sizeof(smime_error_buf)-1]='\0'; goto err; }while(0)
#else
# define GOTO_ERR(x) goto err
#endif
#undef DEBUGLOG
#ifdef DEBUGLOG
extern FILE* Log;
# define LOG(x) do{ if (Log) { fprintf(Log, "%s %d: %s\n", \
__FILE__, __LINE__, (x)); fflush(Log); } }while(0)
# define LOG2(s,x) do{ if (Log) { fprintf(Log, "%s %d: " s "\n", \
__FILE__, __LINE__, (x)); fflush(Log); } }while(0)
( run in 1.065 second using v1.01-cache-2.11-cpan-5735350b133 )