2 * $Id: smime.h 1074 2008-06-04 00:08:43Z hubert@u.washington.edu $
4 * ========================================================================
5 * Copyright 2013-2017 Eduardo Chappa
6 * Copyright 2008 University of Washington
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * ========================================================================
18 #ifndef PITH_SMIME_INCLUDED
19 #define PITH_SMIME_INCLUDED
22 #include "../pith/state.h"
23 #include "../pith/send.h"
24 #include "../pith/filttype.h"
25 #include "../pith/smkeys.h"
27 #include <openssl/x509.h>
28 #include <openssl/rand.h>
29 #include <openssl/err.h>
32 #define DF_PASSWORD_DIR ".alpine-smime/.pwd"
34 #define DF_SMIMETMPDIR ".alpine-smime/smtmp"
36 #define OUR_PKCS7_ENCLOSURE_SUBTYPE "x-pkcs7-enclosure"
39 typedef enum {P7Type
, CharType
, SizedText
} SpareType
;
41 typedef struct smime_sparep_t
{
47 /* exported protoypes */
48 int smime_validate_cert(X509
*cert
, long *error
);
49 int encrypt_file(char *fp
, char *text
, PERSONAL_CERT
*pc
);
50 char *decrypt_file(char *fp
, int *rv
, PERSONAL_CERT
*pc
);
51 int is_pkcs7_body(BODY
*b
);
52 int fiddle_smime_message(BODY
*b
, long msgno
);
53 int encrypt_outgoing_message(METAENV
*header
, BODY
**bodyP
);
54 void free_smime_body_sparep(void **sparep
);
55 int sign_outgoing_message(METAENV
*header
, BODY
**bodyP
, int dont_detach
, BODY
**bp
);
56 void gf_puts_uline(char *txt
, gf_io_t pc
);
57 PERSONAL_CERT
*find_certificate_matching_recip_info(PKCS7_RECIP_INFO
*ri
);
58 PERSONAL_CERT
*get_personal_certs(char *path
);
59 void smime_init(void);
60 void smime_deinit(void);
61 void smime_reinit(void);
62 void renew_store(void);
63 void renew_cert_data(CertList
**data
, WhichCerts ctype
);
64 BIO
*print_private_key_information(char *email
, int itype
);
66 SMIME_STUFF_S
*new_smime_struct(void);
67 int copy_publiccert_dir_to_container(void);
68 int copy_publiccert_container_to_dir(void);
69 int copy_privatecert_dir_to_container(void);
70 int copy_privatecert_container_to_dir(void);
71 int copy_cacert_dir_to_container(void);
72 int copy_cacert_container_to_dir(void);
73 int import_certificate(WhichCerts
, PERSONAL_CERT
*, char *);
74 int copy_dir_to_container(WhichCerts which
, char *contents
);
76 int copy_publiccert_container_to_keychain(void);
77 int copy_publiccert_keychain_to_container(void);
78 #endif /* APPLEKEYCHAIN */
80 int setup_pwdcert(void **pwdcert
);
82 void mark_cert_deleted(WhichCerts ctype
, int num
, unsigned state
);
83 unsigned get_cert_deleted(WhichCerts ctype
, int num
);
84 int smime_expunge_cert(WhichCerts ctype
);
85 int add_file_to_container(WhichCerts ctype
, char *fpath
, char *altname
);
86 void *create_smime_sparep(SpareType stype
, void *s
);
87 SpareType
get_smime_sparep_type(void *s
);
88 void *get_smime_sparep_data(void *s
);
89 STACK_OF(X509
) *get_chain_for_cert(X509
*cert
, int *error
, int *level
);
90 CertList
*certlist_from_personal_certs(PERSONAL_CERT
*pc
);
91 int smime_path(char *rpath
, char *fpath
, size_t len
);
93 #endif /* PITH_SMIME_INCLUDED */