openssl_util.c revision 9dc0df1bac950d6e491f9a7c7e4888f2b301cb15
/*
* 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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <assert.h>
#include <strings.h>
#include "kssladm.h"
static void
print_crypto_error(void)
{
}
/* ARGSUSED */
static int
{
}
{
perror("Unable to open pem file for reading");
return (NULL);
}
if (verbose)
(void) printf("In PEM_get_x509_info_stack: %s opened\n",
filename);
if (x509_info_stack == NULL) {
}
return (x509_info_stack);
}
static EVP_PKEY *
{
perror("Unable to open pem file for reading");
return (NULL);
}
if (verbose)
(char *)password_file);
}
return (pkey);
}
uchar_t *
{
int i, j, v;
X509 *x;
if (x != NULL) {
pkey = X509_get_pubkey(x);
X509_free(x);
return (NULL);
}
v = ((int)(bn->d[i] >> (long)j)) & 0xff;
*m = v;
m++;
}
}
X509_free(x);
}
return (mptr);
}
static uchar_t *
{
int size;
if (size < 0) {
perror("Invalid cert\n");
return (NULL);
}
return (cert_buf);
}
static uchar_t **
init_cert_vars(int **rlens)
{
int i;
int *lcert_lens;
return (NULL);
for (i = 0; i < MAX_CHAIN_LENGTH; i++)
if (lcert_lens == NULL) {
return (NULL);
}
for (i = 0; i < MAX_CHAIN_LENGTH; i++)
lcert_lens[i] = 0;
*rlens = lcert_lens;
return (cert_bufs);
}
static void
print_subject(X509 *x)
{
char buf[256];
(void) X509_NAME_oneline(X509_get_subject_name(x),
}
/*
* Returns DER encoded certs in an array of pointers
* and their sizes in cert_sizes. If the rsa argument is
* not NULL, we return the RSA key in it. The caller needs
* to free the structures when done.
*/
uchar_t **
{
int *cert_lens;
if (x509_info_stack == NULL) {
return (NULL);
}
ncerts = 0;
/* LINTED */
ncerts < MAX_CHAIN_LENGTH) {
ncerts++;
if (verbose)
}
if (ncerts == 0) {
return (NULL);
}
X509 *x;
return (NULL);
if (!X509_check_private_key(x, pkey)) {
"and server private key do not match.\n");
return (NULL);
}
}
return (NULL);
}
/*
* cert_infos[] is constructed from a stack of certificates structure
* and hence the order is high level CA certificate first. SSL protocol
* needs the certificates in the order of low level CA certificate
* first. So, we walk cert_infos[] in reverse order below.
*/
for (i = 0; i < ncerts; i++) {
}
*cert_sizes = cert_lens;
*n = ncerts;
return (cert_bufs);
}
static PKCS12 *
PKCS12_load(const char *filename)
{
perror("Unable to open file for reading");
return (NULL);
}
return (NULL);
}
return (p12);
}
/*
* Returns DER encoded certs in an array of pointers and their
* sizes in cert_sizes. The RSA key is returned in the rsa argument.
* The caller needs to free the structures when done.
*/
uchar_t **
{
int *cert_lens;
char password_buf[1024];
return (NULL);
}
if (get_passphrase(
perror("Unable to read passphrase");
goto done;
}
}
goto done;
}
goto done;
}
goto done;
}
"private key do not match.\n");
goto done;
}
goto done;
goto done;
}
goto done;
}
ncerts = 0;
ncerts++;
/* LINTED */
ncerts < MAX_CHAIN_LENGTH) {
ncerts++;
if (verbose)
}
/*
* certs[1..ncerts-1] is constructed from a stack of certificates
* structure and hence the order is high level CA certificate first.
* SSL protocol needs the certificates in the order of low level CA
* certificate first. So, we walk certs[] in reverse order below.
*/
for (i = 1; i < ncerts; i++) {
}
*cert_sizes = cert_lens;
*n = ncerts;
done:
return (cert_bufs);
}