Print this page
1667 pkcs11 may deadlock when multi-threaded consumers fork


   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  *
  21  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
  22  */
  23 /*
  24  * Copyright 2010 Nexenta Systems, Inc.  All rights reserved.

  25  */
  26 
  27 #ifndef _CRYPTOUTIL_H
  28 #define _CRYPTOUTIL_H
  29 
  30 #ifdef __cplusplus
  31 extern "C" {
  32 #endif
  33 
  34 #include <sys/types.h>
  35 #include <syslog.h>
  36 #include <security/cryptoki.h>
  37 #include <sys/param.h>
  38 
  39 #define LOG_STDERR      -1
  40 #define SUCCESS         0
  41 #define FAILURE         1
  42 #define MECH_ID_HEX_LEN 11      /* length of mechanism id in hex form */
  43 
  44 #define _PATH_PKCS11_CONF       "/etc/crypto/pkcs11.conf"


 199     CK_KEY_TYPE *ktype);
 200 extern CK_RV pkcs11_mech2keygen(CK_MECHANISM_TYPE mech_type,
 201     CK_MECHANISM_TYPE *gen_mech);
 202 extern char *pkcs11_strerror(CK_RV rv);
 203 
 204 extern int
 205 get_metaslot_info(boolean_t  *status_enabled, boolean_t *migrate_enabled,
 206     char **objectstore_slot_info, char **objectstore_token_info);
 207 
 208 extern char *get_fullpath(char *dir, char *filepath);
 209 extern int str2lifetime(char *ltimestr, uint32_t *ltime);
 210 
 211 extern char *pkcs11_default_token(void);
 212 extern int pkcs11_get_pass(char *token_name, char **pdata, size_t *psize,
 213     size_t min_psize, boolean_t with_confirmation);
 214 
 215 extern int pkcs11_seed_urandom(void *sbuf, size_t slen);
 216 extern int pkcs11_get_random(void *dbuf, size_t dlen);
 217 extern int pkcs11_get_urandom(void *dbuf, size_t dlen);
 218 extern int pkcs11_get_nzero_urandom(void *dbuf, size_t dlen);
 219 extern void pkcs11_close_random(void);
 220 extern void pkcs11_close_urandom(void);
 221 extern void pkcs11_close_urandom_seed(void);
 222 extern int pkcs11_read_data(char *filename, void **dbuf, size_t *dlen);
 223 
 224 extern int open_nointr(const char *path, int oflag, ...);
 225 extern ssize_t readn_nointr(int fd, void *dbuf, size_t dlen);
 226 extern ssize_t writen_nointr(int fd, void *dbuf, size_t dlen);
 227 extern int update_conf(char *conf_file, char *entry);
 228 
 229 extern int pkcs11_parse_uri(const char *str, pkcs11_uri_t *uri);
 230 extern void pkcs11_free_uri(pkcs11_uri_t *uri);
 231 
 232 #ifdef __cplusplus
 233 }
 234 #endif
 235 
 236 #endif /* _CRYPTOUTIL_H */


   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  *
  21  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
  22  */
  23 /*
  24  * Copyright 2010 Nexenta Systems, Inc.  All rights reserved.
  25  * Copyright 2014, OmniTI Computer Consulting, Inc. All rights reserved.
  26  */
  27 
  28 #ifndef _CRYPTOUTIL_H
  29 #define _CRYPTOUTIL_H
  30 
  31 #ifdef __cplusplus
  32 extern "C" {
  33 #endif
  34 
  35 #include <sys/types.h>
  36 #include <syslog.h>
  37 #include <security/cryptoki.h>
  38 #include <sys/param.h>
  39 
  40 #define LOG_STDERR      -1
  41 #define SUCCESS         0
  42 #define FAILURE         1
  43 #define MECH_ID_HEX_LEN 11      /* length of mechanism id in hex form */
  44 
  45 #define _PATH_PKCS11_CONF       "/etc/crypto/pkcs11.conf"


 200     CK_KEY_TYPE *ktype);
 201 extern CK_RV pkcs11_mech2keygen(CK_MECHANISM_TYPE mech_type,
 202     CK_MECHANISM_TYPE *gen_mech);
 203 extern char *pkcs11_strerror(CK_RV rv);
 204 
 205 extern int
 206 get_metaslot_info(boolean_t  *status_enabled, boolean_t *migrate_enabled,
 207     char **objectstore_slot_info, char **objectstore_token_info);
 208 
 209 extern char *get_fullpath(char *dir, char *filepath);
 210 extern int str2lifetime(char *ltimestr, uint32_t *ltime);
 211 
 212 extern char *pkcs11_default_token(void);
 213 extern int pkcs11_get_pass(char *token_name, char **pdata, size_t *psize,
 214     size_t min_psize, boolean_t with_confirmation);
 215 
 216 extern int pkcs11_seed_urandom(void *sbuf, size_t slen);
 217 extern int pkcs11_get_random(void *dbuf, size_t dlen);
 218 extern int pkcs11_get_urandom(void *dbuf, size_t dlen);
 219 extern int pkcs11_get_nzero_urandom(void *dbuf, size_t dlen);



 220 extern int pkcs11_read_data(char *filename, void **dbuf, size_t *dlen);
 221 
 222 extern int open_nointr(const char *path, int oflag, ...);
 223 extern ssize_t readn_nointr(int fd, void *dbuf, size_t dlen);
 224 extern ssize_t writen_nointr(int fd, void *dbuf, size_t dlen);
 225 extern int update_conf(char *conf_file, char *entry);
 226 
 227 extern int pkcs11_parse_uri(const char *str, pkcs11_uri_t *uri);
 228 extern void pkcs11_free_uri(pkcs11_uri_t *uri);
 229 
 230 #ifdef __cplusplus
 231 }
 232 #endif
 233 
 234 #endif /* _CRYPTOUTIL_H */