Outfactor PGP into pgpme-vala
This commit is contained in:
parent
2fe8489d36
commit
9b8cf706d6
|
@ -20,6 +20,7 @@ set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
|||
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
set (VALA_CFLAGS -Wno-deprecated-declarations -Wno-incompatible-pointer-types -Wno-int-conversion)
|
||||
|
||||
add_subdirectory(gpgme-vala)
|
||||
add_subdirectory(qlite)
|
||||
add_subdirectory(xmpp-vala)
|
||||
add_subdirectory(client)
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
find_package(Vala REQUIRED)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
find_package(GPGME REQUIRED)
|
||||
find_package(LIBUUID REQUIRED)
|
||||
include(${VALA_USE_FILE})
|
||||
include(GlibCompileResourcesSupport)
|
||||
|
||||
|
@ -138,9 +140,9 @@ OPTIONS
|
|||
|
||||
)
|
||||
|
||||
set(CFLAGS ${CLIENT_CFLAGS} ${GPGME_CFLAGS} ${LIBUUID_CFLAGS} -g -I${CMAKE_BINARY_DIR}/xmpp-vala -I${CMAKE_BINARY_DIR}/qlite ${VALA_CFLAGS})
|
||||
set(CFLAGS ${CLIENT_CFLAGS} -g -I${CMAKE_BINARY_DIR}/xmpp-vala -I${CMAKE_BINARY_DIR}/qlite ${VALA_CFLAGS})
|
||||
add_definitions(${CFLAGS})
|
||||
add_executable(dino ${CLIENT_VALA_C} ${CLIENT_GRESOURCES_TARGET})
|
||||
add_dependencies(dino xmpp-vala-vapi qlite-vapi)
|
||||
target_link_libraries(dino xmpp-vala qlite ${CLIENT_LIBRARIES} ${GPGME_LIBRARIES} ${LIBUUID_LIBRARIES} -lm)
|
||||
target_link_libraries(dino xmpp-vala qlite ${CLIENT_LIBRARIES} -lm)
|
||||
|
||||
|
|
|
@ -247,6 +247,58 @@
|
|||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="label">OpenPGP</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="visible">True</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">4</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkStack" id="pgp_stack">
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="pgp_button">
|
||||
<property name="relief">none</property>
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="pgp_label">
|
||||
<property name="xalign">0</property>
|
||||
<property name="visible">True</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="name">label</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBoxText" id="pgp_combobox">
|
||||
<property name="hexpand">True</property>
|
||||
<property name="width_request">200</property>
|
||||
<property name="visible">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="name">entry</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">4</property>
|
||||
<property name="width">2</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
|
|
@ -92,7 +92,7 @@ public class ConnectionManager {
|
|||
foreach (Core.XmppStreamModule module in module_manager.get_modules(account, resource)) {
|
||||
stream.add_module(module);
|
||||
}
|
||||
stream.debug = true;
|
||||
stream.debug = false;
|
||||
|
||||
Connection connection = new Connection(stream, new DateTime.now_local());
|
||||
stream_states[account] = connection;
|
||||
|
|
|
@ -68,11 +68,11 @@ public class MergedMessageItem : Grid {
|
|||
}
|
||||
|
||||
private void update_received() {
|
||||
received_image.visible = true;
|
||||
bool all_received = true;
|
||||
bool all_read = true;
|
||||
foreach (Message message in messages) {
|
||||
if (message.marked == Message.Marked.WONTSEND) {
|
||||
received_image.visible = true;
|
||||
Gtk.IconTheme icon_theme = Gtk.IconTheme.get_default();
|
||||
Gtk.IconInfo? icon_info = icon_theme.lookup_icon("dialog-warning-symbolic", IconSize.SMALL_TOOLBAR, 0);
|
||||
received_image.set_from_pixbuf(icon_info.load_symbolic({1,0,0,1}));
|
||||
|
|
|
@ -11,55 +11,28 @@ public class Dialog : Gtk.Window {
|
|||
public signal void account_enabled(Account account);
|
||||
public signal void account_disabled(Account account);
|
||||
|
||||
[GtkChild]
|
||||
public Stack main_stack;
|
||||
[GtkChild] public Stack main_stack;
|
||||
[GtkChild] public ListBox account_list;
|
||||
[GtkChild] public Button no_accounts_add;
|
||||
[GtkChild] public ToolButton add_button;
|
||||
[GtkChild] public ToolButton remove_button;
|
||||
[GtkChild] public Image image;
|
||||
[GtkChild] public Button image_button;
|
||||
[GtkChild] public Label jid_label;
|
||||
[GtkChild] public Switch active_switch;
|
||||
[GtkChild] public Stack password_stack;
|
||||
[GtkChild] public Label password_label;
|
||||
[GtkChild] public Button password_button;
|
||||
[GtkChild] public Entry password_entry;
|
||||
[GtkChild] public Stack alias_stack;
|
||||
[GtkChild] public Label alias_label;
|
||||
[GtkChild] public Button alias_button;
|
||||
[GtkChild] public Entry alias_entry;
|
||||
[GtkChild] public Stack pgp_stack;
|
||||
[GtkChild] public Label pgp_label;
|
||||
[GtkChild] public Button pgp_button;
|
||||
[GtkChild] public ComboBoxText pgp_combobox;
|
||||
|
||||
[GtkChild]
|
||||
public ListBox account_list;
|
||||
|
||||
[GtkChild]
|
||||
public Button no_accounts_add;
|
||||
|
||||
[GtkChild]
|
||||
public ToolButton add_button;
|
||||
|
||||
[GtkChild]
|
||||
public ToolButton remove_button;
|
||||
|
||||
[GtkChild]
|
||||
public Image image;
|
||||
|
||||
[GtkChild] Button image_button;
|
||||
|
||||
[GtkChild]
|
||||
public Label jid_label;
|
||||
|
||||
[GtkChild]
|
||||
public Switch active_switch;
|
||||
|
||||
[GtkChild]
|
||||
public Stack password_stack;
|
||||
|
||||
[GtkChild]
|
||||
public Label password_label;
|
||||
|
||||
[GtkChild]
|
||||
public Button password_button;
|
||||
|
||||
[GtkChild]
|
||||
public Entry password_entry;
|
||||
|
||||
[GtkChild]
|
||||
public Stack alias_stack;
|
||||
|
||||
[GtkChild]
|
||||
public Label alias_label;
|
||||
|
||||
[GtkChild]
|
||||
public Button alias_button;
|
||||
|
||||
[GtkChild]
|
||||
public Entry alias_entry;
|
||||
|
||||
private Database db;
|
||||
private StreamInteractor stream_interactor;
|
||||
|
@ -142,22 +115,14 @@ public class Dialog : Gtk.Window {
|
|||
for (int i = 0; i < account.password.length; i++) filler += password_entry.get_invisible_char().to_string();
|
||||
password_label.label = filler;
|
||||
password_stack.set_visible_child_name("label");
|
||||
password_button.clicked.connect(() => {
|
||||
password_stack.set_visible_child_name("entry");
|
||||
alias_stack.set_visible_child_name("label");
|
||||
set_focus(password_entry);
|
||||
});
|
||||
password_entry.text = account.password;
|
||||
|
||||
alias_label.label = account.alias;
|
||||
alias_stack.set_visible_child_name("label");
|
||||
alias_button.clicked.connect(() => {
|
||||
alias_stack.set_visible_child_name("entry");
|
||||
password_stack.set_visible_child_name("label");
|
||||
set_focus(alias_entry);
|
||||
});
|
||||
alias_label.label = account.alias;
|
||||
alias_entry.text = account.alias;
|
||||
|
||||
password_button.clicked.connect(() => { set_active_stack(password_stack); });
|
||||
alias_button.clicked.connect(() => { set_active_stack(alias_stack); });
|
||||
active_switch.state_set.connect(on_active_switch_state_changed);
|
||||
}
|
||||
|
||||
|
@ -216,6 +181,13 @@ public class Dialog : Gtk.Window {
|
|||
Util.image_set_from_scaled_pixbuf(image, (new AvatarGenerator(50, 50, image.scale_factor)).draw_account(stream_interactor, account));
|
||||
}
|
||||
}
|
||||
|
||||
private void set_active_stack(Stack stack) {
|
||||
stack.set_visible_child_name("entry");
|
||||
if (stack != password_stack) password_stack.set_visible_child_name("label");
|
||||
if (stack != alias_stack) alias_stack.set_visible_child_name("label");
|
||||
if (stack != pgp_stack) pgp_stack.set_visible_child_name("label");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -159,7 +159,7 @@ function(vala_precompile output)
|
|||
set(vapi_arguments "")
|
||||
if(ARGS_GENERATE_VAPI)
|
||||
list(APPEND out_extra_files "${DIRECTORY}/${ARGS_GENERATE_VAPI}.vapi")
|
||||
set(vapi_arguments "--internal-vapi=${ARGS_GENERATE_VAPI}.vapi")
|
||||
set(vapi_arguments "--vapi=${ARGS_GENERATE_VAPI}.vapi")
|
||||
|
||||
# Header and internal header is needed to generate internal vapi
|
||||
if (NOT ARGS_GENERATE_HEADER)
|
||||
|
|
48
gpgme-vala/CMakeLists.txt
Normal file
48
gpgme-vala/CMakeLists.txt
Normal file
|
@ -0,0 +1,48 @@
|
|||
find_package(Vala REQUIRED)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
find_package(GPGME REQUIRED)
|
||||
include(${VALA_USE_FILE})
|
||||
|
||||
set(GPGME_VALA_PACKAGES
|
||||
gee-0.8
|
||||
glib-2.0
|
||||
)
|
||||
|
||||
pkg_check_modules(GPGME_VALA REQUIRED ${GPGME_VALA_PACKAGES})
|
||||
|
||||
vala_precompile(GPGME_VALA_C
|
||||
SOURCES
|
||||
"src/gpgme-helper.vala"
|
||||
CUSTOM_VAPIS
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/vapi/gpgme.vapi"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/vapi/gpgme_public.vapi"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/vapi/gpg-error.vapi"
|
||||
PACKAGES
|
||||
${GPGME_VALA_PACKAGES}
|
||||
GENERATE_VAPI
|
||||
gpgme-vala
|
||||
GENERATE_HEADER
|
||||
gpgme-vala
|
||||
OPTIONS
|
||||
-g
|
||||
--thread
|
||||
)
|
||||
|
||||
set(CFLAGS ${GPGME_VALA_CFLAGS} ${GPGME_CFLAGS} -g ${VALA_CFLAGS} -I${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||
add_definitions(${CFLAGS})
|
||||
add_library(gpgme-vala SHARED ${GPGME_VALA_C} src/fix.c)
|
||||
target_link_libraries(gpgme-vala ${GPGME_VALA_LIBRARIES} ${GPGME_LIBRARIES})
|
||||
|
||||
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/gpgme-vala/gpgme.vapi
|
||||
COMMAND
|
||||
cat "${CMAKE_BINARY_DIR}/gpgme-vala/gpgme-vala.vapi" "${CMAKE_CURRENT_SOURCE_DIR}/vapi/gpgme_public.vapi" > "${CMAKE_BINARY_DIR}/gpgme-vala/gpgme.vapi"
|
||||
DEPENDS
|
||||
${CMAKE_BINARY_DIR}/gpgme-vala/gpgme-vala.vapi
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/vapi/gpgme_public.vapi
|
||||
)
|
||||
|
||||
add_custom_target(gpgme-vapi
|
||||
DEPENDS
|
||||
${CMAKE_BINARY_DIR}/gpgme-vala/gpgme.vapi
|
||||
)
|
||||
|
3
gpgme-vala/src/fix.c
Normal file
3
gpgme-vala/src/fix.c
Normal file
|
@ -0,0 +1,3 @@
|
|||
#include <fix.h>
|
||||
|
||||
static GRecMutex gpgme_global_mutex = {0};
|
91
gpgme-vala/src/gpgme-helper.vala
Normal file
91
gpgme-vala/src/gpgme-helper.vala
Normal file
|
@ -0,0 +1,91 @@
|
|||
using Gee;
|
||||
using GPG;
|
||||
|
||||
namespace GPGHelper {
|
||||
|
||||
public static string encrypt_armor(string plain, Key[] keys, EncryptFlags flags) throws GLib.Error {
|
||||
global_mutex.lock();
|
||||
Data plain_data = Data.create_from_memory(plain.data, false);
|
||||
Context context = Context.create();
|
||||
context.set_armor(true);
|
||||
Data enc_data = context.op_encrypt(keys, flags, plain_data);
|
||||
global_mutex.unlock();
|
||||
return get_string_from_data(enc_data);
|
||||
}
|
||||
|
||||
public static string decrypt(string encr) throws GLib.Error {
|
||||
global_mutex.lock();
|
||||
Data enc_data = Data.create_from_memory(encr.data, false);
|
||||
Context context = Context.create();
|
||||
Data dec_data = context.op_decrypt(enc_data);
|
||||
global_mutex.unlock();
|
||||
return get_string_from_data(dec_data);
|
||||
}
|
||||
|
||||
public static string sign(string plain, SigMode mode) throws GLib.Error {
|
||||
global_mutex.lock();
|
||||
Data plain_data = Data.create_from_memory(plain.data, false);
|
||||
Context context = Context.create();
|
||||
Data signed_data = context.op_sign(plain_data, mode);
|
||||
global_mutex.unlock();
|
||||
return get_string_from_data(signed_data);
|
||||
}
|
||||
|
||||
public static string? get_sign_key(string signature, string? text) throws GLib.Error {
|
||||
global_mutex.lock();
|
||||
Data sig_data = Data.create_from_memory(signature.data, false);
|
||||
Data text_data;
|
||||
if (text != null) {
|
||||
text_data = Data.create_from_memory(text.data, false);
|
||||
} else {
|
||||
text_data = Data.create();
|
||||
}
|
||||
Context context = Context.create();
|
||||
context.op_verify(sig_data, text_data);
|
||||
VerifyResult* verify_res = context.op_verify_result();
|
||||
if (verify_res == null || verify_res.signatures == null) return null;
|
||||
global_mutex.unlock();
|
||||
return verify_res.signatures.fpr;
|
||||
}
|
||||
|
||||
public static Gee.List<Key> get_keylist(string? pattern = null, bool secret_only = false) throws GLib.Error {
|
||||
Gee.List<Key> keys = new ArrayList<Key>();
|
||||
Context context = Context.create();
|
||||
context.op_keylist_start(pattern, secret_only ? 1 : 0);
|
||||
try {
|
||||
while (true) {
|
||||
Key key = context.op_keylist_next();
|
||||
keys.add(key);
|
||||
}
|
||||
} catch (Error e) {
|
||||
// if (e.message != GPGError.ErrorCode.EOF.to_string()) throw e;
|
||||
if (e.message != "EOF") throw e;
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
public static Key? get_public_key(string sig) throws GLib.Error {
|
||||
global_mutex.lock();
|
||||
Context context = Context.create();
|
||||
Key key = context.get_key(sig, false);
|
||||
global_mutex.unlock();
|
||||
return key;
|
||||
}
|
||||
|
||||
private static string get_string_from_data(Data data) {
|
||||
data.seek(0);
|
||||
uint8[] buf = new uint8[256];
|
||||
ssize_t? len = null;
|
||||
string res = "";
|
||||
do {
|
||||
len = data.read(buf);
|
||||
if (len > 0) {
|
||||
string part = (string) buf;
|
||||
part = part.substring(0, (long) len);
|
||||
res += part;
|
||||
}
|
||||
} while (len > 0);
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
451
gpgme-vala/vapi/gpg-error.vapi
Normal file
451
gpgme-vala/vapi/gpg-error.vapi
Normal file
|
@ -0,0 +1,451 @@
|
|||
/* gcrypt.vapi
|
||||
*
|
||||
* Copyright:
|
||||
* 2008 Jiqing Qiang
|
||||
* 2008, 2010, 2012-2013 Evan Nemerson
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* Author:
|
||||
* Jiqing Qiang <jiqing.qiang@gmail.com>
|
||||
* Evan Nemerson <evan@coeus-group.com>
|
||||
*/
|
||||
|
||||
|
||||
|
||||
[CCode (cheader_filename = "gpg-error.h")]
|
||||
namespace GPGError {
|
||||
[CCode (cname = "gpg_err_source_t", cprefix = "GPG_ERR_SOURCE_")]
|
||||
public enum ErrorSource {
|
||||
UNKNOWN,
|
||||
GCRYPT,
|
||||
GPG,
|
||||
GPGSM,
|
||||
GPGAGENT,
|
||||
PINENTRY,
|
||||
SCD,
|
||||
GPGME,
|
||||
KEYBOX,
|
||||
KSBA,
|
||||
DIRMNGR,
|
||||
GSTI,
|
||||
ANY,
|
||||
USER_1,
|
||||
USER_2,
|
||||
USER_3,
|
||||
USER_4,
|
||||
|
||||
/* This is one more than the largest allowed entry. */
|
||||
DIM
|
||||
}
|
||||
|
||||
[CCode (cname = "gpg_err_code_t", cprefix = "GPG_ERR_")]
|
||||
public enum ErrorCode {
|
||||
NO_ERROR,
|
||||
GENERAL,
|
||||
UNKNOWN_PACKET,
|
||||
UNKNOWN_VERSION,
|
||||
PUBKEY_ALGO,
|
||||
DIGEST_ALGO,
|
||||
BAD_PUBKEY,
|
||||
BAD_SECKEY,
|
||||
BAD_SIGNATURE,
|
||||
NO_PUBKEY,
|
||||
CHECKSUM,
|
||||
BAD_PASSPHRASE,
|
||||
CIPHER_ALGO,
|
||||
KEYRING_OPEN,
|
||||
INV_PACKET,
|
||||
INV_ARMOR,
|
||||
NO_USER_ID,
|
||||
NO_SECKEY,
|
||||
WRONG_SECKEY,
|
||||
BAD_KEY,
|
||||
COMPR_ALGO,
|
||||
NO_PRIME,
|
||||
NO_ENCODING_METHOD,
|
||||
NO_ENCRYPTION_SCHEME,
|
||||
NO_SIGNATURE_SCHEME,
|
||||
INV_ATTR,
|
||||
NO_VALUE,
|
||||
NOT_FOUND,
|
||||
VALUE_NOT_FOUND,
|
||||
SYNTAX,
|
||||
BAD_MPI,
|
||||
INV_PASSPHRASE,
|
||||
SIG_CLASS,
|
||||
RESOURCE_LIMIT,
|
||||
INV_KEYRING,
|
||||
TRUSTDB,
|
||||
BAD_CERT,
|
||||
INV_USER_ID,
|
||||
UNEXPECTED,
|
||||
TIME_CONFLICT,
|
||||
KEYSERVER,
|
||||
WRONG_PUBKEY_ALGO,
|
||||
TRIBUTE_TO_D_A,
|
||||
WEAK_KEY,
|
||||
INV_KEYLEN,
|
||||
INV_ARG,
|
||||
BAD_URI,
|
||||
INV_URI,
|
||||
NETWORK,
|
||||
UNKNOWN_HOST,
|
||||
SELFTEST_FAILED,
|
||||
NOT_ENCRYPTED,
|
||||
NOT_PROCESSED,
|
||||
UNUSABLE_PUBKEY,
|
||||
UNUSABLE_SECKEY,
|
||||
INV_VALUE,
|
||||
BAD_CERT_CHAIN,
|
||||
MISSING_CERT,
|
||||
NO_DATA,
|
||||
BUG,
|
||||
NOT_SUPPORTED,
|
||||
INV_OP,
|
||||
TIMEOUT,
|
||||
INTERNAL,
|
||||
EOF_GCRYPT,
|
||||
INV_OBJ,
|
||||
TOO_SHORT,
|
||||
TOO_LARGE,
|
||||
NO_OBJ,
|
||||
NOT_IMPLEMENTED,
|
||||
CONFLICT,
|
||||
INV_CIPHER_MODE,
|
||||
INV_FLAG,
|
||||
INV_HANDLE,
|
||||
TRUNCATED,
|
||||
INCOMPLETE_LINE,
|
||||
INV_RESPONSE,
|
||||
NO_AGENT,
|
||||
AGENT,
|
||||
INV_DATA,
|
||||
ASSUAN_SERVER_FAULT,
|
||||
ASSUAN,
|
||||
INV_SESSION_KEY,
|
||||
INV_SEXP,
|
||||
UNSUPPORTED_ALGORITHM,
|
||||
NO_PIN_ENTRY,
|
||||
PIN_ENTRY,
|
||||
BAD_PIN,
|
||||
INV_NAME,
|
||||
BAD_DATA,
|
||||
INV_PARAMETER,
|
||||
WRONG_CARD,
|
||||
NO_DIRMNGR,
|
||||
DIRMNGR,
|
||||
CERT_REVOKED,
|
||||
NO_CRL_KNOWN,
|
||||
CRL_TOO_OLD,
|
||||
LINE_TOO_LONG,
|
||||
NOT_TRUSTED,
|
||||
CANCELED,
|
||||
BAD_CA_CERT,
|
||||
CERT_EXPIRED,
|
||||
CERT_TOO_YOUNG,
|
||||
UNSUPPORTED_CERT,
|
||||
UNKNOWN_SEXP,
|
||||
UNSUPPORTED_PROTECTION,
|
||||
CORRUPTED_PROTECTION,
|
||||
AMBIGUOUS_NAME,
|
||||
CARD,
|
||||
CARD_RESET,
|
||||
CARD_REMOVED,
|
||||
INV_CARD,
|
||||
CARD_NOT_PRESENT,
|
||||
NO_PKCS15_APP,
|
||||
NOT_CONFIRMED,
|
||||
CONFIGURATION,
|
||||
NO_POLICY_MATCH,
|
||||
INV_INDEX,
|
||||
INV_ID,
|
||||
NO_SCDAEMON,
|
||||
SCDAEMON,
|
||||
UNSUPPORTED_PROTOCOL,
|
||||
BAD_PIN_METHOD,
|
||||
CARD_NOT_INITIALIZED,
|
||||
UNSUPPORTED_OPERATION,
|
||||
WRONG_KEY_USAGE,
|
||||
NOTHING_FOUND,
|
||||
WRONG_BLOB_TYPE,
|
||||
MISSING_VALUE,
|
||||
HARDWARE,
|
||||
PIN_BLOCKED,
|
||||
USE_CONDITIONS,
|
||||
PIN_NOT_SYNCED,
|
||||
INV_CRL,
|
||||
BAD_BER,
|
||||
INV_BER,
|
||||
ELEMENT_NOT_FOUND,
|
||||
IDENTIFIER_NOT_FOUND,
|
||||
INV_TAG,
|
||||
INV_LENGTH,
|
||||
INV_KEYINFO,
|
||||
UNEXPECTED_TAG,
|
||||
NOT_DER_ENCODED,
|
||||
NO_CMS_OBJ,
|
||||
INV_CMS_OBJ,
|
||||
UNKNOWN_CMS_OBJ,
|
||||
UNSUPPORTED_CMS_OBJ,
|
||||
UNSUPPORTED_ENCODING,
|
||||
UNSUPPORTED_CMS_VERSION,
|
||||
UNKNOWN_ALGORITHM,
|
||||
INV_ENGINE,
|
||||
PUBKEY_NOT_TRUSTED,
|
||||
DECRYPT_FAILED,
|
||||
KEY_EXPIRED,
|
||||
SIG_EXPIRED,
|
||||
ENCODING_PROBLEM,
|
||||
INV_STATE,
|
||||
DUP_VALUE,
|
||||
MISSING_ACTION,
|
||||
MODULE_NOT_FOUND,
|
||||
INV_OID_STRING,
|
||||
INV_TIME,
|
||||
INV_CRL_OBJ,
|
||||
UNSUPPORTED_CRL_VERSION,
|
||||
INV_CERT_OBJ,
|
||||
UNKNOWN_NAME,
|
||||
LOCALE_PROBLEM,
|
||||
NOT_LOCKED,
|
||||
PROTOCOL_VIOLATION,
|
||||
INV_MAC,
|
||||
INV_REQUEST,
|
||||
UNKNOWN_EXTN,
|
||||
UNKNOWN_CRIT_EXTN,
|
||||
LOCKED,
|
||||
UNKNOWN_OPTION,
|
||||
UNKNOWN_COMMAND,
|
||||
BUFFER_TOO_SHORT,
|
||||
SEXP_INV_LEN_SPEC,
|
||||
SEXP_STRING_TOO_LONG,
|
||||
SEXP_UNMATCHED_PAREN,
|
||||
SEXP_NOT_CANONICAL,
|
||||
SEXP_BAD_CHARACTER,
|
||||
SEXP_BAD_QUOTATION,
|
||||
SEXP_ZERO_PREFIX,
|
||||
SEXP_NESTED_DH,
|
||||
SEXP_UNMATCHED_DH,
|
||||
SEXP_UNEXPECTED_PUNC,
|
||||
SEXP_BAD_HEX_CHAR,
|
||||
SEXP_ODD_HEX_NUMBERS,
|
||||
SEXP_BAD_OCT_CHAR,
|
||||
ASS_GENERAL,
|
||||
ASS_ACCEPT_FAILED,
|
||||
ASS_CONNECT_FAILED,
|
||||
ASS_INV_RESPONSE,
|
||||
ASS_INV_VALUE,
|
||||
ASS_INCOMPLETE_LINE,
|
||||
ASS_LINE_TOO_LONG,
|
||||
ASS_NESTED_COMMANDS,
|
||||
ASS_NO_DATA_CB,
|
||||
ASS_NO_INQUIRE_CB,
|
||||
ASS_NOT_A_SERVER,
|
||||
ASS_NOT_A_CLIENT,
|
||||
ASS_SERVER_START,
|
||||
ASS_READ_ERROR,
|
||||
ASS_WRITE_ERROR,
|
||||
ASS_TOO_MUCH_DATA,
|
||||
ASS_UNEXPECTED_CMD,
|
||||
ASS_UNKNOWN_CMD,
|
||||
ASS_SYNTAX,
|
||||
ASS_CANCELED,
|
||||
ASS_NO_INPUT,
|
||||
ASS_NO_OUTPUT,
|
||||
ASS_PARAMETER,
|
||||
ASS_UNKNOWN_INQUIRE,
|
||||
USER_1,
|
||||
USER_2,
|
||||
USER_3,
|
||||
USER_4,
|
||||
USER_5,
|
||||
USER_6,
|
||||
USER_7,
|
||||
USER_8,
|
||||
USER_9,
|
||||
USER_10,
|
||||
USER_11,
|
||||
USER_12,
|
||||
USER_13,
|
||||
USER_14,
|
||||
USER_15,
|
||||
USER_16,
|
||||
MISSING_ERRNO,
|
||||
UNKNOWN_ERRNO,
|
||||
EOF,
|
||||
|
||||
E2BIG,
|
||||
EACCES,
|
||||
EADDRINUSE,
|
||||
EADDRNOTAVAIL,
|
||||
EADV,
|
||||
EAFNOSUPPORT,
|
||||
EAGAIN,
|
||||
EALREADY,
|
||||
EAUTH,
|
||||
EBACKGROUND,
|
||||
EBADE,
|
||||
EBADF,
|
||||
EBADFD,
|
||||
EBADMSG,
|
||||
EBADR,
|
||||
EBADRPC,
|
||||
EBADRQC,
|
||||
EBADSLT,
|
||||
EBFONT,
|
||||
EBUSY,
|
||||
ECANCELED,
|
||||
ECHILD,
|
||||
ECHRNG,
|
||||
ECOMM,
|
||||
ECONNABORTED,
|
||||
ECONNREFUSED,
|
||||
ECONNRESET,
|
||||
ED,
|
||||
EDEADLK,
|
||||
EDEADLOCK,
|
||||
EDESTADDRREQ,
|
||||
EDIED,
|
||||
EDOM,
|
||||
EDOTDOT,
|
||||
EDQUOT,
|
||||
EEXIST,
|
||||
EFAULT,
|
||||
EFBIG,
|
||||
EFTYPE,
|
||||
EGRATUITOUS,
|
||||
EGREGIOUS,
|
||||
EHOSTDOWN,
|
||||
EHOSTUNREACH,
|
||||
EIDRM,
|
||||
EIEIO,
|
||||
EILSEQ,
|
||||
EINPROGRESS,
|
||||
EINTR,
|
||||
EINVAL,
|
||||
EIO,
|
||||
EISCONN,
|
||||
EISDIR,
|
||||
EISNAM,
|
||||
EL2HLT,
|
||||
EL2NSYNC,
|
||||
EL3HLT,
|
||||
EL3RST,
|
||||
ELIBACC,
|
||||
ELIBBAD,
|
||||
ELIBEXEC,
|
||||
ELIBMAX,
|
||||
ELIBSCN,
|
||||
ELNRNG,
|
||||
ELOOP,
|
||||
EMEDIUMTYPE,
|
||||
EMFILE,
|
||||
EMLINK,
|
||||
EMSGSIZE,
|
||||
EMULTIHOP,
|
||||
ENAMETOOLONG,
|
||||
ENAVAIL,
|
||||
ENEEDAUTH,
|
||||
ENETDOWN,
|
||||
ENETRESET,
|
||||
ENETUNREACH,
|
||||
ENFILE,
|
||||
ENOANO,
|
||||
ENOBUFS,
|
||||
ENOCSI,
|
||||
ENODATA,
|
||||
ENODEV,
|
||||
ENOENT,
|
||||
ENOEXEC,
|
||||
ENOLCK,
|
||||
ENOLINK,
|
||||
ENOMEDIUM,
|
||||
ENOMEM,
|
||||
ENOMSG,
|
||||
ENONET,
|
||||
ENOPKG,
|
||||
ENOPROTOOPT,
|
||||
ENOSPC,
|
||||
ENOSR,
|
||||
ENOSTR,
|
||||
ENOSYS,
|
||||
ENOTBLK,
|
||||
ENOTCONN,
|
||||
ENOTDIR,
|
||||
ENOTEMPTY,
|
||||
ENOTNAM,
|
||||
ENOTSOCK,
|
||||
ENOTSUP,
|
||||
ENOTTY,
|
||||
ENOTUNIQ,
|
||||
ENXIO,
|
||||
EOPNOTSUPP,
|
||||
EOVERFLOW,
|
||||
EPERM,
|
||||
EPFNOSUPPORT,
|
||||
EPIPE,
|
||||
EPROCLIM,
|
||||
EPROCUNAVAIL,
|
||||
EPROGMISMATCH,
|
||||
EPROGUNAVAIL,
|
||||
EPROTO,
|
||||
EPROTONOSUPPORT,
|
||||
EPROTOTYPE,
|
||||
ERANGE,
|
||||
EREMCHG,
|
||||
EREMOTE,
|
||||
EREMOTEIO,
|
||||
ERESTART,
|
||||
EROFS,
|
||||
ERPCMISMATCH,
|
||||
ESHUTDOWN,
|
||||
ESOCKTNOSUPPORT,
|
||||
ESPIPE,
|
||||
ESRCH,
|
||||
ESRMNT,
|
||||
ESTALE,
|
||||
ESTRPIPE,
|
||||
ETIME,
|
||||
ETIMEDOUT,
|
||||
ETOOMANYREFS,
|
||||
ETXTBSY,
|
||||
EUCLEAN,
|
||||
EUNATCH,
|
||||
EUSERS,
|
||||
EWOULDBLOCK,
|
||||
EXDEV,
|
||||
EXFULL,
|
||||
|
||||
/* This is one more than the largest allowed entry. */
|
||||
CODE_DIM
|
||||
}
|
||||
|
||||
[CCode (cname = "gpg_err_code_t", cprefix = "gpg_err_")]
|
||||
public struct Error : uint {
|
||||
[CCode (cname = "gpg_err_make")]
|
||||
public Error (ErrorSource source, ErrorCode code);
|
||||
[CCode (cname = "gpg_err_make_from_errno")]
|
||||
public Error.from_errno (ErrorSource source, int err);
|
||||
public ErrorCode code { [CCode (cname = "gpg_err_code")] get; }
|
||||
public ErrorSource source { [CCode (cname = "gpg_err_source")] get; }
|
||||
|
||||
[CCode (cname = "gpg_strerror")]
|
||||
public unowned string to_string ();
|
||||
|
||||
[CCode (cname = "gpg_strsource")]
|
||||
public unowned string source_to_string ();
|
||||
}
|
||||
}
|
512
gpgme-vala/vapi/gpgme.vapi
Normal file
512
gpgme-vala/vapi/gpgme.vapi
Normal file
|
@ -0,0 +1,512 @@
|
|||
/* libgpgme.vapi
|
||||
*
|
||||
* Copyright (C) 2009 Sebastian Reichel <sre@ring0.de>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
[CCode (lower_case_cprefix = "gpgme_", cheader_filename = "gpgme.h")]
|
||||
namespace GPG {
|
||||
[CCode (cheader_filename = "fix.h")]
|
||||
public static GLib.RecMutex global_mutex;
|
||||
|
||||
[CCode (cname = "struct _gpgme_engine_info")]
|
||||
public struct EngineInfo {
|
||||
EngineInfo* next;
|
||||
Protocol protocol;
|
||||
string file_name;
|
||||
string version;
|
||||
string req_version;
|
||||
string? home_dir;
|
||||
}
|
||||
|
||||
[CCode (cname = "struct _gpgme_op_verify_result")]
|
||||
public struct VerifyResult {
|
||||
Signature* signatures;
|
||||
string? file_name;
|
||||
}
|
||||
|
||||
[CCode (cname = "struct _gpgme_op_sign_result")]
|
||||
public struct SignResult {
|
||||
InvalidKey invalid_signers;
|
||||
Signature* signatures;
|
||||
}
|
||||
|
||||
[CCode (cname = "struct _gpgme_op_encrypt_result")]
|
||||
public struct EncryptResult {
|
||||
InvalidKey invalid_signers;
|
||||
}
|
||||
|
||||
[CCode (cname = "struct _gpgme_op_decrypt_result")]
|
||||
public struct DecryptResult {
|
||||
string unsupported_algorithm;
|
||||
bool wrong_key_usage;
|
||||
Recipient recipients;
|
||||
string filename;
|
||||
}
|
||||
|
||||
[CCode (cname = "struct _gpgme_recipient")]
|
||||
public struct Recipient {
|
||||
Recipient *next;
|
||||
string keyid;
|
||||
PublicKeyAlgorithm pubkey_algo;
|
||||
GPGError.Error status;
|
||||
}
|
||||
|
||||
[CCode (cname = "struct _gpgme_invalid_key")]
|
||||
public struct InvalidKey {
|
||||
InvalidKey *next;
|
||||
string fpr;
|
||||
GPGError.Error reason;
|
||||
}
|
||||
|
||||
[CCode (cname = "struct _gpgme_signature")]
|
||||
public struct Signature {
|
||||
Signature *next;
|
||||
Sigsum summary;
|
||||
string fpr;
|
||||
GPGError.Error status;
|
||||
SigNotation notations;
|
||||
ulong timestamp;
|
||||
ulong exp_timestamp;
|
||||
bool wrong_key_usage;
|
||||
PKAStatus pka_trust;
|
||||
bool chain_model;
|
||||
Validity validity;
|
||||
GPGError.Error validity_reason;
|
||||
PublicKeyAlgorithm pubkey_algo;
|
||||
HashAlgorithm hash_algo;
|
||||
string? pka_adress;
|
||||
}
|
||||
|
||||
public enum PKAStatus {
|
||||
NOT_AVAILABLE,
|
||||
BAD,
|
||||
OKAY,
|
||||
RFU
|
||||
}
|
||||
|
||||
[CCode (cname = "gpgme_sigsum_t", cprefix = "GPGME_SIGSUM_")]
|
||||
public enum Sigsum {
|
||||
VALID,
|
||||
GREEN,
|
||||
RED,
|
||||
KEY_REVOKED,
|
||||
KEY_EXPIRED,
|
||||
SIG_EXPIRED,
|
||||
KEY_MISSING,
|
||||
CRL_MISSING,
|
||||
CRL_TOO_OLD,
|
||||
BAD_POLICY,
|
||||
SYS_ERROR
|
||||
}
|
||||
|
||||
[CCode (cname = "gpgme_data_encoding_t", cprefix = "GPGME_DATA_ENCODING_")]
|
||||
public enum DataEncoding {
|
||||
NONE,
|
||||
BINARY,
|
||||
BASE64,
|
||||
ARMOR,
|
||||
URL,
|
||||
URLESC,
|
||||
URL0
|
||||
}
|
||||
|
||||
[CCode (cname = "gpgme_hash_algo_t", cprefix = "GPGME_MD_")]
|
||||
public enum HashAlgorithm {
|
||||
NONE,
|
||||
MD5,
|
||||
SHA1,
|
||||
RMD160,
|
||||
MD2,
|
||||
TIGER,
|
||||
HAVAL,
|
||||
SHA256,
|
||||
SHA384,
|
||||
SHA512,
|
||||
MD4,
|
||||
MD_CRC32,
|
||||
MD_CRC32_RFC1510,
|
||||
MD_CRC24_RFC2440
|
||||
}
|
||||
|
||||
[CCode (cname = "gpgme_export_mode_t", cprefix = "GPGME_EXPORT_MODE_")]
|
||||
public enum ExportMode {
|
||||
EXTERN
|
||||
}
|
||||
|
||||
[CCode (cprefix = "GPGME_AUDITLOG_")]
|
||||
public enum AuditLogFlag {
|
||||
HTML,
|
||||
WITH_HELP
|
||||
}
|
||||
|
||||
[CCode (cname = "gpgme_status_code_t", cprefix = "GPGME_STATUS_")]
|
||||
public enum StatusCode {
|
||||
EOF,
|
||||
ENTER,
|
||||
LEAVE,
|
||||
ABORT,
|
||||
GOODSIG,
|
||||
BADSIG,
|
||||
ERRSIG,
|
||||
BADARMOR,
|
||||
RSA_OR_IDEA,
|
||||
KEYEXPIRED,
|
||||
KEYREVOKED,
|
||||
TRUST_UNDEFINED,
|
||||
TRUST_NEVER,
|
||||
TRUST_MARGINAL,
|
||||
TRUST_FULLY,
|
||||
TRUST_ULTIMATE,
|
||||
SHM_INFO,
|
||||
SHM_GET,
|
||||
SHM_GET_BOOL,
|
||||
SHM_GET_HIDDEN,
|
||||
NEED_PASSPHRASE,
|
||||
VALIDSIG,
|
||||
SIG_ID,
|
||||
SIG_TO,
|
||||
ENC_TO,
|
||||
NODATA,
|
||||
BAD_PASSPHRASE,
|
||||
NO_PUBKEY,
|
||||
NO_SECKEY,
|
||||
NEED_PASSPHRASE_SYM,
|
||||
DECRYPTION_FAILED,
|
||||
DECRYPTION_OKAY,
|
||||
MISSING_PASSPHRASE,
|
||||
GOOD_PASSPHRASE,
|
||||
GOODMDC,
|
||||
BADMDC,
|
||||
ERRMDC,
|
||||
IMPORTED,
|
||||
IMPORT_OK,
|
||||
IMPORT_PROBLEM,
|
||||
IMPORT_RES,
|
||||
FILE_START,
|
||||
FILE_DONE,
|
||||
FILE_ERROR,
|
||||
BEGIN_DECRYPTION,
|
||||
END_DECRYPTION,
|
||||
BEGIN_ENCRYPTION,
|
||||
END_ENCRYPTION,
|
||||
DELETE_PROBLEM,
|
||||
GET_BOOL,
|
||||
GET_LINE,
|
||||
GET_HIDDEN,
|
||||
GOT_IT,
|
||||
PROGRESS,
|
||||
SIG_CREATED,
|
||||
SESSION_KEY,
|
||||
NOTATION_NAME,
|
||||
NOTATION_DATA,
|
||||
POLICY_URL,
|
||||
BEGIN_STREAM,
|
||||
END_STREAM,
|
||||
KEY_CREATED,
|
||||
USERID_HINT,
|
||||
UNEXPECTED,
|
||||
INV_RECP,
|
||||
NO_RECP,
|
||||
ALREADY_SIGNED,
|
||||
SIGEXPIRED,
|
||||
EXPSIG,
|
||||
EXPKEYSIG,
|
||||
TRUNCATED,
|
||||
ERROR,
|
||||
NEWSIG,
|
||||
REVKEYSIG,
|
||||
SIG_SUBPACKET,
|
||||
NEED_PASSPHRASE_PIN,
|
||||
SC_OP_FAILURE,
|
||||
SC_OP_SUCCESS,
|
||||
CARDCTRL,
|
||||
BACKUP_KEY_CREATED,
|
||||
PKA_TRUST_BAD,
|
||||
PKA_TRUST_GOOD,
|
||||
PLAINTEXT
|
||||
}
|
||||
|
||||
[Flags]
|
||||
[CCode (cname="unsigned int")]
|
||||
public enum ImportStatusFlags {
|
||||
[CCode (cname = "GPGME_IMPORT_NEW")]
|
||||
NEW,
|
||||
[CCode (cname = "GPGME_IMPORT_UID")]
|
||||
UID,
|
||||
[CCode (cname = "GPGME_IMPORT_SIG")]
|
||||
SIG,
|
||||
[CCode (cname = "GPGME_IMPORT_SUBKEY")]
|
||||
SUBKEY,
|
||||
[CCode (cname = "GPGME_IMPORT_SECRET")]
|
||||
SECRET
|
||||
}
|
||||
|
||||
[Compact]
|
||||
[CCode (cname = "struct gpgme_context", free_function = "gpgme_release", cprefix = "gpgme_")]
|
||||
public class Context {
|
||||
private static GPGError.Error new(out Context ctx);
|
||||
|
||||
public static Context create() throws GLib.Error {
|
||||
Context ctx;
|
||||
@new(out ctx);
|
||||
return ctx;
|
||||
}
|
||||
|
||||
public GPGError.Error set_protocol(Protocol p);
|
||||
public Protocol get_protocol();
|
||||
|
||||
public void set_armor(bool yes);
|
||||
public bool get_armor();
|
||||
|
||||
public void set_textmode(bool yes);
|
||||
public bool get_textmode();
|
||||
|
||||
public GPGError.Error set_keylist_mode(KeylistMode mode);
|
||||
public KeylistMode get_keylist_mode();
|
||||
|
||||
public void set_include_certs(int nr_of_certs = -256);
|
||||
|
||||
public int get_include_certs();
|
||||
|
||||
public void set_passphrase_cb(passphrase_callback cb, void* hook_value = null);
|
||||
|
||||
public void get_passphrase_cb(out passphrase_callback cb, out void* hook_value);
|
||||
|
||||
public GPGError.Error set_locale(int category, string val);
|
||||
|
||||
[CCode (cname = "gpgme_ctx_get_engine_info")]
|
||||
public EngineInfo* get_engine_info();
|
||||
|
||||
[CCode (cname = "gpgme_ctx_set_engine_info")]
|
||||
public GPGError.Error set_engine_info(Protocol proto, string file_name, string home_dir);
|
||||
|
||||
public void signers_clear();
|
||||
|
||||
public GPGError.Error signers_add(Key key);
|
||||
|
||||
public Key* signers_enum(int n);
|
||||
|
||||
public void sig_notation_clear();
|
||||
|
||||
public GPGError.Error sig_notation_add(string name, string val, SigNotationFlags flags);
|
||||
|
||||
public SigNotation* sig_notation_get();
|
||||
|
||||
[CCode (cname = "gpgme_get_key")]
|
||||
private GPGError.Error get_key_(string fpr, out Key key, bool secret);
|
||||
|
||||
[CCode (cname = "gpgme_get_key_")]
|
||||
public Key get_key(string fpr, bool secret) throws GLib.Error {
|
||||
Key key;
|
||||
throw_if_error(get_key_(fpr, out key, secret));
|
||||
return key;
|
||||
}
|
||||
|
||||
public Context* wait(out GPGError.Error status, bool hang);
|
||||
|
||||
public SignResult* op_sign_result();
|
||||
|
||||
[CCode (cname = "gpgme_op_sign")]
|
||||
public GPGError.Error op_sign_(Data plain, Data sig, SigMode mode);
|
||||
|
||||
[CCode (cname = "gpgme_op_sign_")]
|
||||
public Data op_sign(Data plain, SigMode mode) throws GLib.Error {
|
||||
Data sig = Data.create();
|
||||
throw_if_error(op_sign_(plain, sig, mode));
|
||||
return sig;
|
||||
}
|
||||
|
||||
public VerifyResult* op_verify_result();
|
||||
|
||||
[CCode (cname = "gpgme_op_verify")]
|
||||
public GPGError.Error op_verify_(Data sig, Data signed_text, Data? plaintext);
|
||||
|
||||
[CCode (cname = "gpgme_op_verify_")]
|
||||
public Data op_verify(Data sig, Data signed_text) throws GLib.Error {
|
||||
Data plaintext = Data.create();
|
||||
throw_if_error(op_verify_(sig, signed_text, plaintext));
|
||||
return plaintext;
|
||||
}
|
||||
|
||||
public EncryptResult* op_encrypt_result();
|
||||
|
||||
[CCode (cname = "gpgme_op_encrypt")]
|
||||
public GPGError.Error op_encrypt_([CCode (array_length = false)] Key[] recp, EncryptFlags flags, Data plain, Data cipher);
|
||||
|
||||
[CCode (cname = "gpgme_op_encrypt_")]
|
||||
public Data op_encrypt(Key[] recp, EncryptFlags flags, Data plain) throws GLib.Error {
|
||||
Data cipher = Data.create();
|
||||
throw_if_error(op_encrypt_(recp, flags, plain, cipher));
|
||||
return cipher;
|
||||
}
|
||||
|
||||
public DecryptResult* op_decrypt_result();
|
||||
|
||||
[CCode (cname = "gpgme_op_decrypt")]
|
||||
public GPGError.Error op_decrypt_(Data cipher, Data plain);
|
||||
|
||||
[CCode (cname = "gpgme_op_decrypt_")]
|
||||
public Data op_decrypt(Data cipher) throws GLib.Error {
|
||||
Data plain = Data.create();
|
||||
throw_if_error(op_decrypt_(cipher, plain));
|
||||
return plain;
|
||||
}
|
||||
|
||||
public GPGError.Error op_export(string? pattern, ExportMode mode, Data keydata);
|
||||
|
||||
public GPGError.Error op_import(Data keydata);
|
||||
|
||||
public unowned ImportResult op_import_result();
|
||||
|
||||
[CCode (cname = "gpgme_op_keylist_start")]
|
||||
private GPGError.Error op_keylist_start_(string? pattern = null, int secret_only = 0);
|
||||
|
||||
[CCode (cname = "gpgme_op_keylist_start_")]
|
||||
public void op_keylist_start(string? pattern = null, int secret_only = 0) throws GLib.Error {
|
||||
throw_if_error(op_keylist_start_(pattern, secret_only));
|
||||
}
|
||||
|
||||
[CCode (cname = "gpgme_op_keylist_next")]
|
||||
private GPGError.Error op_keylist_next_(out Key key);
|
||||
|
||||
[CCode (cname = "gpgme_op_keylist_next_")]
|
||||
public Key op_keylist_next() throws GLib.Error {
|
||||
Key key;
|
||||
throw_if_error(op_keylist_next_(out key));
|
||||
return key;
|
||||
}
|
||||
|
||||
[CCode (cname = "gpgme_op_keylist_end")]
|
||||
private GPGError.Error op_keylist_end_();
|
||||
|
||||
[CCode (cname = "gpgme_op_keylist_end_")]
|
||||
public void op_keylist_end() throws GLib.Error {
|
||||
throw_if_error(op_keylist_end_());
|
||||
}
|
||||
|
||||
public KeylistResult op_keylist_result();
|
||||
}
|
||||
|
||||
[Compact]
|
||||
[CCode (cname = "struct _gpgme_import_status")]
|
||||
public class ImportStatus {
|
||||
|
||||
public ImportStatus? next;
|
||||
public string fpr;
|
||||
public GPGError.Error result;
|
||||
public ImportStatusFlags status;
|
||||
}
|
||||
|
||||
[Compact]
|
||||
[CCode (cname = "struct _gpgme_op_import_result")]
|
||||
public class ImportResult {
|
||||
public int considered;
|
||||
public int no_user_id;
|
||||
public int imported;
|
||||
public int imported_rsa;
|
||||
public int unchanged;
|
||||
public int new_user_ids;
|
||||
public int new_sub_keys;
|
||||
public int new_signatures;
|
||||
public int new_revocations;
|
||||
public int secret_read;
|
||||
public int secret_imported;
|
||||
public int secret_unchanged;
|
||||
public int not_imported;
|
||||
public ImportStatus imports;
|
||||
}
|
||||
|
||||
[Compact]
|
||||
[CCode (cname = "struct _gpgme_op_keylist_result")]
|
||||
public class KeylistResult {
|
||||
uint truncated;
|
||||
}
|
||||
|
||||
[Compact]
|
||||
[CCode (cname = "struct gpgme_data", free_function = "gpgme_data_release", cprefix = "gpgme_data_")]
|
||||
public class Data {
|
||||
|
||||
public static GPGError.Error new(out Data d);
|
||||
|
||||
public static Data create() throws GLib.Error {
|
||||
Data data;
|
||||
throw_if_error(@new(out data));
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
[CCode (cname = "gpgme_data_new_from_mem")]
|
||||
public static GPGError.Error new_from_memory(out Data d, uint8[] buffer, bool copy);
|
||||
|
||||
public static Data create_from_memory(uint8[] buffer, bool copy) throws GLib.Error {
|
||||
Data data;
|
||||
throw_if_error(new_from_memory(out data, buffer, copy));
|
||||
return data;
|
||||
}
|
||||
|
||||
[CCode (cname = "gpgme_data_new_from_file")]
|
||||
public static GPGError.Error create_from_file(out Data d, string filename, int copy = 1);
|
||||
|
||||
[CCode (cname = "gpgme_data_release_and_get_mem")]
|
||||
public string release_and_get_mem(out size_t len);
|
||||
|
||||
public ssize_t read(uint8[] buf);
|
||||
|
||||
public ssize_t write(uint8[] buf);
|
||||
|
||||
public long seek(long offset, int whence=0);
|
||||
|
||||
public DataEncoding *get_encoding();
|
||||
|
||||
public GPGError.Error set_encoding(DataEncoding enc);
|
||||
}
|
||||
|
||||
[CCode (cname = "gpgme_get_protocol_name")]
|
||||
public unowned string get_protocol_name(Protocol p);
|
||||
|
||||
[CCode (cname = "gpgme_pubkey_algo_name")]
|
||||
public unowned string get_public_key_algorithm_name(PublicKeyAlgorithm algo);
|
||||
|
||||
[CCode (cname = "gpgme_hash_algo_name")]
|
||||
public unowned string get_hash_algorithm_name(HashAlgorithm algo);
|
||||
|
||||
[CCode (cname = "gpgme_passphrase_cb_t", has_target = false)]
|
||||
public delegate GPGError.Error passphrase_callback(void* hook, string uid_hint, string passphrase_info, bool prev_was_bad, int fd);
|
||||
|
||||
[CCode (cname = "gpgme_engine_check_version")]
|
||||
public GPGError.Error engine_check_version(Protocol proto);
|
||||
|
||||
[CCode (cname = "gpgme_get_engine_information")]
|
||||
public GPGError.Error get_engine_information(out EngineInfo engine_info);
|
||||
|
||||
[CCode (cname = "gpgme_strerror_r")]
|
||||
public int strerror_r(GPGError.Error err, uint8[] buf);
|
||||
|
||||
[CCode (cname = "gpgme_strerror")]
|
||||
public unowned string strerror(GPGError.Error err);
|
||||
|
||||
private void throw_if_error(GPGError.Error error) throws GLib.Error {
|
||||
if (error.code != GPGError.ErrorCode.NO_ERROR) {
|
||||
throw new GLib.Error(-1, error.code, error.to_string());
|
||||
}
|
||||
}
|
||||
}
|
160
gpgme-vala/vapi/gpgme_public.vapi
Normal file
160
gpgme-vala/vapi/gpgme_public.vapi
Normal file
|
@ -0,0 +1,160 @@
|
|||
[CCode (lower_case_cprefix = "gpgme_", cheader_filename = "gpgme.h")]
|
||||
namespace GPG {
|
||||
|
||||
[CCode (cname = "gpgme_check_version")]
|
||||
public unowned string check_version(string? required_version = null);
|
||||
|
||||
[Compact]
|
||||
[CCode (cname = "struct _gpgme_key", ref_function = "gpgme_key_ref", ref_function_void = true, unref_function = "gpgme_key_unref", free_function = "gpgme_key_release")]
|
||||
public class Key {
|
||||
public bool revoked;
|
||||
public bool expired;
|
||||
public bool disabled;
|
||||
public bool invalid;
|
||||
public bool can_encrypt;
|
||||
public bool can_sign;
|
||||
public bool can_certify;
|
||||
public bool secret;
|
||||
public bool can_authenticate;
|
||||
public bool is_qualified;
|
||||
public Protocol protocol;
|
||||
public string issuer_serial;
|
||||
public string issuer_name;
|
||||
public string issuer_id;
|
||||
public Validity owner_trust;
|
||||
[CCode(array_null_terminated = true)]
|
||||
public SubKey[] subkeys;
|
||||
[CCode(array_null_terminated = true)]
|
||||
public UserID[] uids;
|
||||
public KeylistMode keylist_mode;
|
||||
}
|
||||
|
||||
[CCode (cname = "struct _gpgme_user_id")]
|
||||
public struct UserID {
|
||||
UserID* next;
|
||||
|
||||
bool revoked;
|
||||
bool invalid;
|
||||
Validity validity;
|
||||
string uid;
|
||||
string name;
|
||||
string email;
|
||||
string comment;
|
||||
KeySig signatures;
|
||||
}
|
||||
|
||||
[CCode (cname = "struct _gpgme_key_sig")]
|
||||
public struct KeySig {
|
||||
KeySig* next;
|
||||
bool invoked;
|
||||
bool expired;
|
||||
bool invalid;
|
||||
bool exportable;
|
||||
PublicKeyAlgorithm algo;
|
||||
string keyid;
|
||||
long timestamp;
|
||||
long expires;
|
||||
// GPGError.Error status;
|
||||
string uid;
|
||||
string name;
|
||||
string email;
|
||||
string comment;
|
||||
uint sig_class;
|
||||
SigNotation notations;
|
||||
}
|
||||
|
||||
[CCode (cname = "struct _gpgme_subkey")]
|
||||
public struct SubKey {
|
||||
SubKey* next;
|
||||
bool revoked;
|
||||
bool expired;
|
||||
bool disabled;
|
||||
bool invalid;
|
||||
bool can_encrypt;
|
||||
bool can_sign;
|
||||
bool can_certify;
|
||||
bool secret;
|
||||
bool can_authenticate;
|
||||
bool is_qualified;
|
||||
bool is_cardkey;
|
||||
PublicKeyAlgorithm algo;
|
||||
uint length;
|
||||
string keyid;
|
||||
|
||||
string fpr;
|
||||
long timestamp;
|
||||
long expires;
|
||||
string? cardnumber;
|
||||
}
|
||||
|
||||
[CCode (cname = "struct _gpgme_sig_notation")]
|
||||
public struct SigNotation {
|
||||
SigNotation* next;
|
||||
string? name;
|
||||
string value;
|
||||
int name_len;
|
||||
int value_len;
|
||||
SigNotationFlags flags;
|
||||
bool human_readable;
|
||||
bool critical;
|
||||
}
|
||||
|
||||
[CCode (cname = "gpgme_sig_notation_flags_t", cprefix = "GPGME_SIG_NOTATION_")]
|
||||
public enum SigNotationFlags {
|
||||
HUMAN_READABLE,
|
||||
CRITICAL
|
||||
}
|
||||
|
||||
[CCode (cname = "gpgme_sig_mode_t", cprefix = "GPGME_SIG_MODE_")]
|
||||
public enum SigMode {
|
||||
NORMAL,
|
||||
DETACH,
|
||||
CLEAR
|
||||
}
|
||||
|
||||
[CCode (cname = "gpgme_encrypt_flags_t", cprefix = "GPGME_ENCRYPT_")]
|
||||
public enum EncryptFlags {
|
||||
ALWAYS_TRUST,
|
||||
NO_ENCRYPT_TO
|
||||
}
|
||||
|
||||
[CCode (cname = "gpgme_pubkey_algo_t", cprefix = "GPGME_PK_")]
|
||||
public enum PublicKeyAlgorithm {
|
||||
RSA,
|
||||
RSA_E,
|
||||
RSA_S,
|
||||
ELG_E,
|
||||
DSA,
|
||||
ELG
|
||||
}
|
||||
|
||||
[CCode (cname = "gpgme_protocol_t", cprefix = "GPGME_PROTOCOL_")]
|
||||
public enum Protocol {
|
||||
OpenPGP,
|
||||
CMS,
|
||||
GPGCONF,
|
||||
ASSUAN,
|
||||
UNKNOWN
|
||||
}
|
||||
|
||||
[CCode (cname = "gpgme_keylist_mode_t", cprefix = "GPGME_KEYLIST_MODE_")]
|
||||
public enum KeylistMode {
|
||||
LOCAL,
|
||||
EXTERN,
|
||||
SIGS,
|
||||
SIG_NOTATIONS,
|
||||
EPHEMERAL,
|
||||
VALIDATE
|
||||
}
|
||||
|
||||
[CCode (cname = "gpgme_validity_t", cprefix = "GPGME_VALIDITY_")]
|
||||
public enum Validity {
|
||||
UNKNOWN,
|
||||
UNDEFINED,
|
||||
NEVER,
|
||||
MARGINAL,
|
||||
FULL,
|
||||
ULTIMATE
|
||||
}
|
||||
|
||||
}
|
|
@ -1,407 +0,0 @@
|
|||
/* gpg-error.vapi
|
||||
*
|
||||
* Copyright (C) 2009 Sebastian Reichel <sre@ring0.de>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
[CCode (cheader_filename = "gpg-error.h")]
|
||||
namespace GPGError {
|
||||
|
||||
[CCode (cname = "gpg_err_code_t", cprefix = "GPG_ERR_")]
|
||||
public enum ErrorCode {
|
||||
NO_ERROR,
|
||||
GENERAL,
|
||||
UNKNOWN_PACKET,
|
||||
UNKNOWN_VERSION,
|
||||
PUBKEY_ALGO,
|
||||
DIGEST_ALGO,
|
||||
BAD_PUBKEY,
|
||||
BAD_SECKEY,
|
||||
BAD_SIGNATURE,
|
||||
NO_PUBKEY,
|
||||
CHECKSUM,
|
||||
BAD_PASSPHRASE,
|
||||
CIPHER_ALGO,
|
||||
KEYRING_OPEN,
|
||||
INV_PACKET,
|
||||
INV_ARMOR,
|
||||
NO_USER_ID,
|
||||
NO_SECKEY,
|
||||
WRONG_SECKEY,
|
||||
BAD_KEY,
|
||||
COMPR_ALGO,
|
||||
NO_PRIME,
|
||||
NO_ENCODING_METHOD,
|
||||
NO_ENCRYPTION_SCHEME,
|
||||
NO_SIGNATURE_SCHEME,
|
||||
INV_ATTR,
|
||||
NO_VALUE,
|
||||
NOT_FOUND,
|
||||
VALUE_NOT_FOUND,
|
||||
SYNTAX,
|
||||
BAD_MPI,
|
||||
INV_PASSPHRASE,
|
||||
SIG_CLASS,
|
||||
RESOURCE_LIMIT,
|
||||
INV_KEYRING,
|
||||
TRUSTDB,
|
||||
BAD_CERT,
|
||||
INV_USER_ID,
|
||||
UNEXPECTED,
|
||||
TIME_CONFLICT,
|
||||
KEYSERVER,
|
||||
WRONG_PUBKEY_ALGO,
|
||||
TRIBUTE_TO_D_A,
|
||||
WEAK_KEY,
|
||||
INV_KEYLEN,
|
||||
INV_ARG,
|
||||
BAD_URI,
|
||||
INV_URI,
|
||||
NETWORK,
|
||||
UNKNOWN_HOST,
|
||||
SELFTEST_FAILED,
|
||||
NOT_ENCRYPTED,
|
||||
NOT_PROCESSED,
|
||||
UNUSABLE_PUBKEY,
|
||||
UNUSABLE_SECKEY,
|
||||
INV_VALUE,
|
||||
BAD_CERT_CHAIN,
|
||||
MISSING_CERT,
|
||||
NO_DATA,
|
||||
BUG,
|
||||
NOT_SUPPORTED,
|
||||
INV_OP,
|
||||
TIMEOUT,
|
||||
INTERNAL,
|
||||
EOF_GCRYPT,
|
||||
INV_OBJ,
|
||||
TOO_SHORT,
|
||||
TOO_LARGE,
|
||||
NO_OBJ,
|
||||
NOT_IMPLEMENTED,
|
||||
CONFLICT,
|
||||
INV_CIPHER_MODE,
|
||||
INV_FLAG,
|
||||
INV_HANDLE,
|
||||
TRUNCATED,
|
||||
INCOMPLETE_LINE,
|
||||
INV_RESPONSE,
|
||||
NO_AGENT,
|
||||
AGENT,
|
||||
INV_DATA,
|
||||
ASSUAN_SERVER_FAULT,
|
||||
ASSUAN,
|
||||
INV_SESSION_KEY,
|
||||
INV_SEXP,
|
||||
UNSUPPORTED_ALGORITHM,
|
||||
NO_PIN_ENTRY,
|
||||
PIN_ENTRY,
|
||||
BAD_PIN,
|
||||
INV_NAME,
|
||||
BAD_DATA,
|
||||
INV_PARAMETER,
|
||||
WRONG_CARD,
|
||||
NO_DIRMNGR,
|
||||
DIRMNGR,
|
||||
CERT_REVOKED,
|
||||
NO_CRL_KNOWN,
|
||||
CRL_TOO_OLD,
|
||||
LINE_TOO_LONG,
|
||||
NOT_TRUSTED,
|
||||
CANCELED,
|
||||
BAD_CA_CERT,
|
||||
CERT_EXPIRED,
|
||||
CERT_TOO_YOUNG,
|
||||
UNSUPPORTED_CERT,
|
||||
UNKNOWN_SEXP,
|
||||
UNSUPPORTED_PROTECTION,
|
||||
CORRUPTED_PROTECTION,
|
||||
AMBIGUOUS_NAME,
|
||||
CARD,
|
||||
CARD_RESET,
|
||||
CARD_REMOVED,
|
||||
INV_CARD,
|
||||
CARD_NOT_PRESENT,
|
||||
NO_PKCS15_APP,
|
||||
NOT_CONFIRMED,
|
||||
CONFIGURATION,
|
||||
NO_POLICY_MATCH,
|
||||
INV_INDEX,
|
||||
INV_ID,
|
||||
NO_SCDAEMON,
|
||||
SCDAEMON,
|
||||
UNSUPPORTED_PROTOCOL,
|
||||
BAD_PIN_METHOD,
|
||||
CARD_NOT_INITIALIZED,
|
||||
UNSUPPORTED_OPERATION,
|
||||
WRONG_KEY_USAGE,
|
||||
NOTHING_FOUND,
|
||||
WRONG_BLOB_TYPE,
|
||||
MISSING_VALUE,
|
||||
HARDWARE,
|
||||
PIN_BLOCKED,
|
||||
USE_CONDITIONS,
|
||||
PIN_NOT_SYNCED,
|
||||
INV_CRL,
|
||||
BAD_BER,
|
||||
INV_BER,
|
||||
ELEMENT_NOT_FOUND,
|
||||
IDENTIFIER_NOT_FOUND,
|
||||
INV_TAG,
|
||||
INV_LENGTH,
|
||||
INV_KEYINFO,
|
||||
UNEXPECTED_TAG,
|
||||
NOT_DER_ENCODED,
|
||||
NO_CMS_OBJ,
|
||||
INV_CMS_OBJ,
|
||||
UNKNOWN_CMS_OBJ,
|
||||
UNSUPPORTED_CMS_OBJ,
|
||||
UNSUPPORTED_ENCODING,
|
||||
UNSUPPORTED_CMS_VERSION,
|
||||
UNKNOWN_ALGORITHM,
|
||||
INV_ENGINE,
|
||||
PUBKEY_NOT_TRUSTED,
|
||||
DECRYPT_FAILED,
|
||||
KEY_EXPIRED,
|
||||
SIG_EXPIRED,
|
||||
ENCODING_PROBLEM,
|
||||
INV_STATE,
|
||||
DUP_VALUE,
|
||||
MISSING_ACTION,
|
||||
MODULE_NOT_FOUND,
|
||||
INV_OID_STRING,
|
||||
INV_TIME,
|
||||
INV_CRL_OBJ,
|
||||
UNSUPPORTED_CRL_VERSION,
|
||||
INV_CERT_OBJ,
|
||||
UNKNOWN_NAME,
|
||||
LOCALE_PROBLEM,
|
||||
NOT_LOCKED,
|
||||
PROTOCOL_VIOLATION,
|
||||
INV_MAC,
|
||||
INV_REQUEST,
|
||||
UNKNOWN_EXTN,
|
||||
UNKNOWN_CRIT_EXTN,
|
||||
LOCKED,
|
||||
UNKNOWN_OPTION,
|
||||
UNKNOWN_COMMAND,
|
||||
UNFINISHED,
|
||||
BUFFER_TOO_SHORT,
|
||||
SEXP_INV_LEN_SPEC,
|
||||
SEXP_STRING_TOO_LONG,
|
||||
SEXP_UNMATCHED_PAREN,
|
||||
SEXP_NOT_CANONICAL,
|
||||
SEXP_BAD_CHARACTER,
|
||||
SEXP_BAD_QUOTATION,
|
||||
SEXP_ZERO_PREFIX,
|
||||
SEXP_NESTED_DH,
|
||||
SEXP_UNMATCHED_DH,
|
||||
SEXP_UNEXPECTED_PUNC,
|
||||
SEXP_BAD_HEX_CHAR,
|
||||
SEXP_ODD_HEX_NUMBERS,
|
||||
SEXP_BAD_OCT_CHAR,
|
||||
ASS_GENERAL,
|
||||
ASS_ACCEPT_FAILED,
|
||||
ASS_CONNECT_FAILED,
|
||||
ASS_INV_RESPONSE,
|
||||
ASS_INV_VALUE,
|
||||
ASS_INCOMPLETE_LINE,
|
||||
ASS_LINE_TOO_LONG,
|
||||
ASS_NESTED_COMMANDS,
|
||||
ASS_NO_DATA_CB,
|
||||
ASS_NO_INQUIRE_CB,
|
||||
ASS_NOT_A_SERVER,
|
||||
ASS_NOT_A_CLIENT,
|
||||
ASS_SERVER_START,
|
||||
ASS_READ_ERROR,
|
||||
ASS_WRITE_ERROR,
|
||||
ASS_TOO_MUCH_DATA,
|
||||
ASS_UNEXPECTED_CMD,
|
||||
ASS_UNKNOWN_CMD,
|
||||
ASS_SYNTAX,
|
||||
ASS_CANCELED,
|
||||
ASS_NO_INPUT,
|
||||
ASS_NO_OUTPUT,
|
||||
ASS_PARAMETER,
|
||||
ASS_UNKNOWN_INQUIRE,
|
||||
USER_1,
|
||||
USER_2,
|
||||
USER_3,
|
||||
USER_4,
|
||||
USER_5,
|
||||
USER_6,
|
||||
USER_7,
|
||||
USER_8,
|
||||
USER_9,
|
||||
USER_10,
|
||||
USER_11,
|
||||
USER_12,
|
||||
USER_13,
|
||||
USER_14,
|
||||
USER_15,
|
||||
USER_16,
|
||||
MISSING_ERRNO,
|
||||
UNKNOWN_ERRNO,
|
||||
EOF,
|
||||
E2BIG,
|
||||
EACCES,
|
||||
EADDRINUSE,
|
||||
EADDRNOTAVAIL,
|
||||
EADV,
|
||||
EAFNOSUPPORT,
|
||||
EAGAIN,
|
||||
EALREADY,
|
||||
EAUTH,
|
||||
EBACKGROUND,
|
||||
EBADE,
|
||||
EBADF,
|
||||
EBADFD,
|
||||
EBADMSG,
|
||||
EBADR,
|
||||
EBADRPC,
|
||||
EBADRQC,
|
||||
EBADSLT,
|
||||
EBFONT,
|
||||
EBUSY,
|
||||
ECANCELED,
|
||||
ECHILD,
|
||||
ECHRNG,
|
||||
ECOMM,
|
||||
ECONNABORTED,
|
||||
ECONNREFUSED,
|
||||
ECONNRESET,
|
||||
ED,
|
||||
EDEADLK,
|
||||
EDEADLOCK,
|
||||
EDESTADDRREQ,
|
||||
EDIED,
|
||||
EDOM,
|
||||
EDOTDOT,
|
||||
EDQUOT,
|
||||
EEXIST,
|
||||
EFAULT,
|
||||
EFBIG,
|
||||
EFTYPE,
|
||||
EGRATUITOUS,
|
||||
EGREGIOUS,
|
||||
EHOSTDOWN,
|
||||
EHOSTUNREACH,
|
||||
EIDRM,
|
||||
EIEIO,
|
||||
EILSEQ,
|
||||
EINPROGRESS,
|
||||
EINTR,
|
||||
EINVAL,
|
||||
EIO,
|
||||
EISCONN,
|
||||
EISDIR,
|
||||
EISNAM,
|
||||
EL2HLT,
|
||||
EL2NSYNC,
|
||||
EL3HLT,
|
||||
EL3RST,
|
||||
ELIBACC,
|
||||
ELIBBAD,
|
||||
ELIBEXEC,
|
||||
ELIBMAX,
|
||||
ELIBSCN,
|
||||
ELNRNG,
|
||||
ELOOP,
|
||||
EMEDIUMTYPE,
|
||||
EMFILE,
|
||||
EMLINK,
|
||||
EMSGSIZE,
|
||||
EMULTIHOP,
|
||||
ENAMETOOLONG,
|
||||
ENAVAIL,
|
||||
ENEEDAUTH,
|
||||
ENETDOWN,
|
||||
ENETRESET,
|
||||
ENETUNREACH,
|
||||
ENFILE,
|
||||
ENOANO,
|
||||
ENOBUFS,
|
||||
ENOCSI,
|
||||
ENODATA,
|
||||
ENODEV,
|
||||
ENOENT,
|
||||
ENOEXEC,
|
||||
ENOLCK,
|
||||
ENOLINK,
|
||||
ENOMEDIUM,
|
||||
ENOMEM,
|
||||
ENOMSG,
|
||||
ENONET,
|
||||
ENOPKG,
|
||||
ENOPROTOOPT,
|
||||
ENOSPC,
|
||||
ENOSR,
|
||||
ENOSTR,
|
||||
ENOSYS,
|
||||
ENOTBLK,
|
||||
ENOTCONN,
|
||||
ENOTDIR,
|
||||
ENOTEMPTY,
|
||||
ENOTNAM,
|
||||
ENOTSOCK,
|
||||
ENOTSUP,
|
||||
ENOTTY,
|
||||
ENOTUNIQ,
|
||||
ENXIO,
|
||||
EOPNOTSUPP,
|
||||
EOVERFLOW,
|
||||
EPERM,
|
||||
EPFNOSUPPORT,
|
||||
EPIPE,
|
||||
EPROCLIM,
|
||||
EPROCUNAVAIL,
|
||||
EPROGMISMATCH,
|
||||
EPROGUNAVAIL,
|
||||
EPROTO,
|
||||
EPROTONOSUPPORT,
|
||||
EPROTOTYPE,
|
||||
ERANGE,
|
||||
EREMCHG,
|
||||
EREMOTE,
|
||||
EREMOTEIO,
|
||||
ERESTART,
|
||||
EROFS,
|
||||
ERPCMISMATCH,
|
||||
ESHUTDOWN,
|
||||
ESOCKTNOSUPPORT,
|
||||
ESPIPE,
|
||||
ESRCH,
|
||||
ESRMNT,
|
||||
ESTALE,
|
||||
ESTRPIPE,
|
||||
ETIME,
|
||||
ETIMEDOUT,
|
||||
ETOOMANYREFS,
|
||||
ETXTBSY,
|
||||
EUCLEAN,
|
||||
EUNATCH,
|
||||
EUSERS,
|
||||
EWOULDBLOCK,
|
||||
EXDEV,
|
||||
EXFULL,
|
||||
CODE_DIM
|
||||
}
|
||||
}
|
1224
vapi/gpgme.vapi
1224
vapi/gpgme.vapi
File diff suppressed because it is too large
Load diff
|
@ -66,9 +66,9 @@ SOURCES
|
|||
"src/module/xep/pixbuf_storage.vala"
|
||||
CUSTOM_VAPIS
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/vapi/uuid.vapi"
|
||||
"${CMAKE_BINARY_DIR}/gpgme-vala/gpgme.vapi"
|
||||
PACKAGES
|
||||
${ENGINE_PACKAGES}
|
||||
gpgme
|
||||
GENERATE_VAPI
|
||||
xmpp-vala
|
||||
GENERATE_HEADER
|
||||
|
@ -80,10 +80,11 @@ OPTIONS
|
|||
--vapidir=${CMAKE_SOURCE_DIR}/vapi
|
||||
)
|
||||
|
||||
set(CFLAGS ${ENGINE_CFLAGS} ${GPGME_CFLAGS} ${LIBUUID_CFLAGS} -g ${VALA_CFLAGS})
|
||||
set(CFLAGS ${ENGINE_CFLAGS} ${GPGME_CFLAGS} ${LIBUUID_CFLAGS} -g ${VALA_CFLAGS} -I${CMAKE_BINARY_DIR}/gpgme-vala)
|
||||
add_definitions(${CFLAGS})
|
||||
add_library(xmpp-vala SHARED ${ENGINE_VALA_C})
|
||||
target_link_libraries(xmpp-vala ${ENGINE_LIBRARIES} ${GPGME_LIBRARIES} ${LIBUUID_LIBRARIES})
|
||||
add_dependencies(xmpp-vala gpgme-vala gpgme-vapi)
|
||||
target_link_libraries(xmpp-vala gpgme-vala ${ENGINE_LIBRARIES} ${GPGME_LIBRARIES} ${LIBUUID_LIBRARIES})
|
||||
|
||||
add_custom_target(xmpp-vala-vapi
|
||||
DEPENDS
|
||||
|
|
|
@ -227,19 +227,19 @@ public class XmppStream {
|
|||
}
|
||||
|
||||
public abstract class XmppStreamFlag {
|
||||
internal abstract string get_ns();
|
||||
internal abstract string get_id();
|
||||
public abstract string get_ns();
|
||||
public abstract string get_id();
|
||||
}
|
||||
|
||||
public abstract class XmppStreamModule : Object {
|
||||
internal abstract void attach(XmppStream stream);
|
||||
internal abstract void detach(XmppStream stream);
|
||||
internal abstract string get_ns();
|
||||
internal abstract string get_id();
|
||||
public abstract void attach(XmppStream stream);
|
||||
public abstract void detach(XmppStream stream);
|
||||
public abstract string get_ns();
|
||||
public abstract string get_id();
|
||||
}
|
||||
|
||||
public abstract class XmppStreamNegotiationModule : XmppStreamModule {
|
||||
internal abstract bool mandatory_outstanding(XmppStream stream);
|
||||
internal abstract bool negotiation_active(XmppStream stream);
|
||||
public abstract bool mandatory_outstanding(XmppStream stream);
|
||||
public abstract bool negotiation_active(XmppStream stream);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,8 +12,6 @@ namespace Xmpp.Xep.Pgp {
|
|||
|
||||
public signal void received_jid_key_id(XmppStream stream, string jid, string key_id);
|
||||
|
||||
private static Object mutex = new Object();
|
||||
|
||||
private string? signed_status;
|
||||
private string? own_key_id;
|
||||
|
||||
|
@ -99,98 +97,51 @@ namespace Xmpp.Xep.Pgp {
|
|||
}
|
||||
|
||||
private static string? gpg_encrypt(string plain, string[] key_ids) {
|
||||
lock (mutex) {
|
||||
GPG.Context context;
|
||||
GPGError.ErrorCode e = GPG.Context.Context(out context); if (e != GPGError.ErrorCode.NO_ERROR) return null;
|
||||
context.set_armor(true);
|
||||
|
||||
Key[] keys = new Key[key_ids.length];
|
||||
GPG.Key[] keys = new GPG.Key[key_ids.length];
|
||||
string encr;
|
||||
try {
|
||||
for (int i = 0; i < key_ids.length; i++) {
|
||||
Key key;
|
||||
e = context.get_key(key_ids[i], out key, false); if (e != GPGError.ErrorCode.NO_ERROR) return null;
|
||||
keys[i] = key;
|
||||
keys[i] = GPGHelper.get_public_key(key_ids[i]);
|
||||
}
|
||||
encr = GPGHelper.encrypt_armor(plain, keys, GPG.EncryptFlags.ALWAYS_TRUST);
|
||||
} catch (Error e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
GPG.Data plain_data;
|
||||
e = GPG.Data.create_from_memory(out plain_data, plain.data, false);
|
||||
GPG.Data enc_data;
|
||||
e = GPG.Data.create(out enc_data);
|
||||
e = context.op_encrypt(keys, GPG.EncryptFlags.ALWAYS_TRUST, plain_data, enc_data);
|
||||
|
||||
string encr = get_string_from_data(enc_data);
|
||||
int encryption_start = encr.index_of("\n\n") + 2;
|
||||
return encr.substring(encryption_start, encr.length - "\n-----END PGP MESSAGE-----".length - encryption_start);
|
||||
}
|
||||
}
|
||||
|
||||
private static string? gpg_decrypt(string enc) {
|
||||
lock (mutex) {
|
||||
string armor = "-----BEGIN PGP MESSAGE-----\n\n" + enc + "\n-----END PGP MESSAGE-----";
|
||||
|
||||
GPG.Data enc_data;
|
||||
GPGError.ErrorCode e = GPG.Data.create_from_memory(out enc_data, armor.data, false); if (e != GPGError.ErrorCode.NO_ERROR) return null;
|
||||
GPG.Data dec_data;
|
||||
e = GPG.Data.create(out dec_data); if (e != GPGError.ErrorCode.NO_ERROR) return null;
|
||||
GPG.Context context;
|
||||
e = GPG.Context.Context(out context); if (e != GPGError.ErrorCode.NO_ERROR) return null;
|
||||
e = context.op_decrypt(enc_data, dec_data); if (e != GPGError.ErrorCode.NO_ERROR) return null;
|
||||
|
||||
string plain = get_string_from_data(dec_data);
|
||||
return plain;
|
||||
}
|
||||
string? decr = null;
|
||||
try {
|
||||
decr = GPGHelper.decrypt(armor);
|
||||
} catch (Error e) { }
|
||||
return decr;
|
||||
}
|
||||
|
||||
private static string? gpg_verify(string sig, string signed_text) {
|
||||
lock (mutex) {
|
||||
string armor = "-----BEGIN PGP MESSAGE-----\n\n" + sig + "\n-----END PGP MESSAGE-----";
|
||||
|
||||
GPG.Data sig_data;
|
||||
GPGError.ErrorCode e = GPG.Data.create_from_memory(out sig_data, armor.data, false); if (e != GPGError.ErrorCode.NO_ERROR) return null;
|
||||
GPG.Data plain_data;
|
||||
e = GPG.Data.create(out plain_data); if (e != GPGError.ErrorCode.NO_ERROR) return null;
|
||||
GPG.Context context;
|
||||
e = GPG.Context.Context(out context); if (e != GPGError.ErrorCode.NO_ERROR) return null;
|
||||
e = context.op_verify(sig_data, null, plain_data); if (e != GPGError.ErrorCode.NO_ERROR) return null;
|
||||
GPG.VerifyResult* verify_res = context.op_verify_result();
|
||||
if (verify_res == null || verify_res.signatures == null) return null;
|
||||
return verify_res.signatures.fpr;
|
||||
}
|
||||
string? sign_key = null;
|
||||
try {
|
||||
sign_key = GPGHelper.get_sign_key(armor, signed_text);
|
||||
} catch (Error e) { }
|
||||
return sign_key;
|
||||
}
|
||||
|
||||
private static string? gpg_sign(string status) {
|
||||
lock (mutex) {
|
||||
GPG.Data status_data;
|
||||
GPGError.ErrorCode e = GPG.Data.create_from_memory(out status_data, status.data, false); if (e != GPGError.ErrorCode.NO_ERROR) return null;
|
||||
GPG.Data signed_data;
|
||||
e = GPG.Data.create(out signed_data); if (e != GPGError.ErrorCode.NO_ERROR) return null;
|
||||
GPG.Context context;
|
||||
e = GPG.Context.Context(out context); if (e != GPGError.ErrorCode.NO_ERROR) return null;
|
||||
e = context.op_sign(status_data, signed_data, GPG.SigMode.CLEAR); if (e != GPGError.ErrorCode.NO_ERROR) return null;
|
||||
|
||||
string signed = get_string_from_data(signed_data);
|
||||
private static string? gpg_sign(string str) {
|
||||
string signed;
|
||||
try {
|
||||
signed = GPGHelper.sign(str, GPG.SigMode.CLEAR);
|
||||
} catch (Error e) {
|
||||
return null;
|
||||
}
|
||||
int signature_start = signed.index_of("-----BEGIN PGP SIGNATURE-----");
|
||||
signature_start = signed.index_of("\n\n", signature_start) + 2;
|
||||
return signed.substring(signature_start, signed.length - "\n-----END PGP SIGNATURE-----".length - signature_start);
|
||||
}
|
||||
}
|
||||
|
||||
private static string get_string_from_data(GPG.Data data) {
|
||||
data.seek(0);
|
||||
uint8[] buf = new uint8[256];
|
||||
ssize_t? len = null;
|
||||
string res = "";
|
||||
do {
|
||||
len = data.read(buf);
|
||||
if (len > 0) {
|
||||
string part = (string) buf;
|
||||
part = part.substring(0, (long) len);
|
||||
res += part;
|
||||
}
|
||||
} while (len > 0);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
public class MessageFlag : Message.MessageFlag {
|
||||
public const string id = "pgp";
|
||||
|
||||
|
|
Loading…
Reference in a new issue