2 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
18 * 3. All advertising materials mentioning features or use of this
19 * software must display the following acknowledgment:
20 * "This product includes software developed by the OpenSSL Project
21 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
23 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
24 * endorse or promote products derived from this software without
25 * prior written permission. For written permission, please contact
26 * licensing@OpenSSL.org.
28 * 5. Products derived from this software may not be called "OpenSSL"
29 * nor may "OpenSSL" appear in their names without prior written
30 * permission of the OpenSSL Project.
32 * 6. Redistributions of any form whatsoever must retain the following
34 * "This product includes software developed by the OpenSSL Project
35 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
37 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
38 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
39 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
40 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
41 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
42 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
43 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
44 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
45 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
46 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
47 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
48 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 #pragma ident "@(#)hw_pk11_uri.h 1.1 09/11/10 SMI"
56 #include <security/pkcs11t.h>
58 /* PKCS#11 URI related prefixes and attributes. */
59 #define PK11_URI_PREFIX "pkcs11:"
60 #define FILE_URI_PREFIX "file://"
61 #define PK11_TOKEN "token"
62 #define PK11_MANUF "manuf"
63 #define PK11_SERIAL "serial"
64 #define PK11_MODEL "model"
65 #define PK11_OBJECT "object"
66 #define PK11_OBJECTTYPE "objecttype"
67 #define PK11_ASKPASS "passphrasedialog"
69 /* PIN caching policy. */
70 #define POLICY_NOT_INITIALIZED 0
72 #define POLICY_MEMORY 2
73 #define POLICY_MLOCKED_MEMORY 3
74 #define POLICY_WRONG_VALUE 4
77 * That's what getpassphrase(3c) supports.
79 #define PK11_MAX_PIN_LEN 256
81 /* Add new attributes of the PKCS#11 URI here. */
82 typedef struct pkcs11_uri_struct
{
83 char *object
; /* object label, the only mandatory info */
84 char *objecttype
; /* (private|public|cert), currently unused */
85 char *token
; /* token label */
86 char *manuf
; /* manufacturer label */
87 char *serial
; /* serial number label */
88 char *model
; /* model label */
89 char *askpass
; /* full path to the command to get the PIN */
90 /* Not part of the PKCS11 URI itself. */
91 char *pin
; /* token PIN */
94 /* For URI processing. */
95 extern pthread_mutex_t
*uri_lock
;
97 int pk11_get_pin(char *dialog
, char **pin
);
98 int pk11_get_pin_caching_policy(void);
99 int pk11_process_pkcs11_uri(const char *uristr
, pkcs11_uri
*uri_struct
,
101 int pk11_check_token_attrs(pkcs11_uri
*uri_struct
);
102 void pk11_free_pkcs11_uri(pkcs11_uri
*uri_struct
, CK_BBOOL free_uri_itself
);
103 int pk11_cache_pin(char *pin
);
104 int pk11_token_login(CK_SESSION_HANDLE session
, CK_BBOOL
*login_done
,
105 pkcs11_uri
*uri_struct
, CK_BBOOL is_private
);
106 int pk11_token_relogin(CK_SESSION_HANDLE session
);
108 #endif /* HW_PK11_URI_H */