~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/fs/ecryptfs/debug.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

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

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php