config FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG
	bool "decrypt FRITZ!OS configs 0.4-git"
	default n
	help
		This package provides a set of tools making it possible to decrypt
		encrypted parts (usually credentials) of FRITZ!OS configuration
		files. See
		 https://github.com/PeterPawn/decode_passwords,
		 http://www.ip-phone-forum.de/showthread.php?t=276183,
		 http://www.ip-phone-forum.de/showthread.php?t=295101
		for usage details and technical background.

		NO RESPONSIBILITY DISCLAIMER:
		  Adding easy usable tools like these (to emphasize it once
		  more - tools providing password decryption capabilities)
		  decreases the SECURITY of your box.
		  Use it on YOUR OWN RISK, Freetz is not responsible
		  for any potential losses or damages resulting/arising
		  from adding these tools to your firmware.

if FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG
comment "WARNING: See help for the NO RESPONSIBILITY DISCLAIMER."
endif

choice
	depends on FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG
	prompt "Crypto library"
	default FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG_NETTLE

	config FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG_NETTLE
		bool "Nettle"
		select FREETZ_LIB_libnettle if FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG_ALL_DYN

	config FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG_OPENSSL
		bool "OpenSSL"
		select FREETZ_LIB_libcrypto if FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG_ALL_DYN
		select FREETZ_OPENSSL_VERSION_PROMPT
endchoice

choice
	depends on FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG
	prompt "Link"
	default FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG_CRYPTO_STAT

	config FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG_ALL_DYN
		bool "all libraries dynamically"

	config FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG_CRYPTO_STAT
		bool "crypto libraries statically"

	config FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG_ALL_STAT
		bool "all libraries statically"
endchoice

menu "symlinks to create for faster access to contained tools"
	depends on FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG

# Freetz alias for decode_secrets
config FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG_decrypt_fritzos_cfg
	bool
	default y

config FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG_checksum
	bool "checksum              - compute the checksum of an export file"
	help
		This program computes the CRC-32 value for a FRITZ!OS export file.

config FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG_decode_secrets
	bool "decode_secrets        - decrypt ciphertext values"
	default n
	help
		This is a filter and copies all data from STDIN to STDOUT while decryptable
		cipher-text occurrences are replaced with their clear-text values.

config FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG_decode_export
	bool "decode_export         - decrypt settings export files"
	default n
	help
		This is a filter and copies all data from STDIN to STDOUT while decryptable
		cipher-text occurrences are replaced with their clear-text values.
		It's a replacement for 'decode_secrets' with automatic handling of the special
		encryption for the export password.

config FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG_split_export
	bool "split_export          - split an export file into sub-files, a single file for each settings file"
	default n
	help
		This program splits a single export file into the settings files contained therein.

config FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG_decode_cryptedbinfile
	bool "decode_cryptedbinfile - decrypt data portion of encrypted file sections within an export file"
	default n
	help
		This is a filter and decrypts the content (hexadecimal strings) from a CRYPTEDBINFILE
		entry in an exported settings file.

config FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG_decode_secret
	bool "decode_secret         - decrypt a single value"
	default n
	help
		This function expects the encrypted data and the key as command line arguments.

config FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG_user_password
	bool "user_password         - create a decryption key from a specified password"

config FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG_device_password
	bool "device_password       - create a decryption key from specified device properties"

config FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG_password_from_device
	bool "password_from_device  - create a decryption key from device properties"

config FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG_privatekeypassword
	bool "privatekeypassword    - compute the private key used for '/var/flash/websrv_ssl_key.pem'"
	help
		This program computes the secret key used to encrypt the file '/var/flash/websrv_ssl_key.pem'.


config FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG_HEXUTIL
	bool "hexdec/hexenc         - convert from hexadecimal to binary and vice versa"
	select FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG_hexdec
	select FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG_hexenc

config FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG_hexdec
	bool
config FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG_hexenc
	bool

config FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG_B64UTIL
	bool "b64dec/b64enc         - convert from Base64 to binary and vice versa"
	select FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG_b64dec
	select FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG_b64enc

config FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG_b64dec
	bool
config FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG_b64enc
	bool

config FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG_B32UTIL
	bool "b32dec/b32enc         - convert from Base32 to binary and vice versa"
	select FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG_b32dec
	select FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG_b32enc

config FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG_b32dec
	bool
config FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG_b32enc
	bool

endmenu

config FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG_allcfgconv_c
	bool "allcfgconv-c - allcfgconv with decryption support"
	depends on FREETZ_PACKAGE_DECRYPT_FRITZOS_CFG && !FREETZ_AVM_HAS_ALLCFGCONV_WITH_DECRYPTION_SUPPORT
	default n
	help
		allcfgconv-c is a wrapper script for the AVM's allcfgconv utility
		which readds password decryption capabilities (removed by AVM
		some Fritz!OS versions ago) back to it.

		The main purpose of this script is to simplify the migration of
		the tools used allcfgconv so far and relied on this functionality.

		Just replace all invocations of allcfgconv with allcfgconv-c,
		and that's it.
