Forráskód Böngészése

vcc: check that the crypting is really enabled

intirain 4 éve
szülő
commit
161d364717
4 módosított fájl, 25 hozzáadás és 6 törlés
  1. 1 1
      Makefile
  2. 13 0
      crypt.c
  3. 2 2
      include/vcc/version.h
  4. 9 3
      main.c

+ 1 - 1
Makefile

@@ -1,6 +1,6 @@
 VCC_MAJOR 		= 1
 VCC_MINOR 		= 11
-VCC_PATCH 		= 0
+VCC_PATCH 		= 1
 VCC_STR 		= -rc 
 
 VCC_COMPILE_TIME 	= $(shell date)

+ 13 - 0
crypt.c

@@ -47,6 +47,7 @@
 
 int 			keysize, blksize;
 int 			msgsize;
+int 			crypt_disabled = 0;
 
 char 			*key, *iv;
 gcry_cipher_hd_t 	hd;
@@ -104,6 +105,12 @@ int crypt_init(void *k, void *v) {
 int encrypt(char *msg) {
 	gcry_error_t err;
 
+	if (crypt_disabled) {
+		fprintf(stderr, "error: crypting disabled. \n");
+
+		return 1;
+	}
+
 	if (unlikely((err = gcry_cipher_encrypt(hd, msg, msgsize, NULL, 0)))) {
 		show_err(err);
 
@@ -117,6 +124,12 @@ int encrypt(char *msg) {
 int decrypt(char *msg) {
 	gcry_error_t err;
 
+	if (crypt_disabled) {
+		fprintf(stderr, "error: crypt disabled. \n");
+
+		return 1;
+	}
+
 	if (unlikely((err = gcry_cipher_decrypt(hd, msg, msgsize, NULL, 0)))) {
 		show_err(err);
 

+ 2 - 2
include/vcc/version.h

@@ -1,2 +1,2 @@
-#define VCC_VERSION "VCC 1.11.0 Sun Apr 17 13:51:33 CST 2022 root"
-#define VCC_SEMVER "vcc 1.11.0-rc "
+#define VCC_VERSION "VCC 1.11.1 Fri Apr 22 20:28:40 CST 2022 root"
+#define VCC_SEMVER "vcc 1.11.1-rc "

+ 9 - 3
main.c

@@ -63,13 +63,13 @@ int do_cmd_lself(char *);
 
 int init_socket(const char *server_addr, int server_port);
 
-
 int fd;
 int rate;
 
 char usrname[USRNAME_SIZE];
 struct klist_node banned_people = KLIST_NODE_INIT(&banned_people);
 
+extern int crypt_disabled;
 extern int current_sid;
 
 static char const *help_msg = {
@@ -127,11 +127,17 @@ int vos_login(void) {
 	vcc_login(usrname, passwd);
 	do_cmd_lself(NULL);
 
+	show_algo_info();
+
 	/* crypt_init will copy that into a heap buffer */
 
-	if (!(key = getenv("VOS_KEY")) || !(iv = getenv("VOS_IV"))) 
+	if (!(key = getenv("VOS_KEY")) || !(iv = getenv("VOS_IV"))) {
+		fprintf(stderr, "warning: crypting disabled. \n");
+		crypt_disabled = 1;
+
 		return 1;
-	
+	}
+
 	crypt_init(key, iv);
 
 	return 1;