aboutsummaryrefslogtreecommitdiff
path: root/libdino/vapi
diff options
context:
space:
mode:
Diffstat (limited to 'libdino/vapi')
-rw-r--r--libdino/vapi/gnutls.vapi420
-rw-r--r--libdino/vapi/libgcrypt.vapi872
-rw-r--r--libdino/vapi/libomemo-c.vapi692
-rw-r--r--libdino/vapi/libsrtp2.vapi146
-rw-r--r--libdino/vapi/metadata/Nice-0.1.metadata11
-rw-r--r--libdino/vapi/nice.vapi386
-rw-r--r--libdino/vapi/openssl.vapi322
7 files changed, 2849 insertions, 0 deletions
diff --git a/libdino/vapi/gnutls.vapi b/libdino/vapi/gnutls.vapi
new file mode 100644
index 00000000..86a8c401
--- /dev/null
+++ b/libdino/vapi/gnutls.vapi
@@ -0,0 +1,420 @@
+[CCode (cprefix = "gnutls_", lower_case_cprefix = "gnutls_", cheader_filename = "gnutls/gnutls.h")]
+namespace GnuTLS {
+
+ public int global_init();
+
+ [CCode (cname = "gnutls_pull_func", has_target = false)]
+ public delegate ssize_t PullFunc(void* transport_ptr, [CCode (ctype = "void*", array_length_type="size_t")] uint8[] array);
+
+ [CCode (cname = "gnutls_pull_timeout_func", has_target = false)]
+ public delegate int PullTimeoutFunc(void* transport_ptr, uint ms);
+
+ [CCode (cname = "gnutls_push_func", has_target = false)]
+ public delegate ssize_t PushFunc(void* transport_ptr, [CCode (ctype = "void*", array_length_type="size_t")] uint8[] array);
+
+ [CCode (cname = "gnutls_certificate_verify_function", has_target = false)]
+ public delegate int VerifyFunc(Session session);
+
+ [Compact]
+ [CCode (cname = "struct gnutls_session_int", free_function = "gnutls_deinit")]
+ public class Session {
+
+ public static Session? create(int con_end) throws GLib.Error {
+ Session result;
+ var ret = init(out result, con_end);
+ throw_if_error(ret);
+ return result;
+ }
+
+ [CCode (cname = "gnutls_init")]
+ private static int init(out Session session, int con_end);
+
+ [CCode (cname = "gnutls_transport_set_push_function")]
+ public void set_push_function(PushFunc func);
+
+ [CCode (cname = "gnutls_transport_set_pull_function")]
+ public void set_pull_function(PullFunc func);
+
+ [CCode (cname = "gnutls_transport_set_pull_timeout_function")]
+ public void set_pull_timeout_function(PullTimeoutFunc func);
+
+ [CCode (cname = "gnutls_transport_set_ptr")]
+ public void set_transport_pointer(void* ptr);
+
+ [CCode (cname = "gnutls_transport_get_ptr")]
+ public void* get_transport_pointer();
+
+ [CCode (cname = "gnutls_heartbeat_enable")]
+ public int enable_heartbeat(uint type);
+
+ [CCode (cname = "gnutls_certificate_server_set_request")]
+ public void server_set_request(CertificateRequest req);
+
+ [CCode (cname = "gnutls_credentials_set")]
+ public int set_credentials_(CredentialsType type, void* cred);
+ [CCode (cname = "gnutls_credentials_set_")]
+ public void set_credentials(CredentialsType type, void* cred) throws GLib.Error {
+ int err = set_credentials_(type, cred);
+ throw_if_error(err);
+ }
+
+ [CCode (cname = "gnutls_priority_set_direct")]
+ public int set_priority_from_string_(string priority, out unowned string err_pos = null);
+ [CCode (cname = "gnutls_priority_set_direct_")]
+ public void set_priority_from_string(string priority, out unowned string err_pos = null) throws GLib.Error {
+ int err = set_priority_from_string_(priority, out err_pos);
+ throw_if_error(err);
+ }
+
+ [CCode (cname = "gnutls_srtp_set_profile_direct")]
+ public int set_srtp_profile_direct_(string profiles, out unowned string err_pos = null);
+ [CCode (cname = "gnutls_srtp_set_profile_direct_")]
+ public void set_srtp_profile_direct(string profiles, out unowned string err_pos = null) throws GLib.Error {
+ int err = set_srtp_profile_direct_(profiles, out err_pos);
+ throw_if_error(err);
+ }
+
+ [CCode (cname = "gnutls_transport_set_int")]
+ public void transport_set_int(int fd);
+
+ [CCode (cname = "gnutls_handshake")]
+ public int handshake();
+
+ [CCode (cname = "gnutls_srtp_get_keys")]
+ public int get_srtp_keys_(void *key_material, uint32 key_material_size, out Datum client_key, out Datum client_salt, out Datum server_key, out Datum server_salt);
+ [CCode (cname = "gnutls_srtp_get_keys_")]
+ public void get_srtp_keys(void *key_material, uint32 key_material_size, out Datum client_key, out Datum client_salt, out Datum server_key, out Datum server_salt) throws GLib.Error {
+ get_srtp_keys_(key_material, key_material_size, out client_key, out client_salt, out server_key, out server_salt);
+ }
+
+ [CCode (cname = "gnutls_certificate_get_peers", array_length_type = "unsigned int")]
+ public unowned Datum[]? get_peer_certificates();
+
+ [CCode (cname = "gnutls_session_set_verify_function")]
+ public void set_verify_function(VerifyFunc func);
+ }
+
+ [Compact]
+ [CCode (cname = "struct gnutls_certificate_credentials_st", free_function = "gnutls_certificate_free_credentials", cprefix = "gnutls_certificate_")]
+ public class CertificateCredentials {
+
+ [CCode (cname = "gnutls_certificate_allocate_credentials")]
+ private static int allocate(out CertificateCredentials credentials);
+
+ public static CertificateCredentials create() throws GLib.Error {
+ CertificateCredentials result;
+ var ret = allocate (out result);
+ throw_if_error(ret);
+ return result;
+ }
+
+ public void get_x509_crt(uint index, [CCode (array_length_type = "unsigned int")] out unowned X509.Certificate[] x509_ca_list);
+
+ public int set_x509_key(X509.Certificate[] cert_list, X509.PrivateKey key);
+ }
+
+ [CCode (cheader_filename = "gnutls/x509.h", cprefix = "GNUTLS_")]
+ namespace X509 {
+
+ [Compact]
+ [CCode (cname = "struct gnutls_x509_crt_int", cprefix = "gnutls_x509_crt_", free_function = "gnutls_x509_crt_deinit")]
+ public class Certificate {
+
+ [CCode (cname = "gnutls_x509_crt_init")]
+ private static int init (out Certificate cert);
+ public static Certificate create() throws GLib.Error {
+ Certificate result;
+ var ret = init (out result);
+ throw_if_error(ret);
+ return result;
+ }
+
+ [CCode (cname = "gnutls_x509_crt_import")]
+ public int import_(ref Datum data, CertificateFormat format);
+ [CCode (cname = "gnutls_x509_crt_import_")]
+ public void import(ref Datum data, CertificateFormat format) throws GLib.Error {
+ int err = import_(ref data, format);
+ throw_if_error(err);
+ }
+
+ [CCode (cname = "gnutls_x509_crt_set_version")]
+ public int set_version_(uint version);
+ [CCode (cname = "gnutls_x509_crt_set_version_")]
+ public void set_version(uint version) throws GLib.Error {
+ int err = set_version_(version);
+ throw_if_error(err);
+ }
+
+ [CCode (cname = "gnutls_x509_crt_set_key")]
+ public int set_key_(PrivateKey key);
+ [CCode (cname = "gnutls_x509_crt_set_key_")]
+ public void set_key(PrivateKey key) throws GLib.Error {
+ int err = set_key_(key);
+ throw_if_error(err);
+ }
+
+ [CCode (cname = "gnutls_x509_crt_set_activation_time")]
+ public int set_activation_time_(time_t act_time);
+ [CCode (cname = "gnutls_x509_crt_set_activation_time_")]
+ public void set_activation_time(time_t act_time) throws GLib.Error {
+ int err = set_activation_time_(act_time);
+ throw_if_error(err);
+ }
+
+ [CCode (cname = "gnutls_x509_crt_set_expiration_time")]
+ public int set_expiration_time_(time_t exp_time);
+ [CCode (cname = "gnutls_x509_crt_set_expiration_time_")]
+ public void set_expiration_time(time_t exp_time) throws GLib.Error {
+ int err = set_expiration_time_(exp_time);
+ throw_if_error(err);
+ }
+
+ [CCode (cname = "gnutls_x509_crt_set_serial")]
+ public int set_serial_(void* serial, size_t serial_size);
+ [CCode (cname = "gnutls_x509_crt_set_serial_")]
+ public void set_serial(void* serial, size_t serial_size) throws GLib.Error {
+ int err = set_serial_(serial, serial_size);
+ throw_if_error(err);
+ }
+
+ [CCode (cname = "gnutls_x509_crt_sign")]
+ public int sign_(Certificate issuer, PrivateKey issuer_key);
+ [CCode (cname = "gnutls_x509_crt_sign_")]
+ public void sign(Certificate issuer, PrivateKey issuer_key) throws GLib.Error {
+ int err = sign_(issuer, issuer_key);
+ throw_if_error(err);
+ }
+
+ [CCode (cname = "gnutls_x509_crt_get_fingerprint")]
+ public int get_fingerprint_(DigestAlgorithm algo, void* buf, ref size_t buf_size);
+ [CCode (cname = "gnutls_x509_crt_get_fingerprint_")]
+ public void get_fingerprint(DigestAlgorithm algo, void* buf, ref size_t buf_size) throws GLib.Error {
+ int err = get_fingerprint_(algo, buf, ref buf_size);
+ throw_if_error(err);
+ }
+ }
+
+ [Compact]
+ [CCode (cname = "struct gnutls_x509_privkey_int", cprefix = "gnutls_x509_privkey_", free_function = "gnutls_x509_privkey_deinit")]
+ public class PrivateKey {
+ private static int init (out PrivateKey key);
+ public static PrivateKey create () throws GLib.Error {
+ PrivateKey result;
+ var ret = init (out result);
+ throw_if_error(ret);
+ return result;
+ }
+
+ public int generate(PKAlgorithm algo, uint bits, uint flags = 0);
+ }
+
+ }
+
+ [CCode (cname = "gnutls_certificate_request_t", cprefix = "GNUTLS_CERT_", has_type_id = false)]
+ public enum CertificateRequest {
+ IGNORE,
+ REQUEST,
+ REQUIRE
+ }
+
+ [CCode (cname = "gnutls_pk_algorithm_t", cprefix = "GNUTLS_PK_", has_type_id = false)]
+ public enum PKAlgorithm {
+ UNKNOWN,
+ RSA,
+ DSA,
+ ECDSA;
+ }
+
+ [CCode (cname = "gnutls_digest_algorithm_t", cprefix = "GNUTLS_DIG_", has_type_id = false)]
+ public enum DigestAlgorithm {
+ NULL,
+ MD5,
+ SHA1,
+ RMD160,
+ MD2,
+ SHA224,
+ SHA256,
+ SHA384,
+ SHA512;
+ }
+
+ [Flags]
+ [CCode (cname = "gnutls_init_flags_t", cprefix = "GNUTLS_", has_type_id = false)]
+ public enum InitFlags {
+ SERVER,
+ CLIENT,
+ DATAGRAM
+ }
+
+ [CCode (cname = "gnutls_credentials_type_t", cprefix = "GNUTLS_CRD_", has_type_id = false)]
+ public enum CredentialsType {
+ CERTIFICATE,
+ ANON,
+ SRP,
+ PSK,
+ IA
+ }
+
+ [CCode (cname = "gnutls_x509_crt_fmt_t", cprefix = "GNUTLS_X509_FMT_", has_type_id = false)]
+ public enum CertificateFormat {
+ DER,
+ PEM
+ }
+
+ [Flags]
+ [CCode (cname = "gnutls_certificate_status_t", cprefix = "GNUTLS_CERT_", has_type_id = false)]
+ public enum CertificateStatus {
+ INVALID, // will be set if the certificate was not verified.
+ REVOKED, // in X.509 this will be set only if CRLs are checked
+ SIGNER_NOT_FOUND,
+ SIGNER_NOT_CA,
+ INSECURE_ALGORITHM
+ }
+
+ [SimpleType]
+ [CCode (cname = "gnutls_datum_t", has_type_id = false)]
+ public struct Datum {
+ public uint8* data;
+ public uint size;
+
+ public uint8[] extract() {
+ uint8[] ret = new uint8[size];
+ for (int i = 0; i < size; i++) {
+ ret[i] = data[i];
+ }
+ return ret;
+ }
+ }
+
+ // Gnutls error codes. The mapping to a TLS alert is also shown in comments.
+ [CCode (cname = "int", cprefix = "GNUTLS_E_", lower_case_cprefix = "gnutls_error_", has_type_id = false)]
+ public enum ErrorCode {
+ SUCCESS,
+ UNKNOWN_COMPRESSION_ALGORITHM,
+ UNKNOWN_CIPHER_TYPE,
+ LARGE_PACKET,
+ UNSUPPORTED_VERSION_PACKET, // GNUTLS_A_PROTOCOL_VERSION
+ UNEXPECTED_PACKET_LENGTH, // GNUTLS_A_RECORD_OVERFLOW
+ INVALID_SESSION,
+ FATAL_ALERT_RECEIVED,
+ UNEXPECTED_PACKET, // GNUTLS_A_UNEXPECTED_MESSAGE
+ WARNING_ALERT_RECEIVED,
+ ERROR_IN_FINISHED_PACKET,
+ UNEXPECTED_HANDSHAKE_PACKET,
+ UNKNOWN_CIPHER_SUITE, // GNUTLS_A_HANDSHAKE_FAILURE
+ UNWANTED_ALGORITHM,
+ MPI_SCAN_FAILED,
+ DECRYPTION_FAILED, // GNUTLS_A_DECRYPTION_FAILED, GNUTLS_A_BAD_RECORD_MAC
+ MEMORY_ERROR,
+ DECOMPRESSION_FAILED, // GNUTLS_A_DECOMPRESSION_FAILURE
+ COMPRESSION_FAILED,
+ AGAIN,
+ EXPIRED,
+ DB_ERROR,
+ SRP_PWD_ERROR,
+ INSUFFICIENT_CREDENTIALS,
+ HASH_FAILED,
+ BASE64_DECODING_ERROR,
+ MPI_PRINT_FAILED,
+ REHANDSHAKE, // GNUTLS_A_NO_RENEGOTIATION
+ GOT_APPLICATION_DATA,
+ RECORD_LIMIT_REACHED,
+ ENCRYPTION_FAILED,
+ PK_ENCRYPTION_FAILED,
+ PK_DECRYPTION_FAILED,
+ PK_SIGN_FAILED,
+ X509_UNSUPPORTED_CRITICAL_EXTENSION,
+ KEY_USAGE_VIOLATION,
+ NO_CERTIFICATE_FOUND, // GNUTLS_A_BAD_CERTIFICATE
+ INVALID_REQUEST,
+ SHORT_MEMORY_BUFFER,
+ INTERRUPTED,
+ PUSH_ERROR,
+ PULL_ERROR,
+ RECEIVED_ILLEGAL_PARAMETER, // GNUTLS_A_ILLEGAL_PARAMETER
+ REQUESTED_DATA_NOT_AVAILABLE,
+ PKCS1_WRONG_PAD,
+ RECEIVED_ILLEGAL_EXTENSION,
+ INTERNAL_ERROR,
+ DH_PRIME_UNACCEPTABLE,
+ FILE_ERROR,
+ TOO_MANY_EMPTY_PACKETS,
+ UNKNOWN_PK_ALGORITHM,
+ // returned if libextra functionality was requested but
+ // gnutls_global_init_extra() was not called.
+
+ INIT_LIBEXTRA,
+ LIBRARY_VERSION_MISMATCH,
+ // returned if you need to generate temporary RSA
+ // parameters. These are needed for export cipher suites.
+
+ NO_TEMPORARY_RSA_PARAMS,
+ LZO_INIT_FAILED,
+ NO_COMPRESSION_ALGORITHMS,
+ NO_CIPHER_SUITES,
+ OPENPGP_GETKEY_FAILED,
+ PK_SIG_VERIFY_FAILED,
+ ILLEGAL_SRP_USERNAME,
+ SRP_PWD_PARSING_ERROR,
+ NO_TEMPORARY_DH_PARAMS,
+ // For certificate and key stuff
+
+ ASN1_ELEMENT_NOT_FOUND,
+ ASN1_IDENTIFIER_NOT_FOUND,
+ ASN1_DER_ERROR,
+ ASN1_VALUE_NOT_FOUND,
+ ASN1_GENERIC_ERROR,
+ ASN1_VALUE_NOT_VALID,
+ ASN1_TAG_ERROR,
+ ASN1_TAG_IMPLICIT,
+ ASN1_TYPE_ANY_ERROR,
+ ASN1_SYNTAX_ERROR,
+ ASN1_DER_OVERFLOW,
+ OPENPGP_UID_REVOKED,
+ CERTIFICATE_ERROR,
+ CERTIFICATE_KEY_MISMATCH,
+ UNSUPPORTED_CERTIFICATE_TYPE, // GNUTLS_A_UNSUPPORTED_CERTIFICATE
+ X509_UNKNOWN_SAN,
+ OPENPGP_FINGERPRINT_UNSUPPORTED,
+ X509_UNSUPPORTED_ATTRIBUTE,
+ UNKNOWN_HASH_ALGORITHM,
+ UNKNOWN_PKCS_CONTENT_TYPE,
+ UNKNOWN_PKCS_BAG_TYPE,
+ INVALID_PASSWORD,
+ MAC_VERIFY_FAILED, // for PKCS #12 MAC
+ CONSTRAINT_ERROR,
+ WARNING_IA_IPHF_RECEIVED,
+ WARNING_IA_FPHF_RECEIVED,
+ IA_VERIFY_FAILED,
+ UNKNOWN_ALGORITHM,
+ BASE64_ENCODING_ERROR,
+ INCOMPATIBLE_CRYPTO_LIBRARY,
+ INCOMPATIBLE_LIBTASN1_LIBRARY,
+ OPENPGP_KEYRING_ERROR,
+ X509_UNSUPPORTED_OID,
+ RANDOM_FAILED,
+ BASE64_UNEXPECTED_HEADER_ERROR,
+ OPENPGP_SUBKEY_ERROR,
+ CRYPTO_ALREADY_REGISTERED,
+ HANDSHAKE_TOO_LARGE,
+ UNIMPLEMENTED_FEATURE,
+ APPLICATION_ERROR_MAX, // -65000
+ APPLICATION_ERROR_MIN; // -65500
+
+ [CCode (cname = "gnutls_error_is_fatal")]
+ public bool is_fatal();
+
+ [CCode (cname = "gnutls_perror")]
+ public void print();
+
+ [CCode (cname = "gnutls_strerror")]
+ public unowned string to_string();
+ }
+
+ public void throw_if_error(int err_int) throws GLib.Error {
+ ErrorCode error = (ErrorCode)err_int;
+ if (error != ErrorCode.SUCCESS) {
+ throw new GLib.Error(-1, error, "%s%s", error.to_string(), error.is_fatal() ? " fatal" : "");
+ }
+ }
+} \ No newline at end of file
diff --git a/libdino/vapi/libgcrypt.vapi b/libdino/vapi/libgcrypt.vapi
new file mode 100644
index 00000000..0fa69a02
--- /dev/null
+++ b/libdino/vapi/libgcrypt.vapi
@@ -0,0 +1,872 @@
+/* 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 = "gcrypt.h", lower_case_cprefix = "gcry_")]
+namespace GCrypt {
+ [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 = "gcry_error_t", cprefix = "gpg_err_")]
+ public struct Error : uint {
+ [CCode (cname = "gcry_err_make")]
+ public Error (ErrorSource source, ErrorCode code);
+ [CCode (cname = "gcry_err_make_from_errno")]
+ public Error.from_errno (ErrorSource source, int err);
+ public ErrorCode code ();
+ public ErrorSource source ();
+
+ [CCode (cname = "gcry_strerror")]
+ public unowned string to_string ();
+
+ [CCode (cname = "gcry_strsource")]
+ public unowned string source_to_string ();
+ }
+
+ [CCode (cname = "enum gcry_ctl_cmds", cprefix = "GCRYCTL_")]
+ public enum ControlCommand {
+ SET_KEY,
+ SET_IV,
+ CFB_SYNC,
+ RESET,
+ FINALIZE,
+ GET_KEYLEN,
+ GET_BLKLEN,
+ TEST_ALGO,
+ IS_SECURE,
+ GET_ASNOID,
+ ENABLE_ALGO,
+ DISABLE_ALGO,
+ DUMP_RANDOM_STATS,
+ DUMP_SECMEM_STATS,
+ GET_ALGO_NPKEY,
+ GET_ALGO_NSKEY,
+ GET_ALGO_NSIGN,
+ GET_ALGO_NENCR,
+ SET_VERBOSITY,
+ SET_DEBUG_FLAGS,
+ CLEAR_DEBUG_FLAGS,
+ USE_SECURE_RNDPOOL,
+ DUMP_MEMORY_STATS,
+ INIT_SECMEM,
+ TERM_SECMEM,
+ DISABLE_SECMEM_WARN,
+ SUSPEND_SECMEM_WARN,
+ RESUME_SECMEM_WARN,
+ DROP_PRIVS,
+ ENABLE_M_GUARD,
+ START_DUMP,
+ STOP_DUMP,
+ GET_ALGO_USAGE,
+ IS_ALGO_ENABLED,
+ DISABLE_INTERNAL_LOCKING,
+ DISABLE_SECMEM,
+ INITIALIZATION_FINISHED,
+ INITIALIZATION_FINISHED_P,
+ ANY_INITIALIZATION_P,
+ SET_CBC_CTS,
+ SET_CBC_MAC,
+ SET_CTR,
+ ENABLE_QUICK_RANDOM,
+ SET_RANDOM_SEED_FILE,
+ UPDATE_RANDOM_SEED_FILE,
+ SET_THREAD_CBS,
+ FAST_POLL
+ }
+ public Error control (ControlCommand cmd, ...);
+
+ [CCode (lower_case_cname = "cipher_")]
+ namespace Cipher {
+ [CCode (cname = "enum gcry_cipher_algos", cprefix = "GCRY_CIPHER_")]
+ public enum Algorithm {
+ NONE,
+ IDEA,
+ 3DES,
+ CAST5,
+ BLOWFISH,
+ SAFER_SK128,
+ DES_SK,
+ AES,
+ AES128,
+ RIJNDAEL,
+ RIJNDAEL128,
+ AES192,
+ RIJNDAEL192,
+ AES256,
+ RIJNDAEL256,
+ TWOFISH,
+ TWOFISH128,
+ ARCFOUR,
+ DES,
+ SERPENT128,
+ SERPENT192,
+ SERPENT256,
+ RFC2268_40,
+ RFC2268_128,
+ SEED,
+ CAMELLIA128,
+ CAMELLIA192,
+ CAMELLIA256,
+ SALSA20,
+ SALSA20R12,
+ GOST28147,
+ CHACHA20;
+
+ [CCode (cname = "gcry_cipher_algo_info")]
+ public Error info (ControlCommand what, ref uchar[] buffer);
+ [CCode (cname = "gcry_cipher_algo_name")]
+ public unowned string to_string ();
+ [CCode (cname = "gcry_cipher_map_name")]
+ public static Algorithm from_string (string name);
+ [CCode (cname = "gcry_cipher_map_oid")]
+ public static Algorithm from_oid (string oid);
+ }
+
+ [CCode (cname = "enum gcry_cipher_modes", cprefix = "GCRY_CIPHER_MODE_")]
+ public enum Mode {
+ NONE, /* No mode specified */
+ ECB, /* Electronic Codebook */
+ CFB, /* Cipher Feedback */
+ CBC, /* Cipher Block Chaining */
+ STREAM, /* Used with stream ciphers */
+ OFB, /* Output Feedback */
+ CTR, /* Counter */
+ AESWRAP, /* AES-WRAP algorithm */
+ CCM, /* Counter with CBC-MAC */
+ GCM, /* Galois/Counter Mode */
+ POLY1305, /* Poly1305 based AEAD mode */
+ OCB, /* OCB3 mode */
+ CFB8, /* Cipher Feedback /* Poly1305 based AEAD mode. */
+ XTS; /* XTS mode */
+
+ public unowned string to_string () {
+ switch (this) {
+ case ECB: return "ECB";
+ case CFB: return "CFB";
+ case CBC: return "CBC";
+ case STREAM: return "STREAM";
+ case OFB: return "OFB";
+ case CTR: return "CTR";
+ case AESWRAP: return "AESWRAP";
+ case GCM: return "GCM";
+ case POLY1305: return "POLY1305";
+ case OCB: return "OCB";
+ case CFB8: return "CFB8";
+ case XTS: return "XTS";
+ }
+ return "NONE";
+ }
+
+ public static Mode from_string (string name) {
+ switch (name) {
+ case "ECB": return ECB;
+ case "CFB": return CFB;
+ case "CBC": return CBC;
+ case "STREAM": return STREAM;
+ case "OFB": return OFB;
+ case "CTR": return CTR;
+ case "AESWRAP": return AESWRAP;
+ case "GCM": return GCM;
+ case "POLY1305": return POLY1305;
+ case "OCB": return OCB;
+ case "CFB8": return CFB8;
+ case "XTS": return XTS;
+ }
+ return NONE;
+ }
+ }
+
+ [CCode (cname = "enum gcry_cipher_flags", cprefix = "GCRY_CIPHER_")]
+ public enum Flag {
+ SECURE, /* Allocate in secure memory. */
+ ENABLE_SYNC, /* Enable CFB sync mode. */
+ CBC_CTS, /* Enable CBC cipher text stealing (CTS). */
+ CBC_MAC /* Enable CBC message auth. code (MAC). */
+ }
+ [CCode (cname = "gcry_cipher_hd_t", lower_case_cprefix = "gcry_cipher_", free_function = "gcry_cipher_close")]
+ [SimpleType]
+ public struct Cipher {
+ public static Error open (out Cipher cipher, Algorithm algo, Mode mode, Flag flags);
+ public void close ();
+ [CCode (cname = "gcry_cipher_ctl")]
+ public Error control (ControlCommand cmd, uchar[] buffer);
+ public Error info (ControlCommand what, ref uchar[] buffer);
+
+ public Error encrypt (uchar[] out_buffer, uchar[] in_buffer);
+ public Error decrypt (uchar[] out_buffer, uchar[] in_buffer);
+
+ [CCode (cname = "gcry_cipher_setkey")]
+ public Error set_key (uchar[] key_data);
+ [CCode (cname = "gcry_cipher_setiv")]
+ public Error set_iv (uchar[] iv_data);
+ [CCode (cname = "gcry_cipher_setctr")]
+ public Error set_counter_vector (uchar[] counter_vector);
+
+ [CCode (cname = "gcry_cipher_gettag")]
+ public Error get_tag(uchar[] out_buffer);
+ [CCode (cname = "gcry_cipher_checktag")]
+ public Error check_tag(uchar[] in_buffer);
+
+ public Error reset ();
+ public Error sync ();
+ }
+ }
+
+ [Compact, CCode (cname = "struct gcry_md_handle", cprefix = "gcry_md_", free_function = "gcry_md_close")]
+ public class Hash {
+ [CCode (cname = "enum gcry_md_algos", cprefix = "GCRY_MD_")]
+ public enum Algorithm {
+ NONE,
+ SHA1,
+ RMD160,
+ MD5,
+ MD4,
+ MD2,
+ TIGER,
+ TIGER1,
+ TIGER2,
+ HAVAL,
+ SHA224,
+ SHA256,
+ SHA384,
+ SHA512,
+ SHA3_224,
+ SHA3_256,
+ SHA3_384,
+ SHA3_512,
+ SHAKE128,
+ SHAKE256,
+ CRC32,
+ CRC32_RFC1510,
+ CRC24_RFC2440,
+ WHIRLPOOL,
+ GOSTR3411_94,
+ STRIBOG256,
+ STRIBOG512;
+
+ [CCode (cname = "gcry_md_get_algo_dlen")]
+ public size_t get_digest_length ();
+ [CCode (cname = "gcry_md_algo_info")]
+ public Error info (ControlCommand what, ref uchar[] buffer);
+ [CCode (cname = "gcry_md_algo_name")]
+ public unowned string to_string ();
+ [CCode (cname = "gcry_md_map_name")]
+ public static Algorithm from_string (string name);
+ [CCode (cname = "gcry_md_test_algo")]
+ public Error is_available ();
+ [CCode (cname = "gcry_md_get_asnoid")]
+ public Error get_oid (uchar[] buffer);
+ }
+
+ [CCode (cname = "enum gcry_md_flags", cprefix = "GCRY_MD_FLAG_")]
+ public enum Flag {
+ SECURE,
+ HMAC,
+ BUGEMU1
+ }
+
+ public static Error open (out Hash hash, Algorithm algo, Flag flag);
+ public void close ();
+ public Error enable (Algorithm algo);
+ [CCode (instance_pos = -1)]
+ public Error copy (out Hash dst);
+ public void reset ();
+ [CCode (cname = "enum gcry_md_ctl")]
+ public Error control (ControlCommand cmd, uchar[] buffer);
+ public void write (uchar[] buffer);
+ [CCode (array_length = false)]
+ public unowned uchar[] read (Algorithm algo);
+ public static void hash_buffer (Algorithm algo, [CCode (array_length = false)] uchar[] digest, uchar[] buffer);
+ public Algorithm get_algo ();
+ public bool is_enabled (Algorithm algo);
+ public bool is_secure ();
+ public Error info (ControlCommand what, uchar[] buffer);
+ [CCode (cname = "gcry_md_setkey")]
+ public Error set_key (uchar[] key_data);
+ public void putc (char c);
+ public void final ();
+ public static Error list (ref Algorithm[] algos);
+ }
+
+ namespace Random {
+ [CCode (cname = "gcry_random_level_t")]
+ public enum Level {
+ [CCode (cname = "GCRY_WEAK_RANDOM")]
+ WEAK,
+ [CCode (cname = "GCRY_STRONG_RANDOM")]
+ STRONG,
+ [CCode (cname = "GCRY_VERY_STRONG_RANDOM")]
+ VERY_STRONG
+ }
+
+ [CCode (cname = "gcry_randomize")]
+ public static void randomize (uchar[] buffer, Level level = Level.VERY_STRONG);
+ [CCode (cname = "gcry_fast_random_poll")]
+ public static Error poll ();
+ [CCode (cname = "gcry_random_bytes", array_length = false)]
+ public static uchar[] random_bytes (size_t nbytes, Level level = Level.VERY_STRONG);
+ [CCode (cname = "gcry_random_bytes_secure")]
+ public static uchar[] random_bytes_secure (size_t nbytes, Level level = Level.VERY_STRONG);
+ [CCode (cname = "gcry_create_nonce")]
+ public static void nonce (uchar[] buffer);
+ }
+
+ [Compact, CCode (cname = "struct gcry_mpi", cprefix = "gcry_mpi_", free_function = "gcry_mpi_release")]
+ public class MPI {
+ [CCode (cname = "enum gcry_mpi_format", cprefix = "GCRYMPI_FMT_")]
+ public enum Format {
+ NONE,
+ STD,
+ PGP,
+ SSH,
+ HEX,
+ USG
+ }
+
+ [CCode (cname = "enum gcry_mpi_flag", cprefix = "GCRYMPI_FLAG_")]
+ public enum Flag {
+ SECURE,
+ OPAQUE
+ }
+
+ public MPI (uint nbits);
+ [CCode (cname = "gcry_mpi_snew")]
+ public MPI.secure (uint nbits);
+ public MPI copy ();
+ public void set (MPI u);
+ public void set_ui (ulong u);
+ public void swap ();
+ public int cmp (MPI v);
+ public int cmp_ui (ulong v);
+
+ public static Error scan (out MPI ret, MPI.Format format, [CCode (array_length = false)] uchar[] buffer, size_t buflen, out size_t nscanned);
+ [CCode (instance_pos = -1)]
+ public Error print (MPI.Format format, [CCode (array_length = false)] uchar[] buffer, size_t buflen, out size_t nwritter);
+ [CCode (instance_pos = -1)]
+ public Error aprint (MPI.Format format, out uchar[] buffer);
+
+ public void add (MPI u, MPI v);
+ public void add_ui (MPI u, ulong v);
+ public void addm (MPI u, MPI v, MPI m);
+ public void sub (MPI u, MPI v);
+ public void sub_ui (MPI u, MPI v);
+ public void subm (MPI u, MPI v, MPI m);
+ public void mul (MPI u, MPI v);
+ public void mul_ui (MPI u, ulong v);
+ public void mulm (MPI u, MPI v, MPI m);
+ public void mul_2exp (MPI u, ulong cnt);
+ public void div (MPI q, MPI r, MPI dividend, MPI divisor, int round);
+ public void mod (MPI dividend, MPI divisor);
+ public void powm (MPI b, MPI e, MPI m);
+ public int gcd (MPI a, MPI b);
+ public int invm (MPI a, MPI m);
+
+ public uint get_nbits ();
+ public int test_bit (uint n);
+ public void set_bit (uint n);
+ public void clear_bit (uint n);
+ public void set_highbit (uint n);
+ public void clear_highbit (uint n);
+ public void rshift (MPI a, uint n);
+ public void lshift (MPI a, uint n);
+
+ public void set_flag (MPI.Flag flag);
+ public void clear_flag (MPI.Flag flag);
+ public int get_flag (MPI.Flag flag);
+ }
+
+ [Compact, CCode (cname = "struct gcry_sexp", free_function = "gcry_sexp_release")]
+ public class SExp {
+ [CCode (cprefix = "GCRYSEXP_FMT_")]
+ public enum Format {
+ DEFAULT,
+ CANON,
+ BASE64,
+ ADVANCED
+ }
+
+ public static Error @new (out SExp retsexp, void * buffer, size_t length, int autodetect);
+ public static Error create (out SExp retsexp, void * buffer, size_t length, int autodetect, GLib.DestroyNotify free_function);
+ public static Error sscan (out SExp retsexp, out size_t erroff, char[] buffer);
+ public static Error build (out SExp retsexp, out size_t erroff, string format, ...);
+ public size_t sprint (Format mode, char[] buffer);
+ public static size_t canon_len (uchar[] buffer, out size_t erroff, out int errcode);
+ public SExp find_token (string token, size_t token_length = 0);
+ public int length ();
+ public SExp? nth (int number);
+ public SExp? car ();
+ public SExp? cdr ();
+ public unowned char[] nth_data (int number);
+ public gcry_string nth_string (int number);
+ public MPI nth_mpi (int number, MPI.Format mpifmt);
+ }
+
+ [CCode (cname = "char", free_function = "gcry_free")]
+ public class gcry_string : string { }
+
+ [CCode (lower_case_cprefix = "gcry_pk_")]
+ namespace PublicKey {
+ [CCode (cname = "enum gcry_pk_algos")]
+ public enum Algorithm {
+ RSA,
+ ELG_E,
+ DSA,
+ ELG,
+ ECDSA;
+
+ [CCode (cname = "gcry_pk_algo_name")]
+ public unowned string to_string ();
+ [CCode (cname = "gcry_pk_map_name")]
+ public static Algorithm map_name (string name);
+ }
+
+ public static Error encrypt (out SExp ciphertext, SExp data, SExp pkey);
+ public static Error decrypt (out SExp plaintext, SExp data, SExp skey);
+ public static Error sign (out SExp signature, SExp data, SExp skey);
+ public static Error verify (SExp signature, SExp data, SExp pkey);
+ public static Error testkey (SExp key);
+ public static Error genkey (out SExp r_key, SExp s_params);
+ public static uint get_nbits (SExp key);
+ }
+
+ [CCode (lower_case_cprefix = "gcry_kdf_")]
+ namespace KeyDerivation {
+ [CCode (cname = "gcry_kdf_algos", cprefix = "GCRY_KDF_", has_type_id = false)]
+ public enum Algorithm {
+ NONE,
+ SIMPLE_S2K,
+ SALTED_S2K,
+ ITERSALTED_S2K,
+ PBKDF1,
+ PBKDF2,
+ SCRYPT
+ }
+
+ public GCrypt.Error derive ([CCode (type = "const void*", array_length_type = "size_t")] uint8[] passphrasse, GCrypt.KeyDerivation.Algorithm algo, GCrypt.Hash.Algorithm subalgo, [CCode (type = "const void*", array_length_type = "size_t")] uint8[] salt, ulong iterations, [CCode (type = "void*", array_length_type = "size_t", array_length_pos = 5.5)] uint8[] keybuffer);
+ }
+}
diff --git a/libdino/vapi/libomemo-c.vapi b/libdino/vapi/libomemo-c.vapi
new file mode 100644
index 00000000..8a2b17d3
--- /dev/null
+++ b/libdino/vapi/libomemo-c.vapi
@@ -0,0 +1,692 @@
+namespace Omemo {
+
+ [CCode (cname = "int", cprefix = "SG_ERR_", cheader_filename = "omemo/signal_protocol.h", has_type_id = false)]
+ public enum ErrorCode {
+ [CCode (cname = "SG_SUCCESS")]
+ SUCCESS,
+ NOMEM,
+ INVAL,
+ UNKNOWN,
+ DUPLICATE_MESSAGE,
+ INVALID_KEY,
+ INVALID_KEY_ID,
+ INVALID_MAC,
+ INVALID_MESSAGE,
+ INVALID_VERSION,
+ LEGACY_MESSAGE,
+ NO_SESSION,
+ STALE_KEY_EXCHANGE,
+ UNTRUSTED_IDENTITY,
+ VRF_SIG_VERIF_FAILED,
+ INVALID_PROTO_BUF,
+ FP_VERSION_MISMATCH,
+ FP_IDENT_MISMATCH;
+ }
+
+ [CCode (cname = "SG_ERR_MINIMUM", cheader_filename = "omemo/signal_protocol.h")]
+ public const int MIN_ERROR_CODE;
+
+ [CCode (cname = "int", cprefix = "SG_LOG_", cheader_filename = "omemo/signal_protocol.h", has_type_id = false)]
+ public enum LogLevel {
+ ERROR,
+ WARNING,
+ NOTICE,
+ INFO,
+ DEBUG
+ }
+
+ [CCode (cname = "signal_throw_gerror_by_code_", cheader_filename = "omemo/signal_protocol.h")]
+ private int throw_by_code(int code, string? message = null) throws GLib.Error {
+ if (code < 0 && code > MIN_ERROR_CODE) {
+ throw new GLib.Error(-1, code, "%s: %s", message ?? "libomemo-c error", ((ErrorCode)code).to_string());
+ }
+ return code;
+ }
+
+ [CCode (cname = "int", cprefix = "SG_CIPHER_", cheader_filename = "omemo/signal_protocol.h", has_type_id = false)]
+ public enum Cipher {
+ AES_CTR_NOPADDING,
+ AES_CBC_PKCS5,
+ AES_GCM_NOPADDING
+ }
+
+ [Compact]
+ [CCode (cname = "signal_type_base", ref_function="signal_type_ref_vapi", unref_function="signal_type_unref_vapi", cheader_filename="omemo/signal_protocol_types.h,src/crypto/omemo/helper.h")]
+ public class TypeBase {
+ }
+
+ [Compact]
+ [CCode (cname = "signal_buffer", cprefix = "signal_buffer_", cheader_filename = "omemo/signal_protocol_types.h", free_function="signal_buffer_free")]
+ public class Buffer {
+ [CCode (cname = "signal_buffer_alloc")]
+ public Buffer(size_t len);
+ [CCode (cname = "signal_buffer_create")]
+ public Buffer.from(uint8[] data);
+
+ public Buffer copy();
+ public Buffer append(uint8[] data);
+ public int compare(Buffer other);
+
+ public uint8 get(int i) { return data[i]; }
+ public void set(int i, uint8 val) { data[i] = val; }
+
+ public uint8[] data { get { int x = (int)len(); unowned uint8[] res = _data(); res.length = x; return res; } }
+
+ [CCode (array_length = false, cname = "signal_buffer_data")]
+ private unowned uint8[] _data();
+ private size_t len();
+ }
+
+ [Compact]
+ [CCode (cname = "signal_int_list", cheader_filename = "omemo/signal_protocol_types.h", free_function="signal_int_list_free")]
+ public class IntList {
+ [CCode (cname = "signal_int_list_alloc")]
+ public IntList();
+ [CCode (cname = "signal_int_list_push_back")]
+ public int add(int value);
+ public uint size { [CCode (cname = "signal_int_list_size")] get; }
+ [CCode (cname = "signal_int_list_at")]
+ public int get(uint index);
+ }
+
+ [Compact]
+ [CCode (cname = "session_builder", cprefix = "session_builder_", free_function="session_builder_free", cheader_filename = "omemo/session_builder.h")]
+ public class SessionBuilder {
+ [CCode (cname = "session_builder_process_pre_key_bundle")]
+ private int process_pre_key_bundle_(PreKeyBundle pre_key_bundle);
+ [CCode (cname = "session_builder_process_pre_key_bundle_")]
+ public void process_pre_key_bundle(PreKeyBundle pre_key_bundle) throws GLib.Error {
+ throw_by_code(process_pre_key_bundle_(pre_key_bundle));
+ }
+ public int version { get; set; }
+ }
+
+ [Compact]
+ [CCode (cname = "session_pre_key_bundle", cprefix = "session_pre_key_bundle_", cheader_filename = "omemo/session_pre_key.h")]
+ public class PreKeyBundle : TypeBase {
+ public static int create(out PreKeyBundle bundle, uint32 registration_id, int device_id, uint32 pre_key_id, ECPublicKey? pre_key_public,
+ uint32 signed_pre_key_id, ECPublicKey? signed_pre_key_public, uint8[]? signed_pre_key_signature, ECPublicKey? identity_key);
+ public uint32 registration_id { get; }
+ public int device_id { get; }
+ public uint32 pre_key_id { get; }
+ public ECPublicKey pre_key { owned get; }
+ public uint32 signed_pre_key_id { get; }
+ public ECPublicKey signed_pre_key { owned get; }
+ public Buffer signed_pre_key_signature { owned get; }
+ public ECPublicKey identity_key { owned get; }
+ }
+
+ [Compact]
+ [CCode (cname = "session_pre_key", cprefix = "session_pre_key_", cheader_filename = "omemo/session_pre_key.h,src/crypto/omemo/helper.h")]
+ public class PreKeyRecord : TypeBase {
+ public static int create(out PreKeyRecord pre_key, uint32 id, ECKeyPair key_pair);
+ //public static int deserialize(out PreKeyRecord pre_key, uint8[] data, NativeContext global_context);
+ [CCode (instance_pos = 2)]
+ public int serialze(out Buffer buffer);
+ public uint32 id { get; }
+ public ECKeyPair key_pair { get; }
+ }
+
+ [Compact]
+ [CCode (cname = "session_record", cprefix = "session_record_", cheader_filename = "omemo/signal_protocol_types.h")]
+ public class SessionRecord : TypeBase {
+ public SessionState state { get; }
+ public Buffer user_record { get; }
+ }
+
+ [Compact]
+ [CCode (cname = "session_state", cprefix = "session_state_", cheader_filename = "omemo/session_state.h")]
+ public class SessionState : TypeBase {
+ //public static int create(out SessionState state, NativeContext context);
+ //public static int deserialize(out SessionState state, uint8[] data, NativeContext context);
+ //public static int copy(out SessionState state, SessionState other_state, NativeContext context);
+ [CCode (instance_pos = 2)]
+ public int serialze(out Buffer buffer);
+
+ public uint32 session_version { get; set; }
+ public ECPublicKey local_identity_key { get; set; }
+ public ECPublicKey remote_identity_key { get; set; }
+ //public Ratchet.RootKey root_key { get; set; }
+ public uint32 previous_counter { get; set; }
+ public ECPublicKey sender_ratchet_key { get; }
+ public ECKeyPair sender_ratchet_key_pair { get; }
+ //public Ratchet.ChainKey sender_chain_key { get; set; }
+ public uint32 remote_registration_id { get; set; }
+ public uint32 local_registration_id { get; set; }
+ public int needs_refresh { get; set; }
+ public ECPublicKey alice_base_key { get; set; }
+ }
+
+ [Compact]
+ [CCode (cname = "session_signed_pre_key", cprefix = "session_signed_pre_key_", cheader_filename = "omemo/session_pre_key.h")]
+ public class SignedPreKeyRecord : TypeBase {
+ public static int create(out SignedPreKeyRecord pre_key, uint32 id, uint64 timestamp, ECKeyPair key_pair, uint8[] signature, uint8[]? signature_omemo);
+ [CCode (instance_pos = 2)]
+ public int serialize(out Buffer buffer);
+
+ public uint32 id { get; }
+ public uint64 timestamp { get; }
+ public ECKeyPair key_pair { get; }
+ public uint8[] signature { [CCode (cname = "session_signed_pre_key_get_signature_")] get { int x = (int)get_signature_len(); unowned uint8[] res = get_signature(); res.length = x; return res; } }
+ public uint8[] signature_omemo { [CCode (cname = "session_signed_pre_key_get_signature_omemo_")] get { int x = (int)get_signature_omemo_len(); unowned uint8[] res = get_signature_omemo(); res.length = x; return res; } }
+
+ [CCode (array_length = false, cname = "session_signed_pre_key_get_signature")]
+ private unowned uint8[] get_signature();
+ private size_t get_signature_len();
+ [CCode (array_length = false, cname = "session_signed_pre_key_get_signature_omemo")]
+ private unowned uint8[] get_signature_omemo();
+ private size_t get_signature_omemo_len();
+ }
+
+ /**
+ * Address of an OMEMO message recipient
+ */
+ [Compact]
+ [CCode (cname = "signal_protocol_address", cprefix = "signal_protocol_address_", cheader_filename = "omemo/signal_protocol.h,src/crypto/omemo/helper.h")]
+ public class Address {
+ public Address(string name, int32 device_id);
+ public int32 device_id { get; set; }
+ public string name { owned get; set; }
+ }
+
+ /**
+ * A representation of a (group + sender + device) tuple
+ */
+ [Compact]
+ [CCode (cname = "signal_protocol_sender_key_name")]
+ public class SenderKeyName {
+ [CCode (cname = "group_id", array_length_cname="group_id_len")]
+ private char* group_id_;
+ private size_t group_id_len;
+ public Address sender;
+ }
+
+ [Compact]
+ [CCode (cname = "ec_public_key", cprefix = "ec_public_key_", cheader_filename = "omemo/curve.h,src/crypto/omemo/helper.h")]
+ public class ECPublicKey : TypeBase {
+ [CCode (cname = "curve_generate_public_key")]
+ public static int generate(out ECPublicKey public_key, ECPrivateKey private_key);
+ [CCode (instance_pos = 1, cname = "ec_public_key_serialize")]
+ private int serialize_([CCode (pos = 0)] out Buffer buffer);
+ [CCode (cname = "ec_public_key_serialize_")]
+ public uint8[] serialize() {
+ Buffer buffer;
+ int code = serialize_(out buffer);
+ if (code < 0 && code > MIN_ERROR_CODE) {
+ // Can only throw for invalid arguments or out of memory.
+ GLib.assert_not_reached();
+ }
+ return buffer.data;
+ }
+ [CCode (instance_pos = 1, cname = "ec_public_key_serialize_omemo")]
+ private int serialize_omemo_([CCode (pos = 0)] out Buffer buffer);
+ [CCode (cname = "ec_public_key_serialize_omemo_")]
+ public uint8[] serialize_omemo() {
+ Buffer buffer;
+ int code = serialize_omemo_(out buffer);
+ if (code < 0 && code > MIN_ERROR_CODE) {
+ // Can only throw for invalid arguments or out of memory.
+ GLib.assert_not_reached();
+ }
+ return buffer.data;
+ }
+ public Buffer ed { owned get; }
+ public Buffer mont { owned get; }
+ public int compare(ECPublicKey other);
+ public int memcmp(ECPublicKey other);
+ }
+
+ [Compact]
+ [CCode (cname = "ec_private_key", cprefix = "ec_private_key_", cheader_filename = "omemo/curve.h,src/crypto/omemo/helper.h")]
+ public class ECPrivateKey : TypeBase {
+ [CCode (instance_pos = 1, cname = "ec_private_key_serialize")]
+ private int serialize_([CCode (pos = 0)] out Buffer buffer);
+ [CCode (cname = "ec_private_key_serialize_")]
+ public uint8[] serialize() throws GLib.Error {
+ Buffer buffer;
+ int code = serialize_(out buffer);
+ if (code < 0 && code > MIN_ERROR_CODE) {
+ // Can only throw for invalid arguments or out of memory.
+ GLib.assert_not_reached();
+ }
+ return buffer.data;
+ }
+ public int compare(ECPublicKey other);
+ }
+
+ [Compact]
+ [CCode (cname = "ec_key_pair", cprefix="ec_key_pair_", cheader_filename = "omemo/curve.h,src/crypto/omemo/helper.h")]
+ public class ECKeyPair : TypeBase {
+ public static int create(out ECKeyPair key_pair, ECPublicKey public_key, ECPrivateKey private_key);
+ public ECPublicKey public { get; }
+ public ECPrivateKey private { get; }
+ }
+
+ [CCode (cname = "ratchet_message_keys", cheader_filename = "omemo/ratchet.h")]
+ public class MessageKeys {
+ }
+
+ [Compact]
+ [CCode (cname = "ratchet_identity_key_pair", cprefix = "ratchet_identity_key_pair_", cheader_filename = "omemo/ratchet.h,src/crypto/omemo/helper.h")]
+ public class IdentityKeyPair : TypeBase {
+ public static int create(out IdentityKeyPair key_pair, ECPublicKey public_key, ECPrivateKey private_key);
+ public int serialze(out Buffer buffer);
+ public ECPublicKey public { get; }
+ public ECPrivateKey private { get; }
+ }
+
+ [Compact]
+ [CCode (cname = "ec_public_key_list")]
+ public class PublicKeyList {}
+
+ /**
+ * The main entry point for OMEMO encrypt/decrypt operations.
+ *
+ * Once a session has been established with session_builder,
+ * this class can be used for all encrypt/decrypt operations within
+ * that session.
+ */
+ [Compact]
+ [CCode (cname = "session_cipher", cprefix = "session_cipher_", cheader_filename = "omemo/session_cipher.h", free_function = "session_cipher_free")]
+ public class SessionCipher {
+ public void* user_data { get; set; }
+ public DecryptionCallback decryption_callback { set; }
+ [CCode (cname = "session_cipher_encrypt")]
+ private int encrypt_(uint8[] padded_message, out CiphertextMessage encrypted_message);
+ [CCode (cname = "session_cipher_encrypt_")]
+ public CiphertextMessage encrypt(uint8[] padded_message) throws GLib.Error {
+ CiphertextMessage res;
+ throw_by_code(encrypt_(padded_message, out res));
+ return res;
+ }
+ [CCode (cname = "session_cipher_decrypt_pre_key_signal_message")]
+ private int decrypt_pre_key_message_(PreKeyOmemoMessage ciphertext, void* decrypt_context, out Buffer plaintext);
+ [CCode (cname = "session_cipher_decrypt_pre_key_signal_message_")]
+ public uint8[] decrypt_pre_key_message(PreKeyOmemoMessage ciphertext, void* decrypt_context = null) throws GLib.Error {
+ Buffer res;
+ throw_by_code(decrypt_pre_key_message_(ciphertext, decrypt_context, out res));
+ return res.data;
+ }
+ [CCode (cname = "session_cipher_decrypt_signal_message")]
+ private int decrypt_message_(OmemoMessage ciphertext, void* decrypt_context, out Buffer plaintext);
+ [CCode (cname = "session_cipher_decrypt_signal_message_")]
+ public uint8[] decrypt_message(OmemoMessage ciphertext, void* decrypt_context = null) throws GLib.Error {
+ Buffer res;
+ throw_by_code(decrypt_message_(ciphertext, decrypt_context, out res));
+ return res.data;
+ }
+ public int get_remote_registration_id(out uint32 remote_id);
+ [CCode (cname = "session_cipher_get_session_version")]
+ private int get_session_version_(out uint32 version);
+ [CCode (cname = "session_cipher_get_session_version_")]
+ public uint32 get_session_version() throws GLib.Error {
+ uint32 res;
+ throw_by_code(get_session_version_(out res));
+ return res;
+ }
+ public uint32 version { get; set; }
+
+ [CCode (has_target = false)]
+ public delegate int DecryptionCallback(SessionCipher cipher, Buffer plaintext, void* decrypt_context);
+ }
+
+ [CCode (cname = "int", cheader_filename = "omemo/protocol.h", has_type_id = false)]
+ public enum CiphertextType {
+ [CCode (cname = "CIPHERTEXT_SIGNAL_TYPE")]
+ SIGNAL,
+ [CCode (cname = "CIPHERTEXT_PREKEY_TYPE")]
+ PREKEY,
+ [CCode (cname = "CIPHERTEXT_SENDERKEY_TYPE")]
+ SENDERKEY,
+ [CCode (cname = "CIPHERTEXT_SENDERKEY_DISTRIBUTION_TYPE")]
+ SENDERKEY_DISTRIBUTION
+ }
+
+ [Compact]
+ [CCode (cname = "ciphertext_message", cprefix = "ciphertext_message_", cheader_filename = "omemo/protocol.h,src/crypto/omemo/helper.h")]
+ public abstract class CiphertextMessage : TypeBase {
+ public CiphertextType type { get; }
+ [CCode (cname = "ciphertext_message_get_serialized")]
+ private unowned Buffer get_serialized_();
+ public uint8[] serialized { [CCode (cname = "ciphertext_message_get_serialized_")] get {
+ return get_serialized_().data;
+ }}
+ }
+ [Compact]
+ [CCode (cname = "signal_message", cprefix = "signal_message_", cheader_filename = "omemo/protocol.h,src/crypto/omemo/helper.h")]
+ public class OmemoMessage : CiphertextMessage {
+ public ECPublicKey sender_ratchet_key { get; }
+ public uint8 message_version { get; }
+ public uint32 counter { get; }
+ public Buffer body { get; }
+ //public int verify_mac(uint8 message_version, ECPublicKey sender_identity_key, ECPublicKey receiver_identity_key, uint8[] mac, NativeContext global_context);
+ public static int is_legacy(uint8[] data);
+ }
+ [Compact]
+ [CCode (cname = "pre_key_signal_message", cprefix = "pre_key_signal_message_", cheader_filename = "omemo/protocol.h,src/crypto/omemo/helper.h")]
+ public class PreKeyOmemoMessage : CiphertextMessage {
+ public uint8 message_version { get; }
+ public ECPublicKey identity_key { get; }
+ public uint32 registration_id { get; }
+ public uint32 pre_key_id { get; }
+ public uint32 signed_pre_key_id { get; }
+ public ECPublicKey base_key { get; }
+ public OmemoMessage message { get; }
+ }
+ [Compact]
+ [CCode (cname = "sender_key_message", cprefix = "sender_key_message_", cheader_filename = "omemo/protocol.h,src/crypto/omemo/helper.h")]
+ public class SenderKeyMessage : CiphertextMessage {
+ public uint32 key_id { get; }
+ public uint32 iteration { get; }
+ public Buffer ciphertext { get; }
+ }
+ [Compact]
+ [CCode (cname = "sender_key_distribution_message", cprefix = "sender_key_distribution_message_", cheader_filename = "omemo/protocol.h,src/crypto/omemo/helper.h")]
+ public class SenderKeyDistributionMessage : CiphertextMessage {
+ public uint32 id { get; }
+ public uint32 iteration { get; }
+ public Buffer chain_key { get; }
+ public ECPublicKey signature_key { get; }
+ }
+
+ [CCode (cname = "signal_vala_encrypt", cheader_filename = "src/crypto/omemo/helper.h")]
+ private static int aes_encrypt_(out Buffer output, int cipher, uint8[] key, uint8[] iv, uint8[] plaintext, void *user_data);
+
+ [CCode (cname = "signal_vala_encrypt_")]
+ public uint8[] aes_encrypt(int cipher, uint8[] key, uint8[] iv, uint8[] plaintext) throws GLib.Error {
+ Buffer buf;
+ throw_by_code(aes_encrypt_(out buf, cipher, key, iv, plaintext, null));
+ return buf.data;
+ }
+
+ [CCode (cname = "signal_vala_decrypt", cheader_filename = "src/crypto/omemo/helper.h")]
+ private static int aes_decrypt_(out Buffer output, int cipher, uint8[] key, uint8[] iv, uint8[] ciphertext, void *user_data);
+
+ [CCode (cname = "signal_vala_decrypt_")]
+ public uint8[] aes_decrypt(int cipher, uint8[] key, uint8[] iv, uint8[] ciphertext) throws GLib.Error {
+ Buffer buf;
+ throw_by_code(aes_decrypt_(out buf, cipher, key, iv, ciphertext, null));
+ return buf.data;
+ }
+
+ [Compact]
+ [CCode (cname = "signal_context", cprefix="signal_context_", free_function="signal_context_destroy", cheader_filename = "omemo/signal_protocol.h")]
+ public class NativeContext {
+ public static int create(out NativeContext context, void* user_data);
+ public int set_crypto_provider(NativeCryptoProvider crypto_provider);
+ public int set_locking_functions(LockingFunc lock, LockingFunc unlock);
+ public int set_log_function(LogFunc log);
+ }
+ [CCode (has_target = false)]
+ public delegate void LockingFunc(void* user_data);
+ [CCode (has_target = false)]
+ public delegate void LogFunc(LogLevel level, string message, size_t len, void* user_data);
+
+ [Compact]
+ [CCode (cname = "signal_crypto_provider", cheader_filename = "omemo/signal_protocol.h")]
+ public struct NativeCryptoProvider {
+ public RandomFunc random_func;
+ public HmacSha256Init hmac_sha256_init_func;
+ public HmacSha256Update hmac_sha256_update_func;
+ public HmacSha256Final hmac_sha256_final_func;
+ public HmacSha256Cleanup hmac_sha256_cleanup_func;
+ public Sha512DigestInit sha512_digest_init_func;
+ public Sha512DigestUpdate sha512_digest_update_func;
+ public Sha512DigestFinal sha512_digest_final_func;
+ public Sha512DigestCleanup sha512_digest_cleanup_func;
+ public CryptFunc encrypt_func;
+ public CryptFunc decrypt_func;
+ public void* user_data;
+ }
+ [CCode (has_target = false)]
+ public delegate int RandomFunc(uint8[] data, void* user_data);
+ [CCode (has_target = false)]
+ public delegate int HmacSha256Init(out void* hmac_context, uint8[] key, void* user_data);
+ [CCode (has_target = false)]
+ public delegate int HmacSha256Update(void* hmac_context, uint8[] data, void* user_data);
+ [CCode (has_target = false)]
+ public delegate int HmacSha256Final(void* hmac_context, out Buffer buffer, void* user_data);
+ [CCode (has_target = false)]
+ public delegate int HmacSha256Cleanup(void* hmac_context, void* user_data);
+ [CCode (has_target = false)]
+ public delegate int Sha512DigestInit(out void* digest_context, void* user_data);
+ [CCode (has_target = false)]
+ public delegate int Sha512DigestUpdate(void* digest_context, uint8[] data, void* user_data);
+ [CCode (has_target = false)]
+ public delegate int Sha512DigestFinal(void* digest_context, out Buffer buffer, void* user_data);
+ [CCode (has_target = false)]
+ public delegate int Sha512DigestCleanup(void* digest_context, void* user_data);
+ [CCode (has_target = false)]
+ public delegate int CryptFunc(out Buffer output, Cipher cipher, uint8[] key, uint8[] iv, uint8[] content, void* user_data);
+
+ [Compact]
+ [CCode (cname = "signal_protocol_session_store", cheader_filename = "omemo/signal_protocol.h")]
+ public struct NativeSessionStore {
+ public LoadSessionFunc load_session_func;
+ public GetSubDeviceSessionsFunc get_sub_device_sessions_func;
+ public StoreSessionFunc store_session_func;
+ public ContainsSessionFunc contains_session_func;
+ public DeleteSessionFunc delete_session_func;
+ public DeleteAllSessionsFunc delete_all_sessions_func;
+ public DestroyFunc destroy_func;
+ public void* user_data;
+ }
+ [CCode (has_target = false)]
+ public delegate int LoadSessionFunc(out Buffer record, out Buffer user_record, [CCode (type = "const signal_protocol_address *")] Address address, void* user_data);
+ [CCode (has_target = false)]
+ public delegate int GetSubDeviceSessionsFunc(out IntList sessions, [CCode (array_length_type = "size_t", type = "const char *")] char[] name, void* user_data);
+ [CCode (has_target = false)]
+ public delegate int StoreSessionFunc([CCode (type = "const signal_protocol_address *")] Address address, [CCode (array_length_type = "size_t")] uint8[] record, [CCode (array_length_type = "size_t")] uint8[] user_record, void* user_data);
+ [CCode (has_target = false)]
+ public delegate int ContainsSessionFunc([CCode (type = "const signal_protocol_address *")] Address address, void* user_data);
+ [CCode (has_target = false)]
+ public delegate int DeleteSessionFunc([CCode (type = "const signal_protocol_address *")] Address address, void* user_data);
+ [CCode (has_target = false)]
+ public delegate int DeleteAllSessionsFunc([CCode (array_length_type = "size_t", type = "const char *")] char[] name, void* user_data);
+
+ [Compact]
+ [CCode (cname = "signal_protocol_identity_key_store", cheader_filename = "omemo/signal_protocol.h")]
+ public struct NativeIdentityKeyStore {
+ GetIdentityKeyPairFunc get_identity_key_pair;
+ GetLocalRegistrationIdFunc get_local_registration_id;
+ SaveIdentityFunc save_identity;
+ IsTrustedIdentityFunc is_trusted_identity;
+ DestroyFunc destroy_func;
+ void* user_data;
+ }
+ [CCode (has_target = false)]
+ public delegate int GetIdentityKeyPairFunc(out Buffer public_data, out Buffer private_data, void* user_data);
+ [CCode (has_target = false)]
+ public delegate int GetLocalRegistrationIdFunc(void* user_data, out uint32 registration_id);
+ [CCode (has_target = false)]
+ public delegate int SaveIdentityFunc([CCode (type = "const signal_protocol_address *")] Address address, [CCode (array_length_type = "size_t")] uint8[] key, void* user_data);
+ [CCode (has_target = false)]
+ public delegate int IsTrustedIdentityFunc([CCode (type = "const signal_protocol_address *")] Address address, [CCode (array_length_type = "size_t")] uint8[] key, void* user_data);
+
+ [Compact]
+ [CCode (cname = "signal_protocol_pre_key_store", cheader_filename = "omemo/signal_protocol.h")]
+ public struct NativePreKeyStore {
+ LoadPreKeyFunc load_pre_key;
+ StorePreKeyFunc store_pre_key;
+ ContainsPreKeyFunc contains_pre_key;
+ RemovePreKeyFunc remove_pre_key;
+ DestroyFunc destroy_func;
+ void* user_data;
+ }
+ [CCode (has_target = false)]
+ public delegate int LoadPreKeyFunc(out Buffer record, uint32 pre_key_id, void* user_data);
+ [CCode (has_target = false)]
+ public delegate int StorePreKeyFunc(uint32 pre_key_id, [CCode (array_length_type = "size_t")] uint8[] record, void* user_data);
+ [CCode (has_target = false)]
+ public delegate int ContainsPreKeyFunc(uint32 pre_key_id, void* user_data);
+ [CCode (has_target = false)]
+ public delegate int RemovePreKeyFunc(uint32 pre_key_id, void* user_data);
+
+
+ [Compact]
+ [CCode (cname = "signal_protocol_signed_pre_key_store", cheader_filename = "omemo/signal_protocol.h")]
+ public struct NativeSignedPreKeyStore {
+ LoadPreKeyFunc load_signed_pre_key;
+ StorePreKeyFunc store_signed_pre_key;
+ ContainsPreKeyFunc contains_signed_pre_key;
+ RemovePreKeyFunc remove_signed_pre_key;
+ DestroyFunc destroy_func;
+ void* user_data;
+ }
+
+
+ [Compact]
+ [CCode (cname = "signal_protocol_sender_key_store")]
+ public struct NativeSenderKeyStore {
+ StoreSenderKeyFunc store_sender_key;
+ LoadSenderKeyFunc load_sender_key;
+ DestroyFunc destroy_func;
+ void* user_data;
+ }
+ [CCode (has_target = false)]
+ public delegate int StoreSenderKeyFunc(SenderKeyName sender_key_name, [CCode (array_length_type = "size_t")] uint8[] record, [CCode (array_length_type = "size_t")] uint8[] user_record, void* user_data);
+ [CCode (has_target = false)]
+ public delegate int LoadSenderKeyFunc(out Buffer record, out Buffer user_record, SenderKeyName sender_key_name, void* user_data);
+
+ [CCode (has_target = false)]
+ public delegate void DestroyFunc(void* user_data);
+
+ [Compact]
+ [CCode (cname = "signal_protocol_store_context", cprefix = "signal_protocol_store_context_", free_function="signal_protocol_store_context_destroy", cheader_filename = "omemo/signal_protocol.h")]
+ public class NativeStoreContext {
+ public static int create(out NativeStoreContext context, NativeContext global_context);
+ public int set_session_store(NativeSessionStore store);
+ public int set_pre_key_store(NativePreKeyStore store);
+ public int set_signed_pre_key_store(NativeSignedPreKeyStore store);
+ public int set_identity_key_store(NativeIdentityKeyStore store);
+ public int set_sender_key_store(NativeSenderKeyStore store);
+ }
+
+
+ [CCode (cheader_filename = "omemo/signal_protocol.h")]
+ namespace Protocol {
+
+ /**
+ * Interface to the pre-key store.
+ * These functions will use the callbacks in the provided
+ * signal_protocol_store_context instance and operate in terms of higher level
+ * library data structures.
+ */
+ [CCode (lower_case_cprefix = "signal_protocol_pre_key_")]
+ namespace PreKey {
+ public int load_key(NativeStoreContext context, out PreKeyRecord pre_key, uint32 pre_key_id);
+ public int store_key(NativeStoreContext context, PreKeyRecord pre_key);
+ public int contains_key(NativeStoreContext context, uint32 pre_key_id);
+ public int remove_key(NativeStoreContext context, uint32 pre_key_id);
+ }
+
+ [CCode (lower_case_cprefix = "signal_protocol_signed_pre_key_")]
+ namespace SignedPreKey {
+ public int load_key(NativeStoreContext context, out SignedPreKeyRecord pre_key, uint32 pre_key_id);
+ public int store_key(NativeStoreContext context, SignedPreKeyRecord pre_key);
+ public int contains_key(NativeStoreContext context, uint32 pre_key_id);
+ public int remove_key(NativeStoreContext context, uint32 pre_key_id);
+ }
+
+ /**
+ * Interface to the session store.
+ * These functions will use the callbacks in the provided
+ * signal_protocol_store_context instance and operate in terms of higher level
+ * library data structures.
+ */
+ [CCode (lower_case_cprefix = "signal_protocol_session_")]
+ namespace Session {
+ public int load_session(NativeStoreContext context, out SessionRecord record, Address address, int32 version = 3);
+ public int get_sub_device_sessions(NativeStoreContext context, out IntList sessions, char[] name);
+ public int store_session(NativeStoreContext context, Address address, SessionRecord record);
+ public int contains_session(NativeStoreContext context, Address address);
+ public int delete_session(NativeStoreContext context, Address address);
+ public int delete_all_sessions(NativeStoreContext context, char[] name);
+ }
+
+ [CCode (lower_case_cprefix = "signal_protocol_identity_")]
+ namespace Identity {
+ public int get_key_pair(NativeStoreContext store_context, out IdentityKeyPair key_pair);
+ public int get_local_registration_id(NativeStoreContext store_context, out uint32 registration_id);
+ public int save_identity(NativeStoreContext store_context, Address address, ECPublicKey identity_key);
+ public int is_trusted_identity(NativeStoreContext store_context, Address address, ECPublicKey identity_key);
+ }
+
+ [CCode (cheader_filename = "omemo/key_helper.h", lower_case_cprefix = "signal_protocol_key_helper_")]
+ namespace KeyHelper {
+ [Compact]
+ [CCode (cname = "signal_protocol_key_helper_pre_key_list_node", cprefix = "signal_protocol_key_helper_key_list_", free_function="signal_protocol_key_helper_key_list_free")]
+ public class PreKeyListNode {
+ public PreKeyRecord element();
+ public PreKeyListNode next();
+ }
+
+ public int generate_identity_key_pair(out IdentityKeyPair key_pair, NativeContext global_context);
+ public int generate_registration_id(out int32 registration_id, int extended_range, NativeContext global_context);
+ public int get_random_sequence(out int value, int max, NativeContext global_context);
+ public int generate_pre_keys(out PreKeyListNode head, uint start, uint count, NativeContext global_context);
+ public int generate_last_resort_pre_key(out PreKeyRecord pre_key, NativeContext global_context);
+ public int generate_signed_pre_key(out SignedPreKeyRecord signed_pre_key, IdentityKeyPair identity_key_pair, uint32 signed_pre_key_id, uint64 timestamp, NativeContext global_context);
+ public int upgrade_signed_pre_key(ref SignedPreKeyRecord signed_pre_key, IdentityKeyPair identity_key_pair, NativeContext global_context);
+ public int generate_sender_signing_key(out ECKeyPair key_pair, NativeContext global_context);
+ public int generate_sender_key(out Buffer key_buffer, NativeContext global_context);
+ public int generate_sender_key_id(out int32 key_id, NativeContext global_context);
+ }
+ }
+
+ [CCode (cheader_filename = "omemo/curve.h")]
+ namespace Curve {
+ [CCode (cname = "curve_calculate_agreement")]
+ public int calculate_agreement([CCode (array_length = false)] out uint8[] shared_key_data, ECPublicKey public_key, ECPrivateKey private_key);
+ [CCode (cname = "curve_calculate_signature")]
+ public int calculate_signature(NativeContext context, out Buffer signature, ECPrivateKey signing_key, uint8[] message);
+ [CCode (cname = "curve_verify_signature")]
+ public int verify_signature(ECPublicKey signing_key, uint8[] message, uint8[] signature);
+ }
+
+ [CCode (cname = "session_builder_create", cheader_filename = "omemo/session_builder.h")]
+ public static int session_builder_create(out SessionBuilder builder, NativeStoreContext store, Address remote_address, NativeContext global_context);
+ [CCode (cname = "session_cipher_create", cheader_filename = "omemo/session_cipher.h")]
+ public static int session_cipher_create(out SessionCipher cipher, NativeStoreContext store, Address remote_address, NativeContext global_context);
+ [CCode (cname = "pre_key_signal_message_deserialize", cheader_filename = "omemo/protocol.h")]
+ public static int pre_key_message_deserialize(out PreKeyOmemoMessage message, uint8[] data, NativeContext global_context);
+ [CCode (cname = "pre_key_signal_message_deserialize_omemo", cheader_filename = "omemo/protocol.h")]
+ public static int pre_key_message_deserialize_omemo(out PreKeyOmemoMessage message, uint8[] data, uint32 remote_registration_id, NativeContext global_context);
+ [CCode (cname = "pre_key_signal_message_copy", cheader_filename = "omemo/protocol.h")]
+ public static int pre_key_message_copy(out PreKeyOmemoMessage message, PreKeyOmemoMessage other_message, NativeContext global_context);
+ [CCode (cname = "signal_message_create", cheader_filename = "omemo/protocol.h")]
+ public static int message_create(out OmemoMessage message, uint8 message_version, uint8[] mac_key, ECPublicKey sender_ratchet_key, uint32 counter, uint32 previous_counter, uint8[] ciphertext, ECPublicKey sender_identity_key, ECPublicKey receiver_identity_key, NativeContext global_context);
+ [CCode (cname = "signal_message_deserialize", cheader_filename = "omemo/protocol.h")]
+ public static int message_deserialize(out OmemoMessage message, uint8[] data, NativeContext global_context);
+ [CCode (cname = "signal_message_deserialize_omemo", cheader_filename = "omemo/protocol.h")]
+ public static int message_deserialize_omemo(out OmemoMessage message, uint8[] data, NativeContext global_context);
+ [CCode (cname = "signal_message_copy", cheader_filename = "omemo/protocol.h")]
+ public static int message_copy(out OmemoMessage message, OmemoMessage other_message, NativeContext global_context);
+ [CCode (cname = "curve_generate_key_pair", cheader_filename = "omemo/curve.h")]
+ public static int curve_generate_key_pair(NativeContext context, out ECKeyPair key_pair);
+ [CCode (cname = "curve_decode_private_point", cheader_filename = "omemo/curve.h")]
+ public static int curve_decode_private_point(out ECPrivateKey public_key, uint8[] key, NativeContext global_context);
+ [CCode (cname = "curve_decode_point", cheader_filename = "omemo/curve.h")]
+ public static int curve_decode_point(out ECPublicKey public_key, uint8[] key, NativeContext global_context);
+ [CCode (cname = "curve_decode_point_ed", cheader_filename = "omemo/curve.h")]
+ public static int curve_decode_point_ed(out ECPublicKey public_key, uint8[] key, NativeContext global_context);
+ [CCode (cname = "curve_decode_point_mont", cheader_filename = "omemo/curve.h")]
+ public static int curve_decode_point_mont(out ECPublicKey public_key, uint8[] key, NativeContext global_context);
+ [CCode (cname = "curve_generate_private_key", cheader_filename = "omemo/curve.h")]
+ public static int curve_generate_private_key(NativeContext context, out ECPrivateKey private_key);
+ [CCode (cname = "ratchet_identity_key_pair_deserialize", cheader_filename = "omemo/ratchet.h")]
+ public static int ratchet_identity_key_pair_deserialize(out IdentityKeyPair key_pair, uint8[] data, NativeContext global_context);
+ [CCode (cname = "session_signed_pre_key_deserialize", cheader_filename = "omemo/signed_pre_key.h")]
+ public static int session_signed_pre_key_deserialize(out SignedPreKeyRecord pre_key, uint8[] data, NativeContext global_context);
+
+ [Compact]
+ [CCode (cname = "hkdf_context", cprefix = "hkdf_", free_function = "hkdf_destroy", cheader_filename = "omemo/hkdf.h")]
+ public class NativeHkdfContext {
+ public static int create(out NativeHkdfContext context, int message_version, NativeContext global_context);
+ public int compare(NativeHkdfContext other);
+ public ssize_t derive_secrets([CCode (array_length = false)] out uint8[] output, uint8[] input_key_material, uint8[] salt, uint8[] info, size_t output_len);
+ }
+
+ [CCode (cname = "setup_signal_vala_crypto_provider", cheader_filename = "src/crypto/omemo/helper.h")]
+ public static void setup_crypto_provider(NativeContext context);
+}
diff --git a/libdino/vapi/libsrtp2.vapi b/libdino/vapi/libsrtp2.vapi
new file mode 100644
index 00000000..f8f2d297
--- /dev/null
+++ b/libdino/vapi/libsrtp2.vapi
@@ -0,0 +1,146 @@
+[CCode (cheader_filename = "srtp2/srtp.h")]
+namespace Srtp {
+public const uint MAX_TRAILER_LEN;
+
+public static ErrorStatus init();
+public static ErrorStatus shutdown();
+
+[Compact]
+[CCode (cname = "srtp_ctx_t", cprefix = "srtp_", free_function = "srtp_dealloc")]
+public class Context {
+ public static ErrorStatus create(out Context session, Policy? policy);
+
+ public ErrorStatus protect([CCode (type = "void*", array_length = false)] uint8[] rtp, ref int len);
+ public ErrorStatus unprotect([CCode (type = "void*", array_length = false)] uint8[] rtp, ref int len);
+
+ public ErrorStatus protect_rtcp([CCode (type = "void*", array_length = false)] uint8[] rtcp, ref int len);
+ public ErrorStatus unprotect_rtcp([CCode (type = "void*", array_length = false)] uint8[] rtcp, ref int len);
+
+ public ErrorStatus add_stream(ref Policy policy);
+ public ErrorStatus update_stream(ref Policy policy);
+ public ErrorStatus remove_stream(uint ssrc);
+ public ErrorStatus update(ref Policy policy);
+}
+
+[CCode (cname = "srtp_ssrc_t")]
+public struct Ssrc {
+ public SsrcType type;
+ public uint value;
+}
+
+[CCode (cname = "srtp_ssrc_type_t", cprefix = "ssrc_")]
+public enum SsrcType {
+ undefined, specific, any_inbound, any_outbound
+}
+
+[CCode (cname = "srtp_policy_t", destroy_function = "")]
+public struct Policy {
+ public Ssrc ssrc;
+ public CryptoPolicy rtp;
+ public CryptoPolicy rtcp;
+ [CCode (array_length = false)]
+ public uint8[] key;
+ public ulong num_master_keys;
+ public ulong window_size;
+ [CCode (ctype = "int")]
+ public bool allow_repeat_tx;
+ [CCode (array_length_cname = "enc_xtn_hdr_count")]
+ public int[] enc_xtn_hdr;
+ public Policy* next;
+}
+
+[CCode (cname = "srtp_crypto_policy_t")]
+public struct CryptoPolicy {
+ public CipherType cipher_type;
+ public int cipher_key_len;
+ public AuthType auth_type;
+ public int auth_key_len;
+ public int auth_tag_len;
+ public SecurityServices sec_serv;
+
+ public void set_aes_cm_128_hmac_sha1_80();
+ public void set_aes_cm_128_hmac_sha1_32();
+ public void set_aes_cm_128_null_auth();
+ public void set_aes_cm_192_hmac_sha1_32();
+ public void set_aes_cm_192_hmac_sha1_80();
+ public void set_aes_cm_192_null_auth();
+ public void set_aes_cm_256_hmac_sha1_32();
+ public void set_aes_cm_256_hmac_sha1_80();
+ public void set_aes_cm_256_null_auth();
+ public void set_aes_gcm_128_16_auth();
+ public void set_aes_gcm_128_8_auth();
+ public void set_aes_gcm_128_8_only_auth();
+ public void set_aes_gcm_256_16_auth();
+ public void set_aes_gcm_256_8_auth();
+ public void set_aes_gcm_256_8_only_auth();
+ public void set_null_cipher_hmac_null();
+ public void set_null_cipher_hmac_sha1_80();
+
+ public void set_rtp_default();
+ public void set_rtcp_default();
+
+ public void set_from_profile_for_rtp(Profile profile);
+ public void set_from_profile_for_rtcp(Profile profile);
+}
+
+[CCode (cname = "srtp_profile_t", cprefix = "srtp_profile_")]
+public enum Profile {
+ reserved, aes128_cm_sha1_80, aes128_cm_sha1_32, null_sha1_80, null_sha1_32, aead_aes_128_gcm, aead_aes_256_gcm
+}
+
+[CCode (cname = "srtp_cipher_type_id_t")]
+public struct CipherType : uint32 {}
+
+[CCode (cname = "srtp_auth_type_id_t")]
+public struct AuthType : uint32 {}
+
+[CCode (cname = "srtp_sec_serv_t", cprefix = "sec_serv_")]
+public enum SecurityServices {
+ none, conf, auth, conf_and_auth;
+}
+
+[CCode (cname = "srtp_err_status_t", cprefix = "srtp_err_status_", has_type_id = false)]
+public enum ErrorStatus {
+ ok,
+ fail,
+ bad_param,
+ alloc_fail,
+ dealloc_fail,
+ init_fail,
+ terminus,
+ auth_fail,
+ cipher_fail,
+ replay_fail,
+ replay_old,
+
+ algo_fail,
+ no_such_op,
+ no_ctx,
+ cant_check,
+ key_expired,
+ socket_err,
+ signal_err,
+ nonce_bad,
+ read_fail,
+ write_fail,
+
+ parse_err,
+ encode_err,
+ semaphore_err,
+ pfkey_err,
+ bad_mki,
+ pkt_idx_old,
+ pkt_idx_adv
+}
+
+[CCode (cname = "srtp_log_level_t", cprefix = "srtp_log_level_", has_type_id = false)]
+public enum LogLevel {
+ error, warning, info, debug
+}
+
+[CCode (cname = "srtp_log_handler_func_t")]
+public delegate void LogHandler(LogLevel level, string msg);
+
+public static ErrorStatus install_log_handler(LogHandler func);
+
+} \ No newline at end of file
diff --git a/libdino/vapi/metadata/Nice-0.1.metadata b/libdino/vapi/metadata/Nice-0.1.metadata
new file mode 100644
index 00000000..7fcf046a
--- /dev/null
+++ b/libdino/vapi/metadata/Nice-0.1.metadata
@@ -0,0 +1,11 @@
+Nice cheader_filename="nice.h"
+Address.to_string.dst type="char[]"
+Agent.new_reliable#constructor name="create_reliable"
+Agent.attach_recv skip=false
+Agent.send.buf type="uint8[]" array_length_idx=2
+AgentRecvFunc.buf type="uint8[]" array_length_idx=3
+PseudoTcpCallbacks#record skip
+PseudoTcpSocket#class skip
+
+# Not yet supported by vapigen
+# Candidate copy_function="nice_candidate_copy" free_function="nice_candidate_free" type_id=""
diff --git a/libdino/vapi/nice.vapi b/libdino/vapi/nice.vapi
new file mode 100644
index 00000000..540e2b4e
--- /dev/null
+++ b/libdino/vapi/nice.vapi
@@ -0,0 +1,386 @@
+/* nice.vapi generated by vapigen, do not modify. */
+
+[CCode (cprefix = "Nice", gir_namespace = "Nice", gir_version = "0.1", lower_case_cprefix = "nice_")]
+namespace Nice {
+ [CCode (cheader_filename = "nice.h", type_id = "nice_agent_get_type ()")]
+ public class Agent : GLib.Object {
+ [CCode (has_construct_function = false)]
+ public Agent (GLib.MainContext ctx, Nice.Compatibility compat);
+ public bool add_local_address (Nice.Address addr);
+ public uint add_stream (uint n_components);
+ public bool attach_recv (uint stream_id, uint component_id, GLib.MainContext ctx, Nice.AgentRecvFunc func);
+ [Version (since = "0.1.16")]
+ public async void close_async ();
+ [CCode (cname = "nice_agent_new_reliable", has_construct_function = false)]
+ [Version (since = "0.0.11")]
+ public Agent.create_reliable (GLib.MainContext ctx, Nice.Compatibility compat);
+ [Version (since = "0.1.6")]
+ public bool forget_relays (uint stream_id, uint component_id);
+ [CCode (has_construct_function = false)]
+ [Version (since = "0.1.15")]
+ public Agent.full (GLib.MainContext ctx, Nice.Compatibility compat, Nice.AgentOption flags);
+ public bool gather_candidates (uint stream_id);
+ [Version (since = "0.1.4")]
+ public string generate_local_candidate_sdp (Nice.Candidate candidate);
+ [Version (since = "0.1.4")]
+ public string generate_local_sdp ();
+ [Version (since = "0.1.4")]
+ public string generate_local_stream_sdp (uint stream_id, bool include_non_ice);
+ [Version (since = "0.1.8")]
+ public Nice.ComponentState get_component_state (uint stream_id, uint component_id);
+ public Nice.Candidate get_default_local_candidate (uint stream_id, uint component_id);
+ [Version (since = "0.1.5")]
+ public GLib.IOStream get_io_stream (uint stream_id, uint component_id);
+ public GLib.SList<Nice.Candidate> get_local_candidates (uint stream_id, uint component_id);
+ public bool get_local_credentials (uint stream_id, out string ufrag, out string pwd);
+ public GLib.SList<Nice.Candidate> get_remote_candidates (uint stream_id, uint component_id);
+ public bool get_selected_pair (uint stream_id, uint component_id, Nice.Candidate local, Nice.Candidate remote);
+ [Version (since = "0.1.5")]
+ public GLib.Socket? get_selected_socket (uint stream_id, uint component_id);
+ [Version (since = "0.1.4")]
+ public unowned string get_stream_name (uint stream_id);
+ [Version (since = "0.1.4")]
+ public Nice.Candidate parse_remote_candidate_sdp (uint stream_id, string sdp);
+ [Version (since = "0.1.4")]
+ public int parse_remote_sdp (string sdp);
+ [Version (since = "0.1.4")]
+ public GLib.SList<Nice.Candidate> parse_remote_stream_sdp (uint stream_id, string sdp, string ufrag, string pwd);
+ [Version (since = "0.1.16")]
+ public bool peer_candidate_gathering_done (uint stream_id);
+ [Version (since = "0.1.5")]
+ public ssize_t recv (uint stream_id, uint component_id, [CCode (array_length_cname = "buf_len", array_length_pos = 3.5, array_length_type = "gsize")] out unowned uint8[] buf, GLib.Cancellable? cancellable = null) throws GLib.Error;
+ [Version (since = "0.1.5")]
+ public int recv_messages (uint stream_id, uint component_id, [CCode (array_length_cname = "n_messages", array_length_pos = 3.5, array_length_type = "guint")] out unowned Nice.InputMessage[] messages, GLib.Cancellable? cancellable = null) throws GLib.Error;
+ [Version (since = "0.1.5")]
+ public int recv_messages_nonblocking (uint stream_id, uint component_id, [CCode (array_length_cname = "n_messages", array_length_pos = 3.5, array_length_type = "guint")] out unowned Nice.InputMessage[] messages, GLib.Cancellable? cancellable = null) throws GLib.Error;
+ [Version (since = "0.1.5")]
+ public ssize_t recv_nonblocking (uint stream_id, uint component_id, [CCode (array_length_cname = "buf_len", array_length_pos = 3.5, array_length_type = "gsize")] out unowned uint8[] buf, GLib.Cancellable? cancellable = null) throws GLib.Error;
+ public void remove_stream (uint stream_id);
+ public bool restart ();
+ [Version (since = "0.1.6")]
+ public bool restart_stream (uint stream_id);
+ public int send (uint stream_id, uint component_id, [CCode (array_length_cname = "len", array_length_pos = 2.5, array_length_type = "guint", type = "const gchar*")] uint8[] buf);
+ [Version (since = "0.1.5")]
+ public int send_messages_nonblocking (uint stream_id, uint component_id, [CCode (array_length_cname = "n_messages", array_length_pos = 3.5, array_length_type = "guint")] Nice.OutputMessage[] messages, GLib.Cancellable? cancellable = null) throws GLib.Error;
+ public bool set_local_credentials (uint stream_id, string ufrag, string pwd);
+ public void set_port_range (uint stream_id, uint component_id, uint min_port, uint max_port);
+ public bool set_relay_info (uint stream_id, uint component_id, string server_ip, uint server_port, string username, string password, Nice.RelayType type);
+ public int set_remote_candidates (uint stream_id, uint component_id, GLib.SList<Nice.Candidate> candidates);
+ public bool set_remote_credentials (uint stream_id, string ufrag, string pwd);
+ public bool set_selected_pair (uint stream_id, uint component_id, string lfoundation, string rfoundation);
+ public bool set_selected_remote_candidate (uint stream_id, uint component_id, Nice.Candidate candidate);
+ [Version (since = "0.0.10")]
+ public void set_software (string software);
+ [Version (since = "0.1.4")]
+ public bool set_stream_name (uint stream_id, string name);
+ [Version (since = "0.0.9")]
+ public void set_stream_tos (uint stream_id, int tos);
+ [NoAccessorMethod]
+ [Version (since = "0.1.8")]
+ public bool bytestream_tcp { get; }
+ [NoAccessorMethod]
+ public uint compatibility { get; construct; }
+ [NoAccessorMethod]
+ public bool controlling_mode { get; set; }
+ [NoAccessorMethod]
+ [Version (since = "0.1.14")]
+ public bool force_relay { get; set; }
+ [NoAccessorMethod]
+ public bool full_mode { get; construct; }
+ [NoAccessorMethod]
+ [Version (since = "0.1.8")]
+ public bool ice_tcp { get; set; }
+ [NoAccessorMethod]
+ [Version (since = "0.1.16")]
+ public bool ice_trickle { get; set; }
+ [NoAccessorMethod]
+ [Version (since = "0.1.8")]
+ public bool ice_udp { get; set; }
+ [NoAccessorMethod]
+ [Version (since = "0.1.8")]
+ public bool keepalive_conncheck { get; set; }
+ [NoAccessorMethod]
+ public void* main_context { get; construct; }
+ [NoAccessorMethod]
+ public uint max_connectivity_checks { get; set; }
+ [NoAccessorMethod]
+ [Version (since = "0.0.4")]
+ public string proxy_ip { owned get; set; }
+ [NoAccessorMethod]
+ [Version (since = "0.0.4")]
+ public string proxy_password { owned get; set; }
+ [NoAccessorMethod]
+ [Version (since = "0.0.4")]
+ public uint proxy_port { get; set; }
+ [NoAccessorMethod]
+ [Version (since = "0.0.4")]
+ public uint proxy_type { get; set; }
+ [NoAccessorMethod]
+ [Version (since = "0.0.4")]
+ public string proxy_username { owned get; set; }
+ [NoAccessorMethod]
+ [Version (since = "0.0.11")]
+ public bool reliable { get; construct; }
+ [NoAccessorMethod]
+ [Version (since = "0.1.15")]
+ public uint stun_initial_timeout { get; set construct; }
+ [NoAccessorMethod]
+ [Version (since = "0.1.15")]
+ public uint stun_max_retransmissions { get; set construct; }
+ [NoAccessorMethod]
+ public uint stun_pacing_timer { get; set construct; }
+ [NoAccessorMethod]
+ [Version (since = "0.1.15")]
+ public uint stun_reliable_timeout { get; set construct; }
+ [NoAccessorMethod]
+ public string stun_server { owned get; set; }
+ [NoAccessorMethod]
+ public uint stun_server_port { get; set; }
+ [NoAccessorMethod]
+ public bool support_renomination { get; set; }
+ [NoAccessorMethod]
+ [Version (since = "0.0.7")]
+ public bool upnp { get; set construct; }
+ [NoAccessorMethod]
+ [Version (since = "0.0.7")]
+ public uint upnp_timeout { get; set construct; }
+ public signal void candidate_gathering_done (uint stream_id);
+ public signal void component_state_changed (uint stream_id, uint component_id, uint state);
+ public signal void initial_binding_request_received (uint stream_id);
+ [Version (deprecated = true, deprecated_since = "0.1.8")]
+ public signal void new_candidate (uint stream_id, uint component_id, string foundation);
+ [Version (since = "0.1.8")]
+ public signal void new_candidate_full (Nice.Candidate candidate);
+ [Version (deprecated = true, deprecated_since = "0.1.8")]
+ public signal void new_remote_candidate (uint stream_id, uint component_id, string foundation);
+ [Version (since = "0.1.8")]
+ public signal void new_remote_candidate_full (Nice.Candidate candidate);
+ [Version (deprecated = true, deprecated_since = "0.1.8")]
+ public signal void new_selected_pair (uint stream_id, uint component_id, string lfoundation, string rfoundation);
+ [Version (since = "0.1.8")]
+ public signal void new_selected_pair_full (uint stream_id, uint component_id, Nice.Candidate lcandidate, Nice.Candidate rcandidate);
+ [Version (since = "0.0.11")]
+ public signal void reliable_transport_writable (uint stream_id, uint component_id);
+ [Version (since = "0.1.5")]
+ public signal void streams_removed ([CCode (array_length = false, array_null_terminated = true)] uint[] stream_ids);
+ }
+ [CCode (cheader_filename = "nice.h", copy_function = "nice_candidate_copy", free_function = "nice_candidate_free")]
+ [Compact]
+ public class Candidate {
+ public Nice.Address addr;
+ public Nice.Address base_addr;
+ public uint component_id;
+ [CCode (array_length = false)]
+ public weak char foundation[33];
+ public weak string password;
+ public uint32 priority;
+ public void* sockptr;
+ public uint stream_id;
+ public Nice.CandidateTransport transport;
+ public Nice.TurnServer turn;
+ public Nice.CandidateType type;
+ public weak string username;
+ [CCode (has_construct_function = false)]
+ public Candidate (Nice.CandidateType type);
+ public Nice.Candidate copy ();
+ [Version (since = "0.1.15")]
+ public bool equal_target (Nice.Candidate candidate2);
+ public void free ();
+ }
+ [CCode (cheader_filename = "nice.h", has_type_id = false)]
+ public struct Address {
+ [CCode (cname = "s.addr")]
+ public void* s_addr;
+ [CCode (cname = "s.ip4")]
+ public void* s_ip4;
+ [CCode (cname = "s.ip6")]
+ public void* s_ip6;
+ public void copy_to_sockaddr (void* sin);
+ public bool equal (Nice.Address b);
+ [Version (since = "0.1.8")]
+ public bool equal_no_port (Nice.Address b);
+ public void free ();
+ public uint get_port ();
+ public void init ();
+ public int ip_version ();
+ public bool is_private ();
+ public bool is_valid ();
+ public void set_from_sockaddr (void* sin);
+ public bool set_from_string (string str);
+ public void set_ipv4 (uint32 addr_ipv4);
+ public void set_ipv6 (uint8 addr_ipv6);
+ public void set_port (uint port);
+ public void to_string ([CCode (array_length = false, type = "gchar*")] char[] dst);
+ }
+ [CCode (cheader_filename = "nice.h", has_type_id = false)]
+ [Version (since = "0.1.5")]
+ public struct InputMessage {
+ [CCode (array_length_cname = "n_buffers")]
+ public weak GLib.InputVector[] buffers;
+ public int n_buffers;
+ public Nice.Address from;
+ public size_t length;
+ }
+ [CCode (cheader_filename = "nice.h", has_type_id = false)]
+ [Version (since = "0.1.5")]
+ public struct OutputMessage {
+ [CCode (array_length_cname = "n_buffers")]
+ public weak GLib.OutputVector[] buffers;
+ public int n_buffers;
+ }
+ [CCode (cheader_filename = "nice.h", cname = "TurnServer", has_type_id = false)]
+ public struct TurnServer {
+ public int ref_count;
+ public Nice.Address server;
+ public weak string username;
+ public weak string password;
+ public Nice.RelayType type;
+ }
+ [CCode (cheader_filename = "nice.h", cprefix = "NICE_AGENT_OPTION_", has_type_id = false)]
+ [Flags]
+ [Version (since = "0.1.15")]
+ public enum AgentOption {
+ REGULAR_NOMINATION,
+ RELIABLE,
+ LITE_MODE,
+ ICE_TRICKLE,
+ SUPPORT_RENOMINATION
+ }
+ [CCode (cheader_filename = "nice.h", cprefix = "NICE_CANDIDATE_TRANSPORT_", has_type_id = false)]
+ public enum CandidateTransport {
+ UDP,
+ TCP_ACTIVE,
+ TCP_PASSIVE,
+ TCP_SO
+ }
+ [CCode (cheader_filename = "nice.h", cprefix = "NICE_CANDIDATE_TYPE_", has_type_id = false)]
+ public enum CandidateType {
+ HOST,
+ SERVER_REFLEXIVE,
+ PEER_REFLEXIVE,
+ RELAYED
+ }
+ [CCode (cheader_filename = "nice.h", cprefix = "NICE_COMPATIBILITY_", has_type_id = false)]
+ public enum Compatibility {
+ RFC5245,
+ DRAFT19,
+ GOOGLE,
+ MSN,
+ WLM2009,
+ OC2007,
+ OC2007R2,
+ LAST
+ }
+ [CCode (cheader_filename = "nice.h", cprefix = "NICE_COMPONENT_STATE_", has_type_id = false)]
+ public enum ComponentState {
+ DISCONNECTED,
+ GATHERING,
+ CONNECTING,
+ CONNECTED,
+ READY,
+ FAILED,
+ LAST;
+ [Version (since = "0.1.6")]
+ public unowned string to_string ();
+ }
+ [CCode (cheader_filename = "nice.h", cprefix = "NICE_COMPONENT_TYPE_", has_type_id = false)]
+ public enum ComponentType {
+ RTP,
+ RTCP
+ }
+ [CCode (cheader_filename = "nice.h", cprefix = "NICE_NOMINATION_MODE_", has_type_id = false)]
+ [Version (since = "0.1.15")]
+ public enum NominationMode {
+ REGULAR,
+ AGGRESSIVE
+ }
+ [CCode (cheader_filename = "nice.h", cprefix = "NICE_PROXY_TYPE_", has_type_id = false)]
+ [Version (since = "0.0.4")]
+ public enum ProxyType {
+ NONE,
+ SOCKS5,
+ HTTP,
+ LAST
+ }
+ [CCode (cheader_filename = "nice.h", cname = "PseudoTcpDebugLevel", cprefix = "PSEUDO_TCP_DEBUG_", has_type_id = false)]
+ [Version (since = "0.0.11")]
+ public enum PseudoTcpDebugLevel {
+ NONE,
+ NORMAL,
+ VERBOSE
+ }
+ [CCode (cheader_filename = "nice.h", cname = "PseudoTcpShutdown", cprefix = "PSEUDO_TCP_SHUTDOWN_", has_type_id = false)]
+ [Version (since = "0.1.8")]
+ public enum PseudoTcpShutdown {
+ RD,
+ WR,
+ RDWR
+ }
+ [CCode (cheader_filename = "nice.h", cname = "PseudoTcpState", cprefix = "PSEUDO_TCP_", has_type_id = false)]
+ [Version (since = "0.0.11")]
+ public enum PseudoTcpState {
+ LISTEN,
+ SYN_SENT,
+ SYN_RECEIVED,
+ ESTABLISHED,
+ CLOSED,
+ FIN_WAIT_1,
+ FIN_WAIT_2,
+ CLOSING,
+ TIME_WAIT,
+ CLOSE_WAIT,
+ LAST_ACK
+ }
+ [CCode (cheader_filename = "nice.h", cname = "PseudoTcpWriteResult", cprefix = "WR_", has_type_id = false)]
+ [Version (since = "0.0.11")]
+ public enum PseudoTcpWriteResult {
+ SUCCESS,
+ TOO_LARGE,
+ FAIL
+ }
+ [CCode (cheader_filename = "nice.h", cprefix = "NICE_RELAY_TYPE_TURN_", has_type_id = false)]
+ public enum RelayType {
+ UDP,
+ TCP,
+ TLS
+ }
+ [CCode (cheader_filename = "nice.h", instance_pos = 4.9)]
+ public delegate void AgentRecvFunc (Nice.Agent agent, uint stream_id, uint component_id, [CCode (array_length_cname = "len", array_length_pos = 3.5, array_length_type = "guint", type = "gchar*")] uint8[] buf);
+ [CCode (cheader_filename = "nice.h", cname = "NICE_AGENT_MAX_REMOTE_CANDIDATES")]
+ public const int AGENT_MAX_REMOTE_CANDIDATES;
+ [CCode (cheader_filename = "nice.h", cname = "NICE_CANDIDATE_DIRECTION_MS_PREF_ACTIVE")]
+ public const int CANDIDATE_DIRECTION_MS_PREF_ACTIVE;
+ [CCode (cheader_filename = "nice.h", cname = "NICE_CANDIDATE_DIRECTION_MS_PREF_PASSIVE")]
+ public const int CANDIDATE_DIRECTION_MS_PREF_PASSIVE;
+ [CCode (cheader_filename = "nice.h", cname = "NICE_CANDIDATE_MAX_FOUNDATION")]
+ public const int CANDIDATE_MAX_FOUNDATION;
+ [CCode (cheader_filename = "nice.h", cname = "NICE_CANDIDATE_TRANSPORT_MS_PREF_TCP")]
+ public const int CANDIDATE_TRANSPORT_MS_PREF_TCP;
+ [CCode (cheader_filename = "nice.h", cname = "NICE_CANDIDATE_TRANSPORT_MS_PREF_UDP")]
+ public const int CANDIDATE_TRANSPORT_MS_PREF_UDP;
+ [CCode (cheader_filename = "nice.h", cname = "NICE_CANDIDATE_TYPE_PREF_HOST")]
+ public const int CANDIDATE_TYPE_PREF_HOST;
+ [CCode (cheader_filename = "nice.h", cname = "NICE_CANDIDATE_TYPE_PREF_NAT_ASSISTED")]
+ public const int CANDIDATE_TYPE_PREF_NAT_ASSISTED;
+ [CCode (cheader_filename = "nice.h", cname = "NICE_CANDIDATE_TYPE_PREF_PEER_REFLEXIVE")]
+ public const int CANDIDATE_TYPE_PREF_PEER_REFLEXIVE;
+ [CCode (cheader_filename = "nice.h", cname = "NICE_CANDIDATE_TYPE_PREF_RELAYED")]
+ public const int CANDIDATE_TYPE_PREF_RELAYED;
+ [CCode (cheader_filename = "nice.h", cname = "NICE_CANDIDATE_TYPE_PREF_RELAYED_UDP")]
+ public const int CANDIDATE_TYPE_PREF_RELAYED_UDP;
+ [CCode (cheader_filename = "nice.h", cname = "NICE_CANDIDATE_TYPE_PREF_SERVER_REFLEXIVE")]
+ public const int CANDIDATE_TYPE_PREF_SERVER_REFLEXIVE;
+ [CCode (cheader_filename = "nice.h")]
+ public static void debug_disable (bool with_stun);
+ [CCode (cheader_filename = "nice.h")]
+ public static void debug_enable (bool with_stun);
+ [CCode (cheader_filename = "nice.h")]
+ public static string? interfaces_get_ip_for_interface (string interface_name);
+ [CCode (cheader_filename = "nice.h")]
+ public static GLib.List<string> interfaces_get_local_interfaces ();
+ [CCode (cheader_filename = "nice.h")]
+ public static GLib.List<string> interfaces_get_local_ips (bool include_loopback);
+ [CCode (cheader_filename = "nice.h", cname = "pseudo_tcp_set_debug_level")]
+ [Version (since = "0.0.11")]
+ public static void pseudo_tcp_set_debug_level (Nice.PseudoTcpDebugLevel level);
+}
diff --git a/libdino/vapi/openssl.vapi b/libdino/vapi/openssl.vapi
new file mode 100644
index 00000000..57e4022c
--- /dev/null
+++ b/libdino/vapi/openssl.vapi
@@ -0,0 +1,322 @@
+[CCode (cprefix = "")]
+namespace OpenSSL {
+ [CCode (cprefix = "ASN1_", lower_case_cprefix = "ASN1_", cheader_filename = "openssl/asn1.h")]
+ namespace ASN1 {
+ [Compact]
+ [CCode (cname = "ASN1_INTEGER", lower_case_cprefix = "ASN1_INTEGER_", cprefix = "ASN1_INTEGER_", free_function = "ASN1_INTEGER_free")]
+ public class Integer {
+ public bool @set (long v);
+ }
+
+ [Compact]
+ [CCode (cname = "ASN1_TIME", lower_case_cprefix = "ASN1_TIME_", cprefix = "ASN1_TIME_", copy_function = "ASN1_TIME_dup", free_function = "ASN1_STRING_free")]
+ public class Time {
+ public bool @set (time_t t);
+ }
+ }
+ [Compact]
+ [CCode (cname = "BIO", lower_case_cprefix = "BIO_", cprefix = "BIO_", ref_function = "BIO_up_ref", ref_function_void = true, unref_function = "BIO_free", cheader_filename = "openssl/bio.h", simple_generics = true)]
+ public class BIO<T> {
+ [Compact]
+ [CCode (cname = "BIO_METHOD", lower_case_cprefix = "BIO_meth_", cprefix = "BIO_meth_", unref_function = "BIO_meth_free", simple_generics = true)]
+ public class Method<T> {
+ public Method (Type type, string name);
+ [CCode (has_target = false)]
+ public delegate int WriteFunc<T> (BIO<T> bio, [CCode (type = "const char *", array_length_type = "int")] uint8[] buf);
+ [CCode (has_target = false)]
+ public delegate int ReadFunc<T> (BIO<T> bio, [CCode (type = "char *", array_length_type = "int")] uint8[] out_buf);
+ [CCode (has_target = false, simple_generics = true)]
+ public delegate long CtrlFunc<T> (BIO<T> bio, ControlCommand cmd, long num, void* ptr);
+ public WriteFunc<T> write { get; set; }
+ public ReadFunc<T> read { get; set; }
+ public CtrlFunc<T> ctrl { get; set; }
+ }
+
+ [Flags]
+ [CCode (cname = "int")]
+ public enum Type {
+ SOURCE_SINK,
+ DGRAM,
+ }
+
+ [CCode (cname = "int", cprefix = "BIO_CTRL_", has_type_id = false)]
+ public enum ControlCommand {
+ RESET,
+ EOF,
+ SET,
+ GET,
+ PUSH,
+ POP,
+ GET_CLOSE,
+ SET_CLOSE,
+ PENDING,
+ FLUSH,
+ DUP,
+ WPENDING,
+
+ DGRAM_QUERY_MTU,
+ DGRAM_GET_MTU,
+ DGRAM_SET_MTU,
+ DGRAM_SET_PEER,
+ DGRAM_SET_NEXT_TIMEOUT,
+ DGRAM_GET_PEER,
+ DGRAM_GET_FALLBACK_MTU,
+ DGRAM_SET_DONT_FRAG,
+ DGRAM_GET_MTU_OVERHEAD,
+ }
+
+ public BIO (Method<T> type);
+ public T data { get; set; }
+
+ public void clear_retry_flags ();
+ public void set_retry_read ();
+ public bool should_read ();
+ }
+
+ [CCode (cprefix = "ERR_", lower_case_cprefix = "ERR_", cheader_filename = "openssl/err.h")]
+ namespace ERR {
+ public ulong get_error ();
+ public unowned string lib_error_string (ulong error);
+ public unowned string reason_error_string (ulong error);
+ }
+
+ [CCode (cprefix = "EVP_", lower_case_cprefix = "EVP_", cheader_filename = "openssl/evp.h")]
+ namespace EVP {
+ [Compact]
+ [CCode (cname = "EVP_PKEY", lower_case_cprefix = "EVP_PKEY_", cprefix = "EVP_PKEY_", ref_function = "EVP_PKEY_up_ref", ref_function_void = true, unref_function = "EVP_PKEY_free")]
+ public class Key {
+ public Key ();
+ [CCode (cheader_filename = "crypto/openssl/utils.h")]
+ public Key.generate_ecdsa (string curve);
+ }
+ [Compact]
+ [CCode (cname = "EVP_MD", lower_case_cprefix = "EVP_MD_", cprefix = "EVP_MD_", ref_function = "EVP_MD_up_ref", ref_function_void = true, unref_function = "EVP_MD_free")]
+ public class MessageDigest {
+ }
+
+ [Compact]
+ [CCode (cname = "EVP_CIPHER", lower_case_cprefix = "EVP_CIPHER_", cprefix = "EVP_CIPHER_", ref_function = "EVP_CIPHER_up_ref", ref_function_void = true, unref_function = "EVP_CIPHER_free")]
+ public class Cipher {
+
+ }
+
+ [Compact]
+ [CCode (cname = "EVP_CIPHER_CTX", lower_case_cprefix = "EVP_CIPHER_CTX_", cprefix = "EVP_CIPHER_CTX_", free_function = "EVP_CIPHER_CTX_free")]
+ public class CipherContext {
+ public CipherContext ();
+
+ [CCode (simple_generics = true)]
+ public int ctrl<T>(Control cmd, int p1, T? p2);
+
+ [CCode (cname = "EVP_EncryptInit")]
+ private int encrypt_init_ (Cipher? cipher, [CCode (array_length = false)] uint8[]? key, [CCode (array_length = false)] uint8[]? iv);
+ public void encrypt_init (Cipher? cipher, uint8[]? key, uint8[]? iv) throws GLib.Error {
+ throw_if_error (encrypt_init_ (cipher, key, iv));
+ }
+ [CCode (cname = "EVP_EncryptUpdate")]
+ private int encrypt_update_ ([CCode (array_length = false)] uint8[] out, out int out_len, uint8[] in);
+ public void encrypt_update (uint8[] out, out int out_len, uint8[] in) throws GLib.Error {
+ throw_if_error (encrypt_update_ (@out, out out_len, in));
+ }
+ [CCode (cname = "EVP_EncryptFinal")]
+ private int encrypt_final_ ([CCode (array_length = false)] uchar[] out, out int out_len);
+ public void encrypt_final (uint8[] out, out int out_len) throws GLib.Error {
+ throw_if_error (encrypt_final_ (@out, out out_len));
+ }
+
+ [CCode (cname = "EVP_DecryptInit")]
+ private int decrypt_init_ (Cipher? cipher, [CCode (array_length = false)] uint8[]? key, [CCode (array_length = false)] uint8[]? iv);
+ public void decrypt_init (Cipher? cipher, uint8[]? key, uint8[]? iv) throws GLib.Error {
+ throw_if_error (decrypt_init_ (cipher, key, iv));
+ }
+ [CCode (cname = "EVP_DecryptUpdate")]
+ private int decrypt_update_ ([CCode (array_length = false)] uchar[] out, out int out_len, uint8[] in);
+ public void decrypt_update (uint8[] out, out int out_len, uint8[] in) throws GLib.Error {
+ throw_if_error (decrypt_update_ (@out, out out_len, in));
+ }
+ [CCode (cname = "EVP_DecryptFinal")]
+ private int decrypt_final_ ([CCode (array_length = false)] uchar[] out, out int out_len);
+ public void decrypt_final (uint8[] out, out int out_len) throws GLib.Error {
+ throw_if_error (decrypt_final_ (@out, out out_len));
+ }
+
+ public int reset();
+ public int set_key_length (int keylen);
+ public int set_padding (int pad);
+ }
+
+ [CCode (cname = "int", cprefix = "EVP_CTRL_", has_type_id = false)]
+ public enum Control {
+ INIT,
+ SET_KEY_LENGTH,
+ GET_RC2_KEY_BITS,
+ SET_RC2_KEY_BITS,
+ GET_RC5_ROUNDS,
+ SET_RC5_ROUNDS,
+ RAND_KEY,
+ PBE_PRF_NID,
+ COPY,
+ AEAD_SET_IVLEN,
+ AEAD_GET_TAG,
+ AEAD_SET_TAG,
+ AEAD_SET_IV_FIXED,
+ GCM_SET_IVLEN,
+ GCM_GET_TAG,
+ GCM_SET_TAG,
+ GCM_SET_IV_FIXED,
+ GCM_IV_GEN,
+ CCM_SET_IVLEN,
+ CCM_GET_TAG,
+ CCM_SET_TAG,
+ CCM_SET_IV_FIXED,
+ CCM_SET_L,
+ CCM_SET_MSGLEN,
+ AEAD_TLS1_AAD,
+ AEAD_SET_MAC_KEY,
+ GCM_SET_IV_INV,
+ TLS1_1_MULTIBLOCK_AAD,
+ TLS1_1_MULTIBLOCK_ENCRYPT,
+ TLS1_1_MULTIBLOCK_DECRYPT,
+ TLS1_1_MULTIBLOCK_MAX_BUFSIZE,
+ SSL3_MASTER_SECRET,
+ SET_SBOX,
+ SBOX_USED,
+ KEY_MESH,
+ BLOCK_PADDING_MODE,
+ SET_PIPELINE_OUTPUT_BUFS,
+ SET_PIPELINE_INPUT_BUFS,
+ SET_PIPELINE_INPUT_LENS,
+ GET_IVLEN,
+ }
+
+ public static unowned Cipher? aes_128_gcm ();
+ public static unowned Cipher? aes_256_gcm ();
+
+ public static unowned MessageDigest sha256 ();
+ }
+
+ [CCode (lower_case_cprefix = "RAND_", cprefix = "RAND_", cheader_filename = "openssl/rand.h")]
+ namespace RAND {
+ public static int bytes (uint8[] buf);
+ public static int priv_bytes (uint8[] buf);
+ }
+
+ [Compact]
+ [CCode (cname = "SSL", lower_case_cprefix = "SSL_", cprefix = "SSL_", ref_function = "SSL_up_ref", ref_function_void = true, unref_function = "SSL_free", cheader_filename = "openssl/ssl.h")]
+ class SSL {
+ [Compact]
+ [CCode (cname = "SSL_CTX", lower_case_cprefix = "SSL_CTX_", cprefix = "SSL_CTX_", ref_function = "SSL_CTX_up_ref", ref_function_void = true, unref_function = "SSL_CTX_free")]
+ public class Context {
+ public Context (Method method);
+ public int set_tlsext_use_srtp (string profiles);
+ public int use_certificate (X509.Certificate certificate);
+ [CCode (cname = "SSL_CTX_use_PrivateKey")]
+ public int use_private_key (EVP.Key private_key);
+ }
+
+ [CCode (cname = "const SSL_METHOD*")]
+ public enum Method {
+ [CCode (cname = "DTLS_client_method()")]
+ DTLS_CLIENT,
+ [CCode (cname = "DTLS_server_method()")]
+ DTLS_SERVER,
+ }
+
+ [CCode (cname = "int", has_type_id = false)]
+ public enum Error {
+ NONE,
+ ZERO_RETURN,
+ WANT_READ,
+ WANT_WRITE,
+ WANT_CONNECT,
+ WANT_ACCEPT,
+ WANT_X509_LOOKUP,
+ WANT_ASYNC,
+ WANT_ASYNC_JOB,
+ WANT_CLIENT_HELLO_CB,
+ SYSCALL,
+ SSL
+ }
+
+ public SSL (Context context);
+ public BIO rbio { get; [CCode (cname="SSL_set0_rbio")] owned set; }
+ public BIO wbio { get; [CCode (cname="SSL_set0_wbio")] owned set; }
+
+ [CCode (cname = "SSL_do_handshake")]
+ private int do_handshake_ ();
+ [CCode (cname = "SSL_do_handshake_")]
+ public Error do_handshake () throws GLib.Error {
+ int ret = throw_if_error (do_handshake_ ());
+ return get_error (ret);
+ }
+ [CCode (cname = "SSL_export_keying_material")]
+ private int export_keying_material_ (uint8[] out, string label, size_t llen, [CCode (type = "const unsigned char *")] string context, size_t contextlen, bool use_context);
+ [CCode (cname = "SSL_export_keying_material_")]
+ public void export_keying_material (uint8[] out, string label, string? context = null) throws GLib.Error {
+ throw_if_error (export_keying_material_ (@out, label, label.length, context, context == null ? 0 : context.length, context != null));
+ }
+ public Error get_error (int ret);
+ public void set_accept_state ();
+ public void set_connect_state ();
+ public int want ();
+ }
+
+ [CCode (cprefix = "X509_", lower_case_cprefix = "X509_", cheader_filename = "openssl/x509.h")]
+ namespace X509 {
+ [Compact]
+ [CCode (cname = "X509", lower_case_cprefix = "X509_", cprefix = "X509_", ref_function = "X509_up_ref", ref_function_void = true, unref_function = "X509_free")]
+ public class Certificate {
+ public Certificate ();
+ public ASN1.Time not_before {
+ [CCode (cname = "X509_get_notBefore")]
+ get;
+ [CCode (cname = "X509_set_notBefore")]
+ set;
+ }
+ public ASN1.Time not_after {
+ [CCode (cname = "X509_get_notAfter")]
+ get;
+ [CCode (cname = "X509_set_notAfter")]
+ set;
+ }
+ public ASN1.Integer serial_number {
+ [CCode (cname = "X509_get_serialNumber")]
+ get;
+ [CCode (cname = "X509_set_serialNumber")]
+ set;
+ }
+ [CCode (cname = "X509_digest")]
+ private int digest_ (EVP.MessageDigest type, uchar* md, ref uint len);
+ [CCode (cname = "X509_digest_")]
+ public uint8[] digest (EVP.MessageDigest type, size_t buf_len = 512) throws GLib.Error {
+ uint8[] buf = new uint8[buf_len];
+ uint buf_out_size = (uint) buf_len;
+ throw_if_error (digest_ (type, (uchar*) buf, ref buf_out_size));
+
+ uint8[] ret = new uint8[buf_out_size];
+ for (int i = 0; i < buf_out_size; i++) {
+ ret[i] = buf[i];
+ }
+ return ret;
+ }
+ [CCode (cname = "X509_set_pubkey")]
+ public int set_public_key (EVP.Key public_key);
+ public int set_version (long version);
+ [CCode (cname = "X509_sign")]
+ private int sign_ (EVP.Key private_key, EVP.MessageDigest md);
+ [CCode (cname = "X509_sign_")]
+ public void sign (EVP.Key private_key, EVP.MessageDigest md) throws GLib.Error {
+ throw_if_error (sign_ (private_key, md));
+ }
+ }
+ }
+
+ public int throw_if_error(int res) throws GLib.Error {
+ if (res <= 0) {
+ ulong error = ERR.get_error ();
+ if (error == 0) return res;
+ throw new GLib.Error (-1, (int) error, "%s:%s", ERR.lib_error_string (error), ERR.reason_error_string (error));
+ }
+ return res;
+ }
+} \ No newline at end of file