57 if (secret_len < 32) {
58 g_debug(
"secret corrupted\n");
63 err = gcry_cipher_open(phd, GCRY_CIPHER_3DES, GCRY_CIPHER_MODE_CBC, 0);
66 g_debug(
"gcry_cipher_open failure: %s\n", gcry_strerror(err));
71 err = gcry_cipher_setkey((*phd), secret, 24);
74 g_debug(
"gcry_cipher_setkey failure: %s\n", gcry_strerror(err));
76 gcry_cipher_close((*phd));
80 err = gcry_cipher_setiv((*phd), secret + 24, 8);
83 g_debug(
"gcry_cipher_setiv failure: %s\n", gcry_strerror(err));
85 gcry_cipher_close((*phd));
103 if (!str || str[0] ==
'\0')
109 buf_len = strlen(str);
111 buf_len += 8 - buf_len % 8;
112 buf = (guchar*)g_malloc(buf_len);
113 memset(buf, 0, buf_len);
114 memcpy(buf, str, strlen(str));
116 err = gcry_cipher_encrypt(hd, buf, buf_len, NULL, 0);
119 g_debug(
"gcry_cipher_encrypt failure: %s/%s\n",
123 gcry_cipher_close(hd);
127 result = g_base64_encode(buf, buf_len);
130 gcry_cipher_close(hd);
137 TRACE_CALL(__func__);
143 if (!str || str[0] ==
'\0')
149 buf = g_base64_decode(str, &buf_len);
158 err = gcry_cipher_decrypt(
166 g_debug(
"gcry_cipher_decrypt failure: %s/%s\n",
170 gcry_cipher_close(hd);
174 gcry_cipher_close(hd);
177 buf[buf_len - 1] =
'\0';
186 TRACE_CALL(__func__);
192 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)