export.c revision 49e212991a3065f7e499a4b29ae8d8eaf33f3135
4f680cc668fa6cf678c531083400ade9a9c7934cAli Bahrami * CDDL HEADER START
4f680cc668fa6cf678c531083400ade9a9c7934cAli Bahrami * The contents of this file are subject to the terms of the
4f680cc668fa6cf678c531083400ade9a9c7934cAli Bahrami * Common Development and Distribution License, Version 1.0 only
4f680cc668fa6cf678c531083400ade9a9c7934cAli Bahrami * (the "License"). You may not use this file except in compliance
4f680cc668fa6cf678c531083400ade9a9c7934cAli Bahrami * with the License.
4f680cc668fa6cf678c531083400ade9a9c7934cAli Bahrami * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
4f680cc668fa6cf678c531083400ade9a9c7934cAli Bahrami * See the License for the specific language governing permissions
4f680cc668fa6cf678c531083400ade9a9c7934cAli Bahrami * and limitations under the License.
4f680cc668fa6cf678c531083400ade9a9c7934cAli Bahrami * When distributing Covered Code, include this CDDL HEADER in each
4f680cc668fa6cf678c531083400ade9a9c7934cAli Bahrami * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
4f680cc668fa6cf678c531083400ade9a9c7934cAli Bahrami * If applicable, add the following below this CDDL HEADER, with the
4f680cc668fa6cf678c531083400ade9a9c7934cAli Bahrami * fields enclosed by brackets "[]" replaced with your own identifying
4f680cc668fa6cf678c531083400ade9a9c7934cAli Bahrami * information: Portions Copyright [yyyy] [name of copyright owner]
4f680cc668fa6cf678c531083400ade9a9c7934cAli Bahrami * CDDL HEADER END
4f680cc668fa6cf678c531083400ade9a9c7934cAli Bahrami * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
4f680cc668fa6cf678c531083400ade9a9c7934cAli Bahrami * Use is subject to license terms.
4f680cc668fa6cf678c531083400ade9a9c7934cAli Bahrami#pragma ident "%Z%%M% %I% %E% SMI"
4f680cc668fa6cf678c531083400ade9a9c7934cAli Bahrami * This file implements the export operation for this tool.
4f680cc668fa6cf678c531083400ade9a9c7934cAli Bahrami * The basic flow of the process is to find the soft token,
4f680cc668fa6cf678c531083400ade9a9c7934cAli Bahrami * log into it, find the PKCS#11 objects in the soft token
4f680cc668fa6cf678c531083400ade9a9c7934cAli Bahrami * to be exported matching keys with their certificates, export
4f680cc668fa6cf678c531083400ade9a9c7934cAli Bahrami * them to the PKCS#12 file encrypting them with a file password
4f680cc668fa6cf678c531083400ade9a9c7934cAli Bahrami * if desired, and log out.
int lab_len = 0;
int n_writes = 0;
(*failures)++;
if (cert) {
(*failures)++;
lab_len))
n_writes++;
if (ca_certs) {
(*failures)++;
n_writes++;
(*failures)++;
(*failures)++;
(*failures)++;
(*failures)++;
(*failures)++;
n_writes++;
(*failures)++;
(*failures)++;
static CK_RV
return (rv);
return (CKR_HOST_MEMORY);
return (rv);
return (rv);
return (rv);
*chain_len = 0;
return (CKR_OK);
NULL)
static CK_RV
return (CKR_HOST_MEMORY);
CKR_OK) {
return (rv);
for (i = 0; i < count; i++) {
return (CKR_HOST_MEMORY);
CKR_OK) {
return (rv);
return (CKR_GENERAL_ERROR);
return (CKR_GENERAL_ERROR);
return (CKR_GENERAL_ERROR);
return (CKR_GENERAL_ERROR);
return (CKR_GENERAL_ERROR);
return (CKR_GENERAL_ERROR);
return (CKR_GENERAL_ERROR);
return (CKR_GENERAL_ERROR);
return (CKR_HOST_MEMORY);
return (CKR_OK);
static CK_RV
return (CKR_HOST_MEMORY);
CKR_OK) {
return (rv);
for (i = 0; i < count; i++) {
return (CKR_HOST_MEMORY);
CKR_OK) {
return (rv);
return (CKR_GENERAL_ERROR);
return (CKR_GENERAL_ERROR);
return (CKR_GENERAL_ERROR);
return (CKR_GENERAL_ERROR);
return (CKR_HOST_MEMORY);
return (CKR_OK);
static CK_RV
return (CKR_HOST_MEMORY);
CKR_OK) {
return (rv);
for (i = 0; i < count; i++) {
return (CKR_HOST_MEMORY);
CKR_OK) {
return (rv);
return (CKR_GENERAL_ERROR);
return (CKR_GENERAL_ERROR);
return (CKR_GENERAL_ERROR);
return (CKR_HOST_MEMORY);
return (CKR_OK);
static CK_RV
CKR_OK) {
return (rv);
switch (keytype) {
case CKK_RSA:
case CKK_DSA:
case CKK_DH:
keytype);
return (CKR_GENERAL_ERROR);
static CK_RV
return (CKR_HOST_MEMORY);
CKR_OK) {
return (rv);
for (i = 0; i < count; i++) {
== NULL) {
return (CKR_HOST_MEMORY);
CKR_OK) {
return (rv);
NULL) {
return (CKR_GENERAL_ERROR);
return (CKR_GENERAL_ERROR);
return (CKR_GENERAL_ERROR);
return (CKR_GENERAL_ERROR);
NULL) {
return (CKR_GENERAL_ERROR);
return (CKR_GENERAL_ERROR);
*c = cert;
return (CKR_OK);
static CK_RV
return (rv);
return (rv);
if (chain_len != 0) {
for (i = 0; i < chain_len; i++) {
CKR_OK) {
return (rv);
return (CKR_OK);
int opt;
extern int optind_av;
extern char *optarg_av;
switch (opt) {
if (token_spec)
return (PK_ERR_USAGE);
if (filename)
return (PK_ERR_USAGE);
return (PK_ERR_USAGE);
&serial_no) < 0)
return (PK_ERR_USAGE);
return (PK_ERR_USAGE);
if (argc)
return (PK_ERR_USAGE);
return (PK_ERR_PK11);
return (PK_ERR_PK11);
CKR_OK) {
return (PK_ERR_PK11);
return (PK_ERR_PK11);
if (num_objs == 0) {
return (PK_ERR_SYSTEM);
CKR_OK) {
return (PK_ERR_PK11);
for (i = 0; i < num_objs; i++) {
return (PK_ERR_PK11);
return (PK_ERR_PK11);
return (PK_ERR_OPENSSL);