pkcs11dh_link.c revision ce9f893e21d2ffc6f6a78bf226c038c396740aeb
431a83fb29482c5170b3e4026e59bb14849a6707Tinderbox User * Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC")
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * Permission to use, copy, modify, and/or distribute this software for any
ec5347e2c775f027573ce5648b910361aa926c01Automatic Updater * purpose with or without fee is hereby granted, provided that the above
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson * copyright notice and this permission notice appear in all copies.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * PERFORMANCE OF THIS SOFTWARE.
7693d4de8fca501dfe6989a7f30d8d3c86fe096aAndreas Gustafsson * PKCS#3 DH keys:
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence * CKM_DH_PKCS_PARAMETER_GEN,
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence * CKM_DH_PKCS_KEY_PAIR_GEN,
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence * CKM_DH_PKCS_DERIVE
a1747570262ed336c213aaf6bd31bc91993a46deAndreas Gustafsson * domain parameters:
a1747570262ed336c213aaf6bd31bc91993a46deAndreas Gustafsson * object class CKO_DOMAIN_PARAMETERS
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * key type CKK_DH
7693d4de8fca501dfe6989a7f30d8d3c86fe096aAndreas Gustafsson * attribute CKA_PRIME (prime p)
7693d4de8fca501dfe6989a7f30d8d3c86fe096aAndreas Gustafsson * attribute CKA_BASE (base g)
7693d4de8fca501dfe6989a7f30d8d3c86fe096aAndreas Gustafsson * optional attribute CKA_PRIME_BITS (p length in bits)
df925e6c66d45d960fbac0383169763967d2111cEvan Hunt * public key:
df925e6c66d45d960fbac0383169763967d2111cEvan Hunt * object class CKO_PUBLIC_KEY
df925e6c66d45d960fbac0383169763967d2111cEvan Hunt * key type CKK_DH
df925e6c66d45d960fbac0383169763967d2111cEvan Hunt * attribute CKA_PRIME (prime p)
7693d4de8fca501dfe6989a7f30d8d3c86fe096aAndreas Gustafsson * attribute CKA_BASE (base g)
c7e266b7e5675e12d1ca3cc929f24b3e86d41f8eEvan Hunt * attribute CKA_VALUE (public value y)
18d0b5e54be891a1aa938c165b6d439859121ec8Mark Andrews * private key:
18d0b5e54be891a1aa938c165b6d439859121ec8Mark Andrews * object class CKO_PRIVATE_KEY
18d0b5e54be891a1aa938c165b6d439859121ec8Mark Andrews * key type CKK_DH
18d0b5e54be891a1aa938c165b6d439859121ec8Mark Andrews * attribute CKA_PRIME (prime p)
18d0b5e54be891a1aa938c165b6d439859121ec8Mark Andrews * attribute CKA_BASE (base g)
c7e266b7e5675e12d1ca3cc929f24b3e86d41f8eEvan Hunt * attribute CKA_VALUE (private value x)
604419a812b491cd35fb6fad129c3c39da7200a1Mark Andrews * optional attribute CKA_VALUE_BITS (x length in bits)
c7e266b7e5675e12d1ca3cc929f24b3e86d41f8eEvan Hunt * reuse CKA_PRIVATE_EXPONENT for key pair private value
7693d4de8fca501dfe6989a7f30d8d3c86fe096aAndreas Gustafssonstatic void pkcs11dh_destroy(dst_key_t *key);
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrencestatic isc_result_t pkcs11dh_todns(const dst_key_t *key, isc_buffer_t *data);
7693d4de8fca501dfe6989a7f30d8d3c86fe096aAndreas Gustafsson CK_OBJECT_CLASS keyClass = CKO_PRIVATE_KEY;
7693d4de8fca501dfe6989a7f30d8d3c86fe096aAndreas Gustafsson { CKA_CLASS, &keyClass, (CK_ULONG) sizeof(keyClass) },
7693d4de8fca501dfe6989a7f30d8d3c86fe096aAndreas Gustafsson { CKA_KEY_TYPE, &keyType, (CK_ULONG) sizeof(keyType) },
7693d4de8fca501dfe6989a7f30d8d3c86fe096aAndreas Gustafsson { CKA_TOKEN, &falsevalue, (CK_ULONG) sizeof(falsevalue) },
7693d4de8fca501dfe6989a7f30d8d3c86fe096aAndreas Gustafsson { CKA_PRIVATE, &falsevalue, (CK_ULONG) sizeof(falsevalue) },
7693d4de8fca501dfe6989a7f30d8d3c86fe096aAndreas Gustafsson { CKA_SENSITIVE, &falsevalue, (CK_ULONG) sizeof(falsevalue) },
7693d4de8fca501dfe6989a7f30d8d3c86fe096aAndreas Gustafsson { CKA_DERIVE, &truevalue, (CK_ULONG) sizeof(truevalue) },
c7e266b7e5675e12d1ca3cc929f24b3e86d41f8eEvan Hunt unsigned int i;
7693d4de8fca501dfe6989a7f30d8d3c86fe096aAndreas Gustafsson if ((priv->object != CK_INVALID_HANDLE) && priv->ontoken) {
7693d4de8fca501dfe6989a7f30d8d3c86fe096aAndreas Gustafsson attr = pk11_attribute_bytype(priv, CKA_PRIME);
1aba9fe67899522364a9dbc3ee5a14da081f0314Evan Hunt keyTemplate[6].pValue = isc_mem_get(key->mctx, attr->ulValueLen);
2f012d936b5ccdf6520c96a4de23721dc58a2221Automatic Updater memmove(keyTemplate[6].pValue, attr->pValue, attr->ulValueLen);
7693d4de8fca501dfe6989a7f30d8d3c86fe096aAndreas Gustafsson attr = pk11_attribute_bytype(priv, CKA_BASE);
c7e266b7e5675e12d1ca3cc929f24b3e86d41f8eEvan Hunt keyTemplate[7].pValue = isc_mem_get(key->mctx, attr->ulValueLen);
7693d4de8fca501dfe6989a7f30d8d3c86fe096aAndreas Gustafsson memmove(keyTemplate[7].pValue, attr->pValue, attr->ulValueLen);
7693d4de8fca501dfe6989a7f30d8d3c86fe096aAndreas Gustafsson keyTemplate[7].ulValueLen = attr->ulValueLen;
7693d4de8fca501dfe6989a7f30d8d3c86fe096aAndreas Gustafsson attr = pk11_attribute_bytype(priv, CKA_VALUE2);
c7e266b7e5675e12d1ca3cc929f24b3e86d41f8eEvan Hunt keyTemplate[8].pValue = isc_mem_get(key->mctx, attr->ulValueLen);
7693d4de8fca501dfe6989a7f30d8d3c86fe096aAndreas Gustafsson memmove(keyTemplate[8].pValue, attr->pValue, attr->ulValueLen);
7693d4de8fca501dfe6989a7f30d8d3c86fe096aAndreas Gustafsson keyTemplate[8].ulValueLen = attr->ulValueLen;
c7e266b7e5675e12d1ca3cc929f24b3e86d41f8eEvan Huntpkcs11dh_computesecret(const dst_key_t *pub, const dst_key_t *priv,
28ad0be64ee756013c0f6a474fc447ee613ee0d1Evan Hunt CK_MECHANISM mech = { CKM_DH_PKCS_DERIVE, NULL, 0 };
c7e266b7e5675e12d1ca3cc929f24b3e86d41f8eEvan Hunt { CKA_CLASS, &keyClass, (CK_ULONG) sizeof(keyClass) },
c7e266b7e5675e12d1ca3cc929f24b3e86d41f8eEvan Hunt { CKA_KEY_TYPE, &keyType, (CK_ULONG) sizeof(keyType) },
c7e266b7e5675e12d1ca3cc929f24b3e86d41f8eEvan Hunt { CKA_PRIVATE, &falsevalue, (CK_ULONG) sizeof(falsevalue) },
604419a812b491cd35fb6fad129c3c39da7200a1Mark Andrews { CKA_SENSITIVE, &falsevalue, (CK_ULONG) sizeof(falsevalue) },
c7e266b7e5675e12d1ca3cc929f24b3e86d41f8eEvan Hunt { CKA_EXTRACTABLE, &truevalue, (CK_ULONG) sizeof(truevalue) },
c7e266b7e5675e12d1ca3cc929f24b3e86d41f8eEvan Hunt { CKA_VALUE_LEN, &secLen, (CK_ULONG) sizeof(secLen) }
c7e266b7e5675e12d1ca3cc929f24b3e86d41f8eEvan Hunt unsigned int i;
c7e266b7e5675e12d1ca3cc929f24b3e86d41f8eEvan Hunt attr = pk11_attribute_bytype(pub->keydata.pkey, CKA_PRIME);
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews attr = pk11_attribute_bytype(pub->keydata.pkey, CKA_VALUE);
262c39b2366bf79062f7f86b218947523dd1cbacEvan Hunt ret = pk11_get_session(&ctx, OP_DH, ISC_TRUE, ISC_FALSE, ISC_FALSE,
604419a812b491cd35fb6fad129c3c39da7200a1Mark Andrews mech.pParameter = isc_mem_get(pub->mctx, mech.ulParameterLen);
d8d0c5b1bc97ac0f07e35a31b58ced80ce613c55David Lawrence memmove(mech.pParameter, attr->pValue, mech.ulParameterLen);
c7e266b7e5675e12d1ca3cc929f24b3e86d41f8eEvan Hunt ret = pkcs11dh_loadpriv(priv, ctx.session, &hKey);
c7e266b7e5675e12d1ca3cc929f24b3e86d41f8eEvan Hunt attr->pValue = isc_mem_get(pub->mctx, attr->ulValueLen);
c7e266b7e5675e12d1ca3cc929f24b3e86d41f8eEvan Hunt /* strip leading zeros */
c7e266b7e5675e12d1ca3cc929f24b3e86d41f8eEvan Hunt memmove(r.base, secValue + i, attr->ulValueLen - i);
aeadcd63196f164b219629a53c0e0925519288f3Evan Hunt (void) pkcs_C_DestroyObject(ctx.session, hDerived);
114c14f8adfc249cf2e5cdcb9007af46fed257e3Mark Andrews memset(valTemplate[0].pValue, 0, valTemplate[0].ulValueLen);
604419a812b491cd35fb6fad129c3c39da7200a1Mark Andrews if ((hKey != CK_INVALID_HANDLE) && !priv->keydata.pkey->ontoken)
604419a812b491cd35fb6fad129c3c39da7200a1Mark Andrews (void) pkcs_C_DestroyObject(ctx.session, hKey);
604419a812b491cd35fb6fad129c3c39da7200a1Mark Andrews memset(mech.pParameter, 0, mech.ulParameterLen);
604419a812b491cd35fb6fad129c3c39da7200a1Mark Andrews isc_mem_put(pub->mctx, mech.pParameter, mech.ulParameterLen);
aeadcd63196f164b219629a53c0e0925519288f3Evan Huntpkcs11dh_compare(const dst_key_t *key1, const dst_key_t *key2) {
604419a812b491cd35fb6fad129c3c39da7200a1Mark Andrews memcmp(attr1->pValue, attr2->pValue, attr1->ulValueLen))
604419a812b491cd35fb6fad129c3c39da7200a1Mark Andrews memcmp(attr1->pValue, attr2->pValue, attr1->ulValueLen))
604419a812b491cd35fb6fad129c3c39da7200a1Mark Andrews memcmp(attr1->pValue, attr2->pValue, attr1->ulValueLen))
604419a812b491cd35fb6fad129c3c39da7200a1Mark Andrews attr1 = pk11_attribute_bytype(dh1, CKA_VALUE2);
604419a812b491cd35fb6fad129c3c39da7200a1Mark Andrews attr2 = pk11_attribute_bytype(dh2, CKA_VALUE2);
604419a812b491cd35fb6fad129c3c39da7200a1Mark Andrews memcmp(attr1->pValue, attr2->pValue, attr1->ulValueLen)))
604419a812b491cd35fb6fad129c3c39da7200a1Mark Andrewspkcs11dh_paramcompare(const dst_key_t *key1, const dst_key_t *key2) {
604419a812b491cd35fb6fad129c3c39da7200a1Mark Andrews memcmp(attr1->pValue, attr2->pValue, attr1->ulValueLen))
c0c4512020c0a4a9e5b087cb8cad1cd68fb3f52eEvan Hunt memcmp(attr1->pValue, attr2->pValue, attr1->ulValueLen))
2f012d936b5ccdf6520c96a4de23721dc58a2221Automatic Updaterpkcs11dh_generate(dst_key_t *key, int generator, void (*callback)(int)) {
604419a812b491cd35fb6fad129c3c39da7200a1Mark Andrews CK_MECHANISM mech = { CKM_DH_PKCS_PARAMETER_GEN, NULL, 0 };
604419a812b491cd35fb6fad129c3c39da7200a1Mark Andrews CK_OBJECT_HANDLE domainparams = CK_INVALID_HANDLE;
604419a812b491cd35fb6fad129c3c39da7200a1Mark Andrews CK_OBJECT_CLASS dClass = CKO_DOMAIN_PARAMETERS;
604419a812b491cd35fb6fad129c3c39da7200a1Mark Andrews { CKA_CLASS, &dClass, (CK_ULONG) sizeof(dClass) },
604419a812b491cd35fb6fad129c3c39da7200a1Mark Andrews { CKA_KEY_TYPE, &keyType, (CK_ULONG) sizeof(keyType) },
604419a812b491cd35fb6fad129c3c39da7200a1Mark Andrews { CKA_TOKEN, &falsevalue, (CK_ULONG) sizeof(falsevalue) },
604419a812b491cd35fb6fad129c3c39da7200a1Mark Andrews { CKA_PRIVATE, &falsevalue, (CK_ULONG) sizeof(falsevalue) },
604419a812b491cd35fb6fad129c3c39da7200a1Mark Andrews { CKA_PRIME_BITS, &bits, (CK_ULONG) sizeof(bits) }
c7e266b7e5675e12d1ca3cc929f24b3e86d41f8eEvan Hunt { CKA_CLASS, &pubClass, (CK_ULONG) sizeof(pubClass) },
c7e266b7e5675e12d1ca3cc929f24b3e86d41f8eEvan Hunt { CKA_KEY_TYPE,&keyType, (CK_ULONG) sizeof(keyType) },
c7e266b7e5675e12d1ca3cc929f24b3e86d41f8eEvan Hunt { CKA_TOKEN, &falsevalue, (CK_ULONG) sizeof(falsevalue) },
c7e266b7e5675e12d1ca3cc929f24b3e86d41f8eEvan Hunt { CKA_PRIVATE, &falsevalue, (CK_ULONG) sizeof(falsevalue) },
febaa091847ab004f40500cc475a819f2c73fcddAndreas Gustafsson { CKA_CLASS, &privClass, (CK_ULONG) sizeof(privClass) },
febaa091847ab004f40500cc475a819f2c73fcddAndreas Gustafsson { CKA_KEY_TYPE, &keyType, (CK_ULONG) sizeof(keyType) },
febaa091847ab004f40500cc475a819f2c73fcddAndreas Gustafsson { CKA_TOKEN, &falsevalue, (CK_ULONG) sizeof(falsevalue) },
febaa091847ab004f40500cc475a819f2c73fcddAndreas Gustafsson { CKA_PRIVATE, &falsevalue, (CK_ULONG) sizeof(falsevalue) },
604419a812b491cd35fb6fad129c3c39da7200a1Mark Andrews { CKA_SENSITIVE, &falsevalue, (CK_ULONG) sizeof(falsevalue) },
604419a812b491cd35fb6fad129c3c39da7200a1Mark Andrews { CKA_EXTRACTABLE, &truevalue, (CK_ULONG) sizeof(truevalue) },
febaa091847ab004f40500cc475a819f2c73fcddAndreas Gustafsson { CKA_DERIVE, &truevalue, (CK_ULONG) sizeof(truevalue) },
604419a812b491cd35fb6fad129c3c39da7200a1Mark Andrews pk11_ctx = (pk11_context_t *) isc_mem_get(key->mctx,
604419a812b491cd35fb6fad129c3c39da7200a1Mark Andrews ret = pk11_get_session(pk11_ctx, OP_DH, ISC_TRUE, ISC_FALSE,
604419a812b491cd35fb6fad129c3c39da7200a1Mark Andrews ((bits == 768) || (bits == 1024) || (bits == 1536))) {
501941f0b6cce74c2ff75b10aff3f230d5d37e4cEvan Hunt pubTemplate[4].ulValueLen = sizeof(pk11_dh_bn768);
604419a812b491cd35fb6fad129c3c39da7200a1Mark Andrews isc_mem_get(key->mctx, sizeof(pk11_dh_bn1024));
604419a812b491cd35fb6fad129c3c39da7200a1Mark Andrews pubTemplate[4].ulValueLen = sizeof(pk11_dh_bn1024);
604419a812b491cd35fb6fad129c3c39da7200a1Mark Andrews isc_mem_get(key->mctx, sizeof(pk11_dh_bn1536));
604419a812b491cd35fb6fad129c3c39da7200a1Mark Andrews pubTemplate[4].ulValueLen = sizeof(pk11_dh_bn1536);
604419a812b491cd35fb6fad129c3c39da7200a1Mark Andrews pubTemplate[5].ulValueLen = sizeof(pk11_dh_bn2);
febaa091847ab004f40500cc475a819f2c73fcddAndreas Gustafsson pTemplate[0].pValue = isc_mem_get(key->mctx,
e7220c9b841bbd3d16736726f786a86fec3c0e18Evan Hunt memset(pTemplate[0].pValue, 0, pTemplate[0].ulValueLen);
aa23a35d81a9618a40c4a9b44be48009553e4777Andreas Gustafsson pTemplate[1].pValue = isc_mem_get(key->mctx,
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson memset(pTemplate[1].pValue, 0, pTemplate[1].ulValueLen);
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson pubTemplate[4].pValue = pTemplate[0].pValue;
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson pubTemplate[4].ulValueLen = pTemplate[0].ulValueLen;
12e0477d4e132c9122312246ed60aaa646f819b2Mark Andrews pubTemplate[5].ulValueLen = pTemplate[1].ulValueLen;
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson mech.mechanism = CKM_DH_PKCS_KEY_PAIR_GEN;
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson dh = (pk11_object_t *) isc_mem_get(key->mctx, sizeof(*dh));
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence dh->repr = (CK_ATTRIBUTE *) isc_mem_get(key->mctx, sizeof(*attr) * 4);
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson attr[0].ulValueLen = pubTemplate[4].ulValueLen;
69f3cb5abcb38f105c653c7b3df7cec33b87b292Mark Andrews attr[1].ulValueLen = pubTemplate[5].ulValueLen;
c7e266b7e5675e12d1ca3cc929f24b3e86d41f8eEvan Hunt attr->pValue = isc_mem_get(key->mctx, attr->ulValueLen);
262c39b2366bf79062f7f86b218947523dd1cbacEvan Hunt attr->pValue = isc_mem_get(key->mctx, attr->ulValueLen);
c7e266b7e5675e12d1ca3cc929f24b3e86d41f8eEvan Hunt (void) pkcs_C_DestroyObject(pk11_ctx->session, priv);
604419a812b491cd35fb6fad129c3c39da7200a1Mark Andrews (void) pkcs_C_DestroyObject(pk11_ctx->session, pub);
9c566a852f31c3a5d0b9d6eaf11463114339c01dAndreas Gustafsson (void) pkcs_C_DestroyObject(pk11_ctx->session, domainparams);
604419a812b491cd35fb6fad129c3c39da7200a1Mark Andrews isc_mem_put(key->mctx, pk11_ctx, sizeof(*pk11_ctx));
262c39b2366bf79062f7f86b218947523dd1cbacEvan Hunt (void) pkcs_C_DestroyObject(pk11_ctx->session, priv);
9c566a852f31c3a5d0b9d6eaf11463114339c01dAndreas Gustafsson (void) pkcs_C_DestroyObject(pk11_ctx->session, pub);
c7e266b7e5675e12d1ca3cc929f24b3e86d41f8eEvan Hunt (void) pkcs_C_DestroyObject(pk11_ctx->session, domainparams);
2f012d936b5ccdf6520c96a4de23721dc58a2221Automatic Updater memset(pubTemplate[4].pValue, 0, pubTemplate[4].ulValueLen);
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews memset(pubTemplate[5].pValue, 0, pubTemplate[5].ulValueLen);
c7e266b7e5675e12d1ca3cc929f24b3e86d41f8eEvan Hunt memset(pTemplate[0].pValue, 0, pTemplate[0].ulValueLen);
604419a812b491cd35fb6fad129c3c39da7200a1Mark Andrews memset(pTemplate[1].pValue, 0, pTemplate[1].ulValueLen);
9c566a852f31c3a5d0b9d6eaf11463114339c01dAndreas Gustafsson isc_mem_put(key->mctx, pk11_ctx, sizeof(*pk11_ctx));
9c566a852f31c3a5d0b9d6eaf11463114339c01dAndreas Gustafssonpkcs11dh_isprivate(const dst_key_t *key) {
604419a812b491cd35fb6fad129c3c39da7200a1Mark Andrews return (ISC_TF((attr != NULL) || dh->ontoken));
9c566a852f31c3a5d0b9d6eaf11463114339c01dAndreas Gustafsson INSIST((dh->object == CK_INVALID_HANDLE) || dh->ontoken);
a1747570262ed336c213aaf6bd31bc91993a46deAndreas Gustafsson memset(attr->pValue, 0, attr->ulValueLen);
a1747570262ed336c213aaf6bd31bc91993a46deAndreas Gustafsson memset(dh->repr, 0, dh->attrcnt * sizeof(*attr));
a1747570262ed336c213aaf6bd31bc91993a46deAndreas Gustafsson isc_mem_put(key->mctx, dh->repr, dh->attrcnt * sizeof(*attr));
a1747570262ed336c213aaf6bd31bc91993a46deAndreas Gustafssonuint16_toregion(isc_uint16_t val, isc_region_t *region) {
static isc_result_t
isc_region_t r;
case CKA_VALUE:
case CKA_PRIME:
case CKA_BASE:
glen = 0;
return (ISC_R_NOSPACE);
sizeof(pk11_dh_bn1024)) == 0)
if (glen > 0)
return (ISC_R_SUCCESS);
static isc_result_t
isc_region_t r;
int special = 0;
if (r.length == 0)
return (ISC_R_SUCCESS);
return (ISC_R_NOMEMORY);
return (DST_R_INVALIDPUBLICKEY);
return (DST_R_INVALIDPUBLICKEY);
return (DST_R_INVALIDPUBLICKEY);
switch (special) {
return (DST_R_INVALIDPUBLICKEY);
return (DST_R_INVALIDPUBLICKEY);
return (DST_R_INVALIDPUBLICKEY);
if (special != 0) {
if (glen == 0) {
return (DST_R_INVALIDPUBLICKEY);
if (glen == 0) {
return (DST_R_INVALIDPUBLICKEY);
return (DST_R_INVALIDPUBLICKEY);
return (DST_R_INVALIDPUBLICKEY);
goto nomemory;
goto nomemory;
goto nomemory;
goto nomemory;
return (ISC_R_SUCCESS);
case CKA_VALUE:
case CKA_PRIME:
case CKA_BASE:
return (ISC_R_NOMEMORY);
static isc_result_t
return (DST_R_NULLKEY);
return (DST_R_EXTERNALKEY);
case CKA_VALUE:
case CKA_VALUE2:
case CKA_PRIME:
case CKA_BASE:
return (DST_R_NULLKEY);
goto fail;
fail:
return (result);
static isc_result_t
return (ret);
case TAG_DH_PRIME:
case TAG_DH_GENERATOR:
case TAG_DH_PRIVATE:
case TAG_DH_PUBLIC:
return (ISC_R_SUCCESS);
err:
return (ret);
return (ISC_R_SUCCESS);