56 if (secret_len < 32) {
57 g_debug(
"secret corrupted\n");
62 err = gcry_cipher_open(phd, GCRY_CIPHER_3DES, GCRY_CIPHER_MODE_CBC, 0);
65 g_debug(
"gcry_cipher_open failure: %s\n", gcry_strerror(err));
70 err = gcry_cipher_setkey((*phd), secret, 24);
73 g_debug(
"gcry_cipher_setkey failure: %s\n", gcry_strerror(err));
75 gcry_cipher_close((*phd));
79 err = gcry_cipher_setiv((*phd), secret + 24, 8);
82 g_debug(
"gcry_cipher_setiv failure: %s\n", gcry_strerror(err));
84 gcry_cipher_close((*phd));
102 if (!str || str[0] ==
'\0')
108 buf_len = strlen(str);
110 buf_len += 8 - buf_len % 8;
111 buf = (guchar*)g_malloc(buf_len);
112 memset(buf, 0, buf_len);
113 memcpy(buf, str, strlen(str));
115 err = gcry_cipher_encrypt(hd, buf, buf_len, NULL, 0);
118 g_debug(
"gcry_cipher_encrypt failure: %s/%s\n",
122 gcry_cipher_close(hd);
126 result = g_base64_encode(buf, buf_len);
129 gcry_cipher_close(hd);
136 TRACE_CALL(__func__);
142 if (!str || str[0] ==
'\0')
148 buf = g_base64_decode(str, &buf_len);
151 g_debug (
"%s base64 encoded as %p with length %lu",
157 err = gcry_cipher_decrypt(
165 g_debug(
"gcry_cipher_decrypt failure: %s/%s\n",
169 gcry_cipher_close(hd);
171 return g_strdup(str);
174 gcry_cipher_close(hd);
178 buf[buf_len - 1] =
'\0';
187 TRACE_CALL(__func__);
193 TRACE_CALL(__func__);
gchar * remmina_crypt_decrypt(const gchar *str)
gchar * remmina_crypt_encrypt(const gchar *str)
static gboolean remmina_crypt_init(gcry_cipher_hd_t *phd)