util  Check-in [37cc6dd034]

Overview
Comment:fix addpw/genpw bugs
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 37cc6dd0341e77763f6eff2be104d834ee93244c36ffb1936647379de861d831
User & Date: lexi on 2019-08-16 02:00:36
Other Links: manifest | tags
Context
2019-08-16
02:03
minor tweaks check-in: a2d840e698 user: lexi tags: trunk
02:00
fix addpw/genpw bugs check-in: 37cc6dd034 user: lexi tags: trunk
01:56
fix so it compiles in non-clipboard mode check-in: 6f480eda3f user: lexi tags: trunk
Changes

Modified kpw.d/kpw.c from [baa5c21b20] to [e965fe4be4].

690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
...
707
708
709
710
711
712
713

714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
						e = pwread(true, pw_conf, NULL, _str("- confirm: "));
						if (e != ok) return e;
						if (strcmp(pw,pw_conf) != 0)
							return bad_pw_match;
					}
					acct_pw = pw;
				} else acct_pw = prm, pwlen = strlen(prm);

			} else if (op == genpw) {
				unsigned long long len; 
				if (prm != NULL) {
					alert(a_debug, "converting length parameter to integer");
					bad e = katoi(10, prm, &len);
					if (e != ok) return bad_num;
				} else alert(a_debug, "using default password length"),
................................................................................
				alert(a_debug, "generating new password");
				if (mkpw(mode, pw, len) == bad_entropy) return bad_entropy;
				if (print || !tty_out) {
					write(1, pw, len);
					if(tty_out) write(1, "\n", 1);
				}
				pwlen = len;

			}
#			ifdef _CLIPBOARD
				if (copy_pw) copy(pw, pwlen);
#			endif
			alert(a_debug, "encoding database entry");
			db_sz acctlen = strlen(acct);
			byte plaintext[1 + acctlen +
			               1 + pwlen];
			plaintext[0] = acctlen;
			strncpy(plaintext + 1, acct, acctlen);
			plaintext[1 + acctlen] = pwlen;
			strncpy(plaintext + acctlen + 2, pw, pwlen);
			hexdump(plaintext, sz(plaintext));

			alert(a_debug, "enciphering database entry");

			byte ciphertext[sz(plaintext) + crypto_box_SEALBYTES];
			crypto_box_seal(ciphertext, plaintext, sz(plaintext), key);
			hexdump(ciphertext, sz(ciphertext));







<







 







>











|







690
691
692
693
694
695
696

697
698
699
700
701
702
703
...
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
						e = pwread(true, pw_conf, NULL, _str("- confirm: "));
						if (e != ok) return e;
						if (strcmp(pw,pw_conf) != 0)
							return bad_pw_match;
					}
					acct_pw = pw;
				} else acct_pw = prm, pwlen = strlen(prm);

			} else if (op == genpw) {
				unsigned long long len; 
				if (prm != NULL) {
					alert(a_debug, "converting length parameter to integer");
					bad e = katoi(10, prm, &len);
					if (e != ok) return bad_num;
				} else alert(a_debug, "using default password length"),
................................................................................
				alert(a_debug, "generating new password");
				if (mkpw(mode, pw, len) == bad_entropy) return bad_entropy;
				if (print || !tty_out) {
					write(1, pw, len);
					if(tty_out) write(1, "\n", 1);
				}
				pwlen = len;
				acct_pw = pw;
			}
#			ifdef _CLIPBOARD
				if (copy_pw) copy(pw, pwlen);
#			endif
			alert(a_debug, "encoding database entry");
			db_sz acctlen = strlen(acct);
			byte plaintext[1 + acctlen +
			               1 + pwlen];
			plaintext[0] = acctlen;
			strncpy(plaintext + 1, acct, acctlen);
			plaintext[1 + acctlen] = pwlen;
			strncpy(plaintext + acctlen + 2, acct_pw, pwlen);
			hexdump(plaintext, sz(plaintext));

			alert(a_debug, "enciphering database entry");

			byte ciphertext[sz(plaintext) + crypto_box_SEALBYTES];
			crypto_box_seal(ciphertext, plaintext, sz(plaintext), key);
			hexdump(ciphertext, sz(ciphertext));