Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * eCryptfs: Linux filesystem encryption layer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  * Functions only useful for debugging.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  * Copyright (C) 2006 International Business Machines Corp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  *   Author(s): Michael A. Halcrow <mahalcro@us.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include "ecryptfs_kernel.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)  * ecryptfs_dump_auth_tok - debug function to print auth toks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)  * This function will print the contents of an ecryptfs authentication
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)  * token.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) void ecryptfs_dump_auth_tok(struct ecryptfs_auth_tok *auth_tok)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 	char salt[ECRYPTFS_SALT_SIZE * 2 + 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 	char sig[ECRYPTFS_SIG_SIZE_HEX + 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 	ecryptfs_printk(KERN_DEBUG, "Auth tok at mem loc [%p]:\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 			auth_tok);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 	if (auth_tok->flags & ECRYPTFS_PRIVATE_KEY) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 		ecryptfs_printk(KERN_DEBUG, " * private key type\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 		ecryptfs_printk(KERN_DEBUG, " * passphrase type\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 		ecryptfs_to_hex(salt, auth_tok->token.password.salt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 				ECRYPTFS_SALT_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 		salt[ECRYPTFS_SALT_SIZE * 2] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 		ecryptfs_printk(KERN_DEBUG, " * salt = [%s]\n", salt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 		if (auth_tok->token.password.flags &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 		    ECRYPTFS_PERSISTENT_PASSWORD) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 			ecryptfs_printk(KERN_DEBUG, " * persistent\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 		memcpy(sig, auth_tok->token.password.signature,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 		       ECRYPTFS_SIG_SIZE_HEX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 		sig[ECRYPTFS_SIG_SIZE_HEX] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 		ecryptfs_printk(KERN_DEBUG, " * signature = [%s]\n", sig);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	ecryptfs_printk(KERN_DEBUG, " * session_key.flags = [0x%x]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 			auth_tok->session_key.flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	if (auth_tok->session_key.flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	    & ECRYPTFS_USERSPACE_SHOULD_TRY_TO_DECRYPT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 		ecryptfs_printk(KERN_DEBUG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 				" * Userspace decrypt request set\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 	if (auth_tok->session_key.flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 	    & ECRYPTFS_USERSPACE_SHOULD_TRY_TO_ENCRYPT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 		ecryptfs_printk(KERN_DEBUG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 				" * Userspace encrypt request set\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 	if (auth_tok->session_key.flags & ECRYPTFS_CONTAINS_DECRYPTED_KEY) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 		ecryptfs_printk(KERN_DEBUG, " * Contains decrypted key\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 		ecryptfs_printk(KERN_DEBUG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 				" * session_key.decrypted_key_size = [0x%x]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 				auth_tok->session_key.decrypted_key_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 		ecryptfs_printk(KERN_DEBUG, " * Decrypted session key "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 				"dump:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 		if (ecryptfs_verbosity > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 			ecryptfs_dump_hex(auth_tok->session_key.decrypted_key,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 					  ECRYPTFS_DEFAULT_KEY_BYTES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 	if (auth_tok->session_key.flags & ECRYPTFS_CONTAINS_ENCRYPTED_KEY) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 		ecryptfs_printk(KERN_DEBUG, " * Contains encrypted key\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 		ecryptfs_printk(KERN_DEBUG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 				" * session_key.encrypted_key_size = [0x%x]\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 				auth_tok->session_key.encrypted_key_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 		ecryptfs_printk(KERN_DEBUG, " * Encrypted session key "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 				"dump:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 		if (ecryptfs_verbosity > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 			ecryptfs_dump_hex(auth_tok->session_key.encrypted_key,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 					  auth_tok->session_key.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) 					  encrypted_key_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)  * ecryptfs_dump_hex - debug hex printer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)  * @data: string of bytes to be printed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)  * @bytes: number of bytes to print
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)  * Dump hexadecimal representation of char array
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) void ecryptfs_dump_hex(char *data, int bytes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) 	if (ecryptfs_verbosity < 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) 	print_hex_dump(KERN_DEBUG, "ecryptfs: ", DUMP_PREFIX_OFFSET, 16, 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) 		       data, bytes, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) }