Check-in [d3319fd18b]
Overview
Comment:Refactored DH generation to not need a separate file for DH data. Added missing header files to generated file.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | dh
Files: files | file ages | folders
SHA3-256: d3319fd18ba4fcbfd4a0dd1f6a07cf9c9f2122e5ca4810c1f042f737e57d77ac
User & Date: bohagan on 2023-12-28 23:15:47
Other Links: branch diff | manifest | tags
Context
2023-12-29
00:46
Use env var for OpenSSL executable path. Source: https://core.tcl-lang.org/tcltls/tktview/034c8d2587 check-in: e63b467c48 user: bohagan tags: dh
2023-12-28
23:15
Refactored DH generation to not need a separate file for DH data. Added missing header files to generated file. check-in: d3319fd18b user: bohagan tags: dh
21:27
DH Changes for OpenSSL 3.0 Source: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=275160 and https://cgit.freebsd.org/ports/tree/devel/tcltls/files/dh_params.h?id=2ed62c75d1230bbe8268a1a3c54de2972d50dcf8 check-in: 54c35183c2 user: bohagan tags: dh
Changes

Modified generic/gen_dh_params from [e07a009868] to [791deedc56].

22
23
24
25
26
27
28







29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52

53
54
55
56
57


58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
	fi

	return 1
}

# OpenSSL 3.0 openssl-dhparam has no "-C" option, so we emulate it here
openssl_dhparam3() {







	if openssl dhparam -text 2048 | \
	    sed -E -e '/^---/,/^---/d' \
		-e '/(DH|prime|generator)/d' \
		-e 's/([0-9a-h]{2})(:|$$)/0x\1, /g' \
		-e generateddh.txt
	then
	else
		return 0
	fi


	cat << \_EOF_
/*
 * OpenSSL no longer offers the "-C" option for its dhparam
 * subcommand, so we keep our own C-code here...
 */

static DH * get_dhParams(void) {
	static unsigned char dhp_2048[] = {
#include "generateddh.txt"
	};
	static unsigned char dhg_2048[] = {
		0x02
	};

	DH	       *dh = DH_new();
	BIGNUM	       *p, *g;

	if (dh == NULL)
		return NULL;


	p = BN_bin2bn(dhp_2048, sizeof(dhp_2048), NULL);
	g = BN_bin2bn(dhg_2048, sizeof(dhg_2048), NULL);
	if (p == NULL || g == NULL
	    || !DH_set0_pqg(dh, p, NULL, g)) {
		DH_free(dh);
		BN_free(p);
		BN_free(g);
		return NULL;
	}
	return dh;
}
_EOF_

	return 0
}







>
>
>
>
>
>
>
|

|
|
<
<
<
<
<

<

<
<
<
<
<
<
<
<

|
|

>
|
|

|

>
>
|
|
|
|



|







22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39





40

41








42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
	fi

	return 1
}

# OpenSSL 3.0 openssl-dhparam has no "-C" option, so we emulate it here
openssl_dhparam3() {
	cat << \_EOF_
#include <openssl/dh.h>
#include <openssl/bn.h>
static DH *get_dhParams(void) {
	static unsigned char dhp[] = {
_EOF_

	openssl dhparam -text "$@" | \
	    sed -E -e '/^---/,/^---/d' \
		-e '/(DH|prime|generator|P|G|recommended)/d' \
		-e 's/([0-9a-h]{2})(:|$$)/0x\1, /g'







	cat << \_EOF_








	};
	static unsigned char dhg[] = {
		0x02,
	};

	DH *dh = DH_new();;
	BIGNUM *p, *g;

	if (dh == NULL) {
		return NULL;
	}

	p = BN_bin2bn(dhp, sizeof (dhp), NULL);
	g = BN_bin2bn(dhg, sizeof (dhg), NULL);

	if (p == NULL || g == NULL || !DH_set0_pqg(dh, p, NULL, g)) {
		DH_free(dh);
		BN_free(p);
		BN_free(g);
		return(NULL);
	}
	return dh;
}
_EOF_

	return 0
}