pkcs11gost_link.c revision 12bf5d4796505b4c20680531da96a31e6c2c1144
b6b8f8a0362da8c749021c4b6376cfb96047912bTinderbox User * Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC")
b6b8f8a0362da8c749021c4b6376cfb96047912bTinderbox User * Permission to use, copy, modify, and/or distribute this software for any
5347c0fcb04eaea19d9f39795646239f487c6207Tinderbox User * purpose with or without fee is hereby granted, provided that the above
5347c0fcb04eaea19d9f39795646239f487c6207Tinderbox User * copyright notice and this permission notice appear in all copies.
b6b8f8a0362da8c749021c4b6376cfb96047912bTinderbox User * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
d6fa26d0adaec6c910115be34fe7a5a5f402c14fMark Andrews * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
b6b8f8a0362da8c749021c4b6376cfb96047912bTinderbox User * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
b6b8f8a0362da8c749021c4b6376cfb96047912bTinderbox User * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
b6b8f8a0362da8c749021c4b6376cfb96047912bTinderbox User * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt * PERFORMANCE OF THIS SOFTWARE.
b6b8f8a0362da8c749021c4b6376cfb96047912bTinderbox User#if defined(PKCS11CRYPTO) && defined(HAVE_PKCS11_GOST)
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * RU CryptoPro GOST keys:
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * mechanisms:
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * CKM_GOSTR3411
b6b8f8a0362da8c749021c4b6376cfb96047912bTinderbox User * CKM_GOSTR3410_WITH_GOSTR3411
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * CKM_GOSTR3410_KEY_PAIR_GEN
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * domain parameters:
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * CKA_GOSTR3410_PARAMS (fixed BER OID 1.2.643.2.2.35.1)
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * CKA_GOSTR3411_PARAMS (fixed BER OID 1.2.643.2.2.30.1)
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * CKA_GOST28147_PARAMS (optional, don't use)
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * public keys:
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * object class CKO_PUBLIC_KEY
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * key type CKK_GOSTR3410
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * attribute CKA_VALUE (point Q)
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * attribute CKA_GOSTR3410_PARAMS
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * attribute CKA_GOSTR3411_PARAMS
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * attribute CKA_GOST28147_PARAMS
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * private keys:
7e71f05d8643aca84914437c900cb716444507e4Tinderbox User * object class CKO_PRIVATE_KEY
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * key type CKK_GOSTR3410
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * attribute CKA_VALUE (big int d)
b6b8f8a0362da8c749021c4b6376cfb96047912bTinderbox User * attribute CKA_GOSTR3410_PARAMS
b6b8f8a0362da8c749021c4b6376cfb96047912bTinderbox User * attribute CKA_GOSTR3411_PARAMS
b6b8f8a0362da8c749021c4b6376cfb96047912bTinderbox User * attribute CKA_GOST28147_PARAMS
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * point format: <x> <y> (little endian)
b6b8f8a0362da8c749021c4b6376cfb96047912bTinderbox User/* HASH methods */
b6b8f8a0362da8c749021c4b6376cfb96047912bTinderbox User CK_MECHANISM mech = { CKM_GOSTR3411, NULL, 0 };
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User ret = pk11_get_session(ctx, OP_GOST, ISC_FALSE, ISC_FALSE, NULL, 0);
b6b8f8a0362da8c749021c4b6376cfb96047912bTinderbox User PK11_CALL(pkcs_C_DigestInit, (ctx->session, &mech), ISC_R_FAILURE);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User (void) pkcs_C_DigestFinal(ctx->session, garbage, &len);
b6b8f8a0362da8c749021c4b6376cfb96047912bTinderbox Userisc_gost_update(isc_gost_t *ctx, const unsigned char *buf, unsigned int len) {
b6b8f8a0362da8c749021c4b6376cfb96047912bTinderbox Userisc_gost_final(isc_gost_t *ctx, unsigned char *digest) {
return (ret);
static isc_result_t
sizeof(*pk11_ctx));
return (ISC_R_NOMEMORY);
goto err;
goto token_key;
case CKA_VALUE2:
return (ISC_R_SUCCESS);
err:
return (ret);
static isc_result_t
sizeof(*pk11_ctx));
return (ISC_R_NOMEMORY);
goto err;
goto token_key;
case CKA_VALUE:
return (ISC_R_SUCCESS);
err:
return (ret);
static isc_result_t
static isc_result_t
return (ret);
static isc_result_t
isc_region_t r;
return (ISC_R_NOSPACE);
return (DST_R_SIGNFAILURE);
err:
return (ret);
static isc_result_t
return (ret);
static isc_boolean_t
return (ISC_TRUE);
return (ISC_FALSE);
return (ISC_TRUE);
return (ISC_FALSE);
return (ISC_FALSE);
return (ISC_TRUE);
return (ISC_FALSE);
return (ISC_TRUE);
static isc_result_t
sizeof(*pk11_ctx));
return (ISC_R_NOMEMORY);
goto err;
attr++;
return (ISC_R_SUCCESS);
err:
return (ret);
static isc_boolean_t
return (ISC_FALSE);
case CKA_VALUE:
case CKA_VALUE2:
static isc_result_t
isc_region_t r;
return (ISC_R_FAILURE);
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
static isc_result_t
isc_region_t r;
if (r.length == 0)
return (ISC_R_SUCCESS);
return (DST_R_INVALIDPUBLICKEY);
return (ISC_R_NOMEMORY);
goto nomemory;
goto nomemory;
return (ISC_R_SUCCESS);
case CKA_VALUE:
return (ISC_R_NOMEMORY);
#ifdef PREFER_GOSTASN1
static isc_result_t
int adj;
return (DST_R_NULLKEY);
return (ISC_R_NOMEMORY);
if (adj != 0) {
return (DST_R_CRYPTOFAILURE);
return (ret);
static isc_result_t
return (DST_R_NULLKEY);
return (ISC_R_NOMEMORY);
return (DST_R_CRYPTOFAILURE);
return (ret);
static isc_result_t
return (ret);
if (adj != 0) {
attr++;
return (ISC_R_SUCCESS);
err:
return (ret);
return (ISC_R_SUCCESS);