|
@@ -37,11 +37,7 @@
|
|
|
* ****ing ****ing, that you can't know what you're doing. */
|
|
* ****ing ****ing, that you can't know what you're doing. */
|
|
|
|
|
|
|
|
|
|
|
|
|
-/* i tried aes256 but sometimes i get something garbled. then i
|
|
|
|
|
- * tried des, that traditional alghrithm created by ibm and
|
|
|
|
|
- * it really works. */
|
|
|
|
|
-
|
|
|
|
|
-#define CIPHER_ALGO GCRY_CIPHER_DES
|
|
|
|
|
|
|
+#define CIPHER_ALGO GCRY_CIPHER_AES256
|
|
|
#define show_err(err) fprintf(stderr, "error: %s: %s\n", \
|
|
#define show_err(err) fprintf(stderr, "error: %s: %s\n", \
|
|
|
gcry_strsource(err), gcry_strerror(err))
|
|
gcry_strsource(err), gcry_strerror(err))
|
|
|
|
|
|
|
@@ -112,6 +108,12 @@ int encrypt(char *msg) {
|
|
|
return 1;
|
|
return 1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if (unlikely((err = gcry_cipher_reset(hd)))) {
|
|
|
|
|
+ show_err(err);
|
|
|
|
|
+
|
|
|
|
|
+ return 1;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (unlikely((err = gcry_cipher_encrypt(hd, msg, msgsize, NULL, 0)))) {
|
|
if (unlikely((err = gcry_cipher_encrypt(hd, msg, msgsize, NULL, 0)))) {
|
|
|
show_err(err);
|
|
show_err(err);
|
|
|
|
|
|
|
@@ -130,6 +132,12 @@ int decrypt(char *msg) {
|
|
|
|
|
|
|
|
return 1;
|
|
return 1;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ if (unlikely((err = gcry_cipher_reset(hd)))) {
|
|
|
|
|
+ show_err(err);
|
|
|
|
|
+
|
|
|
|
|
+ return 1;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
if (unlikely((err = gcry_cipher_decrypt(hd, msg, msgsize, NULL, 0)))) {
|
|
if (unlikely((err = gcry_cipher_decrypt(hd, msg, msgsize, NULL, 0)))) {
|
|
|
show_err(err);
|
|
show_err(err);
|