LCOV - code coverage report
Current view: top level - fs/ecryptfs - debug.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 46 0.0 %
Date: 2014-02-18 Functions: 0 2 0.0 %
Branches: 0 26 0.0 %

           Branch data     Line data    Source code
       1                 :            : /**
       2                 :            :  * eCryptfs: Linux filesystem encryption layer
       3                 :            :  * Functions only useful for debugging.
       4                 :            :  *
       5                 :            :  * Copyright (C) 2006 International Business Machines Corp.
       6                 :            :  *   Author(s): Michael A. Halcrow <mahalcro@us.ibm.com>
       7                 :            :  *
       8                 :            :  * This program is free software; you can redistribute it and/or
       9                 :            :  * modify it under the terms of the GNU General Public License as
      10                 :            :  * published by the Free Software Foundation; either version 2 of the
      11                 :            :  * License, or (at your option) any later version.
      12                 :            :  *
      13                 :            :  * This program is distributed in the hope that it will be useful, but
      14                 :            :  * WITHOUT ANY WARRANTY; without even the implied warranty of
      15                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      16                 :            :  * General Public License for more details.
      17                 :            :  *
      18                 :            :  * You should have received a copy of the GNU General Public License
      19                 :            :  * along with this program; if not, write to the Free Software
      20                 :            :  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
      21                 :            :  * 02111-1307, USA.
      22                 :            :  */
      23                 :            : 
      24                 :            : #include "ecryptfs_kernel.h"
      25                 :            : 
      26                 :            : /**
      27                 :            :  * ecryptfs_dump_auth_tok - debug function to print auth toks
      28                 :            :  *
      29                 :            :  * This function will print the contents of an ecryptfs authentication
      30                 :            :  * token.
      31                 :            :  */
      32                 :          0 : void ecryptfs_dump_auth_tok(struct ecryptfs_auth_tok *auth_tok)
      33                 :            : {
      34                 :            :         char salt[ECRYPTFS_SALT_SIZE * 2 + 1];
      35                 :            :         char sig[ECRYPTFS_SIG_SIZE_HEX + 1];
      36                 :            : 
      37                 :          0 :         ecryptfs_printk(KERN_DEBUG, "Auth tok at mem loc [%p]:\n",
      38                 :            :                         auth_tok);
      39         [ #  # ]:          0 :         if (auth_tok->flags & ECRYPTFS_PRIVATE_KEY) {
      40                 :          0 :                 ecryptfs_printk(KERN_DEBUG, " * private key type\n");
      41                 :            :         } else {
      42                 :          0 :                 ecryptfs_printk(KERN_DEBUG, " * passphrase type\n");
      43                 :          0 :                 ecryptfs_to_hex(salt, auth_tok->token.password.salt,
      44                 :            :                                 ECRYPTFS_SALT_SIZE);
      45                 :          0 :                 salt[ECRYPTFS_SALT_SIZE * 2] = '\0';
      46                 :          0 :                 ecryptfs_printk(KERN_DEBUG, " * salt = [%s]\n", salt);
      47         [ #  # ]:          0 :                 if (auth_tok->token.password.flags &
      48                 :            :                     ECRYPTFS_PERSISTENT_PASSWORD) {
      49                 :          0 :                         ecryptfs_printk(KERN_DEBUG, " * persistent\n");
      50                 :            :                 }
      51                 :          0 :                 memcpy(sig, auth_tok->token.password.signature,
      52                 :            :                        ECRYPTFS_SIG_SIZE_HEX);
      53                 :          0 :                 sig[ECRYPTFS_SIG_SIZE_HEX] = '\0';
      54                 :          0 :                 ecryptfs_printk(KERN_DEBUG, " * signature = [%s]\n", sig);
      55                 :            :         }
      56                 :          0 :         ecryptfs_printk(KERN_DEBUG, " * session_key.flags = [0x%x]\n",
      57                 :            :                         auth_tok->session_key.flags);
      58         [ #  # ]:          0 :         if (auth_tok->session_key.flags
      59                 :          0 :             & ECRYPTFS_USERSPACE_SHOULD_TRY_TO_DECRYPT)
      60                 :          0 :                 ecryptfs_printk(KERN_DEBUG,
      61                 :            :                                 " * Userspace decrypt request set\n");
      62         [ #  # ]:          0 :         if (auth_tok->session_key.flags
      63                 :          0 :             & ECRYPTFS_USERSPACE_SHOULD_TRY_TO_ENCRYPT)
      64                 :          0 :                 ecryptfs_printk(KERN_DEBUG,
      65                 :            :                                 " * Userspace encrypt request set\n");
      66         [ #  # ]:          0 :         if (auth_tok->session_key.flags & ECRYPTFS_CONTAINS_DECRYPTED_KEY) {
      67                 :          0 :                 ecryptfs_printk(KERN_DEBUG, " * Contains decrypted key\n");
      68                 :          0 :                 ecryptfs_printk(KERN_DEBUG,
      69                 :            :                                 " * session_key.decrypted_key_size = [0x%x]\n",
      70                 :            :                                 auth_tok->session_key.decrypted_key_size);
      71                 :          0 :                 ecryptfs_printk(KERN_DEBUG, " * Decrypted session key "
      72                 :            :                                 "dump:\n");
      73         [ #  # ]:          0 :                 if (ecryptfs_verbosity > 0)
      74                 :          0 :                         ecryptfs_dump_hex(auth_tok->session_key.decrypted_key,
      75                 :            :                                           ECRYPTFS_DEFAULT_KEY_BYTES);
      76                 :            :         }
      77         [ #  # ]:          0 :         if (auth_tok->session_key.flags & ECRYPTFS_CONTAINS_ENCRYPTED_KEY) {
      78                 :          0 :                 ecryptfs_printk(KERN_DEBUG, " * Contains encrypted key\n");
      79                 :          0 :                 ecryptfs_printk(KERN_DEBUG,
      80                 :            :                                 " * session_key.encrypted_key_size = [0x%x]\n",
      81                 :            :                                 auth_tok->session_key.encrypted_key_size);
      82                 :          0 :                 ecryptfs_printk(KERN_DEBUG, " * Encrypted session key "
      83                 :            :                                 "dump:\n");
      84         [ #  # ]:          0 :                 if (ecryptfs_verbosity > 0)
      85                 :          0 :                         ecryptfs_dump_hex(auth_tok->session_key.encrypted_key,
      86                 :          0 :                                           auth_tok->session_key.
      87                 :            :                                           encrypted_key_size);
      88                 :            :         }
      89                 :          0 : }
      90                 :            : 
      91                 :            : /**
      92                 :            :  * ecryptfs_dump_hex - debug hex printer
      93                 :            :  * @data: string of bytes to be printed
      94                 :            :  * @bytes: number of bytes to print
      95                 :            :  *
      96                 :            :  * Dump hexadecimal representation of char array
      97                 :            :  */
      98                 :          0 : void ecryptfs_dump_hex(char *data, int bytes)
      99                 :            : {
     100                 :            :         int i = 0;
     101                 :            :         int add_newline = 1;
     102                 :            : 
     103         [ #  # ]:          0 :         if (ecryptfs_verbosity < 1)
     104                 :          0 :                 return;
     105         [ #  # ]:          0 :         if (bytes != 0) {
     106                 :          0 :                 printk(KERN_DEBUG "0x%.2x.", (unsigned char)data[i]);
     107                 :            :                 i++;
     108                 :            :         }
     109         [ #  # ]:          0 :         while (i < bytes) {
     110                 :          0 :                 printk("0x%.2x.", (unsigned char)data[i]);
     111                 :          0 :                 i++;
     112         [ #  # ]:          0 :                 if (i % 16 == 0) {
     113                 :          0 :                         printk("\n");
     114                 :            :                         add_newline = 0;
     115                 :            :                 } else
     116                 :            :                         add_newline = 1;
     117                 :            :         }
     118         [ #  # ]:          0 :         if (add_newline)
     119                 :          0 :                 printk("\n");
     120                 :            : }
     121                 :            : 

Generated by: LCOV version 1.9