X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=bluesky%2Fcrypto.c;h=c40c15c6aa6b756a0d1742b8fb88a9f95e5115be;hb=afdaf6a249027cccc296b8923dd95fd38736b70d;hp=defe1b334d12c9b8832c7248295fb70e0a4c7bc1;hpb=9047d936bd8bbf6acc6799e559c2766d4c487263;p=bluesky.git diff --git a/bluesky/crypto.c b/bluesky/crypto.c index defe1b3..c40c15c 100644 --- a/bluesky/crypto.c +++ b/bluesky/crypto.c @@ -13,15 +13,14 @@ #include #include -#include "bluesky.h" +#include "bluesky-private.h" + +static int DISABLE_CRYPTO = 1; /* Cryptographic operations. The rest of the BlueSky code merely calls into * the functions in this file, so this is the only point where we interface * with an external cryptographic library. */ -#define CRYPTO_BLOCK_SIZE 16 /* 128-bit AES */ -#define CRYPTO_KEY_SIZE 16 - GCRY_THREAD_OPTION_PTHREAD_IMPL; void bluesky_crypt_init() @@ -31,8 +30,6 @@ void bluesky_crypt_init() if (gcry_control(GCRYCTL_INITIALIZATION_FINISHED_P)) return; - g_print("libgcrypt not yet initialized, initializing...\n"); - if (!gcry_check_version(GCRYPT_VERSION)) g_error("libgcrypt version mismatch\n"); @@ -49,6 +46,11 @@ void bluesky_crypt_random_bytes(guchar *buf, gint len) /* Encrypt a data block. */ BlueSkyRCStr *bluesky_crypt_encrypt(BlueSkyRCStr *in, const uint8_t *key) { + if (DISABLE_CRYPTO) { + bluesky_string_ref(in); + return in; + } + gcry_error_t status; gcry_cipher_hd_t handle; @@ -89,6 +91,11 @@ BlueSkyRCStr *bluesky_crypt_encrypt(BlueSkyRCStr *in, const uint8_t *key) /* Decrypt a data block. */ BlueSkyRCStr *bluesky_crypt_decrypt(BlueSkyRCStr *in, const uint8_t *key) { + if (DISABLE_CRYPTO) { + bluesky_string_ref(in); + return in; + } + gcry_error_t status; gcry_cipher_hd_t handle;