1 /* -*- mode: c; c-file-style:"stroustrup"; -*- */
2
3 /*
4 * Copyright (c) 2018 Mastercard
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19
20 #include <config.h>
21 #include <stdio.h>
22 #include <string.h>
23 #include <stdlib.h>
24 #include <stdarg.h>
25 #include <ctype.h>
26 #include <openssl/objects.h>
27 #include <openssl/ec.h>
28 #include "pkcs11lib.h"
29
30
31 #define HAS_FLAG(a,fl,t,f) ( (a & fl) ? t : f )
32 #define IS_VENDOR_DEFINED(m,t,f) ( (m & CKM_VENDOR_DEFINED) == CKM_VENDOR_DEFINED ? t : f )
33
34 /* high-level search functions */
35
pkcs11_info_library(pkcs11Context * p11Context)36 func_rc pkcs11_info_library(pkcs11Context *p11Context)
37 {
38 func_rc rc=rc_error_library;
39
40 if(p11Context && p11Context->initialized==CK_TRUE) {
41 CK_INFO libinfo;
42 CK_RV rv;
43
44 if((rv = p11Context->FunctionList.C_GetInfo(&libinfo)) != CKR_OK ) {
45 pkcs11_error( rv, "C_GetInfo" );
46 rc = rc_error_pkcs11_api;
47 goto error;
48 }
49
50 fprintf( stdout,
51 "PKCS#11 Library\n"
52 "---------------\n"
53 "Name : %s\n"
54 "Lib version : %d.%d\n"
55 "API version : %d.%d\n"
56 "Description : %.*s\n"
57 "Manufacturer: %.*s\n"
58 "\n",
59 p11Context->library,
60 libinfo.libraryVersion.major, libinfo.libraryVersion.minor,
61 libinfo.cryptokiVersion.major, libinfo.cryptokiVersion.minor,
62 (int)sizeof(libinfo.libraryDescription), libinfo.libraryDescription,
63 (int)sizeof(libinfo.manufacturerID), libinfo.manufacturerID
64 );
65
66 rc = rc_ok;
67 }
68
69 error:
70 return rc;
71 }
72
73 /* EOF */
74