/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright 2016 Toomas Soome <tsoome@me.com>
*/
/*
* Create sha1 hash for file.
*/
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>
#include <security/cryptoki.h>
#include <cryptoutil.h>
#include <locale.h>
#include "bootadm.h"
/*
* do_digest - Compute digest of a file. Borrowed from digest.
*
* hSession - session
* pmech - ptr to mechanism to be used for digest
* fd - file descriptor
* pdigest - buffer where digest result is returned
* pdigestlen - length of digest buffer on input,
* length of result on output
*/
static CK_RV
{
int err;
return (rv);
}
/* Get the digest */
return (rv);
}
/* There was a read error */
if (nread == -1) {
return (CKR_GENERAL_ERROR);
}
/* result too big to fit? Allocate a bigger buffer */
if (rv == CKR_BUFFER_TOO_SMALL) {
return (CKR_HOST_MEMORY);
}
}
return (rv);
}
int
{
int fd;
int resultstrlen;
int i, exitcode;
/* Initialize, and get list of slots */
"failed to initialize PKCS #11 framework: %s\n"),
return (BAM_ERROR);
}
/* Get slot count */
"failed to find any cryptographic provider: %s\n"),
goto cleanup;
}
/* Found at least one slot, allocate memory for slot list */
goto cleanup;
}
/* Get the list of slots */
"failed to find any cryptographic provider; "
"please check with your system administrator: %s\n"),
goto cleanup;
}
/* Find a slot with matching mechanism */
for (i = 0; i < slotcount; i++) {
continue; /* to the next slot */
} else {
break;
}
}
/* Show error if no matching mechanism found */
if (i == slotcount) {
"found for sha1\n"));
goto cleanup;
}
/* Mechanism is supported. Go ahead & open a session */
goto cleanup;
}
/* Allocate a buffer to store result. */
goto cleanup;
}
mech.ulParameterLen = 0;
goto cleanup;
}
goto cleanup;
}
/* Allocate a buffer to store result string */
goto cleanup;
}
}
if (hSession != CK_INVALID_HANDLE)
(void) C_CloseSession(hSession);
(void) C_Finalize(NULL);
return (exitcode);
}