Blame SOURCES/ntp-4.2.6p5-pwcipher.patch

2b78f7
diff -up ntp-4.2.6p5/html/keygen.html.pwcipher ntp-4.2.6p5/html/keygen.html
2b78f7
--- ntp-4.2.6p5/html/keygen.html.pwcipher	2012-11-23 13:57:26.178868018 +0100
2b78f7
+++ ntp-4.2.6p5/html/keygen.html	2012-11-23 14:44:50.952850361 +0100
2b78f7
@@ -44,8 +44,8 @@
2b78f7
 

Synopsis

2b78f7
 
2b78f7
 

<tt>ntp-keygen [ -deGHIMPT ] [ -b modulus ] [ -c [RSA-MD2 | RSA-MD5 | RSA-SHA

2b78f7
-		| RSA-SHA1 | RSA-MDC2 | RSA-RIPEMD160 | DSA-SHA | DSA-SHA1 ] ] [
2b78f7
-		-i group ]
2b78f7
+		| RSA-SHA1 | RSA-MDC2 | RSA-RIPEMD160 | DSA-SHA | DSA-SHA1 ] ]
2b78f7
+		[ -C cipher ] [ -i group ]
2b78f7
 		[ -m modulus ]  [ -p passwd2 ] [ -q passwd1 ] [ -S
2b78f7
 		[ RSA | DSA ] ] [ -s host ] [ -V nkeys ]</tt>

2b78f7
 
2b78f7
@@ -148,6 +148,9 @@
2b78f7
 	compatibility with FIPS 140-2 is required, either the <tt>DSA-SHA</tt> or <tt>DSA-SHA1</tt> scheme
2b78f7
 	must be used.
2b78f7
 
2b78f7
+
<tt>-C cipher</tt>
2b78f7
+
Select the cipher which is used to encrypt the files containing private keys. The default is three-key triple DES in CBC mode, equivalent to "-C des-ede3-cbc". The openssl tool lists ciphers available in "openssl -h" output.
2b78f7
+
2b78f7
 
<tt>-d</tt>
2b78f7
 
Enable debugging. This option displays the cryptographic data produced for eye-friendly billboards.
2b78f7
 
2b78f7
@@ -215,7 +218,7 @@
2b78f7
 
2b78f7
 

All files begin with two nonencrypted lines. The first line contains the file name in the format <tt>ntpkey_key_host.fstamp</tt>. The second line contains the datestamp in conventional Unix <tt>date</tt> format. Lines beginning with <tt>#</tt> are ignored.

2b78f7
 
2b78f7
-

The remainder of the file contains cryptographic data encoded first using ASN.1 rules, then encrypted using the DES-CBC algorithm and given password and finally written in PEM-encoded printable ASCII text preceded and followed by MIME content identifier lines.

2b78f7
+

The remainder of the file contains cryptographic data encoded first using ASN.1 rules, then encrypted using the cipher selected with <tt>-C</tt> and given password and finally written in PEM-encoded printable ASCII text preceded and followed by MIME content identifier lines.

2b78f7
 
2b78f7
 

The format of the symmetric keys file is somewhat different than the other files in the interest of backward compatibility. Since DES-CBC is deprecated in NTPv4, the only key format of interest is MD5 alphanumeric strings. Following the header the keys are entered one per line in the format

2b78f7
 
2b78f7
@@ -237,4 +240,4 @@
2b78f7
 
2b78f7
 </body>
2b78f7
 
2b78f7
-</html>
2b78f7
\ No newline at end of file
2b78f7
+</html>
2b78f7
diff -up ntp-4.2.6p5/util/ntp-keygen-opts.def.pwcipher ntp-4.2.6p5/util/ntp-keygen-opts.def
2b78f7
--- ntp-4.2.6p5/util/ntp-keygen-opts.def.pwcipher	2009-12-09 08:36:35.000000000 +0100
2b78f7
+++ ntp-4.2.6p5/util/ntp-keygen-opts.def	2012-11-23 13:57:26.211868051 +0100
2b78f7
@@ -34,6 +34,21 @@ flag = {
2b78f7
 	_EndOfDoc_;
2b78f7
 };
2b78f7
 
2b78f7
+flag = {
2b78f7
+    value     = C;
2b78f7
+    name      = cipher;
2b78f7
+    arg-type  = string;
2b78f7
+    arg-name  = cipher;
2b78f7
+    ifdef     = OPENSSL;
2b78f7
+    descrip   = "privatekey cipher";
2b78f7
+    doc = <<-  _EndOfDoc_
2b78f7
+	Select the cipher which is used to encrypt the files containing
2b78f7
+	private keys.  The default is three-key triple DES in CBC mode,
2b78f7
+	equivalent to "-C des-ede3-cbc".  The openssl tool lists ciphers
2b78f7
+	available in "openssl -h" output.
2b78f7
+	_EndOfDoc_;
2b78f7
+};
2b78f7
+
2b78f7
 #include       debug-opt.def
2b78f7
 
2b78f7
 flag = {
2b78f7
@@ -134,7 +149,7 @@ flag = {
2b78f7
     descrip   = "output private password";
2b78f7
     doc = <<-  _EndOfDoc_
2b78f7
 	Encrypt generated files containing private data with the specified
2b78f7
-	password and the DES-CBC algorithm.
2b78f7
+	password and the cipher selected with -C/--cipher.
2b78f7
 	_EndOfDoc_;
2b78f7
 };
2b78f7
 
2b78f7
diff -up ntp-4.2.6p5/util/ntp-keygen.c.pwcipher ntp-4.2.6p5/util/ntp-keygen.c
2b78f7
--- ntp-4.2.6p5/util/ntp-keygen.c.pwcipher	2012-11-23 13:57:26.202868041 +0100
2b78f7
+++ ntp-4.2.6p5/util/ntp-keygen.c	2012-11-23 13:57:26.212868052 +0100
2b78f7
@@ -169,6 +169,7 @@ char	*passwd1 = NULL;	/* input private k
2b78f7
 char	*passwd2 = NULL;	/* output private key password */
2b78f7
 #ifdef OPENSSL
2b78f7
 long	d0, d1, d2, d3;		/* callback counters */
2b78f7
+const EVP_CIPHER * cipher = NULL;
2b78f7
 #endif /* OPENSSL */
2b78f7
 
2b78f7
 #ifdef SYS_WINNT
2b78f7
@@ -236,6 +237,7 @@ main(
2b78f7
 	const EVP_MD *ectx;	/* EVP digest */
2b78f7
 	char	pathbuf[MAXFILENAME + 1];
2b78f7
 	const char *scheme = NULL; /* digest/signature scheme */
2b78f7
+	const char *ciphername = NULL; /* to encrypt priv. key */
2b78f7
 	char	*exten = NULL;	/* private extension */
2b78f7
 	char	*grpkey = NULL;	/* identity extension */
2b78f7
 	int	nid;		/* X509 digest/signature scheme */
2b78f7
@@ -322,6 +324,9 @@ main(
2b78f7
 	if (HAVE_OPT( CERTIFICATE ))
2b78f7
 		scheme = OPT_ARG( CERTIFICATE );
2b78f7
 
2b78f7
+	if (HAVE_OPT( CIPHER ))
2b78f7
+		ciphername = OPT_ARG( CIPHER );
2b78f7
+
2b78f7
 	if (HAVE_OPT( SUBJECT_NAME ))
2b78f7
 		hostname = strdup(OPT_ARG( SUBJECT_NAME ));
2b78f7
 
2b78f7
@@ -418,6 +423,13 @@ main(
2b78f7
 	}
2b78f7
 	if (scheme == NULL)
2b78f7
 		scheme = "RSA-MD5";
2b78f7
+	if (ciphername == NULL)
2b78f7
+		ciphername = "des-ede3-cbc";
2b78f7
+	cipher = EVP_get_cipherbyname(ciphername);
2b78f7
+	if (cipher == NULL) {
2b78f7
+		fprintf(stderr, "Unknown cipher %s\n", ciphername);
2b78f7
+		exit(-1);
2b78f7
+	}
2b78f7
 	if (groupname == NULL)
2b78f7
 		groupname = hostname;
2b78f7
 	fprintf(stderr, "Using host %s group %s\n", hostname,
2b78f7
@@ -520,9 +532,9 @@ main(
2b78f7
 		BN_copy(rsa->q, BN_value_one());
2b78f7
 		pkey = EVP_PKEY_new();
2b78f7
 		EVP_PKEY_assign_RSA(pkey, rsa);
2b78f7
-		PEM_write_PrivateKey(stdout, pkey, NULL, NULL, 0, NULL,
2b78f7
-		    NULL);
2b78f7
-		fclose(stdout);
2b78f7
+		PEM_write_PKCS8PrivateKey(stdout, pkey, NULL, NULL, 0,
2b78f7
+		    NULL, NULL);
2b78f7
+		fflush(stdout);
2b78f7
 		if (debug)
2b78f7
 			RSA_print_fp(stderr, rsa, 0);
2b78f7
 	}
2b78f7
@@ -542,9 +554,9 @@ main(
2b78f7
 		rsa = pkey_gqkey->pkey.rsa;
2b78f7
 		pkey = EVP_PKEY_new();
2b78f7
 		EVP_PKEY_assign_RSA(pkey, rsa);
2b78f7
-		PEM_write_PrivateKey(stdout, pkey,
2b78f7
-		    EVP_des_cbc(), NULL, 0, NULL, passwd2);
2b78f7
-		fclose(stdout);
2b78f7
+		PEM_write_PKCS8PrivateKey(stdout, pkey, cipher, NULL, 0,
2b78f7
+		    NULL, passwd2);
2b78f7
+		fflush(stdout);
2b78f7
 		if (debug)
2b78f7
 			RSA_print_fp(stderr, rsa, 0);
2b78f7
 	}
2b78f7
@@ -584,9 +596,9 @@ main(
2b78f7
 		BN_copy(dsa->priv_key, BN_value_one());
2b78f7
 		pkey = EVP_PKEY_new();
2b78f7
 		EVP_PKEY_assign_DSA(pkey, dsa);
2b78f7
-		PEM_write_PrivateKey(stdout, pkey, NULL, NULL, 0, NULL,
2b78f7
-		    NULL);
2b78f7
-		fclose(stdout);
2b78f7
+		PEM_write_PKCS8PrivateKey(stdout, pkey, NULL, NULL, 0,
2b78f7
+		    NULL, NULL);
2b78f7
+		fflush(stdout);
2b78f7
 		if (debug)
2b78f7
 			DSA_print_fp(stderr, dsa, 0);
2b78f7
 	}
2b78f7
@@ -607,9 +619,9 @@ main(
2b78f7
 		dsa = pkey_iffkey->pkey.dsa;
2b78f7
 		pkey = EVP_PKEY_new();
2b78f7
 		EVP_PKEY_assign_DSA(pkey, dsa);
2b78f7
-		PEM_write_PrivateKey(stdout, pkey, EVP_des_cbc(), NULL,
2b78f7
-		    0, NULL, passwd2);
2b78f7
-		fclose(stdout);
2b78f7
+		PEM_write_PKCS8PrivateKey(stdout, pkey, cipher, NULL, 0,
2b78f7
+		    NULL, passwd2);
2b78f7
+		fflush(stdout);
2b78f7
 		if (debug)
2b78f7
 			DSA_print_fp(stderr, dsa, 0);
2b78f7
 	}
2b78f7
@@ -645,9 +657,9 @@ main(
2b78f7
 		fprintf(stdout, "# %s\n# %s\n", filename,
2b78f7
 		    ctime(&epoch));
2b78f7
 		pkey = pkey_mvpar[2];
2b78f7
-		PEM_write_PrivateKey(stdout, pkey, NULL, NULL, 0, NULL,
2b78f7
-		    NULL);
2b78f7
-		fclose(stdout);
2b78f7
+		PEM_write_PKCS8PrivateKey(stdout, pkey, NULL, NULL, 0,
2b78f7
+		    NULL, NULL);
2b78f7
+		fflush(stdout);
2b78f7
 		if (debug)
2b78f7
 			DSA_print_fp(stderr, pkey->pkey.dsa, 0);
2b78f7
 	}
2b78f7
@@ -664,9 +676,9 @@ main(
2b78f7
 		fprintf(stdout, "# %s\n# %s\n", filename,
2b78f7
 		    ctime(&epoch));
2b78f7
 		pkey = pkey_mvpar[1];
2b78f7
-		PEM_write_PrivateKey(stdout, pkey, EVP_des_cbc(), NULL,
2b78f7
-		    0, NULL, passwd2);
2b78f7
-		fclose(stdout);
2b78f7
+		PEM_write_PKCS8PrivateKey(stdout, pkey, cipher, NULL, 0,
2b78f7
+		    NULL, passwd2);
2b78f7
+		fflush(stdout);
2b78f7
 		if (debug)
2b78f7
 			DSA_print_fp(stderr, pkey->pkey.dsa, 0);
2b78f7
 	}
2b78f7
@@ -886,7 +898,7 @@ gen_rsa(
2b78f7
 		str = fheader("RSAhost", id, hostname);
2b78f7
 	pkey = EVP_PKEY_new();
2b78f7
 	EVP_PKEY_assign_RSA(pkey, rsa);
2b78f7
-	PEM_write_PrivateKey(str, pkey, EVP_des_cbc(), NULL, 0, NULL,
2b78f7
+	PEM_write_PKCS8PrivateKey(str, pkey, cipher, NULL, 0, NULL,
2b78f7
 	    passwd1);
2b78f7
 	fclose(str);
2b78f7
 	if (debug)
2b78f7
@@ -941,7 +953,7 @@ gen_dsa(
2b78f7
 	str = fheader("DSAsign", id, hostname);
2b78f7
 	pkey = EVP_PKEY_new();
2b78f7
 	EVP_PKEY_assign_DSA(pkey, dsa);
2b78f7
-	PEM_write_PrivateKey(str, pkey, EVP_des_cbc(), NULL, 0, NULL,
2b78f7
+	PEM_write_PKCS8PrivateKey(str, pkey, cipher, NULL, 0, NULL,
2b78f7
 	    passwd1);
2b78f7
 	fclose(str);
2b78f7
 	if (debug)
2b78f7
@@ -1108,7 +1120,7 @@ gen_iffkey(
2b78f7
 	str = fheader("IFFkey", id, groupname);
2b78f7
 	pkey = EVP_PKEY_new();
2b78f7
 	EVP_PKEY_assign_DSA(pkey, dsa);
2b78f7
-	PEM_write_PrivateKey(str, pkey, EVP_des_cbc(), NULL, 0, NULL,
2b78f7
+	PEM_write_PKCS8PrivateKey(str, pkey, cipher, NULL, 0, NULL,
2b78f7
 	    passwd1);
2b78f7
 	fclose(str);
2b78f7
 	if (debug)
2b78f7
@@ -1305,7 +1317,7 @@ gen_gqkey(
2b78f7
 	str = fheader("GQkey", id, groupname);
2b78f7
 	pkey = EVP_PKEY_new();
2b78f7
 	EVP_PKEY_assign_RSA(pkey, rsa);
2b78f7
-	PEM_write_PrivateKey(str, pkey, EVP_des_cbc(), NULL, 0, NULL,
2b78f7
+	PEM_write_PKCS8PrivateKey(str, pkey, cipher, NULL, 0, NULL,
2b78f7
 	    passwd1);
2b78f7
 	fclose(str);
2b78f7
 	if (debug)
2b78f7
@@ -1710,7 +1722,7 @@ gen_mvkey(
2b78f7
 	BN_copy(dsa->pub_key, b);
2b78f7
 	pkey = EVP_PKEY_new();
2b78f7
 	EVP_PKEY_assign_DSA(pkey, dsa);
2b78f7
-	PEM_write_PrivateKey(str, pkey, EVP_des_cbc(), NULL, 0, NULL,
2b78f7
+	PEM_write_PKCS8PrivateKey(str, pkey, cipher, NULL, 0, NULL,
2b78f7
 	    passwd1);
2b78f7
 	evpars[i++] = pkey;
2b78f7
 	if (debug)
2b78f7
@@ -1736,7 +1748,7 @@ gen_mvkey(
2b78f7
 	dsa2->pub_key = BN_dup(ghat);
2b78f7
 	pkey1 = EVP_PKEY_new();
2b78f7
 	EVP_PKEY_assign_DSA(pkey1, dsa2);
2b78f7
-	PEM_write_PrivateKey(str, pkey1, EVP_des_cbc(), NULL, 0, NULL,
2b78f7
+	PEM_write_PKCS8PrivateKey(str, pkey1, cipher, NULL, 0, NULL,
2b78f7
 	    passwd1);
2b78f7
 	evpars[i++] = pkey1;
2b78f7
 	if (debug)
2b78f7
@@ -1762,7 +1774,7 @@ gen_mvkey(
2b78f7
 		sdsa->pub_key = BN_dup(xhat[j]);
2b78f7
 		pkey1 = EVP_PKEY_new();
2b78f7
 		EVP_PKEY_set1_DSA(pkey1, sdsa);
2b78f7
-		PEM_write_PrivateKey(str, pkey1, EVP_des_cbc(), NULL, 0,
2b78f7
+		PEM_write_PKCS8PrivateKey(str, pkey1, cipher, NULL, 0,
2b78f7
 		    NULL, passwd1);
2b78f7
 		evpars[i++] = pkey1;
2b78f7
 		if (debug)