Diff

Differences From Artifact [121b16da7e]:

To Artifact [41bf4180f0]:


1

2
3
4
5
6
7
8
9



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30


31
32

33
34
35
36
37
38
39

1
2
3
4
5
6
7


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29


30
31
32

33
34
35
36
37
38
39
40
-
+






-
-
+
+
+



















-
-
+
+

-
+







#! /usr/bin/env bash
#! /usr/bin/env sh

bits='2048'

function openssl_dhparam() {
	local output

	if [ -x "$(which openssl 2>/dev/null)" ]; then
		output="$(set -o pipefail; openssl dhparam -C "$@" 2>/dev/null | sed '/^-----BEGIN DH PARAMETERS-----$/,/^-----END DH PARAMETERS-----$/ d;/^#/ d')" || return 1
	if [ -x "`which openssl 2>/dev/null`" ]; then
		output="`openssl dhparam -C "$@" 2>/dev/null`" || return 1
		output="`echo "${output}" | sed '/^-----BEGIN DH PARAMETERS-----$/,/^-----END DH PARAMETERS-----$/ d;/^#/ d'`" || return 1

		echo "${output}"

		return 0
	fi

	return 1
}

function gen_dh_params_openssl() {
	openssl_dhparam "${bits}" < /dev/null || return 1
	return 0
}

function gen_dh_params_remote() {
	local input output url

	url="https://2ton.com.au/dhparam/${bits}"

	input="$(curl "${url}")" || \
		input="$(wget -O - -o /dev/null "${url}")" || return 1
	input="`curl -sS "${url}"`" || \
		input="`wget -O - -o /dev/null "${url}"`" || return 1

	if output="$(echo "${input}" | openssl_dhparam)"; then
	if output="`echo "${input}" | openssl_dhparam`"; then
		echo "${output}"

		return 0
	fi

	return 1
}