stowing changes
parent
9787a03563
commit
c6aee70900
|
@ -47,6 +47,7 @@ PEP_STATUS init_cryptotech(PEP_SESSION session, bool in_first)
|
|||
cryptotech[PEP_crypt_OpenPGP].key_expired = pgp_key_expired;
|
||||
cryptotech[PEP_crypt_OpenPGP].key_revoked = pgp_key_revoked;
|
||||
cryptotech[PEP_crypt_OpenPGP].key_created = pgp_key_created;
|
||||
cryptotech[PEP_crypt_OpenPGP].pair_has_private = pgp_pair_has_private;
|
||||
#ifdef PGP_BINARY_PATH
|
||||
cryptotech[PEP_crypt_OpenPGP].binary_path = PGP_BINARY_PATH;
|
||||
#endif
|
||||
|
|
|
@ -72,6 +72,9 @@ typedef PEP_STATUS (*key_created_t)(PEP_SESSION session, const char *fpr,
|
|||
|
||||
typedef PEP_STATUS (*binary_path_t)(const char **path);
|
||||
|
||||
typedef PEP_STATUS (*pair_has_private_t)(PEP_SESSION session, const char *fpr,
|
||||
bool *has_private);
|
||||
|
||||
typedef struct _PEP_cryptotech_t {
|
||||
uint8_t id;
|
||||
// the following are default values; comm_type may vary with key length or b0rken crypto
|
||||
|
@ -94,6 +97,7 @@ typedef struct _PEP_cryptotech_t {
|
|||
key_revoked_t key_revoked;
|
||||
key_created_t key_created;
|
||||
binary_path_t binary_path;
|
||||
pair_has_private_t pair_has_private;
|
||||
} PEP_cryptotech_t;
|
||||
|
||||
extern PEP_cryptotech_t cryptotech[PEP_crypt__count];
|
||||
|
|
|
@ -421,6 +421,17 @@ DYNAMIC_API PEP_STATUS myself(PEP_SESSION session, pEp_identity * identity)
|
|||
if (stored_identity)
|
||||
{
|
||||
if (EMPTYSTR(identity->fpr)) {
|
||||
|
||||
// First check to see if it's blacklisted?
|
||||
char* stored_fpr = stored_identity->fpr;
|
||||
|
||||
bool dont_use_fpr = false;
|
||||
|
||||
status = blacklist_is_listed(session, stored_fpr, &dont_use_fpr);
|
||||
if (!dont_use_fpr) {
|
||||
// Make sure there is a *private* key associated with this fpr
|
||||
}
|
||||
|
||||
identity->fpr = strdup(stored_identity->fpr);
|
||||
assert(identity->fpr);
|
||||
if (identity->fpr == NULL)
|
||||
|
|
|
@ -2118,3 +2118,30 @@ PEP_STATUS pgp_binary(const char **path)
|
|||
return PEP_STATUS_OK;
|
||||
}
|
||||
|
||||
PEP_STATUS pgp_pair_has_private(PEP_SESSION session, const char *fpr,
|
||||
bool *has_private) {
|
||||
status = PEP_STATUS_OK;
|
||||
gpg_key_t output_key;
|
||||
gpgme_error_t gpgerr = gpgme_get_key(session->ctx, fpr, &output_key, true);
|
||||
*has_private = false;
|
||||
switch (gpgerr) {
|
||||
case GPG_ERR_EOF:
|
||||
case GPG_ERR_INV_VALUE:
|
||||
status = PEP_KEY_NOT_FOUND;
|
||||
break;
|
||||
case GPG_ERR_AMBIGUOUS_NAME:
|
||||
status = PEP_KEY_HAS_AMBIG_NAME;
|
||||
break;
|
||||
case GPG_ERR_NO_ERROR:
|
||||
*has_private = true;
|
||||
gpgme_key_release(output_key);
|
||||
break;
|
||||
case GPG_ERR_ENOMEM:
|
||||
status = PEP_OUT_OF_MEMORY;
|
||||
break;
|
||||
default:
|
||||
status = PEP_UNKNOWN_ERROR;
|
||||
break;
|
||||
}
|
||||
return status;
|
||||
}
|
|
@ -145,11 +145,14 @@ int main() {
|
|||
}
|
||||
inFile4.close();
|
||||
|
||||
const char* out_msg_plain = text4.c_str();
|
||||
// const char* out_msg_plain = text4.c_str();
|
||||
|
||||
const char* out_msg_plain = "From: krista@kgrothoff.org\nTo: Volker <vb@pep-project.org>\nSubject: Test\nContent-Type: text/plain; charset=utf-8\nContent-Language: en-US\nContent-Transfer-Encoding:quoted-printable\n\ngaga\n\n";
|
||||
char* enc_msg = NULL;
|
||||
char* dec_msg = NULL;
|
||||
|
||||
PEP_STATUS status7 = MIME_encrypt_message(session, text4.c_str(), text4.length(), NULL, &enc_msg, PEP_enc_PGP_MIME, 0);
|
||||
// PEP_STATUS status7 = MIME_encrypt_message(session, text4.c_str(), text4.length(), NULL, &enc_msg, PEP_enc_PGP_MIME, 0);
|
||||
PEP_STATUS status7 = MIME_encrypt_message(session, out_msg_plain, strlen(out_msg_plain), NULL, &enc_msg, PEP_enc_PGP_MIME, 0);
|
||||
assert(status7 == PEP_STATUS_OK);
|
||||
|
||||
cout << enc_msg << endl;
|
||||
|
|
Loading…
Reference in New Issue