1 |
/* wptSymEnc.cpp - Symmetric encryption support |
/* wptSymEnc.cpp - Symmetric encryption support |
2 |
* Copyright (C) 2002, 2003, 2004, 2005 Timo Schulz |
* Copyright (C) 2002-2006 Timo Schulz |
3 |
* |
* |
4 |
* This file is part of WinPT. |
* This file is part of WinPT. |
5 |
* |
* |
59 |
|
|
60 |
/* Perform symmetric encryption on the current clipboard data. |
/* Perform symmetric encryption on the current clipboard data. |
61 |
Return 0 for success. */ |
Return 0 for success. */ |
62 |
int |
gpgme_error_t |
63 |
gpg_encrypt_symmetric (void) |
gpg_clip_sym_encrypt (void) |
64 |
{ |
{ |
65 |
gpgme_ctx_t ctx; |
gpgme_ctx_t ctx; |
66 |
gpgme_data_t plain=NULL; |
gpgme_data_t plain=NULL; |
80 |
if (rc) |
if (rc) |
81 |
goto leave; |
goto leave; |
82 |
rc = gpgme_data_new (&ciph); |
rc = gpgme_data_new (&ciph); |
83 |
|
if (rc) |
84 |
|
goto leave; |
85 |
gpgme_set_armor (ctx, 1); |
gpgme_set_armor (ctx, 1); |
86 |
|
gpgme_set_textmode (ctx, 1); |
87 |
|
|
88 |
gpgme_set_passphrase_cb (ctx, sym_passphrase_cb, pass); |
gpgme_set_passphrase_cb (ctx, sym_passphrase_cb, pass); |
89 |
|
|
90 |
rc = gpgme_op_encrypt (ctx, NULL, (gpgme_encrypt_flags_t)0, plain, ciph); |
rc = gpgme_op_encrypt (ctx, NULL, (gpgme_encrypt_flags_t)0, plain, ciph); |
91 |
if (rc) |
if (rc) |
92 |
msg_box (NULL, gpgme_strerror (rc), _("Symmetric Encryption"), MB_ERR); |
msg_box (NULL, gpgme_strerror (rc), _("Symmetric Encryption"), MB_ERR); |
93 |
else { |
else { |
103 |
gpgme_data_release (ciph); |
gpgme_data_release (ciph); |
104 |
gpgme_release (ctx); |
gpgme_release (ctx); |
105 |
sfree_if_alloc (pass); |
sfree_if_alloc (pass); |
106 |
return rc? WPTERR_GENERAL : 0; |
return rc; |
107 |
} |
} |