summaryrefslogtreecommitdiffstats
path: root/pki/base/native-tools/src/tkstool/modules.c
blob: 0c42972511e92a2db9aa945d740272db3f6bc3cd (plain)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* --- BEGIN COPYRIGHT BLOCK ---
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; version 2 of the License.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 * 
 * Copyright (C) 2007 Red Hat, Inc.
 * All rights reserved.
 * --- END COPYRIGHT BLOCK ---
 */

#include "tkstool.h"

/*
 *  L i s t S e c M o d u l e s
 *
 *  Print a list of the PKCS11 security modules that are
 *  available. This is useful for smartcard people to
 *  make sure they have the drivers loaded.
 *
 */
SECStatus
TKS_ListSecModules( void )
{
    PK11SlotList        *list;
    PK11SlotListElement *le;

    /* get them all! */
    list = PK11_GetAllTokens( 
    /* mechanism type */      CKM_INVALID_MECHANISM,
    /* need R/W       */      PR_FALSE,
    /* load certs     */      PR_FALSE,
    /* wincx          */      NULL );

    if( list == NULL ) {
        return SECFailure;
    }

    /* look at each slot */
    for( le = list->head ; le ; le = le->next ) {
        PR_fprintf ( PR_STDOUT,
                     "\n" );
        PR_fprintf ( PR_STDOUT,
                     "    slot: %s\n",
                     PK11_GetSlotName( /* slot */  le->slot ) );
        PR_fprintf ( PR_STDOUT,
                     "   token: %s\n",
                     PK11_GetTokenName( /* slot */  le->slot ) );
    }

    PK11_FreeSlotList( /* slot list */  list );

    return SECSuccess;
}