opensslgost_link.c revision 0c91911b4d1e872b87eaf6431ed47fe24d18dd43
/*
* Copyright (C) 2010-2012 Internet Systems Consortium, Inc. ("ISC")
*
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: opensslgost_link.c,v 1.5 2011/01/19 23:47:12 tbox Exp $ */
#include <config.h>
#ifdef HAVE_OPENSSL_GOST
#include "dst_internal.h"
#include "dst_openssl.h"
#include "dst_parse.h"
static const EVP_MD *opensslgost_digest;
return (opensslgost_digest);
}
isc_buffer_t *data);
static isc_result_t
return (DST_R_OPENSSLFAILURE);
if (evp_md_ctx == NULL)
return (ISC_R_NOMEMORY);
return (ISC_R_FAILURE);
}
return (ISC_R_SUCCESS);
}
static void
if (evp_md_ctx != NULL) {
}
}
static isc_result_t
return (ISC_R_FAILURE);
return (ISC_R_SUCCESS);
}
static isc_result_t
isc_region_t r;
unsigned int siglen = 0;
return (ISC_R_NOSPACE);
return (ISC_R_FAILURE);
return (ISC_R_SUCCESS);
}
static isc_result_t
int status = 0;
switch (status) {
case 1:
return (ISC_R_SUCCESS);
case 0:
return (dst__openssl_toresult(DST_R_VERIFYFAILURE));
default:
"EVP_VerifyFinal",
}
}
static isc_boolean_t
return (ISC_TRUE);
return (ISC_FALSE);
return (ISC_FALSE);
return (ISC_TRUE);
}
static int
{
union {
void *dptr;
void (*fptr)(int);
} u;
int p;
p = EVP_PKEY_CTX_get_keygen_info(ctx, 0);
u.fptr(p);
return (1);
}
static isc_result_t
union {
void *dptr;
void (*fptr)(int);
} u;
}
if (EVP_PKEY_keygen_init(ctx) <= 0)
return (ISC_R_SUCCESS);
err:
return (ret);
}
static isc_boolean_t
}
static void
}
unsigned char gost_prefix[37] = {
0x30, 0x63, 0x30, 0x1c, 0x06, 0x06, 0x2a, 0x85,
0x03, 0x02, 0x02, 0x13, 0x30, 0x12, 0x06, 0x07,
0x2a, 0x85, 0x03, 0x02, 0x02, 0x23, 0x01, 0x06,
0x07, 0x2a, 0x85, 0x03, 0x02, 0x02, 0x1e, 0x01,
0x03, 0x43, 0x00, 0x04, 0x40
};
static isc_result_t
isc_region_t r;
int len;
if (r.length < 64)
return (ISC_R_NOSPACE);
p = der;
return (ISC_R_SUCCESS);
}
static isc_result_t
isc_region_t r;
const unsigned char *p;
if (r.length == 0)
return (ISC_R_SUCCESS);
if (r.length != 64)
return (DST_R_INVALIDPUBLICKEY);
p = der;
return (dst__openssl_toresult2("d2i_PUBKEY",
return (ISC_R_SUCCESS);
}
static isc_result_t
unsigned char *der, *p;
int len;
return (DST_R_NULLKEY);
}
return (ISC_R_NOMEMORY);
p = der;
goto fail;
}
fail:
return (result);
}
static isc_result_t
const unsigned char *p;
/* read private key file */
if (ret != ISC_R_SUCCESS)
return (ret);
} else {
}
return (ISC_R_SUCCESS);
err:
return (ret);
}
static void
opensslgost_cleanup(void) {
if (e != NULL) {
ENGINE_finish(e);
ENGINE_free(e);
e = NULL;
}
}
static dst_func_t opensslgost_functions = {
NULL, /*%< verify2 */
NULL, /*%< computesecret */
NULL, /*%< paramcompare */
NULL, /*%< fromlabel */
NULL, /*%< dump */
NULL /*%< restore */
};
/* check if the gost engine works properly */
e = ENGINE_by_id("gost");
if (e == NULL)
return (dst__openssl_toresult2("ENGINE_by_id",
if (ENGINE_init(e) <= 0) {
ENGINE_free(e);
e = NULL;
return (dst__openssl_toresult2("ENGINE_init",
}
/* better than to rely on digest_gost symbol */
if (opensslgost_digest == NULL)
/* from openssl.cnf */
if (ENGINE_register_pkey_asn1_meths(e) <= 0)
"ENGINE_register_pkey_asn1_meths",
if (ENGINE_ctrl_cmd_string(e,
"CRYPT_PARAMS",
"id-Gost28147-89-CryptoPro-A-ParamSet",
0) <= 0)
return (ISC_R_SUCCESS);
err:
ENGINE_finish(e);
ENGINE_free(e);
e = NULL;
return (ret);
}
#else /* HAVE_OPENSSL_GOST */
#endif /* HAVE_OPENSSL_GOST */
/*! \file */